- at
execute commands at a later time
$ at now + 2 minutes
ls
job ask.854115763.a will be run at Fri Jan 24 08:22:43 1997
- awk
Pattern scanning and processing language
$ ls -l | awk '{sum+=$5} END { print sum}'
212744
- biff
Notify user if mail arrives and who it is from.
Biff is named after the dog at UCB who barked when
the postman delivered the mail.
- cal
print calendar
$ cal 9 1752
September 1752
Sun Mon Tue Wed Thu Fri Sat
1 2 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
- cat
Concatenate
$ cat filein >fileout
- cd
Change working directory
$ cd /etc
- chgrp
Change group
$ chgrp staff little.c
- chmod
Change mode
$ chmod 644 little.c
- chown
Change owner and group of a file
$ chown kochis little.c
- clear
clear terminal screen
- cp
Copy
$ cp /usr/home/instruct/kochis/unix/data? .
- crontab
User clock daemon.
$ crontab -l
15 6-17 * * * collector
- crypt
Encode/decode using DES.
- cut
Cut out selected fields of each line of a file
$ date | tr -s ' ' ':' | cut -d: -f4
07
- date
Print and set the date
$ date
Wed May 26 10:57:25 CDT 1993
- df
Disk free
$ df
Filesystem Total KB free %used iused %iused Mounted on
/dev/hd4 49152 16824 65% 1131 9% /
/dev/hd2 1515520 625240 58% 25126 6% /usr
/dev/hd3 327680 304436 7% 309 0% /tmp
/dev/hd1 163840 44296 72% 2401 5% /home
/dev/hd5 409600 103116 74% 4537 4% /public
- diff
Differential file and directory comparator
$ diff int.c new.c
- du
Summarize disk usage
$ du .
328 ./CC
224 ./Homework
712 .
- echo
Echo arguments
$ echo $TERM
vt100
- expr
Evaluate arguments as an expression
$ expr 5 + 6
11
- file
Determine file type
$ file *
CC: directory
a.out: executable
cgi-lib.pl: ascii text
int.c: c program text
little: commands text
mailfile: ascii text
- find
Find files
$ find . -name mcq1 -print
./Outline/Unix/quizes/mcq1
$ find c -type d -print
c
c/utility
c/fmt
c/acctng
c/obfuscated
c/obfuscated/1984
c/obfuscated/1985
c/obfuscated/1986
c/class
c/class/problems
Sometimes find is the ONLY way to remove a file.
For example how many files in the following directory?
$ ls
new
It looks like 1 file, but using the -l option shows two files!
$ ls -l
total 0
-rw-r--r-- 1 stud staff 0 May 30 12:22
-rw-r--r-- 1 stud staff 0 May 30 12:20 new
Since we can't see the name of the first file we assume it was
created using special characters. The -b option will show the characters.
$ ls -1b
\006
new
We can't type the file name as it is an unprintable character.
We can obtain the inode of the files with the -I option.
$ ls -1I
4321
4320 new
Find will let us access a file by it inode number to remove it.
$ find . -inum 4321 -exec rm {} \;
$ ls -1b
new
- finger
User information lookup program
$ finger ask
Login name: ask In real life: Allan Kochis
Directory: /u/ask Shell: /bin/ksh
On since Jan 08 07:29:59 on pts/2 from trd.tea.state.tx
1 minute 14 seconds Idle Time
No Plan.
- grep
Search a file for a pattern
$ grep -in title *.html
a010.html:3:$lt;title> Unix Syllabus</title>
a020.html:3:<title> Unix Assignments</title>
a030.html:3:<title> Unix History</title>
a040.html:3:<title> OS and Shell</title>
- groups
Show group memberships
$ groups
staff web
- head
Give first few lines of a file
$ head -4 a010.html
<html>
<head>
<title> Unix Syllabus</title>
</head>
- hostname
Set or print name of current host system
$ hostname
testbed.austin.cc.tx.us
- kill
Terminate a process with extreme prejudice
$ kill -9 67455
- last
Indicate last logins of users and teletypes
$ last ask
ask hft/0 Thu Jan 23 14:41 - 14:42 (00:01)
ask hft/0 Thu Jan 23 14:17 - 14:31 (00:13)
- ln
make links
Symbolic (soft) link.
$ ln -s fileX fileY
$ ls -il file?
-rw-r--r-- 1 root system 0 Oct 26 11:12 fileX
lrwxrwxrwx 1 root system 5 Oct 26 11:12 fileY -> fileX
Hard Link.
$ ln fileX fileY
$ ls -il file?
-rw-r--r-- 2 root system 0 Oct 26 11:13 fileX
-rw-r--r-- 2 root system 0 Oct 26 11:13 fileY
- lpq
Spool queue examination program
$ lpq
Queue Dev Status Job Files User PP % Blks Cp Rnk
------- ----- --------- --- ----------------- ---- -- ----- --- ---
bsh bshde READY
- lp
Off line print
$ lp little.c
- ls
List contents of directory
$ ls file?
fileX fileY
- mail
Send and receive mail
$ mail -s"Test" kochis
Hi there
This is a test message
^d
- man
Display on line reference manual information
$ man awk
AWK(1)
NAME
awk - Scans and processes patterns
SYNOPSIS
awk [-Fc] prog [parameters] [files]
awk [-Fc] -f file [parameters] [files]
DESCRIPTION
The awk command scans each input file for lines
- mkdir
Make a directory
$ mkdir new
- more,pg
File perusal filter for CRT viewing
$ more index.html
- mv
Move or rename files
$ mv index.html index.old
- nice
Run a command at low priority (sh only)
$ nice sort <filein >fileout &
- od
Octal, decimal, hex, ascii dump
$ od a.out | head -2
0000000 000737 000007 030665 155012 000000 004042 000000 000076
0000020 000110 010002 000413 000001 000000 000554 000000 000070
- pagesize
Print system page size
$ pagesize
4096
- passwd
Change login password
- paste
Merge same lines of several files or subsequent lines of one file
- perl
Practical Extraction and Report Language
- pine
User menu driven mail interface.
- ps
Process status
$ ps
PID TTY TIME COMMAND
98871 p044 0:00 sh
94236 p044 0:00 csh
18656 p044 0:00 ps
- pwd
Working directory name
$pwd
/home/student/student01
- quota
Display disk usage and limits
$ quota -v
Disk quotas for student (uid 1123):
Filesystem usage quota limit
/fs1 9530 40000 40200
/fs2 6 10000 10050
- rm,rmdir
Remove (unlink) files or directories
- sed
Stream editor (non interactive text editor)
- sleep
Suspend execution for an interval
$ date; sleep 10; date
Wed May 26 11:16:20 CDT 1993
Wed May 26 11:16:30 CDT 1993
- sort
Sort or merge files
$ du .
110384 ./96
25316 ./94
18156 ./93
18420 ./92
12976 ./91
4724 ./90
119348 ./97
$ du . | sort -n
4724 ./90
12976 ./91
15632 ./95
18156 ./93
18420 ./92
25316 ./94
110384 ./96
119348 ./97
- stty
Set terminal options
$ stty
speed 9600 baud; -parity hupcl
brkint -inpck -istrip icrnl -ixon onlcr tab3
echo echoe echok
- tail
Output the last part of a file
$ tr -sc '[A-Z][a-z]' '[\n*]' <a010.html | sort | uniq -c | sort -n | tail -3
148 center
192 Align
384 TD
- tar
Process tape archives. Tar will convert a directory structure to a
flat file or expand a flat file to a directory structure.
$ tar -xvf unix.tar
x UNIX
x UNIX/vitutor
x UNIX/vitutor/a.out, 90884 bytes, 178 tape blocks
x UNIX/vitutor/vitutor.c, 56076 bytes, 110 tape blocks
x UNIX/FNG
x UNIX/FNG/Oct.98, 15 bytes, 1 tape blocks
x UNIX/FNG/memo.09.10.98, 25 bytes, 1 tape blocks
x UNIX/FNG/bridge.data, 15 bytes, 1 tape blocks
x UNIX/FNG/route.data, 493 bytes, 1 tape blocks
x UNIX/FNG/data2 , 55 bytes, 1 tape blocks
x UNIX/a.out, 3525 bytes, 7 tape blocks
x UNIX/files
x UNIX/files/data1, 114 bytes, 1 tape blocks
x UNIX/files/data2, 221 bytes, 1 tape blocks
x UNIX/makeit.c, 353 bytes, 1 tape blocks
- tee
Pipe fitting
$ echo hello | tee junk
hello
$ cat junk
hello
- time
Time a command
$ time ls -al /usr >/dev/null
real 0m0.12s
user 0m0.01s
sys 0m0.02s
- tr
Translate characters
$ who | cut -c1-8 | tr '[a-z]' '[A-Z]'
JONES
FRED
STUDENT
SMITH
$ who | tr -s ' ' ' '
jones ttyp1 Jun 11 16:32
fred ttyp9 Jun 11 17:46
student ttypa Jun 6 09:14
smith ttypd Jun 7 10:04
$ who | tr -d '[0-9]'
jones ttyp Jun :
fred ttyp Jun :
- uniq
Report repeated lines in a file (See tail for an example).
- uptime
Show how long system has been up
$ uptime
11:21am up 3 days, 22:03, 66 users, load average: 20.17 20.09 20.76
- vi,view
screen oriented (visual) text editors based on ex
- wc
Word count
$ wc find.txt
22 101 717 find.txt
- which
Locate a program file including aliases and paths (csh only)
% which grep
/bin/grep
- who
Who is on the system
$ who
student1 lft0 Oct 14 08:24
student2 pts/3 Oct 14 08:26