Ten Things I Wish I Knew When Becoming A Linux Admin

Anthony James —  February 24, 2012

Ten years ago I installed Linux for the very first time. To be exact, it was Slackware 7, the best distribution at the time in my opinion. Since then I’ve come to favor Debian Linux as my favorite version…at least for my Linux servers. I like to have a solid core system installed that I can build from scratch, but this is for another time. This article is for you new Linux admins; here are the ten things I wish I knew when starting my Linux admin journey.


1.) When in doubt check your logs. EVERYTHING is logged inside of Linux. If you are dealing with a nagging problem, the first thing you always need to do is check your logs. In most systems, this is found in /var/log/. /var/log/syslog logs all the system messages and is where you will find most common error messages. I encourage you to start digging through your logs and getting familiarized with those error messages.

2.) You can use the Tail command to view the last ten lines of a file. You can use the -f flag, or tail -f /var/log/syslog to watch the most recent lines append to the log file. This is a great tool to use while watching for error messages. You can also use the Head command to view the first ten lines of a specified file.

3.) Monitor your server resources. Depending on your disk and partition size, sometimes you can run out of space or your log files can take up most of your root partition. You can monitor the size of the partitions by using the df command. Two flags to know when starting are the -h and -m flag. The -h flag puts information in human readable form such as 5g. The -m flag puts information in megabyte form and displays only in megabytes.

4.) Never Use Root To Login. The most common hacks are done by port scanners and random password generators trying to break into your system with root as the username. Basic “admin 101″ says the first thing you should do on your system is disable root login. You do this by going into /etc/ssh and edit sshd_config. Change this line PermitRootLogin yes to PermitRootLogin no. When you are finished, restart ssh /etc/init.d/ssh restart.

5.) Get to know chown and chmod if you are going to be hosting any websites. Permissions security and file ownership are very important. Having the wrong permissions can leave your code open to exploits or hacks.

6.) Use SFTP instead of FTP. SFTP encrypts passwords through the tunnel where as port 21 ftp allows password information to be sent via clear text. Hackers could listen into and grab your passwords when using port 21.

7.) ls -al – LS lists the directory contents. The -a flag tells the ls command to list all files, even those that begin with a . (dot). The -l flag tells LS to list the contents and also display the date files were modified. This command should just be the basic ls -al command when you want to list directory contents. I use it when I use ls regardless of need.

8.) Top – top command will display your highest usage processes on your system. If your processor is running high, this will help you find the process and fix the problem.

9.) Use grep to search files for a specific word/expression. Grep is extensive…very extensive. This is why it is one of the best tools to search files. For example, grep -r pinehead.tv /etc/* will recursively search the /etc/ directory and all the directors under it that have the word pinehead.tv.

10.) Redirect the results of a grep search into a new file. This is easy to do. We can take the search results from our command above and write them to a file instead of reading them in the shell. Just type grep -r pinehead.tv /etc/* > test.test.
A few things about pipes…

> Creates a new file containing standard output. If the specified file exists, it’s overwritten.
>> Appends standard output to the existing file. If the specified file doesn’t exist, it creates it.

Anthony James

Posts Twitter Facebook

Anthony is a Web Software Developer & Linux Systems Engineer. With 11 years of experience in these fields. He is also the founder and main contributor at Pinehead.tv. He is passionate about passing on his technical knowledge through training and educating others.

7 responses to Ten Things I Wish I Knew When Becoming A Linux Admin

  1. Thanks so much for the information! I love Linux and try to learn all I can about it! It is people Like you who make Linux so great! Keep up the good work!

  2. I wish I had known of tac earlier. Tac is the opposite of cat, for those as don’t know. And you see the top of the file last. As much of our documentation has important notes first, having that in front first is of great help.

  3. Great highlights indeed .. Thanks for sharing!
    I’d like to few, but what’s popping to my mind now:
    . I’d add -h to the ls to be ls -alh
    . Create another user with root access before disabling root login
    . watch -n0.5 “ps aux :grep nginx -i” is one of the most commands I catch myself typing
    . Change the default editor to vim

    Looking for the other story of “I like to have a solid core system installed that I can build from scratch” :)

    Keep up the great work!

  4. Oh .. please edit my previous comment for:
    watch -n0.5 “ps aux | grep nginx -i”
    :-)

  5. A very nice article. The info wasn’t strange to me since I just did LPIC 2 a few weeks ago but it’s really nice that someone took time out to inform or remind us of basic Linux-admin knowledge.
    Thanks for the article.

  6. Thanks foe the tips… I am strating to ry to get used to my log files… I have a little ubuntu server and I will follow your advice about disabling root login on my SSH. I will constatly follow Pinehead.tv for more tutorials and advice.

Trackbacks and Pingbacks:

  1. Links 27/2/2012: Linux 3.3 RC5, Orange and x86 | Techrights - February 27, 2012

    [...] Ten Things I Wish I Knew When Becoming A Linux Admin Ten years ago I installed Linux for the very first time. To be exact, it was Slackware 7, the best distribution at the time in my opinion. Since then I’ve come to favor Debian Linux as my favorite version…at least for my Linux servers. I like to have a solid core system installed that I can build from scratch, but this is for another time. This article is for you new Linux admins; here are the ten things I wish I knew when starting my Linux admin journey. [...]