Professional Documents
Culture Documents
Unix Commands in A Nutshell 2
Unix Commands in A Nutshell 2
• Introduction
• Unix Shell
• Unix commands
• Vi Editor
• String Manipulation
• Unix Utilities Monitoring Tools
• Scheduling Jobs
HP-UX HP
Solaris SUN
Feature Description
File Management
Networking And Security
Services
Input / Output
Date and Time
Services
Services
UNIX
SYSTEM Process
Signal
Scheduling
Handling KERNEL
System
Memory
Administration
Management
and Accounting
C Shell (csh)
C Shell (csh)
All features of modern shell like command line history, alias are included in this shell
TC Shell (tcsh)
This shell provides all the features of C shell along with scripting similar to original Bourne shell (sh)
Unix Shells
This shell is full implementation of IEEE Posix shell and tool specifications.
All features of modern shell like command line history, alias, command line editing etc are included in this shell.
- Ordinary Files
- Directory Files
- Special Files
- Standard Files
* Removable
* File Independence
rm removes a file
e.g.,
$ Is -I List the files along with the protection bits and the user
$ Is -1 symtab.c
symtab.o
treegen
test
wc Word Count
$wc [Options] filename
e.g.,
$ cp test.c test.c.bak
test.c and test.c.bak contain the same contents
Extra disk storage
In Create link
e.g.,
$ ln first.c second.c
The file is referenced by two different names
No Extra disk storage
-i interactive mode
e.g.,
$ mv old.c new.c
Renames the file old.c as new.c
rm Deletes the indicated file(s) files
If files are same no output is sent to the terminal, or else The line number
and the byte at which the first difference occurs is reported
Return code
e.g.,
$ cmp test1 test2
test1 and test2 differ in char 36 line 3
$ cmp -s test1 test2
$ echo $?
Outputs: n1 a n3,n4
n1,n2 d n3
n1,n1 c n3,n4
$comm -[123] f1 f2
Prints a three column output:
- lines that occur only in f1
- lines that occur only in f2
- lines that occur in both
comm -12 - prints lines common to the two files
comm -23 - prints only lines in the first file but not in the
second
comm -123 - prints nothing
e.g.,
$ pack <filename>
The value of each digit is subtracted from the corresponding "digit" specified by
the system for the creation of a file.
split Splits the file into different files as specified by the number of lines
e.g., $ split -20 test.c
Splits the file test.c in blocks of 20 lines and creates files xaa, xab
and so on, such that
xaa has first 20 lines of test.c
xab has the next 20 lines of test.c
...
The file test.c is unaffected
$ split-20 test.c try Generates files as tryaa , tryab , tryac
The editor
* Powerful full screen editor
* vi v/s ed, ex
* Mostly single key stroke commands
* Interface with ‘ex’
* Macro facility
* Ability to process text
Invoking $ vi filename
e.g., $ vi pgm.c
Modes :
* Command mode
* Insert mode
* From Insert mode Pressing <ESC>
remitts Command mode
Command mode
Cursor Movement
Line Oriented :
Character oriented
h move left
l move right
j move down
k move up
* Executes .profile for bsh, ksh and bash when user logs on
* Executes .logout for C Shell when user logs out from C-Shell
$ PATH=$PATH:/usr/games
$ export PATH
$ echo $PATH
:.:/usr/bin:/bin:/usr/games:
File related
$ test -s file True if file exists and has size greater than zero
e.g.,
$ grep -ni func1 *.c Prints all the lines and line
numbers in files *.c that match pattern func1
ignoring the case
Cut
5511 - pid
$ps
3432 2 0 : 24 -sh
5765 2 0 : 03 ps
5511 2 0 : 51 somecommand
$ kill 5511
$ ps
pid tty time command
3432 2 0 : 24 -sh
5985 2 0 : 03 ps
$ ps
pid tty time command
3432 2 0 : 24 -sh
6004 2 0 : 03 ps
5995 2 0 : 44 stubborn-cmd
$ kill -9 5995
$ ps
pid tty time command
3432 2 0 : 24 -sh
6103 2 0 : 03 ps
TS=$(date +%m%d%y%H%M%S)
This date command gives two digits for month, day, year,
hour, minute, and second: