Below is a list of Linux commands organized by theme. Use man and info to learn more about each command (or use the links to the right for some tutorials).
Running software remotely or in the background
- Please see this tutorial for information about running processes in the background.
Exiting from a shell prompt (to close a terminal window or to log out)
- or by pressing <ctrl+d> - the general end of text control character.
File system navigation / directories
We have a tutorial on manipulating files.
- pwd [options] - to obtain/print the name of your current/working directory.
- cd [options] [directoryname | ~ | ./ | ../ | - ] - to change your working directory.
- ls [options] directoryname - to list the contents of directories.
- mkdir [options] directoryname - to create new directories.
- rmdir [options] directoryname - to remove/delete directories.
- cp [options] source destination - to copy files and directories.
- mv [options] source destination - to move files and directories.
- rm [options] filenamelist - to remove/delete files.
Searching for files by name
- locate [options] <searchstring>
- find [options] <searchstring>
Searching through contents of files
- grep [options] <searchstring>
Determining file types
- file [options] filename
Viewing text files
- cat [options] filename - to display the file contents without pause or break.
- less [options] filename - to display file contents page by page.
- more [options] filename - to display file contents page by page.
- tail [options] filename - to display the last few lines of a file.
- head [options] filename - to display the first few lines of a file.
Editing text files
- To edit a text file type: editorname filename [&], where editorname could be one of the following: GNU-emacs, vi, joe, pico, etc. (note: change these links to the internal editor site)
Compressing and decompressing files
|File extension||Compression command||Decompression command|
|.gz||gzip||gunzip or gzip -d|
|.bz2||bzip2 or bzip2 -d||bunzip2|
Reading compressed text files
- zless [options] compressedfilename - to display the contents page by page without uncompressing the file.
Archiving (packaging) files and directories
- tar [options] filenamelist archive.tar - to archive files (store and extract). Compression and decompression is available in the following formats: .bz2(.bz) or .gz .
- cpio [options] filenamelist - to copy files to and from an archive.
- zip / unzip [options] archivename.zip filenamelist - to package and unpackeage compressed archives.
- zoo [options] archive filename - to create and maintain collections of files in compressed form.
Commands for managing print jobs
- lpr [options] filenames... - to print files.
- lpq [options] - to check printer que status.
- lprm [options] printjobIDs - to cancel print jobs.
Using floppy diskettes and CD-ROMs
- mount /mnt/floppy - to mount floppies.
- mount /mnt/cdrom - to mount CD-ROMs.
- umount /mnt/floppy - to unmount floppies.
- umount /mnt/cdrom - to unmount CD-ROMs.
- mtools - alternative file manipulation commands for DOS disks. Instead of mounting a disk, with the mount command as above, and using standard Linux commands like cp, ls, mv, etc. one can use the mtool commands to manipulate files. Consult man mtools for information about these commands.
- ssh [options] user[@host] - to make secure shell connections.
- scp [options] [user1@host1]:filenames... user2@host2:filenames... - to securely copy individual files.
- sftp [options] [user]@host - to start a powerful interactive secure file transfer program.
To run applications in the background
- nohup commandname [arguments] - to run a command, with a non-tty output, that should continue running after exiting the prompt.
- nice [options] commandname [arguments] - to run a program with modified scheduling priority.
- renice priority [options] - to alter the priority of a running process.
- & - to put a job in the background (for example emacs mytext.txt &).
- bg [jobspec] - to resume the suspended job jobspec in the background as if it had been started with &.
- fg [jobspec] - to put the specified job in the foreground (to make it the current job).
Useful system commands
- ps [options] - to display active proccesses.
- kill [options] processID - to send a signal to a process ("kill" is a misnomer).
- top [options] - to display top CPU processes.
- free [options] - to display information about free and used memory on the system.
- df [options] file(system)name - to get information on filesystem disk space usage.
- du [options]filename - to estimate file space usage.
Command line history, I/O redirection, and piping
- history [options] - to display the command line history.
- <tab> key - to complete a partially typed file/directory name or command.
- up and down arow keys - to navigate the command history buffer.
- ; - to separate multiple commands on a single line. Ffor example command1 ; command2.
- >,>> - to redirect the output of a command. For example ls -la directoryname > myfile.txt will write the output of the ls command to the file myfile.txt (and not to the screen!) while overwriting any previous contents of the file. If >> is used instead of > the original contents of the file myfile.txt will not be ereased but the output of ls will be appended to it.
- < - to use a specific file as an input to a command. For example cpio [options] < filenamelistfile.txt
- | - to pipe the output of one command to another command. Ffor example ls -al directoryname | less.
- date [options] - to display and set the system date and time.
- clear - to clear the terminal window.
- reset [options] - to reset the terminal window to its default display settings.
- To launch an application from a shell prompt simply type the name of the appliaction at the prompt.
The basic viewer applications
|.ps||ggv ghostview gs|
|.jpeg .png||xview gthumb eog|
Transforming between document formats
Image manipulation from a shell prompt
There are programs for manipulating image files that can be run at a shell prompt without a need for a graphical interface like the one that the gimp application uses. These programs are know under the collective name Netpbm which also stands for a collection of image formats (also known as npm formats) that can be used as intermediary formats for converting bettwen the most popular standard image types (e.g. .jpeg, .png). These formats have extensions like .ppm which stands for portable pixmap, .pgm for portable graymap, and .pbm for portable bitmaps. To learn more about these commands check out the Netpbm link in our useful websites box to the right, or visit the manual or info pages for the jpegtopnm command.