Topics Map > Engineering Workstations (EWS)
Topics Map > Hardware and Software
Topics Map > Instructional Services
Topics Map > User Services
Linux Command Quick Reference
A quick reference for common commands in a Linux terminal
|Lists the contents of your working directory.|
ls -aLists all of your files, including the "dot" files. There are a number of files that start with a . that won't normally show up when you type ls. An example of such a file is your .newsrc file
Gives you a listing of your files along with their size in kilobytes.
Gives you a "long listing," which means that your files will be shown in one vertical column and the file size and file access modes for all files will be shown.
All of these switches can be combined, so one might type
to list all of one's files and find their size.
|Copies a file to a specified location. Can be used to copy a directory with files in it using:|
cp –r Usage: cp[ -r ][source file(s) or directory(ies)] [destination file(s) or directory(ies)]
cp ~/myfile ~/mydir/ cp file1.txt newfile.txt cp –r ~/myproject/ ~/myprojectbackup/
|Moves (or renames) a file to a specified location. Similar to cp except that it deletes the source file (or directory, no option needed). Similar to cut and paste.|
Usage: mv [source file(s) or directory(ies)] [destination file or directory(ies)]
mv ~/myoldfilename ~/mynewfilename mv file* ~/mydirectoryoffiles/ mv ~/mydir/ ~/myotherdir/
Deletes file(s) or directory trees. There is no undoing! Can be used to delete all files and subdirectories with rm –rf .
Usage: rm [-rf] [file or directory]
rm mytxtfile.txt rm –rf ~/mydir/ (removes the directory and everything in it) rm –rf ~/ (don't do this!)
It's just like above, except you won't get the very data saving confirmation messages if you're deleting many files.
An alternative is to
which will use /bin/rm until you logout.
|Prints the working directory. This could be called your current path or view.|
Changes your working directory or view or where you're “in” to another specified location.
Usage: cd [destination path]
cd ~/ (home directory) cd somedir/someotherdir/ cd / (root directory) cd .. (parent directory) cd - (previous directory)
Creates a new directory. You can specify a location if you like.
Usage: mkdir [directory path and name]
mkdir newdir mkdir ~/newdir mkdir olddir/newdir mkdir -p newdir/newdir2 (makes parent directories as needed)
Removes (deletes) a directory. You can only use this on empty directories.
Usage: rmdir [directory path and name]
rmdir ~/olddir rmdir olddir/empty/
Lists all files and folders with their associated total sizes in KiloBytes.
Usage: du –k [directory path or file]
du –k (from current directory) du –ks ~/.mozilla (displays sum of all files' sizes in your mozilla tree)
Displays your current disk and print quota usage. The –w option allows you to see work directory quotas as well.
Usage: uquota –w
Modifies the permissions of files or directories. Permissions are rules about how and which users can access the files or directories. You can use the symbols or numeric mode to make the changes. We will cover the symbolic mode, the three switches covered here are: r -read access, w -write access, x –execute access.
Usage: chmod [u,g,o][+,-][r,w,x] [file(s) or directory]
chmod +r myfile (adds read access for everyone for myfile) chmod a+r myfile (same as above) chmod g+r myfile (adds read access to group only) chmod –w myfile (removes write access to myfile) chmod +x myfile (adds execute access to myfile) chmod ug=rw,o=r myfile (sets user and group to read and write, others to read)
Creates a symbolic link to a file or directory. Symbolic links are analagous to windows shortcuts, and are simply pointers. You can create one in your home directory to avoid having to cd into another directory you use frequently.
Usage: ln –s [link file] [target]
ln -s fortunelink /usr/local/share/terminfo/f/fortune ln –s otherlink ~/something/somethingelse
The man Linux tool is shorthand for "manual." Most Linux programs and utilities have brief documentation installed on the system. In order to access these online manuals,
Usage: man [program name]
where [program name] is a Linux utility or application such as those in this guide.
Note: Not all utilities and applications have "man" pages.
There are many types of files that are commonly used in Linux systems that may never be seen by an individual that is only familiar with Windows. The "apropos" utility is a helpful tool for finding the proper utility or application that opens a particular file type. Note that apropos may not be aware of all filetypes.
Usage: apropos [file type]
(where [file type] is the file's extension)
Example: apropos pdf
Note: This utility currently works correctly only on linux workstations.
|The top utility displays a list of the top ten (default number) programs running ordered by how much cpu or computing power the programs are using. A user can stop programs that they started from this screen by pressing 'k' then entering the Process ID (first column number) and pressing enter. In order to quit top simply press 'q'.|
The ps utility is another way to display a list of programs running on the system. Just typing ps will display a list of programs that have been started from the particular terminal window that the user is in. In order to see a more useful list of all programs running on the system,
Usage: ps –ef Example: ps -ef |grep [username]
(returns all the processes that are running for [username])
Use this Linux utility in conjunction with ps in order to end a running program on the system by the Process ID (first column in ps's output).
Usage: kill [PID] Example: kill 2458
lpr can be used to print ONLY postscript or flat text files from the command line or from within an applications print dialog.
Usage: lpr –P[printer name]@print [file name]
If you leave out the -P... the file will be printed to the default printer for each lab.
To override the default double sided printing and pring single-sided, use lpr -o sides=one-sided
lpr -Pdcllas1@print myfile.ps lpr -Pel252-bwd1@print myfile.ps lpr -o sides=one-sided myfile.ps lpr mytextfile
mpage is a tool used to print multiple pages per sheet on a PostScript printer. It has the ability to print out text or PostScript documents. mpage can be used on any text or postscript file at the command line of your xterm or within many programs' print dialogs. To print a document using mpage , simply replace [file name] with the file you wish to print and the [#] with the number of pages you wish to put on one page (i.e 2 , 4 or 8).
Usage: mpage –[#] -P[printer name]@print [file name] Example: mpage -4 -Pmelas1@print
The Acrobat Reader allows users to view and print PDF files. It can be invoked by typing acroread from the command line.
Once acrobat is running, the file to be viewed can be chosen by clicking File and Open. Scroll up and down the list to find the desired file, and click on that file to open it.
GhostView is a program to view and navigate through PostScript and PDF documents on an X display, by providing a user interface for the ghostscript interpreter. GhostView can be started by typing gv at the command line.
Print Queues are used to print your job after it has been spooled to the printer. pq is used when printing on the Linux computers.
Secure Shell is a program to log into another computer over a network, to execute commands in a remote machine, and to move files from one machine to another. It provides strong authentication and secure communications over insecure channels.
Usage: ssh [username]@[workstation name]
where [workstation name] is the name of the remote workstation and optional [username] is the username you wish to login with.
ssh remsun (on the ews network using your current username) ssh email@example.com (outside the ews network with netid janedoe)
The sftp utility is the secure version of ftp and works almost identically. Ftp is a file tranfer protocol that allows you to upload and download files to a computer running an sftp server (all EWS machines do as part of ssh access).
Usage: sftp [workstation name] or sftp [username]@[workstation name]
(Similar to the ssh command)
Copies a single file or a folder with multiple files using secure protocol over TCP/IP (the network) from one computer to another. This is rarely useful within the EWS environment, since your home directory is mounted on all workstations. However, it may be useful to copy to another machine on or off campus that runs an ssh server.
To copy one file from a remote workstation to your workstation:
Usage: scp [remote workstation name]:[file name] [local path]
Where [local path] is the location where you wish to save the copied file (the location . is your current location).
Similarly, to copy one from your workstation to a remote workstation:
Usage: scp [local file name] [remote workstation name]:[path]
To copy an entire folder as above respectively:
Usage: scp –r [workstation name]:[remote directory path] [local destination path] Or: scp –r [local directory path] [workstation name]:[remote destination path]
scp . firstname.lastname@example.org:~/myfile scp -r ~/ name@machine:/usr/local/src/ scp -r docs/ user@machine:~/
telnet rlogin rsh rcp rdist
|These remote access methods are unsupported. These methods do not use encryption and therefore are not part of EWS's commitment to using secure communication.|
|Mozilla FireFox lock files|
When mozilla firefox exits abnormally such as when mozilla firefox exits unexpectedly due to a programming bug, a lock file can sometimes be left behind causes the mozilla firefox profile that was used to become unusable. Run this command to remove any lock or .parentlock files:
Running a second time will delete the entire firefox profile including any bookmarks, etc.
The getskel utility reloads the default shell and X windows configuration to your account. Use this in case changes have been made to your configuration files that are causing problems.
Note: This will erase any customizations you have added to your startup files.
|This utility is an easy way to ensure that permissions on your web space files are correct. Simply run this utlity and the permission on all files and directories in your ~/public_html folder are set correctly.|
|Using disks and cdroms|
Before you can access your disk, you must first mount it. To do this, place the disk in the drive and from the Linux prompt type volcheck . The machine will check for any new disks and mount them appropriately. The files on the mounted disk will be found in either /floppy , /zip , or /cdrom . When you have finished using a disk, the following should be used on the appropriate disk type to eject it.
eject-cdrom eject-floppy eject-zip