Slashdot Mirror


Top 10 Items in the Linux Admin Toolkit

Joe Barr writes "Joe 'Zonker' Brockmeier has listed his favorite top ten tools for Linux system administration in a story on Linux.com, one of Slashdot's sister sites." From the site: " Since I spend a lot of my time working with text files, either when I'm writing and editing or when I'm mucking with configuration files and shell scripts, I've become very attached to my editor of choice -- Vim. Over the years, I've tried a lot of other editors, but none of them has been sufficient to coax me away from Vim. Part of the reason for that is the fact that I no longer have to think about using Vi-style keybindings, and adjusting to anything else would seriously hinder my productivity."

38 of 357 comments (clear)

  1. strace by epiphani · · Score: 2, Informative

    by far the most useful tool in troubleshooting.

    --
    .
    1. Re:strace by lky · · Score: 3, Informative

      Dont forget these, any one will provide the needed/wanted tools for recovery.

      Forensic and Incident Response Environment: http://fire.dmzs.com/
      Linux Bootable Business Card: http://www.lnx-bbc.org/
      Ultimate Boot CD: http://ubcd.sourceforge.net/
      Knoppix Security Tools Distribution: http://www.knoppix-std.org/
      SystemRescueCd: ahref=http://www.sysresccd.org/rel=url2html-26348h ttp://www.sysresccd.org/>

  2. Re:Vim? Emacs foreva! by Rosco+P.+Coltrane · · Score: 2, Informative

    You're right, with this, Emacs rocks.

    --
    "A door is what a dog is perpetually on the wrong side of" - Ogden Nash
  3. Zonker... by xanie · · Score: 1, Informative

    Zonker is a great, and extremely smart guy. I had the opportunity to work with him for about 8 months at a data center. Anything I would have trouble with... and I mean ANYTHING, Zonker would always have the answer. He has lots of great articles, I recommend reading them!

    --
    Fundamentalism stops a thinking mind.
  4. Webmin by lthown · · Score: 3, Informative

    One of the most useful remote admin packages out there. Especially useful for those just getting into Linux/Unix. Want to install a Perl module? just select or enter the name. Wanna change a cron job for a user, it's in the Cron screen.

    http://www.webmin.com/

  5. Re:Mine by Stephen+Williams · · Score: 4, Informative

    Shame on those that only provide info, text, or worst, html documentation (or none)

    For reading HTML docs over ssh or on an X11-less machine, might I recommend w3m? It's a very comfortable text-mode web browser. Unlike Lynx, it renders tables nicely, and even makes a brave attempt at frames.

    -Stephen

  6. Re:SSH by kaarlov · · Score: 2, Informative
    ssh -p 25 mail.example.com
    is far less useful than:
    telnet mail.example.com smtp
  7. Re:Mine by illustir · · Score: 2, Informative

    I agree with most of your stuff and you're probably better at *NIX than I am but I might suggest replacing telnet with nc which does both connecting and listening.

    --
    -- Alper
  8. Re:SSH by drinkypoo · · Score: 2, Informative

    telnet is the program that lets you test SMTP by connecting to 25/tcp, unlike ssh.

    --
    "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  9. Re:SSH by fimbulvetr · · Score: 4, Informative

    I'm actually suprised this guy used telnet. I find netcat (man nc) as a much better alternative. I can script it, I can do udp, and I can do port "testing".

  10. Re:Mine by mindriot · · Score: 5, Informative

    While rsync is very nice for syncing files, I've found another, somewhat related tool much nicer for my purposes. I have a desktop and a laptop computer, and to a great extent I work on the same files on both. Syncing my home directories could be done using rsync to some degree, but it's rather painful if you have modified files on both sides.

    This is where unison comes in handy. It keeps two directories synchronized nicely, adjusting changes in both directions automatically and querying the user in case of collisions. One of my favorite tools, and I'm sure I'm far from being the only one with a need for something like it.

  11. Without a doubt: tcpdump by mybecq · · Score: 2, Informative
    When you absolutely, positively have to know why your system isn't interoperating with the rest of the network, tcpdump will provide the answer. That is, assuming you know what it all means.

    There's no easier way to lay the blame squarely in the Windows camp (or to eat your hat)...

    A few diagnoses I've performed:
    • Providing the exact query in a web-developers app that was causing major problems
    • IE doesn't work with proxy because it sends invalid HTTP/1.0-formatted requests.
    • Connection to AD only works intermittently because your LDAP bind limit of 5 seconds is not long enough
    • Latency through the roof due to email/web/etc
    • Service unavailable because remote port is not listening
    • etc...

    I would say tcpdump is the #1 program for serious problem-solving -- at least with the work I did...
  12. Re:Mine by Anonymous Coward · · Score: 2, Informative

    rsync - although its binary diff algorithm is not very good, rsync is close to heavenly

    Except it's a piece of junk! We used to use it to maintain a set of files between two servers. As long as the number of files was trivial, it worked. When copying 22M files with gigabit ethernet between two Sun servers each with 8 gigabytes of RAM, it took almost a week to copy over the single file that had changed. rsync took almost a gigabyte of RAM and almost a week of time just to copy one file! Now we just run a simple script that runs find then scp to copy complete files that changed. It take about two hours. The simple shell script is over 75 times faster than rsync.

    These problems with rsync have been known for years. Do a search on deja.com to see all of the complaints.

  13. Depends on the admin role I'm in by jd · · Score: 4, Informative
    For network administration, I'd probably have a top 10 of:


    • hping3
    • bing
    • pchar
    • ping
    • traceroute
    • ncat
    • tcp dump
    • webmin
    • wget
    • ngrep


    Now, some of those are "well-known", but there are plenty there that few people (even on Slashdot) are likely to be overly familiar with.

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  14. Re:Vim? Colour hell! by sylvandb · · Score: 2, Informative

    when I have to change a word ([^ ]+) up to the next space, my screen ends up full of yellow blocks.

    Worst vi enhancement ever!

    (yes I know about :syn off)


    But do you know about :nohls (to disable HighLight Search results until the next search) or :set nohls (to disable for the session)?

    I quite often benefit from highlighting my search results. But when they annoy me, I simply turn off the highlighting.

    Definitely a good vi enhancement.

    sdb

  15. great tools by codepunk · · Score: 3, Informative

    All the best tools are the great networking tools which allow me to track down and eradicate owned windows machines on the network.

    nmap - hmmm what trojan do we have on the network today
    tcpdump - great at finding worms scanners
    iptraf - for finding weird clients p2p movie downloaders etc.
    ethereal - great for grabbing pop and telnet passwords
    aimsniff - just for amusement

    With just those couple of tools I can keep the helpdesk busy for weeks by finding owned machines that need cleaning.

    --


    Got Code?
  16. Re:Mine by i.r.id10t · · Score: 3, Informative

    Better thank lynx is links. Handles tables, frames, etc. no problem. Also, it can be compiled with various options to make it a graphical browser too, which is handy for X exported over SSH type things.

    --
    Don't blame me, I voted for Kodos
  17. Maybe a few lesser-known by toofast · · Score: 4, Informative

    ethtool and mii-tool. The Cisco 2970 switch we use has the knack of initializing the interface in half-duplex mode if the port is set to "Auto". Easily fixed by setting the port to Full, but useful nonetheless.

    strings. Good to check if executables are using /etc/hosts.allow and /etc/hosts.deny, or where pop3/imap are looking for PEM certificates to configure pop3s/imaps, etc...

    vmstat. Think your system is paging, or a card is generating too many interrupts? /proc filesystem. Favorites include /proc/net/dev, and /proc/uptime, /proc/cpuinfo, /proc/loadavg. Good for aggregating individual server load data in a cluster.

    awk and sed. Mentioned elsewhere, but priceless.

    chmod. I think the Linux filesystem permissions are too ... permissive. Cut down on access to your logfiles and to config files in /etc.

    *quota*. A must for restricting disk space use.

    umask. When you need root, set your default umask fairly tight. I use 0077, but when you need to cpan some common perl modules, switch to the more common 0022.

    jobs, fg and bg. Old-school unix commands to play with jobs that .. might take a while. When you forgot to & your command, use CTRL+Z then bg your job.

    There may be more, but I can't think of any others right now...

    1. Re:Maybe a few lesser-known by Nailer · · Score: 2, Informative

      > strings. Good to check if executables are using /etc/hosts.allow and /etc/hosts.deny, or where pop3/imap are looking for PEM certificates to configure pop3s/imaps, etc...

      Sure, but ldding the binary is a better way to discover is the app supports TCP wrappers.
      ldd /usr/sbin/sshd, for example, mentions libwrap.so

      But really, whether an app uses TCP Wrappers or where it looks for SSL certificates should be documented plainly. I think /etc/pki may also be an upcoming FHS standard for certificates too.

      strings is still handy tho - to find out what a binary from a rootkit does, without running it.

  18. Re:Other comments on GNU Screen? by Wizarth · · Score: 5, Informative

    Screen is very useful. I think of it as providing virtual terminals (you know, Ctrl-F1 to Ctrl-F6) but over remote login (usually ssh in my case)

    My normal usage is like so:
    ssh into the box
    screen -r (resume session, that was created first time I went in after bootup, with screen -S)
    Ctrl-A Ctrl-N (next virtual terminal) to flick through things i have running, usually centericq (text multi protocol chat client) and btdownloadcurses, or the results of a compile I left going.
    Ctrl-A Ctrl-C (open new virtual terminal) which gives you another command prompt. Here I'll wget a tarball, extract it, start the compile, then Ctrl-A Ctrl-N back to centericq

    I'll disconnect from the box (Ctrl-A Ctrl-D to disconnect from screen, then Ctrl-D to close the login shell), go home, reconnect from one of my other machines, go through the same process.

    Also, I can stay connected, go to another machine, and use screen -x to have multiple connections to the same screen. In the case of a dropped connection, and screen thinks my old login is still valid, screen -rD will disconnect the old login.

    Oh, and Ctrl-A ? will show all the in-screen escape sequences. Some of them I haven't used (there is one to do horiz split display, but it crashes btdownloadcurses), but look like they could be even more useful!

    But really, the best part is not having programs killed on me because the internet connection dropped (as happens all too often around these parts).

  19. Re:Clasis usability by Macka · · Score: 3, Informative


    I like vim for command line.....

    You can't do a whole lot of typing on the command line then either. I've never bothered to learn to use the Emacs editor (tried about 15 years ago and hated it) so I always use the vi editor ... but when it comes to command line editing, "emacs mode" whoops "vi mode" totally. Being able to use the arrow keys to scroll back commands or navigate the command line, along with ^a (beginning of line) ^e (end of line) ^r (to search for strings in your command history) ... "esc." (that's "dot" not a full stop, to recall the last field in the previous command string, etc, etc, etc....

    The only time I've had to use vi mode for command line editing is on HP-UX, where the lack of a modern shell by default and crap emacs mode support have forced me into it. The usability difference is horribly noticeable.

  20. Re:Other comments on GNU Screen? by jptxs · · Score: 3, Informative

    Step 1. Begin compiling some huge thing (tm) during your screen session.
    Step 2. Spend all day doing other things as compilation is off in some hidden window in screen.
    Step 3. Check on compiling every now and then, you will be able to scroll back and forth as needed as if you'd been sitting with an xterm open the whole time.
    Step 4. Leave work for home.
    Step 5. Reattach to you screen session and check on your compiling some more.
    Step 6. Realize inner peace knowing you need not worry about where you started some long process ever again by using screen.

    --
    we speak the way we breathe --Fugazi
  21. Re:Vim? Emacs foreva! by hackstraw · · Score: 2, Informative

    (I didn't know this until I learned emacs many years ago and realized that C-a and C-e worked in bash too. Then I noticed, hey, so does C-t, C-p, C-n, etc. C-r [isearch-reverse] is now my favorite bash feature, thanks to emacs. I always like it when learning one thing [emacs] makes another easier [bash].)

    As for vi, I know how to do basic stuff in it, but it basically upsets me. I have a wrt54g that doesn't have emacs on it and editing config files is a PITA. Why doesn't vi let me go to the end of the line by pressing, say, end or going to the end of a shorter line and then pressing the up arrow? Irritating. I know a vi guru is going to explain how to do this now, but I don't really care about the answer. What am I going to do the next time I'm stuck in vi and have a problem? (Hint: ESC :q!


    Disclaimer, I don't care what you or my neighbors use for a text editor, nor do I care what kind of toilet you prefer to take a dump in. Its not that big of a deal.

    I will say, that I find it a little strange that shells come with emacs bindings, when vi is kinda the default. I'm saying this because vi (or for some historical reason, ex) is the default editor and bindings in things like less and more. Aside from ^e and ^a, I don't know any other emacs commands. I do know that most shells will take vi commandline editing commands. Honestly, I forgot how to do this in my shell, zsh. Or maybe its the default. One of the things I like about zsh is that it is the only shell that correctly does multiline editing in vi mode, or at least it was. bash was unusable and broken at least in the past, there is no reason to change now.

    Oh, and going to the end of the line and beginning of the line in vi uses the carat ^ to the beginning and $ to go to the end. I've never tried keys that are on the dark side of the keyboard (where my hands aren't), so I don't know about that. The ^ and $ are not that foreign, because they are used to denote the beginning and end of lines in regular expressions. Intuitive? No. Easy to remember and associate with other stuff that I do every day, yup.

    As for vi, I know how to do basic stuff in it, but it basically upsets me. I have a wrt54g that doesn't have emacs on it and editing config files is a PITA.

    Again, I don't care. But I will say that emacs is not a standard UNIX thing, vi is. vim, my favorite editor, is not. I too have to deal with using "plain vi" sometimes. Its close, but certainly no cigar. I will say, that it is frustrating to work with someone that does not know vi at all. I'm not saying guru, but at least the basics. I would say that ^ and $ are a little beyond the basics, but it is something that someone should be able to pick up and remember after the first time of hearing about it.

    Again, vi, vim, or emacs are not better. vim and emacs have been in active development and used extensively over the years. They are both powerful editors. But everybody needs to learn the basics of vi if they are going to be using UNIX systems. Its one of those things. You do not have to like it.

  22. Re:indispensable: zsh & mmv by Florian · · Score: 2, Informative

    Besides from being shorter, mmv doesn't stop there. Your example doesn't scale to multiple replacements within one string, i.e. 'mmv "*_*.htm" "#1-#2.html"'. But above all, your example isn't safe. You could avoid filename collisions and accidental overwriting by aliasing "mv" to "mv -i"; however, that still wouldn't give you a complete check in advance, but make the command exit half-finished and non-reversable. mmv on the other hand cancels the operation before doing anything if there are any name collisions. - If you try to put all these features and safety measure into your shell script, you will probably end up with something that is as complex as the the C sourcecode of mmv...

    --
    gopher://cramer.plaintext.cc http://cramer.plaintext.cc:70
  23. Re:Vim? Emacs foreva! by crazyvas · · Score: 2, Informative
    Emacs, OTOH, has a keybinding style that translates great to other apps. GNU apps all use emacs keybindings (I wonder why), and even IDEs like eclipse have compatibility modes. I'm glad I'm not a vi user because I know I would never be able to get things done in GUI programs like eclipse.

    Vi plugin for the Eclipse editor: http://www.satokar.com/viplugin/

    Anyway, if you use a GNU system like Linux, you should learn emacs. Bash (readline), info, etc. all work just like emacs. It will really save you time and effort when every app uses the same keystrokes. C-t is a great timesaver in both bash and emacs.

    Glad you realized you can use emacs keystrokes on bash. This doesn't mean much for emacs though. Bash allows for either emacs or vi keystrokes to be used. Type "set -o vi" to get it it use vi keystrokes, complete with the two modes. "set -o emacs" (which happens to be the default) to use emacs.

    Also note, that while info might use keybindings similar to emacs, 'less', which is one of the most often used commands, uses vi keybindings.

    Why doesn't vi let me go to the end of the line by pressing, say, end or going to the end of a shorter line and then pressing the up arrow? Irritating. I know a vi guru is going to explain how to do this now, but I don't really care about the answer.

    Next time you don't really care about the answer, please do us a favor and quit blaming it on vi.

  24. Re:Mine by cwry · · Score: 2, Informative
    The comment on nasty, resource-hogging pipes is interesting, because on my system, using grep instead of -name is consistently faster than find:
    $ for ((i=0;i<5;i++)); do time find ~ 2>&1 | grep foo > /dev/null; done 2>&1 | grep real
    real 0m0.486s
    real 0m0.482s
    real 0m0.486s
    real 0m0.481s
    real 0m0.484s
    $ for ((i=0;i<5;i++)); do time find ~ -name foo 2>&1 > /dev/null; done 2>&1 | grep real
    real 0m0.575s
    real 0m0.581s
    real 0m0.577s
    real 0m0.576s
    real 0m0.579s
    Sure, it's not a huge difference, but the fact that grep is ~16% faster doesn't make me think twice about using the more generic | grep foo. The speed difference is even larger when you introduce wildcards. For example -name '*.foo' versus grep '.*foo$'
  25. Re:Mine by tzot · · Score: 2, Informative
    egrep = grep -E
    fgrep = grep -F
    $ ls -l /usr/bin/?grep
    lrwxrwxrwx 1 root root 10 2004-10-12 23:46 /usr/bin/egrep -> /bin/egrep
    lrwxrwxrwx 1 root root 10 2004-10-12 23:46 /usr/bin/fgrep -> /bin/fgrep
    -r-xr-xr-x 2 root root 33872 2004-04-06 06:56 /usr/bin/pgrep
    -rwxr-xr-x 3 root root 3456 2004-04-06 06:49 /usr/bin/zgrep
    --
    I speak England very best
  26. Instead of cdargs... by Clueless+Moron · · Score: 3, Informative
    I define these functions in my shell .rc:
    mk() { eval ${1:-MKPWD}=\"`pwd`\"; }
    rt() { eval cd \"\$${1:-MKPWD}\";pwd; }

    You type "mk" (as in "mark") and "rt" (as in "return") to mark a directory and later go back to it.

    Or you can give it a name: do "mk foo", and later on "rt foo" will move you back there.

    But the Big Win? With the above, it gets set as a shell var: $foo is also set to the directory, so you can do things like "cp $foo/*.baz ." to good benefit. In addition, setting up this system is just a trivial matter of setting environment variables in your .profile.

    PS: Trivia: the "mk" and "rt" names were inspired by troff, where those commands were used to keep mark and go back to vertical positions on a page... yeah I'm an oldie.

  27. Re:SSH by hazem · · Score: 2, Informative

    If you need to automate something like telnet or ftp (or anything interactive on the command line), "expect" allows for some very powerful scripting.

    It "expects" certain things and provides an appropriate output.

  28. Re:GNU Screen. by darkwhite · · Score: 2, Informative

    Concur. But even more importantly, screen by default doesn't come with any sort of on-screen window list. This .screenrc line makes a screen session tremendously more comprehensible to me:

    backtick 1 0 0 whoami
    caption always "%>%{kw}%1`@%H %{bw}%?%-Lw%?%{bW}%n*%f %t%?(%u)%?%{bw}%?%+Lw%?%"

    This will put a caption at the bottom of the screen listing your open shells and highlighting the current one.

    --

    [an error occurred while processing this directive]
  29. Re:GNU Screen. by darkwhite · · Score: 2, Informative

    Also, put this in your ~/.bash_profile:

    if [[ `who -m` ]] ; then
                    [ -z "$WINDOW" ] && screen -xdR
    fi

    to start screen automatically on terminal logins and grab the previous screen session.

    --

    [an error occurred while processing this directive]
  30. Re:SSH by Pheersome · · Score: 4, Informative

    I was actually going to say something very similar, and then I realized that I use telnet over netcat for certain purposes, because telnet notifies me when it actually connects. However, a couple minutes ago I realized I was being an idiot, because 'nc -v' does the same thing.

    Also, if you haven't already, check out nmap-ncat.

    --
    Better to light a candle than to curse the darkness.
  31. Elinks rocks... by arcadum · · Score: 3, Informative

    Elinks has javascript support. I've deployed elinks to many systems as a last resort for the tech support crew when the ppp connect is hosed.

  32. Re:Mine by Anonymous Coward · · Score: 1, Informative
    Honorable mention - /bin/sh Only because it is always there by definition on UNIX systems, and a good shell programming language. tcsh, csh, and zsh are not as good as /bin/sh, and its always available, but a little boring to write about.

    It is somewhat distressing that there are so many people in the Linux community who have missed out on a whole era of Unix and it's history. I'm being perhaps a little pedantic here but for clarity, /bin/sh is a link to /bin/bash on all Linux systems I've been on. So what the author really meant to say was, I like /bin/bash (me too!). /bin/sh is there to satisfy backwards compatibility with the Bourne and later POSIX shells. Strictly speaking, when bash is invoked as /bin/sh it should defer to the historical behaviour of Bourne or POSIX shells. Likewise it is telling (and painful) that no mention is made of 'ksh' (korn shell), IMHO the best shell of all (from a programming perspective). Much of bash is taken from ksh. I suppose that if bash becomes fully compatible with ksh I will have no longer of have a need ksh but until then, ksh still sits as king of the shell hill-top. And yes, please spend some time writting shell programs. Shell is a most underated programming tool. It is much more capable than many people realize.

  33. Re:Mine by Nailer · · Score: 2, Informative

    Nice post, but...

    > * [rs]sh - enables me to go places w/o passwords, copy files, and remotely execute commands. I can't live without it

    rsh has lots of known security vulernabilities and shouldd not be used at all.

    > * telnet - no, I never telnet to login to a machine, but I do it to test if a port is open, what's listening there, etc. very handy.

    You should use nc for this. Telnet will fail with lots of data, only does TCP, and can't listen on ports. nc handles lots of data, can do TCP or UDP, and can listen as well as send.

    > * Honorable mention - /bin/sh Only because it is always there by definition on UNIX systems, and a good shell programming language. tcsh, csh, and zsh are not as good as /bin/sh, and its always available, but a little boring to write about.

    True, but also, if the only Unix-like OSs you use are Linux, /bin/bash is there by definition. Functions, arrays, and other useful stuff.

  34. dmidecode! by Nailer · · Score: 2, Informative

    Your /proc stuff if great, here's a handy accompaniment: ever logged onto a system and had no idea what it is? Maybe a crappy Dell Poweredge or whiteboxx kit, maybe a nice solid IBM/HP box? Wanted to get the system's asset tag for support reasons?

    dmidecode. Part of the kernel-utilss package on most Linux distros.

  35. multitail by flok · · Score: 2, Informative

    Sorry for plugging my own project but I think MultiTail can be very usefull for a lot of admin tasks. MultiTail lets you view one or multiple files like the original tail program. The difference is that it creates multiple windows on your console (with ncurses). It can also monitor wildcards: if another file matching the wildcard has a more recent modification date, it will automatically switch to that file. That way you can, for example, monitor a complete directory of files. Merging of 2 or even more logfiles is possible. It can also use colors while displaying the logfiles (through regular expressions), for faster recognition of what is important and what not. It can also filter lines (again with regular expressions). It has interactive menus for editing given regular expressions and deleting and adding windows. One can also have windows with the output of shell scripts and other software. When viewing the output of external software, MultiTail can mimic the functionality of tools like 'watch' and such. For a complete list of features, look here. Multitail can be found here: http://www.vanheusden.com/multitail/.

    --

    www.vanheusden.com - home of Multitail, HTTPing, CoffeeSaint, EntropyBroker, rsstail, bsod, listener, nagcon, nagi
  36. Oh yeah? (pr0n howto) by identity0 · · Score: 3, Informative

    As this table shows, curl does not have "Recursive Downloads", which wget does. Which is the most useful feature of wget - you can point it at a pr0n link or gallery site like so:

    wget -r -k -H --level=3

    and it will follow all the pr0n links to three levels down, and retrieve all the pix/movies it links to. Saves you tens of hours of frustrated clicking and saving manually. Not that I personally use it for such vile things, of course :)