Even More Unix Commands
Notes
Italics indicate arguments to the command. These are user supplied files, directories, etc. as appropriate.
^ indicates a control character. For example to do a ^c, hold the control key down while c is pressed. This is like using the shift for uppercase letters.
[optional items], square brackets, [ ], indicate optional items, they may be omitted or included.
Many commands may have options specified to alter the command's behavior, the options are almost always preceded by a - (dash).Look at the manual entry for a command (man command) for more details.
Commands
Compiling, Running Programs
^c Generates an interrupt. This usually terminates a running program.
g++ file.cpp Compile the program in file file.cpp , by default the executable is named a.out
./a.out Run the program a.out (the file a.out).
Editing, Viewing Files
less file View (ascii) file file . Pressing the spacebar scrolls down through the file, "enter" moves down 1 line, "u" scrolls up, "q" to quit.
more file View (ascii) file file . An older version of less, sometimes they are the same.
cat file [ file2 etc. ] Output the contents of the files to the screen. Can concatenate files. Use with output redirection below. Use on text files only.
vim file Start the vim editor on file file .
vi file Start the vi editor on file file . Sometimes vi and vim are the same.
emacs file Start the emacs editor on file file .
Printing
lp -d xtermlab file Print file file to the printer in xtermlab, room 162. DO NOT PRINT NONTEXT FILES LIKE A.OUT!
lpquota Show your laser printer usage.
lpstat xtermlab Show entries on the laser printer queue in the specified location.
cancel job-id Remove entries from the laser printer queue. Get job-id from lpstat
I/O Redirection
Be careful to use the correct one of > and <, files can be overwritten and their contents lost.
command > file
Redirect the output of command from stdout (by default the window) to file.
./a.out > out.txt
ls -l > files.txt
command < file
Redirect the input to command from stdin (by default the keyboard) to file.
command1 | command2 Pipe (redirect) the output of command1 from stdout (by default the window) to command2.
ls -l | less
Miscellaneous
man command The manual page for command is displayed on the screen. Pressing the spacebar scrolls through the entry, q to quit.
grep pattern file Search text file for pattern.
history Shows the last few commands you have typed. Shortcut: typing, for example, !23 will cause command 23 in the history list to be rerun. Also using the up and down arrows you can access previous commands from the history. Using the left and right arrows you can modify the command, press enter to execute the command.
passwd Change your password.
ping computer_name See if a remote computer is reachable. If the command is successful the computer may not be usable, it may be in an administrative operational level and not admitting logins.
ping loki.cs.kent.edu
file file Determine what type of file file is; ascii (text), executable, etc.
Environment
alias alias_name=command Makes typing alias_name the same as typing command. Typing alias by itself shows what aliases you have. Aliases only apply to the current shell, add aliases to the bottom of your .bash_profile file to have them created everytime you log in.