Quick Reference¶
Console tips¶
Readline tab completion
Readline history up/down arrows
Control-c to send SIGINT
Control-d to send EOT/EOF
Paths¶
/The root directory (top of the hierarchical filesystem).
~Your own home directory, which is space set aside for your personal files.
.A special child listed in every directory that refers to itself. That is,
path/.is the same aspath, and just.refers to the working directory...A special child listed in every directory that refers to its parent. That is,
path/child/..is the same aspath, and just..refers to the directory above the working directory.- Absolute path
A path that starts with a
/, such as/usr/local/bin, starts from the root directory.- Relative path
A path that doesn’t start with
/, such asinput.txtorsource/main.c, starts from the working directory.
Working with files and directories¶
mkdir pathMake a new directory named
path.rmdir pathRemove a directory named
path, but only if it is empty.rm pathRemove a regular file named
path. There is no trash; the deleted file cannot be easily recovered.rm -r pathRemove a directory named
path, and all of its contents recursively. There is no trash; the deleted files cannot be easily recovered.rm -f pathRemove
pathby force, i.e. do not complain if the file is read-only or already doesn’t exist. There is even less protection than a normalrm.mv source destMove/rename
sourcetodest. Thesourcecan be a directory or a file, it doesn’t matter.cp source destMake a copy of regular file
sourcenameddest.cp -r source destMake a copy of directory
sourcenameddest, copying all of its contents over recursively.
For cp and mv, if dest is a directory
that already exists, the source will be copied or moved into
that directory without changing its name, i.e. it is as though you had
specified dest/source.
Synchronizing files with a server¶
rsync -a path user@server:Copy
path(recursively ifpathis a directory) intouser’s home directory onserver.rsync -a user@server:path .Copy
pathonserverinto the local working directory. Ifpathis relative, start fromuser’s home directory.
Following a git repository¶
git clone urlGet your own copy of the repository from the given
url, creating a new directory named after the repository to hold its contents.git pullRun within your clone of a repository, to download and incorporate any updates from the original.
Working with programs¶
running bare command to find in PATH
running with absolute path
running with relative path e.g. ./
gcc -g -Wall -o program name.c
gcc -c -g -Wall -o name.o name.c
gcc -g -o program objects
make
make targete.g. clean
Working with archives¶
tar czf name.tar.gz pathCreate a compressed archive of
path. The archive will be namedname.tar.gz.tar tzf name.tar.gzList the contents of the archive
name.tar.gz. This is a good way to see what is in an archive without extracting anything.tar xzf name.tar.gzExtract the contents of the archive
name.tar.gz.
RTFM¶
man pageRead the specified
pageof the manual, i.e.man lsto learn more about the options to ls, orman manto learn more about how to read the manual.man section pageRead the specified
pageof the manual in a particularsection. The sections help disambiguate documentation for things with the same name; for example,man 1 printfshows the page for the shell command named printf, whereasman 3 printfshows the page for the C standard library function namedprintf.whatis pageList all of the manual pages named
page, with their section numbers and short descriptions. For example, if you try to look up information on the C standard library functionprintfand are surprised to get the manual page for the shell command named printf, you can runwhatis printfto see a list of all the pages with that name and figure out which one you want.apropos queryPrint the manual for pages that are relevant to
query, by searching their titles and short descriptions for matching text.