HOBALL 筆記簿

October 14, 2009

Useful Linux commands

Filed under: Linux — Tags: , , — hoball @ 5:17 pm

Find files older than 60 days
find * -mtime +60

Delete files in backup folder which are older than 60 days
rm -f `find /backup/ -mtime +60`

Search for a string inside files
grep -H -r “search me” /var/www

Find files owned by apache user
find /var/www/ -user apache

Find directories owned by apache user
find /var/www/ -user apache –type d

Listing files in a directory
ls -lh

Copy an entire directory (files + subdirectories)
cp -R existingdir/ newdir/

Zip up an entire directory
zip -r zipefilename foldername

Count total number of files in a directory
ls -1 | wc -l
find . -type f | wc -l

Get directory size
du -hs /var/www

Get amount of free disk space available
df -h

Get Linux version details
uname -a
cat /proc/version

Source: http://eisabainyo.net/weblog/useful-linux-commands/

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: