Quick Tips For Linux Administrators

Quick Tips For Linux AdministratorsThe first time you use sudo on a Linux system, it quotes the famous line from Spiderman: “with great power comes great responsibility.” Using your power responsibly can be challenging on a system as powerful as Linux, where one typo can turn an ordinary rm command into a command which removes your root directory. Here are a few tricks which have helped keep me out of trouble:



Linux Administrators Love Backups



Everyone tells you to make frequent and (if possible) automated backups. You know you should—but you haven’t gotten around to it yet. I won’t belabor this point; if you don’t have backups already, you probably already feel guilty. Now just imagine how guilty you will feel if your server crashes before you get around to setting up backups.


Superusers Check Before They Sudo



Here’s a simple way to avoid making critical mistakes: don’t add the sudo or su to a command until you’ve checked it. For example, if you want to update the location database (which requires root privileges), type updatedb, check it to make sure the command looks correct, press the Home key on your keyboard, and (only then) type sudo.

Adding the sudo or su after you check your command helps prevent dangerous typos.



Linux Administrators Love Documentation



What’s your favorite part of a manual page? I bet it’s the Examples section. That’s often the first place I look when I’m skimming documentation.

If you frequently look up information in the manual pages or anywhere else, make your own examples section. Just open a file in vi or emacs (or any other editor) and start recording example command lines that you use too infrequently to remember, but frequently enough to know you need them.

I especially recommend that you record dangerous command lines which must be typed precisely. For example, I keep a record of the mdadm command lines I need to add new hard drives to RAID arrays so I don’t accidentally wipe out existing arrays and lose all of the computer’s data.



Use Negative Filtering To Improve Linux Administration



As a Linux administrator, you get inundated with information. It’s tempting to start filtering out information you don’t think is important—but you need to be careful.

There are two ways to filter data—collecting data which matches a particular pattern (positive matching) and discarding data which match a different pattern (negative matching). It’s easy, for example, to move all automatic cron mail to a GMail folder using a positive pattern—but that could prevent you from seeing an important notice.

It’s usually better to filter out information you know is useless. For example, edit your cron jobs so that they don’t send you unimportant data. That way you don’t get dozens or hundreds of emails from cron everyday—and you know the ones you do get are important.



Automate Even Infrequent Repeated Tasks



System administrators love writing shell scripts to automate tasks, but sometimes a task seems so trivial and so infrequent that it hardly seems worth automating. Automate it anyway.

You know the old saying: “to err is human.” Any time you touch a server, you can make a mistake. If you’re messing around with special privileges, a single small mistake can take hours to fix.

But if you automate a task, your chance of making a mistake diminishes greatly. Plus, automated tasks are easy to explain and delegate to junior system administrators—or even the office secretary—saving you time and making you an even more efficient Linux administrator.