LINUX CHEAT SHEET


My favorite Linux tips



Trick 1 - Searching for a file or directory by name using the find command


Sooner or later, it happens to you. You see a tutorial on howtoforge, follow the instructions, start the service and, kaput. You get a path error. Welcome to the biggest pain with linux. And, if you’re from a Windows background, it will drive you nuts. Fortunately, there’s a magic little helper built in to the system, the find command.

Here’s what you do. Launch the find command specifying the path using the -name modifier and specify part or the whole filename of the file you’re looking for:

find / -name filename.extension
find / -name partialfilename*
find / -name partialfilename.*

Practical example; you’ve installed and compiled ProFTPD, you’ve installed and configured the monit and mun services, you go to the monit web page and you have an error on getting the status for ProFTPD. You need to modify the path to the PID file for ProFTPD, so you do the following:

[ /var/]#cd /
[ /]#find / -name proftpd.pid
./usr/local/var/proftpd.pid

The find command returns the proper file path.Once you have it, modify the monit configuration file to have the proper path to the ProFTPD PID file.

I would say the find command is one of the most, if not the most useful commands in the linux arsenal when you are deploying new applications or services. Note on the syntax: the path is important, if you don’t know under which tree the file is found, using the root (/) path will search the entire system. If you don’t specify a path, find will query the directory tree below the directory from which you are launching your search.

Trick 2 - a text editor for human beings


If you hang long enough with Unix heads, you see they like to do things the hard way. Me? I like the good stuff, and I like the easy stuff. Which is why if you give me the choice between sticking a hot poker in my eyes and using VI, I have a hard time deciding. Fortunately, there is a better way for those of us who come from the dark side. It’s called Joe.

Joe is a wonderful text editor. As a matter of fact, if you are as old - or older - than me, it will remind you of those wonderful, early, pre-windows days. Joe is very Wordstar like. Ctl-K-H brings up a help menu with all the common commands, like Ctl-K-U to go to the top of the file, Ctl-K-F to find a text screen, etc. If you’re happy with VI or VIM, fine, but if you, like me, want something a little less memory intensive (my memory, not the computer’s), you might want to install Joe. Using yum, you install it with the following:

yum install joe

And that’s it. Enjoy.