Linux Quick Reference Guide
Linux is a popular operating system that is available at Temple on three central computer systems: owlsnest.hpc.temple.edu (high performance computing cluster), compute.temple.edu (research system for SAS programmers), and astro.temple.edu (general user website and programming).
Astro is a general user system. All students, faculty, and staff have access to Astro by default. To obtain access to the High Performance Computing cluster or compute.temple.edu, send an email to the HPC support team at firstname.lastname@example.org.
You can access your Linux account in a computer lab or through a secure telnet program, such as SSH Secure Shell available atTemple's Download web site.
Once you have logged on, you will see a system prompt where you type Linux commands.
Keep in mind that Linux commands are case sensitive. This means that you must type commands exactly as they appear, paying attention to upper and lower case letters.
Upon logging in, the system places you in your home directory. The full home directory path has a subdirectory listed with a letter and number and then another subdirectory named after your login name. For example, if your login name is jroscoe, your home directory could be: /home/a003/jroscoe where the home directory has a subdirectory called a003 and within a003 there is a subdirectory called jroscoe. The letter and number for the a003 subdirectory will vary since it is just a way for the system to randomly group users so everyone is not in one giant directory.
The directory which you are currently in is referred to as your working directory. Unless you change to another directory, your working directory will be your home directory. To view your current directory, type pwd (stands for print working directory) at the system prompt and press Enter. To see a list of files and subdirectories in your current working directory, type ls -F and press Enter. The -F will display directories as items followed by a slash (/). All other items are files.
On Temple's Linux systems, you can store files and create directories only in your home directory or the /tmp directory. To create a directory within your home directory type mkdir (stands for make directory) and specify the directory name. For example, you might type mkdir test. Then, type ls -F to verify that a new directory called test was created. To change to the new directory, type cd test. To confirm that you are in the test directory, type pwd. Assuming your home directory is /home/a003/jroscoe, you should then see: /home/a003/jroscoe/test. To move back one directory (for example, to return to the jroscoe directory), type cd .. and press Enter. Note that there is a space between the cd and the two periods (..). To go to your home directory from any other directory, type cd (stands for change directory) and press Enter.
The purpose of a directory is to store files. Files, in turn, are used to store information. Linux filenames can be made up of any combination of letters and numbers but should not include spaces or special characters such as *, &, and @. When files are created, Linux maintains the following information about them: creation date, modification date, access date, size, ownership, security, links, and type.
After creating a file with an editor such as pico (Astro only), nano (HPC and Compute), or vi (see section IV), you can type ls -F to verify that the file was created. You can view the contents of the file by typing cat filename or more filename and pressing Enter. If you use the more command, the system will display one screen of the file at a time. To proceed to the next screen, press the Spacebar. To exit before viewing the entire file, type q.
IV. Creating files using pico or nano
The pico editor is available on Astro. The nano editor is available on HPC and Compute. Alternately, vi is available on all these systems. You can use these editors to create and modify files.
The pico and nano editors are simple, straightforward programs useful for basic text editing. The vi editor is a standard Linux program that offers more features than pico but takes longer to learn.
If you are using Astro, this section will cover the basics of pico. To use vi, see Educational Bulletin E-310, Unix Editor (vi) .
If you are using Astro, type pico filename and press Enter. If you are using HPC or Compute, type nano filename and press Enter. Filename is the name of an existing file or the name of a new file you will create. This command will bring you into the pico screen.
Once you are in the pico screen, you will see commands along the bottom of the screen. These commands are prefaced by the Control (^) character. In order to activate a command, you must hold down the Control or Ctrl key and tap the letter shown next to the Control character. Even though the letters are shown as capital letters, you can type them in lower case. For example, if you hold down the Control key and tap the letter g for Get Help, you will see the Pico Help screen. If you then press ^V to go to the next screen, you will see a summary of all the pico commands. Press ^X to exit Help.
In the pico screen, you can begin typing to create or edit your file. If you come to the end of a line, you can continue typing as pico is set to automatically wrap the text to the next line. If the text fills the screen, pico will automatically add another page. If your file is longer than one page, press ^Y to go backward to the previous page in the file or press ^V to go to forward to the next page.
It's always a good idea to save your file as you work. To do so, press ^O for WriteOut. Press Enter to accept the filename or type a new name and press Enter to save the file.
To cut or delete a line of text, move the cursor to the line and press ^K. To undo the cut, press ^U. To move the line, cut it and then move the cursor to the new location and press ^U.
To mark a group of text for cutting or copying, move the cursor to the beginning of the text, hold down the Control and Shift keys, and tap the number 6 key. "Mark Set" will appear at the bottom of the screen. (If this doesn't work, press the Esc key twice and then press the Shift key with the number 6 key.) Then, use the arrow keys to highlight or mark the text. (To shut off the Mark Text feature at any time, press Control/Shift/6 again.) Once you have highlighted the text, press ^K. Then, to copy the text, first press ^U to recopy the text to the original location and then move the cursor to other location and press ^U to also copy it there. To move the text, simply move the cursor to the new location and press ^U.
If you are creating a file and wish to include another file you have already created, move the cursor to the location where you would like the file to go and press ^R. You will then be prompted for the filename. If the file is in your home directory and you know the name, type the filename and press Enter. Otherwise, press ^T. The files and directories in your home directory will appear. If the file is in your home directory, move the highlight bar over the filename and press the Enter key. If the file is in a subdirectory, move the highlight bar to the subdirectory and press Enter twice. Then select the file. If you need to move up a directory, move the highlight bar over .. (parent dir) and press Enter twice. The file will then be brought into your current file and the cursor will be placed at the end of the file.
To exit pico, press ^X. If you have made any changes to the file, the system will prompt you with a message about saving changes. To save the changes, press y for yes. If you do not wish to save the changes, press n for no. If you type y for yes, the system will then display the filename. Press Enter to accept the filename or type a new name and press Enter to save the file.
Using the pipe symbol (|), located above the backslash key (\), you can send the output of one command into another command.
For example, suppose you type ls to list the files in your home directory, but you cannot read them all because they scroll by too quickly. To display this information one screen at a time, you can pipe the list to the more command by typing ls | more and pressing Enter. Then press the Spacebar to proceed through each screen.
The history file, by default, keeps track of the last 40 commands you have issued. As a shortcut, you can use the history file to reissue commands instead of retyping them.
To reissue a command, type history | more at the system prompt and press Enter. The system will then display a list of commands preceded by a number. To reissue a command type !n and press Enter, where n is the number of the command you want to reissue. For example, to reissue command 32, type !32 and press Enter. (If your account is set to the enhanced c shell (tcsh), you can also press the down and up arrow keys to retrieve the last command that you typed.)
To learn more about a Linux command, you can read the extensive online documentation provided on the system. To do this, type man command at the system prompt and press Enter. For example, to obtain information about the ls command, type man ls and press Enter. Then press the Spacebar to proceed through each screen or type q to exit.
If you don't know the name of the command, you can have the man program search the online documentation for similar entries. To do this, perform a keyword search using the -k parameter. For example, if you want to know the command for changing your password, type man -k password and press Enter. After viewing the keyword list, you can determine the proper entry (in this case, passwd) and read the man page. To exit before reading the entire keyword list, type q.
To log off the system, type exit at the system prompt.
© . Temple University. All rights reserved.