Control Character Commands
^ h
Backspace.
^ d
End text input, EOF for mail, write
(also acts as logout command).
^ w
Delete last word typed.
^ u
Delete (undo) last line typed.
^ r
Repeat last line typed.
^ s
Stop the screen from scrolling
(sometimes takes a while to be effective).
^ q
Unlock terminal screen, continue scrolling.
^ c
Interrupt running program ([Del] in System V).
^ z
Suspend running program, and send it to the background
(fg brings it back to the foreground. Note: while a program is in the background it doesn’t run. It must be brought to the foreground to resume).
Getting Help
man command
displays the manual page for the given command.
man -k keyword
looks up the given keyword in an index and lists the commands that may be relevant.
Navigating within the file system
pwd
shows the full path of your current working directory
cd
change directory
* cd ~username: home directory of user
* cd ..: to go up to parent directory
mkdir
creates a new directory
rmdir
deletes a directory, if it is empty
rm -r
deleltes a directory with all its contents
ls
lists the contents of a directory
* ls -l: a long listing,in alphabetical order, showing permissions, filesize, date and time of file modification, and filename.
* ls -a: a complet file list, including files whose name begins with a dot.
* ls -t: lists files according to date and time of modification (newest first).
Manipulating files
cp
copy a file or directory
mv
moves a file/directory to a new location or renames a file/directory
* mv -i: prompts user if an existing file is about to be overwritten
rm
deletes files/directories
* rm -r: deletes a directory and all its contents
* rm -i: prompts user before deleting a file
cmp
compares two files and writes out a list of differences between them
diff
compares two files and gives a detailed list of differences between them
sort
sorts the contents of a file
* sort -n: sort by numerical value
* sort: (no option) sort alphabetically
* sort -r: display in reverse order
* sort -u: remove duplicate lines
grep
search a file or list of files for a specific pattern
Displaying the contents of a file
more
displays the contents of the file on your screen, and allows you to scroll through one screenful at a time. Also has crude search possibilities
view
uses a read-only version of the vi text-editor to display a file oni your screen.view does not allow editing of the file
head
allows you to display the start of a file
* head - [number]:displays the first [number] lines of a file
tail
allows you to display the end of a file
* tail - [number]: displays the last [number] lines of a file
cat
concatenates the contents of a file and displays them on your screen. If more than one file is specified then all files will be displayed one after the other.
Wildcards
* An asterisk matches any number of characters
in a filename, including none.
? The question mark matches any single
character.
[ ] Brackets enclose a set of characters, any
one of which may match a single character
at that position.
- A hyphen used within [ ] denotes a range of
characters.
~ A tilde at the beginning of a word expands
to the name of your home directory. If you
append another user’s login name to the
character, it refers to that user’s home
directory.
Redirecting Output
<
specifies a file from which input must be taken
* command < filename:take input from file filename
>
specifies file to which output must be sent
* command > filename:send output of command to filename (if filename does not exist it will be created)
|
pipe. Takes the output of a command and uses it for the input of another command
* command1 | command2:take output of command1 and send it (pipe it) to command2
Remote access to a UNIX system
ftp
file transfer protocol. Used to transfer files from one system to another (between UNIX systems or between A UNIX system and a different system. ftp does not allow commands other than those for file transfer
ftp commands:
* ftp remote.host to connect to remote system
* cd: to change directory on remote host
* lcd:to change directory on local system, without quitting ftp
* get filename: bring filename from remote system to local one
* mget file1 file2: multiple get, brings all files specified from remote system to local
* put filename: transfer filename from local system to remote one
* mput file1 file2: multiple put, transfers all files specified from local system to remote
telnet
login to remote system, and work as on local system. Unlike ftp, with telnet it is possible to perform commands
ref : http://www.biu.ac.il/LS/bio/unixintro/commands.html