This page is from the old wiki. It’s a guide for becoming more familiar with the command line. These are some basic GNU/Linux terminal commands that are useful to know as a minimum. Feel free to edit this post as a wiki page – just click the “edit” button.
Built-in Documentation
Most commands come with documentation in the form of “man[ual] pages”. To read the man page for a command use the man command.
Example: to read the documentation for the ls command, type man ls in a terminal. You can also search Google for information on any command.
List of Useful Commands
ls – list directory contents. Also ls -l, ls -R, and ls -al.
cd – change directory
cp – copy files
mv – move a file or directory. Also for renaming things
mkdir – make a directory
rm – remove a file. Also rm -rf, but very dangerous. See this story for a warning on how dangerous it can be.
rmdir — remove a directory
touch – create a new empty file
pushd – move to another directory with a bookmark (actually a stack of directories you’ve jumped from, so you can use it multiple times)
popd – jump back to the place where you pushd’d from
pwd – show current location
clear – clear the terminal. Also ctrl-l
less – display output with pagination
vim – type vimtutor and see the [[Vim]] page.
nano – simple console editor
cat – display a file and/or concatenate it
top – show processes. If you like that, install htop.
tree – e.g., tree -d >> outputfile.txt. You may need to install it first.
tar, zip, gzip – manage archives
wc – count things: lines, bytes, characters, words, etc. Example: wc -l filename.txt will count the lines in a file.
tee – redirect the output to a file and the screen at the same time. E.g., ls -1 *.py | wc -l | tee count.txt which counts the number of Python files in your directory, writes it to the screen, and saves it to a file.
kill
ps
locate
find
shutdown
reboot
uptime
chmod
chown
du
df
head
tail
diff
date
df
sleep
which
apropos – can’t remember a command? Use this to find commands about a keyword, like: apropos wireless
Most recent favorite shortcut in Bash and similar shells
(ctrl-x ctrl-x) jumps to the beginning of the current input
repeat it to go back to where you were
More specifically, it moves to a marker that defaults to start of the line
and you can use (ctrl-space) to set it to a new location
history - show a history of recently-invoked commands for this tty (then use !1234, for example, to re-run the earlier ID as seen)
touch - not only creates new files but can be used to change the timestamp of an existing one, useful for archival purposes or if working on caching code which looks for recent activity (or to age a file with touch -c -t 201901010000 example.txt)
echo - a humble program to say something to the terminal, usually in combination with something else like concatenating to an existing file
>, >> and 2> (redirection commands) - The first is used to send the standard output to a new file or to overwrite an existing one. The second as shown is used to create a new file or to append to an existing one. The third version shows how to additionally send the standard error output to a new file like in the first example.
| (pipe command) - Used to string together the output of the first command as the input to the next (as in history | grep ls)
sudo - Allows a temporary elevation to the root user from the current one, often used when running system-level commands like reboot
pkill - A friendlier version of kill if there’s only one instance running of a command or if you wish to kill all those so-named, for example, sudo pkill node
nslookup - A program to help troubleshoot DNS-related problems
ifconfig - A report of the network devices and their state
dmesg - A report of device-related logged messages
iwlist - A report of wi-fi zones as seen and related information (sometimes also iw)
In my opinion, it’s an absolute gem of a book – extremely approachable and well laid out. I wish I had it 20 years ago! It is unapologetically Linux-focused though, so no guarantees which parts will carry over to OSX and other operating systems.