ACCTCOM |
:: |
See the commands of all users |
acctcom | tail -20 |
See the commands of a particual user |
acctcom -u <username> | tail -20 |
Show entries for a specific commandpattern |
acctcom -n <pattern> | tail -20 |
Show all entries for commands staring with "l" |
acctcom -n '^l' | tail -30 |
Swho the output in reverse order |
acctom -b | more |
AGREP |
:: |
Find words with possible misspellings (here 2) |
agrep -2 'macropperswan' <file> |
AT |
:: |
Execute a command once in the future |
at now + 5 days < scriptfile |
AWK |
:: |
Take first column of a file |
awk '{print $1}' <file> |
Take first two colums inverted |
awk '{print $2,"\t",$1}' <file> |
Print sum of first two colums |
awk '{print $1 + $2}' <file> |
Find lines with "money" and print last column |
awk '/money/ {print $NF}' <file> |
Find lines with "money" in second column |
awk '$2 ~ /money/ {print $0}' <file> |
Find lines without "A" at end of 3-rd column |
awk '$3 !~ /A$/ {print $0}' <file> |
BASH |
:: |
Bourne again shell. Best interaktive shell right after zsh |
BC |
:: |
Calculate sin(5) |
echo 's(5)' | bc -l |
BG |
:: |
Put last stopped job into the background |
bg |
BREAK |
:: |
Leave the inermost loop (while/until/for) |
break |
CANCEL |
:: |
Stop a print job allready started |
cancel <jobid> ( as found with lpstat -o) |
CASE in ESAC |
:: |
Selective structure in sh/bash/ksh |
|
CC |
:: |
Compile a file.c |
cc -o <outfile> <infile> |
CHGRP |
:: |
Change group of a file |
chgrp <newgroupname> <file> |
CHOWN |
:: |
Change owner of a file |
chown <newowner> <file> |
CMP |
:: |
Act on the difference of two files |
cmp <file1> <file2> || <command> |
COL |
:: |
Printing the man pages without thousand "^H" |
man <command> | col -b | <printcommand> |
CRONTAB |
:: |
See your crontab file |
crontab -l |
Edit your crontab file |
crontab -e |
Every monday on 05:10 do /home/fred/foo.ksh |
10 5 * * 1 /home/fred/foo.ksh |
CRYPT |
:: |
Encrypt a file with a password |
crypt password < infile > cryptfile |
Decrypt the above file |
crypt password < cryptfile > cleanfile |
CSH |
:: |
Oldest Berkley shell |
|
CUT |
:: |
Get the hostname field from the last output |
last | cut -c11-40 |
DATE |
:: |
Set the date (root only) |
date <mmddhhmm> |
Special format of date (e.g. month only) |
date +%m |
DF |
:: |
See the used space of the disks in kB |
df -k |
DIRCMP |
:: |
Compare two directories |
dircmp <dir1> <dir2> |
DTKSH |
:: |
dtksh is a ksh93 with X11 graphics |
dtksh |
DU |
:: |
du = diskusage |
du -ks |
ED |
:: |
Commandline editor. Only used if all else fails |
ed <file> |
EGREP |
:: |
Grep with "or" |
egrep '(A|B)' <file> |
Exclude a and B |
egrep -v '(A|B)' <file> |
EX |
:: |
Edit a file from within a shell script |
ex -s file <<EOF g/money/s//cash/ EOF |
Edit a file with a script |
ex -s file < scriptfile |
EXPR |
:: |
Calculate modulus |
expr 10 % 7 |
Check for string in variable |
expr $var : 'string' |
Show first group of digits in string |
expr $var : '[^0-9]*\([a-z]*\)' |
FG |
:: |
Put the last stopped job into the foreground |
fg |
FGREP |
:: |
Find a string which is not a pattern |
fgrep '*,/.()' <file> |
FILE |
:: |
See the file type (e.g. ascii) |
file <file> |
FIND |
:: |
Find a file in the whole computer |
find / -type f -name <file> -print |
Find a file pattern |
find . -type f -name "*<foo>*" -print |
Delete all cores in the system |
find / -type f -name core -exec /bin/rm -f {} \; |
Find all files with a word in them |
find . -type f -exec grep -l <word> {} \; |
Find files modified longer than a month ago |
find . -type f -ctime +30 -print |
Use found files more then once with xargs |
find . -name "*.c" -print | xargs -i cp {} {}.bak |
Don't search in nfs mounted filesystems |
find . -local ... |
Follow the links while searching |
find . -follow ... |
Look for files larger than 1 megabyte |
find /path -size 1000000c -print |
Run find but discard the "permission denied"'s |
find ... 2>/dev/null ( in sh/bash/ksh only) |
Find all manualpage directories |
find / -type d -print | egrep '.*/(catman|man)$' |
Find all directories with write permissions |
find / -type d -perm -002 -print |
GAWK |
:: |
The gnu version of nawk |
|
GREP |
:: |
Find patterns in lines of files or stdin |
grep '[a-z][0-9]' <file> |
Find lines without pattern |
grep -v '^From' <file> |
Find files which contain a pattern |
grep -l '^[cC]' *.f |
Count lines with pattern |
grep -c '[Ss]uccess' <file> |
Search while ignoreing case |
grep -i 'lAbEgF' <file> |
Print a line number in front of the line |
grep -n 'mo.*y' <file> |
HINV |
:: |
Get infos about your host on silicon graphics |
hinv -v |
IF then else ENDIF |
:: |
Branching structure in csh/tcsh |
|
IF then else FI |
:: |
Branching structure in sh/bash/ksh |
if [[ condition ]];then commands;fi |
KSH |
:: |
Korn shell. (ksh88) |
|
KSH93 |
:: |
ksh93 with real number arithmetics |
ksh93/ksh...depends on the system |
LINE |
:: |
Reprint lines until eof (sh/bash/ksh) |
while line;do :;done |
LN |
:: |
Make a hard link b to file A |
ln a B |
Make a symbolik link b to file A |
ln -s a B |
Romove link B |
rm B |
LP |
:: |
Print file on default printer |
lp <file> |
Print file on specific printer |
lp -d <destination> <file> |
LPSTAT |
:: |
Show all printers |
lpstat -a |
Check the printer queue |
lpstat -o |
Show defoult printer destination |
lpstat -d |
Show printer status |
lpstat -p |
Show sceduler status |
lpstat -r |
MAKE |
:: |
Make the first target of a makefile |
make |
Make a specific target of a makefile |
make <target> |
Make according to another file than makefile |
make -f <mymakefile> |
Just show what would be done but don't |
make -n <target> |
MKDIR |
:: |
Make a directory with subdirectories at once |
mkdir -p <path>/<path>/<path> |
MOUNT |
:: |
See what is mounted |
mount |
See what is mounted, but formated |
mount -p |
Mount a cdrom to /cdrom |
mount /dev/cdrom /cdrom |
Mount a diskpartition to /usr |
mount /dev/dsk/c0t3d0s5 /usr |
NAWK |
:: |
Enhanced version af awk |
|
NL |
:: |
Number text lines from a file |
nl -bt -nln <file> |
NOHUP |
:: |
Start a job imune to logouts |
nohup <command> & |
OSVIEW |
:: |
View system activity on SGI |
osview |
PACK |
:: |
An old form of compress. Use gzip instead. |
pack <file> |
PASSWD |
:: |
Change your password |
passwd |
Delete password of a user (as root) |
passwd -d <username> |
Change password of a user (as root) |
passwd <username> |
PASTE |
:: |
Put single col files into one file with as many cols |
paste <file1> <file2> > <newfile> |
PERL |
:: |
Programming language which can also be used from the commandline or from ksh scripts. |
PR |
:: |
Format an ascii file for printing (76 lines) |
pr -l76 -h"title" <filename> |
Copy a file from one computer to another |
rcp <comp1>:/<path>/<file> <comp2>:/<path>/ |
REGCMP |
:: |
Compile a regexp from a file |
regcmp <file> |
Entry in the file above (example) |
varname "^[a-z].*[0-9.*$" |
RESET |
:: |
Reset the terminal after having messed it up |
reset |
RPCINFO |
:: |
Get portinfo from <host> |
rpcinfo -p <host> |
RSH |
:: |
Execute a command on a remote computer |
rsh <host> <comand> |
RUSER |
:: |
See who is logged in in the local network |
rusers |
RWHO |
:: |
Like rusers, but mostly doesn't work |
|
SCRIPT |
:: |
This logges all which passes the screen |
script <logfile> |
SED |
:: |
Substitute a string in a file |
sed -e 's/fred/john/g' <file> |
Substitute a pattern in a file |
sed -e 's/[0-9]+/number/g' <file> |
Change all "X" to red in a html file |
sed -e 's!X!<font color="#FF0000">X</font>!g; |
Rename files with suffix .suf1 to files with suffix .suf2 |
ls -1 | grep '\.suf1$' | sed -e 's/\(.*\.\)suf1/mv & \1suf2/' | sh |
Change a to b but only on lines with C |
sed -e '/C/s/A/B/' <infile> ><outfile> |
Delete all lines which contain "you owe me" |
sed -e '/you owe me/d' <infile> > <outfile> |
Have many editing commands in a file |
sed -f <commandfile> <infile> > <outfile> |
SH |
:: |
Shell. The oldest AT&T shell, which is standard for universal shell scripts. Ksh is it's successor. |
SHUTDOWN |
:: |
Stop the system |
shutdown -h now |
SLEEP |
:: |
Tell ashell script to pause for 10 seconds |
sleep 10 |
SORT |
:: |
Sort lines of a file alphabetically |
sort <file> |
Sort lines of a file numerically |
sort -n <file> |
Sort and reverse the order |
sort -r <file> |
Sort and take only one of equal lines |
sort -u <file> |
Show the used user ID's from /etc/passwd |
sort +2n -t: /etc/passwd | cut -d: -f3 |
SPELL |
:: |
Check for misspelled words in a file |
spell <file> |
Check, but ignore words from okfile |
spell +<okfile> <file> |
SPLIT |
:: |
Split a big file for putting on floppy |
split -b1m <file> |
Put splitters together if their name starts with x |
cat x* > <newfile> |
STRINGS |
:: |
Read ascii strings from a binary file |
strings <file> |
STTY |
:: |
Show the terminal settings |
stty -a |
Change the deletions chatachter to "^H" |
stty erase "^H" |
Do no more show what is typed in scripts |
stty -echo |
Show the typeing again |
stty echo |
SU |
:: |
Become root with own environment |
su |
Become root with root environment |
su - |
As root become another user |
su <username> |
TAIL |
:: |
Report certain lines from a growing file |
tail -f <file> | grep <pattern> |
TAR |
:: |
Pack together a whole directory |
tar cvf <outfile>.tar <dir> |
Unpack a tar file |
tar xvf <file>.tar |
Unpack and untar a file with normal tar |
gzip -dc <file>.tar.gz | tar xvf - |
Unpack and untar a file with gnutar |
tar xzvf <file>tar.gz |
Set the tape variable in the .cshrc for tar |
tape=/dev/rmt/0mbn |
Put a dir onto the tape |
tar cv <dir> |
Retrieve the dir from the tape |
tar xv |
Retrieve only a single file from the tape |
tar xv <file> |
Get table of contents from tape |
tar t |
Copy a directory with links and propper permissions |
(cd fromdir && tar -cBf - . ) | ( cd todir && tar -xBf - ) |
TCSH |
:: |
Good interaktive shell from Berkly. Only second to bash. |
TEE |
:: |
Put output on screen and append to file |
who | tee -a > <file> |
TEST |
:: |
Check for a file |
test -a <file> |
Check for beeing root |
test -O /usr/bin/su |
Check for astrin beeing non null |
test -n "$foo" |
Compare two strings numerically |
test $var1 -gt $var2 |
In a ksh script one uses "test" indirectly |
if [[ -a <file> ]];then ...;fi |
TIME |
:: |
See how much time a command needs |
time <command> |
TOUCH |
:: |
Protect against the the crontab |
find /myscratch -exec touch {} \; |
TR |
:: |
Replace a with x, b with y and c with z |
tr '[a-c]' '[x-z]' < infile > outfile |
TRAP |
:: |
Catch "^C" etc. and execute a subroutine |
trap "mysub;exit" 0 1 2 15 |
TRUE |
:: |
Make a non extisting command to return 0 |
ln -s /usr/bin/true ranlib |
TRUSS |
:: |
See what system calls a command uses |
truss <command> > /dev/null |
TYPSET |
:: |
Show the functions which are active |
typset |
TTY |
:: |
See the device for your terminal |
tty |
ULIMIT |
:: |
Show the max file size you can write |
ulimit |
UMASK |
:: |
Show your umask for new files |
umask |
Set a save umask |
umask 077 |
UNIQ |
:: |
Find a line of each equal ones an say how many |
sort <file> | uniq -c |
Find uniq lines |
sort <file> | uniq -u |
UPTIME |
:: |
Show how long the computer is running |
uptime |
UUENCODE |
:: |
Encode a file for mailing |
uuencode decodedname namenow > codedname |
UUDECODE |
:: |
Decode a uuencoded file |
uudecode <file> |
WAIT |
:: |
Wait for a background job to terminate |
wait $jobid |
VI |
:: |
The main unix editor |
vi <file> |
WC |
:: |
Count lines in a file |
wc -l <file> |
XARGS |
:: |
Execute a command for each line from pipe |
<command> | xargs -i grep 'pattern' {} |
XON |
:: |
Get an xterm from another computer |
xon <host> |
Get anything from another computer |
xon <host> <X-client> |