For the past few months, I’ve been working with Linux a lot more than I used to. With that increased exposure has come some helpful commands that I’ve come across, so I thought I’d share a few of them here. I’m sure many of them are fairly common knowledge, but I’ll share them nonetheless…

Tail!

Shows the you last part of a particular file. Works best with the follow option (-f), which continues to output new information added to the file in real-time. For example:

tail -f error_log

More info on tail is available on about.com

Find & Locate

Another couple of my favorites, Find allows you to find a file (Duh). Locate does essentially the same thing, however it requires you to update the servers database (# updatedb) in order to be accurate.

find ./ -iname [filename]

locate [filename]

Find the 10 largest Files/Directories

du -a / | sort -n -r | head -n 10

Delete files older than 5 days

find /path/to/files* -mtime +5 -exec rm {} \;

I’ll post more in the future, probably with a little more thought behind the commands.

Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>