The 15 Essential UNIX commands
Learning UNIX is a seemingly daunting task, there are thousands of commands out there, each with hundreds of options. But in reality you only need to know a few of them.
I use unix quite a bit, usually either on one of our Linux servers, or on my Powerbook with OS X. And these are the 15 commands that I use most. If you can memorize these 15 commands, you can do quite a bit on a unix operating system, and add unix as a skill on your resume.
The 15 Most Important UNIX commands
- man - show manual for a command, example:
qto exit the man page.
- cd - change directory, example:
- ls - list directory, similar to
diron windows. example:
ls /etc, use
ls -l /etcto see more detail
- cp - copy a file or directory, example:
cp source destif you want to copy a directory use the
-Roption for recursive:
cp -R /source /dest
- mv - move a file, example:
mv source dest
- rm - remove a file, example:
rm somefileto remove a directory you may need the -R option, you can also use the -f option which tells it not to confirm each file:
rm -Rf /dir
- cat - concatenate, or output a file
- more - outputs one page of a file and pauses. example:
qto exit before getting to the bottom. You can also pipe to more
| morefrom other commands, for example
ls -l /etc | more
- scp - secure copy, copies a file over SSH to another server. example:
scp /local/file firstname.lastname@example.org:/path/to/save/file
- tar - tape archiver, tar takes a bunch of files, and munges them into one
.tarfile, the files are often compressed with the gzip algorithm, and use the
.tar.gzextension. to create a tar
tar -cf archive.tar /directory, then to extract the archive to the current directory run
tar -xf archive.tarto use gzip, just add a
zto the options, to create a tar.gz:
tar -czf archive.tar.gz /dirto extract it
tar -xzf archive.tar.gz
- grep - pattern matcher, grep takes a regular expression, or to match a simple string you can use fast grep,
fgrep failure /var/log/messages, I'm usually just looking for a simple pattern so I tend to use fgrep more than regular grep.
- find - lists files and directories recursively on a single line, I usually pipe grep into the mix when I use find, eg:
find / | fgrep log
- tail - prints the last few lines of a file, this is handy for checking log files
tail /var/log/messagesif you need see more lines, use the
tail -n 50 /var/log/messagesyou can also use the
-foption, which will continuously show you the end of the file as things are added to it (very handy for watching logs)
tail -f /var/log/messages
- head - same as tail, but shows the first few lines the file
- vi - text editor, there are several text editors such as emacs, and nano, but vi is usually installed on any server so its a good one to learn. To edit a file type
vi fileto edit a line press
Esc ithen to save changes and exit use
Esc wq, or to quit without saving use
Esc q!. There are a million other commands, but that will enable you to edit files at a basic level.
Once you learn these commands, and are comfortable with them, you shouldn't stop there, there are lots of other commands that can make your life easier.
Did I miss any commands that you think are essential to using a UNIX based operating system?
- Howto Backup your Mac incrementally over SSH - March 10, 2006
- Shell Script for backpack todo lists - August 20, 2005
- Why is my cron.daily script not running? - January 10, 2018
- Unix Job processing - November 28, 2005
- Linux and OS X Shell Commands - March 7, 2005
- Docker Container exited with code 137
- Why is my cron.daily script not running?
- Announcing FuseGuard Version 3
- CFSummit 2017
- Java Unlimited Strength Crypto Policy for Java 9 or 1.8.0_151
- Java 9 Security Enhancements
- Upcoming CFML Conferences in April 2017
- CFSummit 2016 Slides