Unix Quicksheet in HTML
UNIX QUICK SHEET (Basic Commands)
Quick Unix
DISPLAYING AND MANIPULATING DATA
cat {file} copy file(s) to StdOut
- listing to screen
more {file} display file(s) on StdOut, one screenful
at a time.
- listing to the screen
crypt encrypt or decrypt StdIn to StdOut
- make files no one else can read
echo {string} write strings to StdOut
- same as in DOS
egrep pattern {file} find pattern, allows regular expressions
fgrep pattern {file} find pattern, fixed string only
grep pattern {file} find pattern, allows extended wildcards
tee file copy StdIn to StdOut and to file
- whatever you're doing goes to file and screen
wc {file} count lines, words, and characters in file
MAINTAINING FILES AND DIRECTORIES
chmod ugo+rwx file change file attributes (+ could also be -)
cp src dest copy files
ls {filespec} list files
- -l long listing
- -a all including hidden files
- -F symbols at the end of file names indicating
directories, executables, etc.
- -C show in columns
mkdir dir create a directory
mv src dest move or rename files
rm file remove files
- -r remove recursively i.e. delete all
subdirectories and their contents
rmdir path remove directories
- directory must be empty. if it is not, and you
want to remove it and its contents use 'rm -r dir'
touch file update date-time-stamp or create a file
SHELL PROGRAMMING - more on this when you want to go wild
exit finish a script
sleep [-s] Time wait for a while
test [expr] evaluate a logical expression
true returns 1
SHELL AND SYSTEM MANAGEMENT AND CONFIGURATION
alias name string set up a shell function
date show time and date
df disk space info
du -k disk usage info & directory tree
- -k show in kilobytes. this is the best way
exit finish the shell. just like logout
set like setenv but mostly for sh
setenv name set an environmental variable. used in csh
time does not give time! is used to time how long
a task has been running
unalias name same as unset
unset name delete shell functions
unsetenv name same as unset
SHELL AND SYSTEM MONITORING
alias by itself lists aliases
env show the shell's environment
- printenv and setenv without parameters are
the same
set by itself shows environment variables
history show the history list
UTILITIES
compress compress a file filename -> filename.Z
find path -name filename -print
list matching files
man [command] online help
sort sort StdIn to StdOut
- see man pages for switches
tar tape archiver
- to untar a file 'tar xvf filename'
- to tar a directory 'tar cvf file directoryname'
uncompress uncompress file filename.Z -> filename
w who is on and what are they doing
MISCELLANEOUS
cd [path] change work directory
clear clear the screen
pwd print work directory
SUPER SLICK
to untar a compressed file without decompressing first
zcat filename.tar.Z | tar xvf -
EXTENDED WILDCARDS:
* matches anything
? matches one character
[xyz] matches x, y, or z
[x-z] matches x, ..., z
I/O REDIRECTION:
< redirect StdIn
> redirect StdOut, create
>> redirect StdOut, append
>>& redirect StdErr, append
| pipe