To begin using the command line while sitting at a Linux desktop/lab system, you need to open a terminal window. To so so, right-click on the desktop and select Open Terminal
You should then be presented with a terminal window similar to the following
When Linux is waiting for the user to enter a command, it displays what we call the a prompt. The prompt is a sequence of characters on the video display (possibly a shell window) which is really a request from the operating system to the user to enter another command. A typical Linux prompt could be
[student@hostname ~]$ _
When you look at your screen, you will see the name student replaced by your username and hostname replaced by the name of the machine (or host) you are using. The value after the hostname is the directory that you're currently in. The tilda (~) means that you are in your home directory. When a prompt appears on the screen you will also see an insertion point one space past the % sign. When you type a command this insertion point is where the characters will appear (the ‘_’ represents the insertion point. For example:
[student@hostname ~]$ date_
To issue a date command, you press the Enter key. If that were done in the previous example, you would see on your screen something similar to the following:
[student@hostname ~]$ date Mon Jul 26 09:58:44 EDT 2004 [student@hostname ~]$
Notice that the next prompt appears automatically when the last command has completed.
In Linux, it is important to remember that the commands are usually in lower case letters. Therefore, ‘date’ works but ‘DATE’ does not! We say that Linux is case sensitive. Try both ‘date’ and ‘DATE’.
[student@hostname ~]$ DATE DATE: Command not found. [student@hostname ~]$
Some commands have options that are specified by a minus sign followed by characters. For example, ‘date’ may have the ‘-u’ option that displays universal time or Greenwich Mean Time.
[student@hostname ~]$ date -u
If you spell the command name correctly but supply an improper option, an improper argument or the wrong number of arguments, many of the commands will not give you an error message but only display a brief description of usage. The command assumes you mistyped something and need some assistance. Try an incorrect option for date and you will see an example of a usage message:
[student@hostname ~]$ date -p date: illegal operation --p usage: date [-u] mmddHHMM[[cc]y] date [-u] [+format] date -a [-]sss[.fff]
If you ever receive a ‘usage’ message, you typed something wrong. In a usage description, the square brackets ‘[ ]’ means that part is optional. Obviously from date's usage message, it allows several other features.
The first time you log in you may want to change your password from the one given you by the computer center to one of your own choosing. A word of warning, it is important not only to choose a password which you can remember, but one which another user will not be able to guess. Your password is a security device that ensures only you have access to your files. To safeguard against unauthorized use of your account, be sure that you (and only you!) know your password. Your password should contain at least 6 characters and should not be based on a word contained in a dictionary. An easy way to meet this guideline is to choose two small words, join them together, and replace one or more of the characters with a digit. For example, you might join the words 'box' and 'door' and replace the o's with 3's (e.g. b3xd33r).
To change your password, type the passwd at the Linux prompt and press Enter.
When you press the Enter key, you will be asked to type in your old password. After entering your old password, you will be asked to enter the new password; after entering the new password, you will be asked to verify it by entering it again. If you don't type the same password the second time or if you incorrectly typed your old password, the system will print an appropriate error message and your password will not be changed. If this happens, just start over by typing passwd again.
[student@hostname ~]$ passwd Changing password for user student. Enter login(LDAP) password: New UNIX password: Retype new UNIX password: passwd: password successfully changed for student
Don't forget your password! Don't tell anyone else your password!
Data is stored in a file. A file can contain a program (a list of instructions for the computer to follow), data, or the text of a paper. A file is like a piece of paper on which you can put lots of characters, in any order. One of the primary functions of an operating system is to maintain user files, making sure that each user has access to their own files.
Files can be created in several ways. You can create the file, say, using an editor or programs can create files. For example, the C++ compiler creates files.
So that you can tell your files apart, you give a name to each one you create. When you create files, you should give them names that are meaningful to you. File names can contain most printable character, but to avoid pitfalls, you should use only letters, digits, dashes, periods and underscores. The following are legal file names: lab1, LAB3, Lab1, Alongname, read.me, program1.cc, program1.java
Remember that capital letters are different from lower case ones in Linux. Therefore, Lab1 is a different file name from lab1.
It is obvious that with so many people using the Linux workstations, there are a huge number of files on the systems. One needs a way to organize all of them as well as keep peoples' files separate. Linux does this with directories and sub-directories (directories inside of directories).
When you are given a Linux account, your login is associated with a directory. When you login you are placed in this directory which is called your home directory . Your home directory is a file that contains a list of all of your files (if any) and a list of all your sub-directories (if any). When you are in a directory, say your home directory, and you create a file, it is placed in that directory.
So that the Linux system knows which files are yours, it associates your computer account with your home directory. The files in your home directory and sub-directories are yours; no one else can create, change or remove them except you (or someone who has superuser privilege like the System Administrator).
Sub-directories are used to organize your files much like file folders are used to organize a heap of documents. For example, you might place all the files for your labs in a sub-directory called ‘labs’ and your programs in another one called ‘progs’.
Some commands in Linux require an identifying part of the file name called a suffix. This suffix is part of the file name and contains a period followed by a single character or several characters. For example, the C++ compiler requires the .cc suffix in the file name. Therefore, prog1.cc is a file name that would contain a C++ program. Some popular suffixes follow:
.c for a C program .cc for a C++ program .java for a Java program .h for a header file .o object file (created by compiler) .tex for a TeX document
A wildcard character is a symbol that you can use with many Linux commands to specify more than one file. In Linux, the wildcard character is the ‘*’ and it matches zero or more characters in that place of the filename argument. Therefore, b*.java matches all files starting with b and ending with the suffix .java. You could list all the Java program files in a directory starting with b by typing:
[student@hostname ~]$ ls b*.java
You can use more than one wildcard in a filename argument as shown below:
[student@hostname ~]$ ls do*at*
That would list the following files: doat, doat21, doormat, dogcatcher and documentation.
One way to create a file is to copy an existing file. The Linux command to copy a file is cp. After the command you type the file to be copied and a new file name. Copy two files into your directory by doing the following:
[student@hostname ~]$ cp ~csci203/examples/humpty myhumpty [student@hostname ~]$ cp ~csci203/examples/jack_theory .
In the first line we copied a file called humpty in the sub-directory examples under csci203’s home directory (~username is a user's home directory and csci203 is a username) and placed the contents of the file into a newly created file called myhumpty. The second line is the same except that we were lazy and typed a period that tells Linux to use the same name. You made no changes to csci203’s existing files.
The long string of directory/sub-directory/filename is an example of a pathname that is how you specify any file on the system. Many commands take pathnames as possible arguments (see the section entitled "Using Pathnames").
The command cp may use a wildcard character in the filename argument. You could have copied all of the files in my examples directory by doing the following:
[student@hostname ~]$ cp ~csci203/examples/* .
Here the period is important to give each file the same name.
Now try listing your directory by using the command ls and the two files should be there.
[student@hostname ~]$ ls myhumpty jack_theory
Try ls with the -a option.
[student@hostname ~]$ ls -a
You should see several file names which begin with a period, for example a .cshrc file. These dot files control how your system looks when you login and were placed there by the Systems Administrator. If you remove or alter these files you may experience many problems and may find you can't even login! If this should ever happen see your instructor immediately. Later, when we are more advanced, we may alter some of these files. Try ls with the -l option to list the files in extended form.
[student@hostname ~]$ ls -l
You can combine the two options by typing -al.
[student@hostname ~]$ ls -al
You can also list a filename or a filename argument with a wildcard. For example, you could list all the files starting with ‘lab’ by:
[student@hostname ~]$ ls -l lab*
The command more followed by the filename displays the contents of that file. Try more on myhumpty and jack_theory. Hit the spacebar to display the next window full. While using more on jack_theory press an h and read the on-line help of the commands available in more. Hit the spacebar to get out of the help display. To go back a page, type “b.” To quit type “q.” Using the command cat can also complete this operation. However, the latter command scrolls through the entire document without page pausing. Note this command would not be desirable for displaying long documents.
[student@hostname ~]$ more jack_theory [student@hostname ~]$ cat jack_theory
Like most commands that take a filename argument, more allows a wildcard character (the ‘*’). Therefore, we could be lazy and type:
[student@hostname ~]$ more j* [student@hostname ~]$ cat j*
That will do more on all files in the current directory beginning with “j.” In this case, there is only one: jack_theory.
Many times we need to clean up our directories and we desire to remove some files. The command rm removes or deletes the file specified by the filename.
Copy your file myhumpty to several new file names, say junk and baloney. Then remove junk and baloney from your directory. Using ls, check that they were removed.
[student@hostname ~]$ rm junk baloney [student@hostname ~]$ ls
To avoid inadvertently deleting the wrong file, type carefully when you use rm. The command rm allows a wildcard but you should be very careful when you use it or you will remove files you wanted to keep.
After becoming comfortable with Linux, most users use many directories to organize their files. For example, you could make a new directory for each new programming assignment.
To create a new directory, use the command mkdir which stands for make directory. The conventions for names of directories is the same as the names of files, i.e., you should use letters, digits, dashes, periods and underscores. From your home directory make two directories (also called sub-directories) named labs and progs.
[student@hostname ~]$ mkdir labs [student@hostname ~]$ mkdir progs
Check using ls -l to see that they were created. The ‘d’ in the first column means they are directories.

The above diagram shows the structure of the three directories and the two files we have made so far (we are not showing the dot files). To change the current working directory to a new one, use the cd command. To change to the labs directory type:
[student@hostname ~]$ cd labs
Try an ls command now. You will see no files as you haven't created any in this directory. To return to your home directory, you use the cd command and no file name.
[student@hostname ~/labs]$ cd
When you copy a file you end up with two files - the original file and the new one. Sometimes you may wish to move a file to another directory or keep it in the same directory but with another name. The command mv (for move) does both.
Move to your home directory if you have not done so. Move the file jack_theory from your current directory to the labs directory by typing the following:
[student@hostname ~]$ mv jack_theory labs

Using the cd command, change your working directory to labs and check that jack_theory is there.
You can always tell what is your current working directory by using the pwd command (print working directory). pwd is a very useful and important unix command.
[student@hostname ~]$ pwd
Notice that pwd displays the whole pathname with something like:
/home/accounts/student/initial_letter/username/labs
Change your current working directory to your home directory and try pwd there.
Most, if not all, the Linux commands that use a filename can also take a pathname. A pathname is a string of directory names separated by ‘/’s where the last entry is a file name. The full pathname specifies where a file resides. You can see the full pathname when you type a pwd command. However, you don't need to use the whole pathname most of the time. There are shortcuts that we will describe below. If you are in your working directory (in this case your home directory) and want to display the contents of jack_theory in the sub-directory labs, you could use more with a pathname.
[student@hostname ~]$ more labs/jack_theory
From your current working directory you can go ‘down’ the directory structure by using the directory name, a ‘/’ and file name. You can go ‘up’ the directory structure by using ‘..’s. For example, change your working directory to labs and type the following:
[student@hostname ~]$ more ../myhumpty
We could also have used “~” to specify your home directory because myhumpty is in your home directory.
[student@hostname ~]$ more ~/myhumpty
You can have as many layers of directories as you want. Make a new directory called lab1 under labs.
[student@hostname ~]$ cd ~/labs [student@hostname ~/labs]$ mkdir lab1
As another example of using pathnames, we will copy a file in the home directory to the new lab1 directory two different ways. First, while in the home directory we will issue the cp command to make a copy of myhumpty called humpty1 and place it in the directory lab1.
[student@hostname ~]$ cd [student@hostname ~]$ cp myhumpty labs/lab1/humpty1
Now we move to the lab1 directory and copy the file from there and name the new copy humpty2.
[student@hostname ~]$ cd [student@hostname ~]$ cd labs/lab1 [student@hostname ~/labs/lab1]$ cp ~/myhumpty humpty2
Move to the lab1 directory and make sure the two humpties are there.
For a final example, we will move jack_theory from labs to progs with the same name. Assuming we are in the labs directory, we go ‘up’ one directory with ‘..’ and ‘down’ another by specifying the directory name.
[student@hostname ~]$ cd ~/labs [student@hostname ~/labs]$ mv jack_theory ../progs/.

Above are the directories and files we have now. It is important that you understand how to move around in directories and how to specify the correct pathname. If you are still confused in any way, go over this section again carefully studying the commands and using the diagrams.
Linux has manual pages stored on-line for most commands. The command man followed by the command name displays these reference manual pages.
To read the manual pages on the command man, type the following:
[student@hostname ~]$ man man
Since the command man uses more to display the text, you use more’s commands to get around, i.e., the space bar for the next page, b to go back a page, and q to quit. The manual pages are not written for the beginning user. Therefore, the beginner needs to learn how to extract useful information by selectively skipping over sections and ignoring large portions. Try reading some other man pages, say for ls and cd.
If you don't know the command you want but want to find an appropriate one, you can try a keyword search of man. Using the -k option and the keyword does this. Say you want to copy a file but can't remember the command. Trying ‘man copy’ gives the message “No manual entry for copy” that means there is no command spelled “copy”. We could try the following keyword search:
[student@hostname ~]$ man -k copy
And find lots of commands that do copying including cp that is what we wanted.
To print a text file (a file which you can edit), you use the lp command where you specify the printer and the name of the file. The default printer is whatever printer is in the lab you’re currently using. To print the Java source file called myprog1.java you type the following:
[student@hostname ~]$ lp myprog1.java
An option -d and the name of the printer specify the different printers. The names of the printers are the following:
brki167-lp1 laser printer in Breakiron 167 (specifically for Jr/Sr CS Majors). brki164-lp1 laser printer in Breakiron 164. dana213-lp1 laser printer in Dana 213.
For example, to print a letter to Mom on the laser printer in Breakiron 164, you would type the following:
[student@hostname ~]$ lp –dbrki164-lp1 letter.mom
The command lp only prints what's in the file. It does not include the date or even the filename! One uses the pr command to add the date, time, name of file and page number at the top of each page. Normally one uses the following for printing programs and output which is to be handed in for a class.
[student@hostname ~]$ pr myprog1.cc | lp
In the above, pr formats the C++ file myprog1.cc and pipes (read about pipes in Section 2.8.6 on “Pipes and Filters.”) the formatted output to lp to be printed. You may choose the alternate two columns output format for your submission. You would type the following to submit your homework:
[student@hostname ~]$ a2ps –Pdana213-lp1 myprog1.cc
Since several people may request to print a file on a printer at the same time, your request is placed in a queue. You can display the contents of a printer's queue with the lpstat command where you specify the printer name by using the –o (lowercase letter o) option. To check the queue of the laser printer in room 164 Breakiron, you would type.
[student@hostname ~]$ lpstat –o brki164-lp1
At times you find you may need to remove a request from a printer's queue. Perhaps, you discover that you printed the wrong file and don’t want to waste paper. First, perform a lpstat command and notice the job ID of the print request to be removed. Then issue a cancel command specifying the job ID. Below we remove job ID brki164-lp1-20 from the line printer queue.
[student@hostname ~]$ cancel brki164-lp1-20
On rare occasions, a print request will hang the printer. If there are print requests in the queue and the printer has not printed for many minutes, perhaps the first (top) job in the queue is problematic. After checking that the printer is turned on, has paper, not jammed, is on-line, etc., then remove the first job from the queue with cancel. You can remove only your own printer requests. If the first job is not yours then you need to find that person or report the problem to the System Administrator.
This section covers some Linux commands that are important but less frequently used.
To search for a word, a phrase or any string of characters in a file use the grep command. You specify the string of characters then the file as shown.
[student@hostname ~]$ grep Humpty humpty Humpty Dumpty sat on a wall. Now Humpty's unscrambled and good as new.
Two useful options for grep are -i that ignores the case of letters and -n that displays the line numbers at the front of the line. Here is the output after one asks grep to find all occurrences of ‘and’ including both upper and lower case letters and displaying the line numbers.
[student@hostname ~]$ grep -i -n and jack_theory 37: This is Chaotic Confusion and Bluff 46: This is the Cybernetsics and Stuff 47: That covered Chaotic Confusion and Bluff 49: And thickened the Erudite Verbal Haze 57: To make with the Cybernetics and Stuff 58: To cover Chaotic Confusion and Bluff 60: And thickened the Erudite Verbal Haze 69: That made with the Cybernetics and Stuff 72: And, shredding the Erudite Verbal Haze 77: And Demolished the Theory Jack built
As with many Linux commands, grep can take a wildcard for the filename. (see the section entitled “Using Wildcard Characters in Filenames.”) Here we search for ‘to’ in all the files of the directory.
[student@hostname ~]$ grep -i -n to * humpty:3:The King set the Tme Machine back to two. jack_theory:56: This is the Button to Start ther Machine jack_theory:57: To make with the Cybernetics and Stuff jack_theory:58: To cover Chaotic Confusion and Bluff jack_theory:68: Who pushed the Button to Start the Machine
Notice that it displayed the filename before the line number.
All student accounts are limited in the amount of disk space (called disk quota) that they may use. This is typically fifty megabytes. If you bump up against this limit, you won't be able to create new files. If you exceed your quota, you must first delete some files. If you find you can't delete any other data (because you need it), then contact the System Administrator about increasing your quota.
To see what your disk usage and quota are use the quota command.
[student@hostname ~]$ quota -v
Disk quotas for user student (uid 15341):
Filesystem blocks quota limit grace files quota limit grace
medusa.eg.bucknell.edu:/vol/vol1/home
57956 92160 102400 3035 4294967295 4294967295The blocks column shows your current disk usage (in kilobytes) and the first limit column shows your disk quota (in kilobytes).
Doing an du -sh * (disk usage) in a directory will show the size of each direcotry and files.
4K helloworld.c 4K Labs
The -h option tells du to print the size in a human readable format. K means kilobytes (about 1,000 bytes), M means megabytes (about 1,000,000 bytes), and G means gigabytes (about 1,000,000,000 bytes).
When you do an ls -l command, the current permissions are displayed for each file. The first 10 characters are the permission fields for that file. A ‘-’ in column one means a plain file. A ‘d’ in first column means a directory.
-rw-r--r-- 1 student student 245 Aug 14 14:16 humpty -rw-r--r-- 1 student student 2147 Aug 14 14:16 jack_theory
The next nine characters are grouped into three characters each (rwx, r-x and r-) for the permissions for owner, group and world respectively. The owner of the file is the login name that created it. In the above, both files are owned by csci203. The three characters for the owner's permission are ‘rwx’ which means the owner can read, can write and can execute the file. The System Administrator determines which login names are in a group. In this case, others in cs's group can read and execute the files but can't write or change them. The world is all others on the system. Anyone can read the files but can't changed them or execute them.
For a directory, execute permission is interpreted to mean permission to search the directory. The permissions and file modes are summarized as follows:
r or '4' the file is readable; w or '2' the file is writable; x or '1' the file is executable; - the indicated permission is not granted.
The chmod command allows the owner to change the permissions on a file. The form of chmod is:
chmod <who><op><permission> filename where <who> is a combination of: u User's permissions (owner). g Group permissions. o Others (world). a All. <op> is one of: + To add the permission. - To remove the permission. <permission> is any combination of: r Read. w Write. x Execute
A few examples, will help you to understand how to use chmod. To set the file humpty so no one but the owner can read, write or execute it, we would type the following:
[student@hostname ~]$ chmod go-rwx humpty
Note: no spaces are allowed in ‘go-rwx’. Doing an ls -l humpty shows the following permissions.
-rwx------ 1 student student 161 Jul 30 16:30 humpty
To set humpty's permissions back to what they were before, we need to do two chmod commands. One for the group and another for others.
[student@hostname ~]$ chmod g+rx humpty [student@hostname ~]$ chmod o+r humpty [student@hostname ~]$ ls -l humpty -rwxr-xr-- 1 student student 161 Jul 30 16:30 humpty
If you want to hide all your programs so only you can read them, you could use a wildcard. The below changes all the files in the directory so only you, the owner, can read, write and execute them.
[student@hostname ~]$ chmod go-rwx *
Or you could have changed the permissions on the directory of where the files reside.
For instance, here are a few of the common ones:
644 is rw-r--r--
the owner can read and write the file or directory, everybody else
can only read it.
755 is rwxr-xr-x
the owner can read, write and execute the file, everybody else can
read or execute it. For a directory, this mode is equivalent to 644.
711 is rwx--x--x
the owner can read, write and execute the file, everybody else can
only execute it. Most users find themselves issuing the same command repeatedly during a work session. Since Linux commands can be lengthy and subsequently tedious to type out, there are shortcuts to repeating a command. For these shortcuts, Linux provides a history feature, which records the last several commands (typically the last 40) for each shell window (a window with hostname % prompt).
To display the last so many commands, type history.
[student@hostname ~]$ history
If you have an alias set for the history command, you should be able to type just ‘h’.
[student@hostname ~]$ h
Was ‘h’ defined? If not, you can add the alias later when we cover ‘dot’ files and command aliases in the next two sections.
When you display the history, you will see an associated number with the commands you typed before. To redo a command, type “!” followed by the number (No spaces between “!” and number!) For example to redo the command with 23.
[student@hostname ~]$ !23
To do the last command, you type “!!”. You can redo the last command starting with a string by typing “!” followed by the string. For example to repeat the last use of more, you would type:
[student@hostname ~]$ !m
When you issue the ls -a command in your home directory, you should see a series of dot files or filenames that start with a period. Below are some common dot files and their purposes. You may display them with more to see what is in them. Be sure you know what you are doing before you make any changes!!
| .cshrc | The .cshrc file is executed every time you start a new shell. This is where to place your own command aliases. See next section. |
| .gnome, .gnome2, .gconf | These dot directories sets features for GNOME. |
| .login | This file is executed whenever you login. |
| .emacs | This file is used by Emacs to set up features. |
It is very easy to customize your frequently used Linux commands by adding aliases to your .cshrc file. Using ‘more’ display your .cshrc file in your home directory. Notice that there are some aliases already existed. For example that you can type ‘lo’ for ‘logout’ and ‘m’ for ‘more.’ If you want to add your own aliases just edit this .cshrc file and you may use the aliases already there as models. Here are some examples:
alias cls clear alias pinebox 'ssh pine.bucknell.edu'
Redirecting the input to and the output (I/O) from a command is easy in Linux. To send the output of any command or program to a file instead of the screen, use >.
For example, to place a list of the files in the current directory in a file called ‘myfiles,’ you would type the following:
[student@hostname ~]$ ls > myfiles
Again for any command or program, to read input from a file instead of the keyboard, use <. For example, to input from a file called data for a program called myprog type:
[student@hostname ~]$ myprog > data
The symbol >> operates much as > does, except that it means, “add to the end of the file.” Redirecting input from a file and output to a file is especially useful with writing programs from other computer languages.
Many commands, e.g., emacs, don't finish after a few seconds and, therefore, tie up the window in which you typed the command. Linux allows you to easily place the command (or program) in the background and run by itself. Then it is no longer associated with the window where you typed the command. This allows you to continue using the window's screen and keyboard. This is called submitting a background process. Processes are just instances of programs in execution. Any command (or program) can be submitted as a background process by adding “&” on the end of it. For example, to sort a large file and redirect the output to the file sort-output and not tie up your window while doing it, one would type the following:
[student@hostname ~]$ sort large-file > sort-output &;
Some commands when run under GNOME, e.g. emacs, create a special window to run in. If run in the background, the window stays until you quit or kill it.
To see a list of your current processes including both foreground and background processes, type the following:
[student@hostname ~]$ ps -ef
The ‘-ef’ are options to the ps command. Do a man ps to read about all the options.
In desperation, you can kill a runaway or hung up process. Use the ps -ef command to find the process-id. Then type the following:
[student@hostname ~]$ kill process-id
Pipes and filters are some of the niftiest features of Linux. A Linux command's output may be redirected directly to another command's input by the pipe symbol |. For example, to list a directory with too many files to display in the window at one time, one can pipe the output of ls into ‘more’ by the following:
[student@hostname ~]$ ls -l | more
This is similar to redirecting the output of ls to a temporary file then displaying the contents of the file using ‘more’ as follows:
[student@hostname ~]$ ls -l > temp [student@hostname ~]$ more temp [student@hostname ~]$ rm temp
The use of the pipe symbol | is a lot handier than using a temporary file especially since we tend to forget to remove the temporary file. Pipes are really handy as shown by the below examples.
To count the number of users on system, one could type:
[student@hostname ~]$ who | wc -l
where the -l (that's minus el) is an option to wc (word count) to only display the number of lines.
To look for a particular user “csci203” when you do a ps command, type the following:
[student@hostname ~]$ ps -ef | grep csci203 | more
In the previous example, we would say that grep is a filter as it filters or selects only portions of the output. The command grep displays each line in which it finds the string (see the section entitled “Grep - Searching a File For a String”).
Assume you have written a C++ program that displays the names (last name first) of the members of your organization but they are not in alphabetical order. To sort the names and then print them, you could pipe the output of the C++ program to sort, then pipe its output to pr to format it and then pipe its output to the printer.
[student@hostname ~]$ names | sort | pr | lpr
However, if you do this, make sure the amount of output to the printer is reasonable.
Files and Directories Commands:
| ls | - list files in current directory. |
| ls -a | - list dot files in current directory. |
| ls -l | - list files in current directory in full form. |
| pwd | - print working (current) directory. |
| mkdir name | - make new directory. |
| cd pathname | - change to directory. |
| cd | - change directory to home directory. |
| rmdir name | - remove directory. |
| cat file | - display a file; concatenate several files. |
| more file | - display file on screen pausing at each screenful. Press space to continue. Press h for help. |
| cp file1 file2 | - copy file1 to file2. |
| mv file1 file2 | - move file1 to file2 (rename). |
| mv file dir | - move file to directory dir. |
| rm file | - remove file (delete). |
| du | - disk space used (do in home directory). |
| quota -v | - displays your disk quota or allotment. |
| chmod <who><op><permission> file | - change permissions on a file. |
Useful Commands:
| a2ps -Pprinter file | - prints file in two column format. |
| lp –dlobby file | - prints file on laser printer in Dana lobby. |
| lp –dbrki167-lp1 file | - prints file on laser printer in room 167 Breakiron. |
| lp –ddana213-lp1 file | - prints file on laser printer in room 213 Dana. |
| lp –dbrki164-lp1 file | - prints file on laser printer outside room 164 Breakiron. |
| lpstat –o printer | - list printer queues. |
| cancel job-id | - remove job from printer queue (get job-id from lpstat). |
| man command | - displays manual page to screen (on-line help). |
| man -k keyword | - displays one line of commands which contain keyword. |
| logout | - to log off of UNIX. |
| script | - to capture a work session in a file. |
| exit | - to end a script session. To end a rlogin session. |
| who | - displays who is on your machine. |
| ssh hostname | - remote login to another computer (exit to get off). |
| date | - displays time and date. |
| wc file | - word count of file. |
| cal | - prints a calendar. |
| spell file | - displays misspellings of the file |
| sort file | - displays file sorted alphabetically. |
| grep 'string' file | - displays all lines in file containing the string. |
| history | - history of commands you have typed (!number to redo). |
| ps | - display your processes running on your machine. |
| ps -ef | - display all processes running on your machine. |
| kill process-id | - kill a runaway process (get process-id with ps). |
| passwd | - change your password. |