So you’re about to graduate from college and while looking for a job, and someone expresses surprise when you confess that you’re not well-versed at Linux. Uh oh.
Everyone who expects to work in computing should know some basics about Linux. So much of the world runs Linux these days–phones, thermostats, TVs, cars.
Here’s a list of tasks that the young computer scientist should be able to do with Linux. The goal isn’t for you to be able to get a job as a “sysadmin” but to have a general familiarity with enough different things that you can solve real world problems with a Linux system. Of course, much of this applies to Mac OS X, too.
- Install CentOS or Ubuntu into a virtual machine on your Windows or Mac desktop/laptop. Open a Terminal window.
- You’ll probably get most of your help through Google searching, but on the command line, you can get help with specific commands by using the man command. E.g., man ls
- Basic file navigation: ls, cd, pwd, pushd, popd, dirs, df, du, mv. Be careful with rm.
- Basic editing with vim (open a file, save it, close it without saving, edit it, copy/paste with yank, jump to a specific line number, delete a word, delete a line, replace a letter.) (You can use nano while you’re coming up to speed on vim.)
- Use grep, less, cat, tail, head, diff commands. Use with pipes. Use of tail -f, less +F, tail -10, head -5 (or other numbers) is handy.
- tar and gzip to create and expand archives of files.
- Use sed, awk — replace the contents of a file, print the column of a file.
- Command-line git commands to checkout, edit files, commit, and push back to a remote repository (e.g., Github).
- Basic process navigation: ps, top, kill, fg, bg, jobs, pstree, Ctrl-Z, Ctrl-C.
- Unix permissions: chmod, chgrp, useradd, sudo, su; what do 777, a+rw, u+r mean, how to read the left column of ls -l / output.
- Simple bash scripts: Write a loop to grep a file for certain output, set command aliases
- Compile a simple C program with gcc. Use gdb to set breakpoints, view variables in a C program being debugged (where, bt, frame, p).
- Use tcpdump to watch HTTP traffic to a certain host.
- Understand /etc/rc.d and /etc/init.d scripts
- A basic understanding of /etc/rc.sysinit
- Attach a new disk and format it with fdisk or parted and mkfs.ext4. Run fsck. mount it. Check it with df.
- Know how to disable selinux and iptables for debugging. (service, chkconfig)
- How to use the route, ifconfig, arp, ping, traceroute, dig, nslookup commands.
- Write an iptables rule to forward a low number port (e.g, 80) to a high number port (e.g, 5000). Why would someone want to do this?
- A cursory understanding of the filesystem layout — what’s in /etc, /bin, /usr, /var, etc.
- A cursory understanding of what’s in /proc.
- Configure and use SSH keys for automatic login to another host.
- Forward a GUI window over SSH with X11
- Reboot and halt the machine safely (shutdown -h now, reboot, halt -p, init, etc commands)
- yum and apt-* commands (CentOS and Ubuntu, respectively)
- Modify boot options in grub to boot single user, to boot to a bash shell
For extra credit:
- The find command is a complicated beast, but simple to get started with.
- Copy files over SSH with scp.
- The dd command is useful for dealing with a variety of tasks, such as grabbing an image of a disk, getting random data from /dev/urandom, or wiping out a disk, and so on. Also be aware of the special files /dev/zero and /dev/null.
- Figure out how to recover a forgotten root password.
- Disable X11 and be able to do these tasks without the GUI.
- Do the same tasks above on a FreeBSD machine.
- Without the GUI, configure the machine to use a static IP address instead of DHCP.
- Use screen to create multiple sessions. Logout and re-attach to an existing screen session.
- Write a simple Makefile for a group of C or C++ files.
- What does chmod +s do? Other special bits.
- netstat, ncat, ntop.
- ldd, strings, nm, addr2line, objdump
- Grep with regular expressions
- What’s in /etc/fstab?
- history, !<number>, !!, !$, Ctrl-R
Books to peruse:
- Unix Power Tools
- sed & awk
- bash Cookbook
- Learning Python Every computing professional should know a simple scripting language that ties to the OS for more complex scripts than are rational than bash; python is an excellent place to start.
- Advanced Programming in the UNIX Environment, 3rd Edition (be sure to get the latest edition)
- If you’re interested in networking, be sure to read TCP/IP Illustrated, Volume 1: The Protocols (2nd Edition)
- You probably took an OS class. While Tanenbaum and Silberschatz write great books, if you want to know Linux internals better, Rubini’s device driver book is an excellent read. There is a 4th edition coming later this year. Linux Device Drivers, 3rd Edition