Showing posts with label commands. Show all posts
Showing posts with label commands. Show all posts

Monday, June 11, 2012

Thursday, April 26, 2012

du command

I was finally able to harness the power of the du command. The -s flag has a cryptic definition in the man page (nothing new for man there). But using the -s flag allows you to summarize the file size for directories.


This command will give you a summary of the directory sizes in root. You can of course target down to other folders like so

Update 8/17/2015

Often I need to sort the output by size. Here you go.

Monday, March 26, 2012

Deleting files older than X on Linux

The following is handy if you need to delete files older than X on a Linux server. I like to run the find command first before actually moving or deleting the files. Just to make sure the files I want to remove are returned from the find command.


find /fullpath -mtime +4 -ls

The -ls flag will list out the details of the file so you can verify that the mtime parameter returns the right files.


find /fullpath -mtime +4 -ls -exec mv {} /destination ;

After you verify that the find command returns the files you want then you are ready to use the -exec flag on the find command to actually execute the move/delete. I also like to use full path here on the find command, just to make sure I move the right files.

Monday, February 27, 2012

makewhatis

So that took longer than it should. There is a command called whatis that gives you a single line description of a command:



whatis grep


grep (1) - print lines matching a pattern
grep (1p) - search a file for a pattern
grep (rpm) - The GNU versions of grep pattern matching utilities



A nice little tool to use. I just installed CentOS 5 in a VM and noticed that all my whatis commands were returning nothing appopriate…I quickly found the makewhatis command on some articles but could not locate it for CentOS 5 at first. Finally found the location:


/usr/sbin/makewhatis



This command builds the database and now my whatis commands are working.

Thursday, February 23, 2012