The Basic Computational Environment 1 1 Introduction – The Basic Computational Environment This chapter provides you with some basic introduction to your 'Computational Work desk'. It is structured into three parts. The first one consists of some quick tutorial how to login into your machine. The second part deals with basic steps in a UNIX-like environment and introduces the 'SHELL', the UNIX command line. In the third part two of the most used editors are presented in order to enable the user to manipulate text files at will. 1.1 Login Into Your Computer Before you can login it is essential that you haven been provided with a username and a password. Usually these are provided by your chemistry department or your system administrator. The first thing you will see is the 'login-screen', asking you to type in your username. Figure 1: a typical login screen The screen might look somewhat different, but it should be similar to the one shown above. Once you typed in your username and pressed the <RETURN> key, the system will ask you for your password, which you are expected to type, again followed by <RETURN>. (The pressing of the <RETURN> key after typing in some commands or other things is assumed from now on.) Having succeeded in providing the correct password you are provided with your graphical desktop. All your actions will take place in this environment. The next thing to do is to open a window containing a command- line, which is usally called a 'shell'. This is nothing else than a window where you can type in your commands. Click unto the icon on the left bottom (or top) and search for a program called 'Konsole' or 'Terminal'. Having done so, your screen will look similar to the one in the figure below: The Basic Computational Environment 2 Figure 2: The graphical desktop with a shell window The following part deals with commands you can enter into this command window and how to find your way around in a UNIX system. 1.2 The UNIX Command Line Although most computer use graphical displays and fancy graphical user interfaces nowadays, UNIX is traditionally rooted in text based environments without any graphics, that is, you tell the computer what to do only by typing in commands without further use of a mouse or by clicking onto menu bars. In this it is not so different from very old personal computers running MS-DOS in times when no Windows was around. One essential feature of the shell is the administration and organisation of the files within your home directory. Typing in the command 'pwd' the computer will tell you where in the directory hierarchy you are at the moment, e. g. /home/frankw. Unix directories are sperated by the slash '/' character. So /home/frankw means, the directory 'frankw' in the 'home' directory which itself is located at the root of all directories on this computer, called root, or '/'. When you just opened you command window, you usually end up in your 'HOME' directory, the directory which is your own private data space. Here you can copy files, create further directories, execute programs and all other things usually done with a computer. When you get lost in all the directories, 'pwd' (print working directory; you see most UNIX commands are abbreviations or acronyms....) will tell you where you are now and a simple 'cd' (change directory) will bring you back to the top of your HOME directory. Some useful commands dealing with files and directories are listed in Table 1. The Basic Computational Environment 3 Table 1: Some useful unix commands for dealing with files and directories Command Description pwd Print working directory ls List all files in the current directory ls *.inp List all files with extension .inp in the present directory (analogous to dir *.inp under windows) ls -l List all files in current directory with detailed information cp file1 file2 Copy a file with name “file1” to a file with name “file2” (analogous to the copy file1 file2 command under windows) cp -r dir1 dir2 Copy a directory with name “dir1” to a directory with name “dir2” mkdir calc Make the directory “calc” (same under windows) cd calc Change into the directory calc (same under windows) cd .. Change to a lower directory level rm *.tmp Remove all files with extension .tmp (CAREFUL: in unix there is no “undelete” command – gone is gone!). mv file1 file2 Rename the file “file1” to “file2” find . -name Find all files in all subdirectories with extension "*.inp" .inp In the following table some commands are listed dealing with text files. Text files are especially important since they are used almost everywhere in UNIX, for example, they contain the input and output of your calculations, provide the system with information, customize your shell etc. Table 2: Some useful unix commands for dealing with the contents of text files Command Description cat file Print contents of file (without pausing on screen boundaries) more file Print contents of file, pausing when screen end is reached. Pressing <RETURN> scrolls down one line, <SPACE> on screen grep -i "string" Search in file for "string" and print all lines file containing this string sed Search in file for all occurences of string1 and "s/string1/string2" replace them with string2 and print the result on the file screen Some other commands which might come in useful are listed in the following table. Especially the man command is useful, for it provides you with a help text about other commands. Table 3: Some more useful linux commands and tools Command Description man ls Gives you all information about the command 'ls'. xterm & Opens another command window. (The ‘&’ signifies that the processs xterm is to be send to the background The Basic Computational Environment 4 while you can keep on working in your present window). tar cvf Creates an archive of 'directory' into 'file' file directory gzip file Compresses the contents of 'file', most often used with archives gzip -d Uncompressed some archive (with suffix .tgz), which archive.tar.gz ; has been created before using tar and gzip. tar xvf archive.tar There are a few other things you should know about UNIX commands. Usually if you type in a command or start a program, which is essentially the same, it uses some INPUT, does some work or calculation, and produces some OUTPUT. Usually this means that all INPUT comes from the keyboard (for you to type in), and all OUTPUT will be directed to the screen. Sometimes the OUTPUT, for example from some calculation, becomes so large, that you would rather put it into a file for looking at it afterwards in your own time. To do so, UNIX provides you with INPUT/OUTPUT redirection, e. g. find . -name "*" > all_your_files This command will 'find' all your files, from the current directory onwards (from '.') and put them into the file 'all_your_files'. This output redirection via '>' works with all kinds of commands. Another important feature of the UNIX command line is the ability to put commands into the 'background'. Usually, if you enter a command or a program name the program does it's work and meanwhile you have to wait until it finishes. Now, if you put a '&' character at the end of you command line, you will be greeted immediately to enter the next command. In the meantime your program is executed invisibly in the background! For example: orca test.inp >& output & 1.3 The Texteditor You need to use a text editor in order to edit textfiles, that is, to produce input to the quantum chemical program packages. For this you can use the standard editors vi and emacs or nedit. The latter is not available on all unix machines but is essentially self- explanatory. The other editors are standard software but are a bit less convenient to use. Basic familiarity with them is helpful. Some fundamental concepts and commands are presented hereafter. The Basic Computational Environment 5 1.3.1 The VI Editor One of the most widely used editors on UNIX systems is the vi editor. Although it lacks the look and feel of today's editors, it has the advantages of being available on all UNIX systems and being very quick to use (and in extended versions also very powerful). You can load a file into vi just by typing: vi filename If the file did not exist before it will be created. One feature that is somwhat difficult to grasp at the beginning is that editing in vi takes place in two different modes: A command mode and an insert or edit mode. Vi starts in command mode. You can always get back into command mode by pressing <ESC>. In this mode you can move the cursor around on the screen and position it where you want to modify your text. For moving around you can use the CURSOR keys or the keys h, j, k, l. Having positioned the cursor, press i for insert mode. Now you can enter your text. Pressing <ESC> enters command- mode again. In the following table are the most common keys accessible in command mode. Table 4: usage of the vi editor Command Description h, j, k, l Movement (left, down, up, right) i, I Insert text before cursor position (before first character of the line) a, A Append text after cursor position (at the end of current line) o, O Open new line below the current line (or above current line) X Delete charcter under cursor Dd Delete whole line D Delete line from cursor position to the end of line r, R Replace character under cursor (replace from cursor on onwards until leaving by <ESC>) :wq Save file and exit vi :wfile Save current contents in 'file'.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages20 Page
-
File Size-