This document gives the 'survival skills' necessary to manage your files under a Unix?inux operating system. It gives a basic introduction to several editors and describes the basics of the operating system.
Editors are word processors that have been oriented toward a particular computer's requirements or to particular software format requirements. This section gives a very brief description of the most important editors. Much more can be learned by their help facility or by perusing the documentation. Note that not all editors are available on all hosts.
Each editor is invoked by the editor name followed by the name of the file to edit. Full-screen editors allow the use of the arrow keys to position the cursor within the file.
vi is the standard full-screen editor available on all Unix systems that people love to hate.
vi <filename> starts an editing session using the file <filename>
There are three modes in communicating with vi:
In the surfing mode:
The command mode can be accessed only from the surfing mode by typing :, followed by a single command like the ones described below. Having executed that command, vi returns to the surfing mode.
Emacs is a popular Unix full-screen editor from Free Software Foundation, installed on most Unix systems. It allows the use of the delete key besides the arrows (unlike vi). It also automatically saves the original copy with a different name, so if the changes turn out to be unneeded, you can go back to the previous version. There is a command line at the bottom of the screen, and at certain times prompts will appear there.
Cntrl-V moves the cursor one page down, ESC followed by V moves one page up. To go to a specific line number, type ESC, followed by X then the text goto line followed by the linenumber.
To replace a certain string with another, type ESC followed by X, then the text replace string, followed by the old and the new string, both closed by enter key.
To exit, type: CNTRL-X and CNTRL-C. It will query you if you want to save the changes.
2. Operating system
Unix/Linux uses a tree-structured hierarchy, similar to the file structure on MS-DOS for the IBM PC's (and compatibles) or to the hierarchy of folders in the Macintosh and Windows. At each level of this hierarchy, one can have actual files containing data, programs and the like or a directory that points to a lower level of the hierarchy. Below is an example.
Here anything that ends with a / is a directory. The ellipsis (...) is used to indicate a directory that is not described here. Files are specified by the path of directories leading to them, thus the full name of the .login file at the second level is /.login while the .login file at the fourth level is /user/lorant/.login. Notice that Unix is case sensitive and usually uses lower case letters.
When a user logs on the system is in the user's directory,
To find out which directory you are currently in type pwd.
To change the directory to a new one use the command cd <new>. Here <new> can be
A. full directory path: cd /user/lorant/mopac;
B. directory path staring from a current directory: cd mopac/vitamin_c/ ;
C. pointing to one directory level up: cd ...
Issuing command A any time the user will change to the mopac directory. Issuing command B while in the login directory results a change into the vitamin_c directory. Issuing it from any other directory would result in an error message. Command C can be issued from any directory, it will step the user up with one level. For example, issuing it after a successful command B, the user will be in the mopac directory.
To obtain a list of files and directories in a given directory, type ls.
To find out how much disk space is used by your files, the command du -sk <directoryname> gives the number of blocks used by that directory (if <directoryname> is omitted, the space used by all the files and directories in the current directory will be shown).
To see the contents of a text file, type more <filename>. The more commands stops after each page - hit space to continue. CNTRL-C aborts the listing.
To copy file A to file B issue cp A B. Here A and B can include directory path. For example
cp mopac/vitamin_c/min.inp mmm.i
would copy min.inp to the current directory with the name mmm.i. However, if mmm.i is the name of a directory currently existing in the current directory then min.inp will be copied into that directory with tha same naime.
To rename a file, type mv <old_name> <new_name>.
To delete a file, type rm <filename>. To delete a directory (after having emptied it) type rmdir <dir_name>.
Generally a filename can contain any alphanumeric characters,
underscore and some others. It usually consists of two parts,
separated by a period (.) where the second part is used to
say something about the type of the file,
whatnot 0.5in test.prog.c out_put
When referring to files, the symbol * is used as a 'Wild Card', meaning that anything that matches the rest of the name will be referred to. Thus the command rm *.f on deletes ALL files with extension f, or the command cp *.f dirname would copy all files with extension f into the (existing!) directory newdir To create a so-called tar file that contains all files in a directory (including its subdirectory) use the command
tar -cf tarfilename.tar directory
To reverse the process, type tar -xv <tarfilename>tar. To see the content of a tar file, type tar -t <tarfilename>.tar.
To run a program,
When the execution of a program requires several commands, they are usually put in a file, called script file. When running jobs in batch mode the argument of the qsub command is the name of the script file.
Previous commands can be recalled and edited: !! reexecutes the last command, ^oldstring^newstring^ modifies the last command by replacing <oldstring> with <newstring> and executes it. The up and down arrow keys let you scan the previous twenty commands typed. A command brought back in such a way can be edited before execution.
Most Unix systems have extensive built-in help facilities. The man <subject> command will reproduce the manual (reference) pages for the <subject>, if there are any. Typically, <subject> is the name of a command. apropos <subject> gives a list of commands that involve <subject>.