Linux command guide
The following is a short list of the most common or useful commands you can find on Harvard’s instructional UNIX environment and on most modern Linux distributions.
||list names of files and directories (see: directory)|
||print the date|
||print a calendar|
||copy a file or directory1|
||move a file or directory1|
||remove a file1 (see: removal)|
||output the contents of a file or concatenate many files|
||remove an empty directory1|
||make a new empty directory|
||print the path of the current working directory (see: working directory)|
||change working directory (see: working directory)|
||exit the shell (see: shell)|
||edit text files with a simple interface (see: text file)|
||edit text files with speed and efficiency (see: text file)|
||edit text files and give yourself various wrist strain injuries (see: text file)|
||securely obtain shell access to a remote computer|
||read a text file (see: pager)|
||read a text file (see: pager)|
||display any differences between two files|
||show who else is logged in|
||get help and information from the manual pages|
In Linux, it is useful to visualize a file system like the
underground roots of a tree: the stump is the topmost directory, known
/. A directory in the topmost directory,
alpha, would be
beta directory inside
alpha would be known as
/alpha/beta. Because we are showing the entire root structure from
stump to tiny roots, these paths are known as absolute.
Relative paths are paths specified with respect to your current
working directory. Let’s say I’m in a directory called
absolute path is
/home/alexander/harvard/s111. When constructing a
relative file path, you use the keywords
.. (one period and
two periods) to refer to the current directory and the parent directory,
respectively. So, if my current working directory is
/home/alexander/harvard/s111, the relative path
../ refers to the
directory known by the absolute path
the relative path
../../ goes up two directories. I can even use this
method to specify another file or directory in my home folder
/home/alexander), perhaps my todo list:
../../todo. In a shell,
.. can be used instead of specifying an absolute
path, wherever necessary.
directory. Analogous to a “folder” in a graphical user environment like Windows or Mac OS X. Contains files and other directories.
pager. A program that divides a text file into pages and allows the user to read the file one page at a time. Each page is as large as the terminal window.
relative file path. Specifying the way to reach a file relative to your
current working directory (e.g., the relative path
../test.txt) refers to a file
test.txt in the
directory containing the current working directory).
removal. Analogous to deleting a file in a graphical user environment like Windows or Mac OS X, but not alike to moving a file to the Recycle Bin or Trash. Removing a file destroys it, with little hope of recovery. Be careful!
shell. A program that gives you the ability to run other programs and see the output of those programs. The characters that appear each time the shell is waiting for your input is called the prompt.
text file. Also called a plain text file. These often have the simple
.txt. Such files contain just characters;
no ability to adjust formatting (like fonts or color). Text
files are used to write source code for programming (like
Java or C programs).
working directory. The directory the shell considers the “current” one; in other words, when specifying a relative file path, the shell “starts” in the working directory.