CSC161 2011S Imperative Problem Solving

Linux Commands

Sam's attempt to summarize the important Linux commands we have covered this semester. The commands are in alphabetical order. Parameters in square braces are optional (such as the files in cat). In most cases, commands that take files as parameters will read from standard input if given no file.

Command Purpose Common Options
cat [file(s)] Display the contents of a file or files
-n number lines
-v show nonprinting characters
cd directory Change working directory none
evince file View PDF and PostScript files none
head [file] Get the first few lines of the given file. none
history List the most recent commands none
ls directory List files and directories
-l long listing; include file info
-F append an indicator of file type (e.g., a / for directories
-t sort by time the file was last modified (instead of alphabetically)
-r reverse the sorting order
man command View the manual page for a command
-k get the man papes that mention a keyword
mkdir directory Create a new directory
-p Make parent directories, if necessary. (Used when the directory has a path, such as csc161/labs/linux1.)
popd Pop the most recently pushed directory, returning to that directory none
pushd directory Push a directory, remembering it so that you can return with popd none
pwd Print (or present) working directory none
sleep secs Pause for the given number of seconds. none
whereis cmd Determine where various parts of a program are none
which cmd Determine where a program is none

You've also learned some common ways to glue commands together or to take the output of one and send it to another.

Form Purpose Notes
cmd > file Send the output of cmd to the given file.  
cmd >> file Append the output of cmd to the given file.  
cmd < file Read the input of cmd from the given file.  
cmd0 | cmd1 Run cmd0 sending its output to cmd1

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Wed Jan 26 15:02:38 2011.
The source to the document was last modified on Wed Jan 26 15:02:37 2011.
This document may be found at

Samuel A. Rebelsky,