| Command |
Description |
Examples |
| !! |
re-executes
the last command in C shell |
|
| !$ |
repeat the
last argument from the previous command |
|
| !* |
repeat all
arguments of the previous command |
|
| !n:p |
allows you to
see a command but not execute it. |
|
| !number |
repeats a
specific number command |
|
| alias |
The alias and
unalias utilities create or remove a pseudonym or shorthand term for
a command or series of commands. |
Change copy
(cp) to include a confirmation prompt before overwritting a file:
alias cp="cp -i" |
| cal |
The cal utility writes a Gregorian calendar to standard output. |
$ cal
$ cal 2000
$ cal 9 2005 |
| cancel |
The cancel
utility cancels print requests |
$ cancel
printer1-203
request "printer1-203" cancelled
$ cancel -u <username> |
| cat |
Concatenate
and display files |
$ cat dante
The Life and Times of Dante
by Dante Pocai
Mention "Alighieri" and
few may know about whom you
are talking. Say "Dante," instead, and the whole world
knows whom you mean. For Dante Alighieri, like Raphael
$ |
| cd |
The cd utility will
change the working directory of the current shell execution
environment |
$ cd
$ cd ..
$ cd /home/user2/dir1
$ cd ./dir1 |
| chmod |
Change File
or Directory Permissions |
Deny execute
permission to everyone:
$ chmod a-x filename
Allow only read permission to
everyone:
$ chmod 444 file1
Make a file readable and writable by
the group and others:
$ chmod go+rw file2 |
| compress |
The
compress utility will attempt to reduce the size of the named files. |
-v,
-f
$ compress -vf file
file: compression 37% -- replaced with file.Z
|
| cp |
Copies files |
-i, -r
$ cp ~/home/* /tmp
$ cp -i ~/home/user2/* /bkup
$ cp -ri ~/home/user2/* /bkup |
| diff |
The diff
utility will compare the contents of 2 files and write to standard
output a list of changes necessary to convert the first file into
the second file. No output will be produced if the files are
identical. |
$ diff -c
fruit fruit2
*** fruit Fri May 8 11:32:49 1998
--- fruit2 Fri May 8 14:55:21 1998
***********
***2, 8****
orange
apple
banana
-pear
-mango
tomato
pomegranate
---2, 8-----
orange
apple
banana
tomato
+guava
+mango
pomegranate |
| ENV |
Variable used
in conjunction with personalizing the login environment |
ENV=$HOME/.kshrc;
export ENV |
| file |
Determines
file type |
$ file
dante
dante: English text
$ file beans
beans: Frame Maker Document
$ file da* fi*
dante: English Text
dante_1: English Text
file1: English Text
file2: ascii text
files.jar: java program
files.tar: USTAR tar archive |
| find |
The
find utility recursively descends the directory hierarchy for each
path seeking files that match a Boolean expression. |
-o
$ find /home/user2 -name 'dir*'
/home/user2/dir2
/home/user2/dir3
|
| ftp |
The ftp (File
Transfer Protocol) application is part of the TCP/IP protocol suite
and is standard with the UNIX operating system. It can be used to
transfer files using ASCII or binary mode between systems using
similar or dissimilar operating systems. |
$ ftp venus
Connected to 129.150.212.16.
220 venus FTP server (UNIX(r) System V Release 4.0) ready.
Name (129.150.212.16:lister): Return <CR>
331 Password required for lister.
Password: xxx
230 User lister logged in.
ftp> cd /etc/inet
250 CWD command successful.
ftp> bin
200 Type set to I.
ftp> get hosts /tmp/hosts
200 PORT command successful.
150 Binary data connection for hosts (129.159.129.38,33425)
(77 bytes)
226 Transfer complete.
local: /tmp/hosts remote: hosts
77 bytes received in 0.0014 seconds (5,25 Kbytes/s)
ftp> bye |
| grep |
Searches
a file for a pattern. |
-i
$ grep banana ./*
/home/user2/fruit: banana
/home/user2/fruit.tar:banana
/home/user2/fruit2: banana
/home/user2/fruit2.tar:banana
|
| groups |
displays all
the groups a user is a member of. |
$ groups
user1 user2
user1 : staff
user2 : staff |
| head |
Displays the
first few lines of files. |
$ head -5 /usr/dict/words
1st
2nd
3rd
4th
5th
$ |
| history |
This utility
lists or edits and re-executes commands previously entered into an
interactive shell. |
$ history
339 man grep
340 pwd
341 grep banana ./*
342 history
$ r 340
pwd
/home/user2
$ |
| id |
Returns
the user identity. |
-a
$ id
uid=1002(user2) gid=10(staff)
$ id -a
uid=1002(user2) gid=10(staff) groups=10(staff) |
| init
0 |
Its primary
role is to create processes from information stored in the file
/etc/inittab.
At any given time, the system is in
one of eight possible run levels. A run level is a software
configuration under which only a selected group of processes
exist. Run levels 0, 5, 6 are reserved states for shutting the
system down.
|
|
| jar |
Combines
backup and compress into one tool. |
c,t,x,
f, v
$ jar cvf bundle.jar *
adding 0.au
adding 1.au
adding 2.au
adding 3.au
$ |
| kill |
The kill
utility sends a signal to the process or processes specified by each
pid operand. |
-9
$ kill -9 100 -165
$ kill -s kill 100 -165 |
| lp |
lp submits
print requests to a destination. |
-d, -o, -n,
-m
$ lp ~/fruit2
request id is printer1-203 (1 file(s)) |
| lpsched |
The lpsched
command starts or restarts the LP print service |
|
| lpstat |
lpstat
displays information about the current status of the LP print
service to standard output |
$ lpstat
printer1
printer1-106 root 587 Mar 22 16:06 on printer1
printer1-107 user2 85 Mar 22 16:10 on printer1
$ |
| ls |
For each file
that is a directory, ls lists the contents of the directory; for
each file that is an ordinary file, ls repeats its name and any
other information requested. |
-a,-F,-l,-lt,-ld,-E
$ ls
dante dir1 dir3
$ ls -l
-rwxr-xr-x 1 user2 staff 110 Apr 19
dante
drwxr-xr-x 5 user2 staff 110 Apr 19
dir1
drwxr-xr-x 4 user2 staff 110 Apr 19
dir3
|
| mailx |
Interactive
message processing system. |
$ mailx
user2@cisco.com < dante.doc |
| man |
The man
command displays information from the reference manuals. It displays
complete manual pages that you select by name, or one-line summaries
if selected by keyword |
-s, -k
$ man man
$ man cd
|
| mkdir |
The mkdir
command creates the named directories in mode 777 (possibly altered
by the file mode creation mask umask(1)). |
$ mkdir
Reports
$ ls -dl Reports
drwxr-xr-x 2 user2 staff 512 Jan 28 16:24 Reports
$ mkdir -p practice/dir1/admin
$ ls -R practice
practice:
dir1 mailbox project research
practice/dir1:
admin
practice/dir1/admin: |
| more |
The more
utility is a filter that displays the contents of a text file on the
terminal, one screen at a time. It normally pauses after
each full screen. |
$ cat dante
| more |
| mv |
Moves files |
-i
$ mv file1 file_april30
$ mv file1 /home/user2/bkup |
| noclobber |
Command which
prevents the overwriting of files during redirection |
$ set -o
noclobber
$ cat fruit > fruit2
/bin/ksh: fruit2: file already exists |
| passwd |
Changes login
password and password attributes |
$ passwd
passwd: Changing password for user2
Enter login password: abc123
New password: unix123
Re-enter new password: unix123
passwd (SYSTEM): passwd successfully changed for user2
$ |
| pgrep |
The pgrep
utility examines the active processes on the system and reports the
process Ids of the processes whose attributes match the criteria
specified on the command line. |
Obtain the
process ID of sendmail:
$ pgrep -x -u root sendmail
283
|
| ping |
The ping
command tests basic connectivity between TCP/IP hosts by sending an
ICMP (Internet Control Message Protocol) echo request to another
computer or "host" on a TCP/IP network. If there is a
reply from the destination host, then there is a good connection
between them. |
$ ping
jupiter
jupiter is alive
$ ping 192.13.145.10
192.13.145.10 is alive
|
| pkill |
searches for
the process to kill |
Terminate
the most recently created xterm:
$ pkill -n xterm
|
| ps |
The ps
command prints information about active processes. |
-e, -f, -u
$ ps
|
| PS1 |
A variable
which can be changed by the user to alter the appearance of the
default shell prompt. |
$
PS1="new prompt$ "
$ PS1="$PWD $ "
|
| pwd |
pwd writes an
absolute path name of the current working directory to standard
output |
$ pwd
/home/user2/dir1 |
| rlogin |
Use the
rlogin command to establish a remote login session on another
workstation. |
$ rlogin
saturn
Password:
Last login: Mon Dec 21 11:04:27 from venus
Sun Microsystems Inc. SunOS 5.7 Generic October 1998
$ |
| shutdown |
By default,
shutdown brings the system to a state where only the console has
access to the operating system. This state is called single-user. |
|
| sleep |
The sleep
utility will suspend execution for at least the integral number of
seconds specified in the time operand |
$ sleep
60& |
| r |
Repeats a
command from the history list. |
170 pwd
171 ls
172 cd ~
$ r 170
|
| rm |
Remove directory entries |
-i,-r
$ rm -r dir1
|
| set
+ o vi |
Turns command
line editing on. |
|
| set
- o vi |
Turns command
line editing off. |
|
| set
prompt |
Sets the
default shell prompt in a C shell. |
% set
prompt="hello %" |
| sort |
The sort
command sorts lines of all the named files together and writes the
result on the standard output. |
$ sort
file1
$ sort +1n file2
|
| strings |
Finds
printable strings in an object or binary file |
$ strings /usr/bin/cat
SUNW_OST_OSCMD
usvtebn
usage: cat [ -usvtebn ] [-|file] ...
cat: Cannot stat stdout
cat: cannot open %s
cat: cannot stat %s
cat: input/output files '%s' identical
cat: close error
<some output omitted> |
| su |
Allows
a user to become super user or another user |
-
username
$ su -student6
Password:
$ |
| tail |
Displays the
last few lines of files. |
$ tail -5 /usr/dict/words
zounds
z's
zucchini
Zurich
zygote
$ |
| tar |
The tar command archives and extracts files to and from a single file called a
tarfile. |
c,t,x,
f, v
$ tar cvf backup.tar /home/user2/*
|
| telnet |
Telnet is
another good network troubleshooting tool. It is a non-graphical
communications utility that can be used to check the upper layers of
the OSI model. |
$ telnet
beach
Trying 192.168.49.10 ...
Connected to beach
Escape character is '^]'.
4.2 BSD UNIX (beach)
login: jdupont
Password:
Last login: Wed Jun 1 19:03:33 on console
beach% (Enter commands)
beach% exit
Connection closed by foreign host
$ |
| touch |
The touch
utility sets the access and modification times of each file.
The file is created if it does not already exist |
$ cd
~/practice
$ touch mailbox project research
$ ls
mailbox project research |
| unalias |
The alias and
unalias utilities create or remove a pseudonym or shorthand term for
a command or series of commands. |
$ alias
cp="cp -i"
$ unalias cp |
| uncompress |
The
uncompress utility will return a previously compressed file back to
its original size |
-v
$ uncompress -vf file.Z
|
| unset
history |
Turns history
tracking off. |
|
| vi
editor Command Mode |
Initial
default mode for creating and editing files, cursor positioning and
modification of existing text. All commands are initiated from this
mode. Pressing Esc from either of the other modes will return you to
command mode. |
|
| vi
editor Entry Mode |
Used for
entry of new text. Entering an insert command such i (insert), a
(append) and o (open new line) will take you from command mode to
entry mode. Pressing escape (Esc) returns to command mode. Entry
commands are entered by themselves without pressing the Enter key. |
a, i, o, A, I, O |
| vi
editor Last Line Mode |
Used for
saving your work and quitting vi. Type a colon (:) to get to this
mode. Pressing the Enter key to returns to command mode. |
:w, :wq, ZZ,
:q!, :wq! |
| wc |
The wc
utility reads one or more input files and, by default, writes the
number of newline characters, words, and bytes contained in each
input file to the standard output. |
$ wc dante
33 223 1320 dante
$ wc -l dante
33 dante |
| whatis |
whatis looks
up a given command and displays the header line from the manual
section |
$ whatis cd
cd cd (1) -change working directory |
| who |
Lists
who is on the system. |
0H,-q
$ who
user2 console Apr 30 12:37 (:0)
user2 pts/4 Apr 30 12:40 (:0.0)
$
|
| whoami |
Displays
the effective current username |
$ whoami
user2 |
| who
am i |
Displays
the effective current username. |
$ who am i
user2 pts/4 Apr 30
12:40 (:0.0) |