Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

unix commands

http://unlser1.unl.csi.cuny.edu/tutorials/unix_commands.html

unix commands
outline
help directories and processes files system unix system directories finding things input/output fun commands

help

help when you don't know the command help when you know the command print help to a file

man -k the_topic man the_command man -k the_topic > filename

directories and processes

print the current directory's name list the current directory's files list information about the directory's files save the directory in a text file move to parent directory move to a subdirectory make a directory delete a directory list you processes end a process

pwd ls ls - l ls > filename cd .. cd the_directory mkdir the_directory rmdir the_directory ps kill process_number

files

print a file to the screen print a long file, page by page give a file a new name make a copy of a file delete a file print a file to the default printer list all the printers print a file to any printer

cat filename cat filename |more mv original newname cp original newname rm filename lpr filename cat etc/printcap |more lpr -Pthe_printer file

1 of 3

27/4/2012 10:59 AM

unix commands

http://unlser1.unl.csi.cuny.edu/tutorials/unix_commands.html

list the default printer's queue delete an item from the queue

lpq lprm item_number

system

print a string print the type of the current shell list the directories in the current path list the terminal settings list the most recent commands repeat the previous command repeat a command define a command find a program add a directory to the path shart a xterminal

echo "hello" echo $shell echo $path setenv history !! !first_letter of command alias nickname "the command" whereis a_program set path="($path new_dir) xterm &

unix system directories


name /bin /usr/bin /usr/local/bin /lib /usr/include /user contents system commands standard software other frequently used software C libraries headers for C libraries people's accounts

finding things
grep the_string the_file print a list of the lines inwhich the string occurs in the file grep the_string * expand the list to include all reference in the current directory fgrep the_string the_file -n add the line number to the output ls *.txt find -name *.txt -print two ways to find all the *.txt files in the current directory find ~ -name *.txt -print find all the *.txt files in yout account find -name *.txt -print -mtime +10 only look for *.txt files that have not been viewed for 10 days find -name *.txt -print -mtime -10 only look for *.txt files that have been recently modified
2 of 3

27/4/2012 10:59 AM

unix commands

http://unlser1.unl.csi.cuny.edu/tutorials/unix_commands.html

input / output
one_command | another_command send the output of one command to another any_command > out_file send the output of the command to the output file any_command >> out_file append the output of the command to the output file any_command < in_file take the input for the command from the input file any_command < in_file > out_file combine the two previous ideas any_command < in_file > out_file & push the command into the background

fun commands
show how much space is left on the disks show how is logged on show what someone is up to print the number of lines, and words in a file print a calender for the 4th month of 1995 print the date and time search for misspelled words sort a grocery list print the differences between two files df who finger username wc filename cal 4 1995 date spell filename sort < unsorted_list > sorted_list diff file_1 file_2

CSI resources (main directory) CSI homepage GMU homepage

3 of 3

27/4/2012 10:59 AM

You might also like