Documentation and Information:Getting started with Linux
Before proceeding please either be at a Linux workstation (e.g. in Fine Hall) or acquaint yourself with how to connect to connect to login servers via ssh and connect to math.princeton.edu or pacm.princeton.edu with ssh in the way appropriate for your computer. You should have been provided with a username and password for the Math/PACM Linux network. If you do not and you believe you should please check the help contacts for relevant contact info.
This is a very quick and dirty introduction to command line use on Linux that should help you to get started with command Linux use. At the end of this documents you can find links to much better and more detailed tutorials.
Before you begin reading this document there is a commands that you should remember very closely "man" - anytime you are at a loss on how to use a particular command or what it does first try "man command", e.g. "man cp" and you will get a man page with lots of details. Not every command has a man page but I am sure you will find man essential nevertheless.
Shell, prompt, commands
After connecting to the cluster with ssh you will be presented with a prompt that resembles the following (here we use sample user "mathuser"):
[mathuser@math mathuser]
The prompt is presented by the shell, the first program that the system runs on your behalf as soon as you connect and that will help you interact with the remote computer by interpreting commands you issue at the prompt. For example:
[mathuser@math mathuser] cp mycalc.c newproject/mycalc-new.c
where the first word "cp" is the command name and the remainder of the line are command's parameters.
Shell, prompt, commands
After connecting to the cluster with ssh you will be presented with a prompt that resembles the following (here we use sample user "mathuser"):
[mathuser@math mathuser]
The prompt is presented by the shell, the first program that the system runs on your behalf as soon as you connect and that will help you interact with the remote computer by interpreting commands you issue at the prompt. For example:
[mathuser@math mathuser] cp mycalc.c newproject/mycalc-new.c
where the first word "cp" is the command name and the remainder of the line are command's parameters.
Files and directories
File names in Linux can contain virtually any character except "/" which is used as a separator between directories in path names. For example "/home/mathuser/mycalc.c" would be the full path to mycalc.c in mathuser home directory.
All files on the system are located in the directory tree that starts at the "root" - "/". Most of the directory tree is reserved for system use and is carefully partitioned. For example "/bin" and "/usr/bin" contain many of the commands that you will be using.
Each user has a home directory to holds user documents, configuration files and other data. For example mathuser home directory would be "/home/mathuser". mathuser can also refer to its home directory by an alternate name "~". For example, instead of saying "/home/mathuser/newproject/mycalc-new.c" mathuser could also refer to the same file with "~/newproject/mycalc-new.c".
Changing, creating, deleting directories
cd, cwd, pwd
Whenever you issue a command you will be doing it from within a certain directory - called a "current working directory" (cwd) and you can change between directories by using "cd" command and "pwd" will print the current working directory (more explanations of following examples follow below):
[mathuser@math mathuser] pwd /home/mathuser [mathuser@math mathuser] cd newproject [mathuser@math newproject] pwd /home/mathuser/newproject [mathuser@math newproject] cd .. [mathuser@math mathuser] pwd /home/mathuser [mathuser@math mathuser] cd . [mathuser@math mathuser] pwd /home/mathuser
Note that the shell is configured by default to not only show you your username and the machine to which you are connected (mathuser@math) but also the name of the current working directory.
".." (two dots) are a shortcut that means the directory below the current working directory which is how in above example we returned to /home/mathuser. A single dot "." refers to the current working directory.
All file references are done relevant to the current working directory. For example if the cwd is "/home/mathuser" then we can refer to "/home/mathuser/newproject/mycalc-new.c" also as "newproject/mycalc-new.c" or as "./newproject/mycalc-new.c". If the cwd was "/home/mathuser/newproject" then we could just refer to it as "mycalc-new.c" or, if we want to get even more complicated and use .. and . "../newproject/./mycalc-new.c".
mkdir, rmdir = create/delete directory
mkdir will create a directory:
[mathuser@math mathuser] mkdir newproject2
rmdir will remove it:
[mathuser@math mathuser] rmdir newproject2
Basic file operation
cp = copy
"cp" command is used to copy files and directories. For example:
[mathuser@math mathuser] cp mycalc.c newproject/mycalc-new.c
copies mycalc.c files into directory newproject with new name mycalc-new.c (if it already exists it will be overwritten). You can use wildcards to copy more than one file at a time (but the destination then has to be a directory):
[mathuser@math mathuser] cp *.c newproject
copies all files that end with .c into directory newproject. An alternate way to do this would be:
[mathuser@math mathuser] cd newproject [mathuser@math newproject] cp ../*.c .
note the use of .. to refer to the directory below the newproject directory and of the "." to refer to the current working directory. The same could've been accomplished with:
[mathuser@math mathuser] cd newproject [mathuser@math newproject] cp ~/*.c /home/mathuser/newproject/
cp command, just like most other commands, accepts options that can modify its behaviour. For example if you were beginning to work on newproject2007 and wanted start by copying all the files from newproject you could do the following:
[mathuser@math mathuser] cp -r newproject newproject2007
which could recursively ("-r") copy the directory newproject to directory newproject2007 (caveat: if the directory newproject2007 existed you would get as a result a copy of newproject as newproject2007/newproject, if it didn't exist newproject2007 directory would be created and its contents would match newproject contents).
rm = remove files
rm command will remove files (and directories with special flags). For example:
[mathuser@math mathuser] rm newproject/*.c
or if we wanted to remove the directory newproject with all of its contents:
[mathuser@math mathuser] rm -rf newproject
which forces the removal of newproject directory and all of its subdirectories. Be VERY careful with "-rf" options.
mv = move files
mv command can be used to move/rename files. For example the following will rename myfftw2.c to fftw3.c
[mathuser@math mathuser] mv myfftw2.c fftw3.c
and the following will move all the fortran files into f90 subdirectory (that needs to exist already):
[mathuser@math mathuser] mv *.f90 *.f77 *.f f90/
ls = list files
ls command will list files in the current (with no params) or given directory:
[mathuser@math mathuser] ls newproject atlas.f90 fftw3.c fftw3.h Makefile gftw.c [mathuser@math mathuser] ls -d newproject newproject [mathuser@math mathuser] ls newproject/*.c fftw3.c gftw.c [mathuser@math mathuser] ls -ld newproject/*.c newproject -rw-r----- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c -rw-rw-r-- 1 mathuser ugrad 111921 Feb 3 09:40 newproject/gftw.c drwx------ 5 mathuser ugrad 4096 May 16 11:28 newproject
"-l" will make ls produce a long listing with details for every file and "-d" option makes it so that ls doesn't show the contents of the directory but the directory itself.
Consider the detailed listing - besides the file name at the end of the line you can also find the time the file was modified, the name of the user that owns the file (mathuser), the name of the group associated with the file (used only to determine who can access the file or directory in question) and the file size (in bytes).
The first field "-rw-rw-r--" or "drwx------" shows the type of the file and access rights to the file. The first letter will be "-" for files, "d" for directories and "l" for symbolic links (more on them later). The remaining characters determine access rights to the file - for the user (letters 2,3,4), for the group (5,6,7) and for everyone else (8,9,10). These are some of the possible rights:
File Type | Right | Explanation |
---|---|---|
file | r | file is readable |
file | w | file is writeable |
file | x | file is executable - for programs |
directory | r | contents of the directory can be read |
directory | w | new files and dirs can be created in the directory |
directory | x | directory can be entered |
Examples:
- "-rw-rw-r-- mathuser ugrad" for gftw.c - it is a file and the owner of the file (mathuser) and anyone in the ugrad group can both read and modify the file and everyone else on the system can read it.
- "-rw-r----- mathuser ugrad" for fftw3.c - it is a file and the owner of the file (mathuser) can read and modify the file, members of the ugrad group can read it and everyone else cannot access it in any way.
- "drwx------ mathuser ugrad" for newproject - it is a directory and only its owner (mathuser) can list its contents, create new files/dirs in it and enter it.
chmod = change access rights
You have seen above how to view access rights and what they mean, you can modify them with chmod. The first parametar determines the rights and should be followed by file/directory names. Examples follow:
[mathuser@math mathuser] ls -ld newproject/*.c newproject -rw-r----- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c -rw-rw-r-- 1 mathuser ugrad 111921 Feb 3 09:40 newproject/gftw.c drwx------ 5 mathuser ugrad 4096 May 16 11:28 newproject [mathuser@math mathuser] chmod g+rwx newproject [mathuser@math mathuser] ls -ld newproject drwxrwx--- 5 mathuser ugrad 4096 May 16 11:28 newproject [mathuser@math mathuser] chmod g-w newproject [mathuser@math mathuser] ls -ld newproject drwxr-x--- 5 mathuser ugrad 4096 May 16 11:28 newproject [mathuser@math mathuser] chmod o-r newproject/*.c [mathuser@math mathuser] ls -l newproject/*.c -rw-r----- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c -rw-rw---- 1 mathuser ugrad 111921 Feb 3 09:40 newproject/gftw.c [mathuser@math mathuser] chmod a+r newproject/*.c [mathuser@math mathuser] ls -l newproject/*.c -rw-r--r-- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c -rw-rw-r-- 1 mathuser ugrad 111921 Feb 3 09:40 newproject/gftw.c [mathuser@math mathuser] chmod -R og-rwx newproject [mathuser@math mathuser] ls -ld newproject/*.c newproject -rw------- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c -rw------- 1 mathuser ugrad 111921 Feb 3 09:40 newproject/gftw.c drwx------ 5 mathuser ugrad 4096 May 16 11:28 newproject
Logic is simple - you can add or remove rights for the user (u), group (g), others (o) or all (a). E.g. g+rwx - add read, write and execute for the group, or a+r - add read for all, or g-w - deny write for the group.
You can use "-R" option to apply the same rights to the directory and all of it contents. Especially useful flag is X, e.g. "chmod -R a+X dir" will make all the directories (and any executable files) executable but it will not add executable right to files that do not have it already.
ln = links
Besides files and directories you can also use links which allow you to access the same file or directory in different locations in the file system. There are 2 types of links - symbolic links and hard links. Hard links work only for files and allow you to have an identical file appear in mutliple places in the same filesystem. In other words you can refer to the same file content with different file names and in different locations. ln command creates links, its first parametar is the name of the file to which you want to create a link to and second parametar is the name of the link you are about to create:
[mathuser@math mathuser] ls -l newproject/fftw3.c newproject2006/fftw4.c -rw------- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c ls: newproject2006/fftw4.c: No such file or directory [mathuser@math mathuser] ln newproject/fftw3.c newproject2006/fftw4.c [mathuser@math mathuser] ls -l newproject/fftw3.c newproject2006/fftw4.c -rw------- 2 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c -rw------- 2 mathuser ugrad 2563 May 16 11:28 newproject2006/fftw4.c [mathuser@math mathuser] rm newproject/fftw3.c [mathuser@math mathuser] ls -l newproject/fftw3.c newproject2006/fftw4.c ls: newproject/fftw3.c: No such file or directory -rw------- 1 mathuser ugrad 2563 May 16 11:28 newproject2006/fftw4.c
If, in this example, you were to edit fftw4.c and change it you would be able to see that fftw3.c would change as well and continue to be exactly the same as fftw4.c. Note also that the number between the file rights and owner of the file lists the number of hard links for that particular file - initially 1 but as soon as we created another hard link it became 2. A file that is hard linked anywhere on the file system will only really be deleted when all the hard links are gone.
Symbolic links are pointers to any other file or directory on the system rather than just different names for the same file. Whenever you try to read/access a symbolic link the operating system will try to resolve it by starting at the directory where the symbolic link is located and show you the file or directory that the link points to. It is very important to understand how symbolic links are resolved - again, from the directory they are located in. E.g. take a look at the following example (that also shows that symbolic links can point to a file/dir that does not exist):
[mathuser@math mathuser] ln -s ~/newproject/fftw3.c newproject2006/fftw4.c [mathuser@math mathuser] ls -l newproject/fftw3.c newproject2006/fftw4.c -rw------- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c lrwxrwxrwx 1 mathuser ugrad 2563 May 16 11:28 newproject2006/fftw4.c -> /home/mathuser/newproject/fftw3.c [mathuser@math mathuser] more newproject2006/fftw4.c .... contents ....
The above example creates a symbolic link with an absolute reference pointing to ~/newproject/fftw3.c and we verify it works. Note that the listing of the link shows both that it is a link "lrwxrwxrwx", the name of the link and to what it points to. Now example on why to be careful:
[mathuser@math mathuser] ln -s ~/newproject/fftw3.c newproject2006/fftw4.c [mathuser@math mathuser] ls -l newproject/fftw3.c newproject2006/fftw4.c -rw------- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c lrwxrwxrwx 1 mathuser ugrad 2563 May 16 11:28 newproject2006/fftw4.c -> newproject/fftw3.c [mathuser@math mathuser] more newproject2006/fftw4.c more: newproject2006/fftw4.c: No such file or directory
The system cannot find newproject2006/fftw4.c because the symbolic link is located in the directory newproject2006 and since it is not an absolute reference it tries to read newproject2006/newproject/fftw3.c that does not exist. An example how to create a working relative symbolic link follows:
[mathuser@math mathuser] ln -s ../newproject/fftw3.c newproject2006/fftw4.c [mathuser@math mathuser] ls -l newproject/fftw3.c newproject2006/fftw4.c -rw------- 1 mathuser ugrad 2563 May 16 11:28 newproject/fftw3.c lrwxrwxrwx 1 mathuser ugrad 2563 May 16 11:28 newproject2006/fftw4.c -> ../newproject/fftw3.c [mathuser@math mathuser] more newproject2006/fftw4.c .... contents ....
This time it works because the system tries to access newproject2006/../newproject/fftw3.c which does work. Note that all kinds of problems can occur when you use symlinks and you start moving them and the files they point to so careful use of either relative or absolute links is required.
Note again that you can only create symbolic links to directories, not hard links.
View files
cat = display full content
cat will display the full contents of a file, as in "cat newproject/fftw3.c", without stopping after each screenfull or any other user interaction.
cat can be used to concatenate multiple files, as in "cat data1 data2 data3 > alldata" which writes the first three files sequentially into a file called alldata.
You can also use the >> pipe commands to append a file to another file, as in "cat potcar.H >> POTCAR" which will write potcar.H at the end of POTCAR.
more/less = display files slowly
more/less commands will display file contents but only a screenfull at a time. You can display the next page by pressing space, go back to previous page with "b", search within the document after pressing "/" and so on. Commands more and less are similar in what they are intended to do but have different capabilities. Man page of each can tell you more about key combinations they understand.
Editors
There are a couple of different editors you can consider using.
nano = simple, limited
nano is a very simple editor but one that cannot do much. Start it up by giving it a file name you want to edit/create:
[mathuser@math mathuser] nano newproject/fftw3.c
It understands few commands and they are all listed at the bottom of the screen. E.g. "^X" means that you should press together control-X (to exit the nano program).
emacs = powerfull, complicated
emacs is a very powerfull, complicated and, if I may be forgiven, bloated editor that you can use to do anything from editing files, being your psychotherapist to reading your e-mails. In particular it can help you with your work because it uses by default syntax highlighting of the document according to its type. E.g. it will recognize a C document and have different colors for statements, comments and variables. It will even try to help you match up braces ({ and }). Start it up by typing something like:
[mathuser@math mathuser] emacs newproject/fftw3.c
Here are some of the basic commands that you can use in emacs. You can get more detailed help in emacs itself, you can use "info emacs" or you can just find info on the net.
Key combination | action |
---|---|
Ctrl-x Ctrl-c | quit emacs (if not saved you will be asked if you want to save the file you are working on) |
Ctrl-x Ctrl-s | save the document you are working on |
Ctrl-g | interrupt, e.g. interrupt whatever other command you might've been trying to type |
Ctrl-x Ctrl-f | open a file (a new one) |
Ctrl-x Ctrl-v | open a file in place of the current one |
Ctrl-x Ctrl-b | list all open files/buffers |
Ctrl-x b | go to the next buffer |
Ctrl-x 2 | split the screen into 2 |
Ctrl-x 1 | unsplit the screen and only leave the current window |
Ctrl-x 0 | switch to other window |
Ctrl-x u | undo (can be used multiple times) |
Ctrl-x i | insert a file at the current location of the cursor |
Ctrl-s | search forwards |
Ctrl-r | search backwards |
Ctrl-k | delete to the end of the current line |
Ctrl-y | paste recently deleted text |
Esc x doctor | talk to the psychotherapist (you'll need it after working on your thesis for too long...) |
These are just scratching the surface...
vim/vi = powerfull, unintuitive, fast
vim is a clone of vi, a traditional Unix editor. It is fast, efficient and capable - e.g. it also has syntax highlighting. It is more cryptic and less intuitive to get going initially but rewarding if you stick with it.
Unlike most other editors in vi you cannot immediately start editing - that's because vi can be in a couple of different modes. You are initially placed in "command mode" where you can enter various commands and move the cursor through the file. E.g. if after moving the cursor to where you want to start typing you press i you will move to "insert mode" and only then you can start your editing. To exit various editing modes you can press the escape key. Note that in the following table of basic commands all the commands have to be issued in the command mode:
Command (case matters) | action |
---|---|
Esc | exit the current mode and return to command mode |
i | insert mode - start inserting text at the location of the cursor |
a | append/insert mode - like insert but after the location of the cursor |
R | replace mode - overwrite existing text, do not insert |
x | delete a character under the cursor |
D | delete until the end of the line |
/ | start a forward search |
? | start a backward search |
:w | save the file |
:q | quit vi |
:wq | save and quit |
. | redo last action |
b | move cursor a word back |
w | move cursor a word forward |
{ | move cursor to the beginning of the previous paragraph |
} | move cursor to the beginning of the next paragraph |
G | move to the end of the file |
gg | move to the beginning of the file |
23G | move to the 23rd line in the file |
dd | delete the whole line |
db | delete previous word |
d} | delete next paragraph |
yy | copy the present line into buffer |
yw | copy the next word into buffer |
yG | copy all the tex from the cursor to the end of the file into buffer |
p | paste text from buffer after current line |
P | paste text from buffer before current line |
o | insert a new line after the current one |
O | insert a new line before the corrent one |
Note how certain commands, like d or y, can be combined with movement commands. E.g. dG would delete everything from the cursor location until the end of the document.
gedit=familiar interface, very useful
It looks and behaves like wordpad (the upgraded version of notepad)
grep, find, locate = looking for files and strings
There will be a time when you won't remember where did you implement that particular function or you will need to find out which system library contains the function that prevents your program from successfully linking or just where is that file you know you have somewhere among thousands of files. So let's see how to search.
grep = find strings in files
grep can be used to find strings in files. It expects a strings that it is going to be looking for and a list of files where to look for the string. For example:
[mathuser@math mathuser] grep integrate_partial *.c *.h integrate.h: void integrate_partial_one( integrate.h: int integrate_partial( integrate_helper.c: void integrate_partial_one(INTEGRAL *to_integrate, int attempt) { integrate.c: int integrate_partial(INTEGRAL *to_integrate) {
looks for integrate_partial in all files ending with .c or .h. It first prints the file name where it found it as well as the line that contains the string. Note that it matched both integrate_partial_one and integrate_partial.
By default grep is case sensitive but you can specify -i option to make it ignore the case. You can also tell grep to look recursively through a directory. More examples:
[mathuser@math mathuser] grep -ri integrate_partial . integrate.h: void integrate_partial_one( integrate.h: int integrate_partial( integrate.h: #define INTEGRATE_PARTIAL_ATTEMPTS 100 integrate_helper.c: void integrate_partial_one(INTEGRAL *to_integrate, int attempt) { integrate_helper.c: if (attempt < INTEGRATE_PARTIAL_ATTEMPTS) { integrate.c: int integrate_partial(INTEGRAL *to_integrate) { Binary file compile_intel/integrate_helper.o matches Binary file compile_intel/integrate.o matches Binary file compile_gcc4/integrate_helper.o matches Binary file compile_gcc4/integrate.o matches
here we ignored the case (compare with previous example) and we also instructed grep to search recursively through "." i.e. the current directory. Also note that when binary files match grep will only tell you so but, they being binary, it cannot show you any content. Even then it is still useful. For example if you are unsure which library you need to link in to satisfy a dependency for pthread_join function you could do:
[mathuser@math mathuser] grep pthread_join /lib64/lib* /lib/lib* Binary file /lib64/libpthread-0.10.so matches Binary file /lib64/libpthread.so.0 matches Binary file /lib/libpthread-0.10.so matches Binary file /lib/libpthread.so.0 matches
Note that I've searched through /lib64 and /lib - that is because hydra is a 64bit machine and has both 64 bit and 32 bit libraries.
You can also do invert the match - i.e. select non-matching lines - by using "-v" option. You can find an example of that below in "pipe" section.
find = find files
find command can be used to search for files and directories. It is an extremely complex command and we will just mention a few simple commands as well as give a more complex example just to show what it is capable of. Please check the main page for more options. Examples:
[mathuser@math mathuser] find ~ -name fftw3.c
looks for a file called exactly fftw3.c in mathuser home directory.
[mathuser@math mathuser] find newproject -name \*.c
looks for all files that end with .c in newproject subdirectory. Here we used a star (*) because we wanted all files ending with .c but note that we had to "escape it", i.e. prefix it with "\". That is so because usually the shell tries to expand such entries before it gives them over to find command. Therefore if there was a .c file in the current working directory, say fftw2.c and fftw3.c, and we didn't use "\*.c" but just "*.c" then shell would end up executing "find newproject -name fftw2.c fftw3.c". That would fail but in other situations it might seem to work but not give the desired result.
If you want to ignore case you can use iname option:
[mathuser@math mathuser] find newproject -iname \*.c
And here is a more complicated example that looks for a cxx file that has integrate_string in it and if it finds it then it will remove that file:
[mathuser@math mathuser] find newproject -name \*.cxx -exec grep -q integrate_string "{}" \; -exec rm -f "{}" \;
locate = find files on the system
The system maintains a database of files and their locations that you can quickly search through, e.g.:
[mathuser@math mathuser] locate libnss_dns-2.3.2.so /opt/teamhpc/node-ssi/rootfs/lib64/libnss_dns-2.3.2.so /opt/pathscale-1.4/x86_64-pathscale-linux/lib/libnss_dns-2.3.2.so /opt/pathscale-1.4/x86_64-pathscale-linux/lib64/libnss_dns-2.3.2.so /opt/pathscale-2.0/x86_64-pathscale-linux/lib/libnss_dns-2.3.2.so /opt/pathscale-2.0/x86_64-pathscale-linux/lib64/libnss_dns-2.3.2.so /lib64/libnss_dns-2.3.2.so /lib/libnss_dns-2.3.2.so
but, unfortunately, it will not search through your home directory (/home or /storage) so it can only be used for files on the local system.
pipe = combining commands
One of the great strengths of Linux shell command line is that you can combine commands by processing the output of one commands with other commands by using pipe "|". For example:
[mathuser@math mathuser] locate libnss_dns-2.3.2.so | grep -v pathscale /opt/teamhpc/node-ssi/rootfs/lib64/libnss_dns-2.3.2.so /lib64/libnss_dns-2.3.2.so /lib/libnss_dns-2.3.2.so
here we pipe the output of locate's search for libnss_dns-2.3.2.so to grep which does a reverse match for pathscale (i.e. excludes anything that matches pathscale string) and prints it out.
redirecting >> data
You can redirect data with the > and >> arrows. The single arrow will write data to a new file (it must not exist). Type "ll > file_list" to create a file composed of the names of all files in your current directory. Double arrows will redirect the output by appending it to the end of a file. Type "date >> file1" to have the current date and time written to the end of file1.
Finding documentation and help on the system itself
Most of the system commands and much of the software that is installed on the system comes with documentation. That includes man pages, info documents and all kinds of other documents (pdf, txt, postscript and others). Here you will find hints on how to find it all.
Ask for help from the command itself
Many commands can give you their basic options and usage if you ask for it with -h or --help option. E.g. try some of the following examples:
[mathuser@math mathuser] cp --help [mathuser@math mathuser] man -h
man pages
Man (manual) pages are included with much of the software that is installed on the system and almost all of the system commands have a man page that describes how to use that command. E.g. to view a man page for cp command you would type:
[mathuser@math mathuser] man cp
and on that page you will find detailed information on the cp command, including all the arguments that it can be used with. Note that, just like with more/less, you can search through the man page you are looking it as well as scroll back and forth.
Man pages also contain documentation for various system calls and some operating system features.
You can also search through descriptions of man pages ("man -k ...") which might help if you are looking for a specific command and cannot remember it exactly. For example if you were looking for DNS related man pages:
[mathuser@math mathuser] man -k DNS dig (1) - DNS lookup utility dnsdomainname [hostname] (1) - show the system's DNS domain name dnssec-keygen (8) - DNSSEC key generation tool dnssec-makekeyset (8) - DNSSEC zone signing tool dnssec-signkey (8) - DNSSEC key set signing tool dnssec-signzone (8) - DNSSEC zone signing tool host (1) - DNS lookup utility nsupdate (8) - Dynamic DNS update utility
Note also the number between brackets - it determines the man page section in which the relevant man page is located. For example to get nsupdate man page from section 8 you could request it with
[mathuser@math mathuser] man 8 nsupdate
Info manuals
Some programs also have info manuals. They are generally much more comprehensive than man pages but fewer programs have them. For example you can find extensive info manual pages on gcc and emacs, e.g.:
[mathuser@math mathuser] info gcc
Press "?" while viewing an info manual to get information on commands you can use with info program.
A lot of programs install together with additional information in various formats. Most of it is located in /usr/share/doc in a subdirectory named after program's name and version. For example you can find additional octave documentation under "/usr/share/doc/octave-2.1.57/" (or a similar location - might change if we upgrade octave to a newer version). Programs installed under /opt might have documentation there too. For example pathscale has some documentation under "/opt/pathscale/share/doc/pathscale-compilers-2.4" - again, will change when pathscale compiler is upgraded.
Other Tutorials
These are just some of numerous tutorials you can find on the net. They are all better and more detailed then the above introduction but they also cover a lot of ground that you may not need or care about at this point.
- Linux Tutorial from the Linux Documentation Project
- Red Hat Step by step guide
- BASH Commands (useful for writing scripts)