Beruflich Dokumente
Kultur Dokumente
Com
PATH:
To specify a list of directories separated by ‗:‘
Man:
Unix online help. Used to view manual page.
Echo:
1.Used to display a message.
Syntax: $echo ―message‖
Ex: echo ―UNIX‖
UNIX
Printf:
An alternative to ‗echo‘ to display formatted output.
Syntax: $printf ―data‖
Ex: $printf ―Hai‖
Script:
Used to record your login session.
Syntax: $script
Passwd:
To assign a password to your login or to change current password .
Syntax: $passwd:*******
(current) UNIX password:***********
New UNIX password: ***********
Retry new UNIX password:
Uname :
To find the name of the UNIX system.
Syntax: $uname [-options]
Options: -n displays hostname
-r displays version of O.S..
-s displays name of O.S.
$uname
Linux
$uname –n
Localhost.local domain
$uname –r
2.6.9 -1.667smp
$uname –s
Linux
Who:
To know who are currently logged in.
Syntax: $who
Ex:$who
Cse561 console jan30 10:00
Cse567 tty01 jan30 10:06
Cse569 tty02 jan30 10:15
$who am i
To display current login name.
Date:
To display system clock.
Syntax: $date [-options]
Options: +%m displays month in no.
+%h displays month in alphabets
+d . day of month
Stty:
To set options for a terminal.
Syntax: $stty
Speed 96 baud: Line=0
-brkint -imaxbel
Pwd:
To know your current directory.
Syntax: $pwd
/home/cse
Cd:
To change path of directory.
Syntax: $cd directory
Ex: $pwd
/home/cse
$cd cse1
/home/cse/cse1
Mkdir:
To make a directory .
Syntax: $mkdir directoryname
Ex: $mkdir cse_B
Rmdir:
To remove a directory .
Syntax: $rmdir directoryname
Ex: $rmdir cseB
$ls cseB
No such file or directory.
Ls:
To list files in a directory.
Syntax: $ls [-options]
Options:
-X displays multicolumnar outpt.
-F marks exe with *,directory with / and symoliclinks with @.
-a shows all file including .,..
-R recursive listing
-d listing of directories
$ls
A b c file1
File2 file3 switch.sh w1.sh
Cp:
Mv:
To move or rename a file or group of files.
Syntax:1:$mv oldname newname
Ex:$mv file2 file1
Syntax:2 $mv files destinationdirectory
Ex: $mv file1 file2 ppk
Rm:
To delete files.
Syntax: $rm [-options] filename
Ex: $rm file3
Options:* deletes all files of a directory.
:- i interactive deletion
Cat:
To create files.
Syntax: $cat>filename
Ex: $cat>myfile
123
456
789
[ctrl+d}
To display files
Syntax: $cat filename
Ex: $cat myfile
123
456
789
More:
Displays the contents of a file on the screen one page at a time.
Syntax: $more [-options] filename
Ex: $more myfile
Options -c cleans screen before displaying page
-d displays error messages
-s squeezes blanks into single one
Output: unix
Wc:
To count no. of lines, words, characters in a file.
Syntax: $wc [-options] filename
Ex: $wc myfile
4 3 9 myfile
Options: –l counts only no. of lines
-w counts only no. of words
-c counts only no. of characters
Lp:
To print the contents of the specified files to the default printers.
Syntax: $lp [-options] filenames
Unlink:
Deletes the name from the filesystem
Syntax: $unlink filename
Ex: $unlink file1
‗ file1‘ deleted
Process Utilities :
Disk Utilities:
Df: Disk Free
To find out free disk space.
Syntax: $df
(/dev/root): 612286 blocks 524153 files
Do1(/dev/dsk/dev): 510064 blocks 676613 files
java (/dev/dsk/dev2): 6453518 blocks 614547 files
Tail:
Displays flast few lines of the text file.
Syntax: $tail filename
Ex: $tail myfile.sh
Output:
Who
Who am i
Cat
Cp
Mkdir
Rmdir
Sort:
Sorts the contents of afile in ASCII code characters
Syntax: $sort [-opt] filename
$sort –t \| +1 shortlist
5423|barry wood |chairman |admin |08/30/56|160000
9876|bill johnson |director |production |03/12/50|130000
2233|charless harris |g.m. |sales |12/12/52| 90000
2365|john woodcock |director |personnel |05/11/47|120000
5678|Robert Dylan |d.g.m. |marketing |04/19/43| 85000
-n
$sort –t: +2 -3 –n group1
root:x:0:root
bin:x:l:root,bin,deamon
dialout:x:18:root,henry
lp:x:19:lp
adm:x:25:adm,deamon,listen
ftp:x:50:
users:x:200:henry,image,enquiry
-u
$cut –d”|” –f3 shortlist | sort –u |tee desigx.lst
chairman
d.g.m.
director
g.m.
Nl:
Used to prefix line no. for each line in a file.
-s
$nl –w1 –s: desigx.lst
1:chairman
2:d.g.m.
3:director
4:g.m.
Uniq:
To search duplicate & non-duplicate lines in a file.
Syntax: $uniq [-options] filename
$cat dept.lst
01:accounts:6213
01:accounts:6213
02:admin:5423
03:marketing:6521
03:marketing:6521
03:marketing:6521
04:personnel:2365
05:production:9876
06:sales:1006
Options :
-u displays only non-repeated characters.
$uniq –u dept.lst
02:admin:5423
04:personnel:2365
05:production:9876
06:sales:1006
Cut:
To extract a particular columns/columns ina file.
Syntax: $cut [-options] filename
-c
$cut –c1-4 group1
root
bin:
user
adm
dial
lp:x
ftp:
-f
$cut –d: -f1,3 gorup1
root:0
bin:1
users:200
adm:25
dialout:18
lp:19
ftp:50
Paste:
To combine different text lines of 2 files together.
Syntax: $paste [-options] filename
$paste –d: group1 dept.lst
root:0 : accounts|6213
bin:1 : admin|5423
Join:
For merging of two different files.
Syntax: $join [-options] filename1 filename2
$cat>file1
GIET COLLEGE
RJY
$cat>file2
Tee:
It accepts input from standard input and copies output at 2 different locations.
Syntax: $tee [-options ] filename
$who |tee file1|wc –l
20
Pg:
To view files pagewise.
Syntax: $pg [-options ] filename
Output: It displays the given file information that has longer pages
Comm:
Prints lines that are common in 2 files.
Syntax: $comm [-options ] file1 file2
$comm file1 file2
COLLEGE
Cmp:
To compare between 2 files
Syntax: $cmp [-options] file1 file2
$cmp file1 file2
Lines-1 Bytes-2
Diff:
To display differences between 2 files by comparing line- by – line.
Syntax: $diff [-options ] file1 file2
$diff file1 file2
Lines-1 Bytes-2
Tr:
To translate character set to another.
Syntax: $tr [-options ] string1 string2
$tr ‗G‘ ‗g‘ <file1
gIET COLLEGE
RJY
Back Up Utilities:
Cpio:
Used to copy a file to any back up or retrieve data from the backup drive.
Tar:Tape archiver
Options:
-c creates a new archive
-x Extracts files from archive
-t List contents of archive
-r Appends files at end of archive
-u Like r, but only if files are newer than those in archive
-c:counting occurrences
$grep –c director e mp*.lst
Director of the year
Co-director
*(asterisk):
It refers immediately preceding character.
$grep “true*man” emp.lst
Trueman :executive
Truman :g.m.
fgrep
Search a file for a fixed-character string.
Syntax
fgrep [-b] [-c] [-h] [-i] [-l] [-n] [-s] [-v] [-x] [ -e pattern_list] [-f pattern-
file] [pattern] [ file]
$fgrep ‘ trueman
>Truman ‘ mp.lst
Output:
Trueman
truman
sed
Sort for Stream Editor sed allows you to use pre-recorded commands to make changes
to text
Syntax
sed [ -n ] [ -e script ] ... [ -f script_file ] ... [ file ... ]
PATH:
To specify a list of directories separated by ‗:‘
man:
Unix online help. used to view manual page.
echo:
I.echo is used to display a message.
Syntax: $echo ―message‖
Ex:$ echo “UNIX”
UNIX
printf:
An alternative to ‗echo‘ to display formatted output.
Syntax: $printf ―data‖
Ex: $printf “Hai”
Hai
script:
Used to record your login session.
Ex:$script
Script started, file is typescript.
passwd:
To assign a password to your login or to change current password .
Syntax: $passwd
Ex:$passwd
Old password :***********
New password :***********
Reenter password:***********
uname :
To find the name of the UNIX system.
Syntax: $uname [-options]
$uname
Linux
-n displays hostname
$uname –n
Localhost.local domain
who:
To know who are currently logged in.
Syntax: $who
Ex:$who
cse576 cse576 jan 30 10:00
cse568 cse568 jan 30 10:06
cse569 cse569 jan 30 10:15
$who am i
To display current login name.
date:
To display system clock.
Syntax: $date [-options]
Options: +%m displays month in no.
+%h displays month in alphabets
+d day of month
+y last 2 digits of year
stty:
To set options for a terminal.
Syntax: $stty
Speed 96 baud: Line=0
-brkint -imaxbel
pwd:
To know your current directory.
Syntax: $pwd
/home/cse
cd:
To change path of directory.
Syntax: $cd directory
Ex: $pwd
/home/cse
$cd cse576
/home/cse/cse576
mkdir:
To make a directory .
Syntax: $mkdir directoryname
Ex: $mkdir cse_B
rmdir:
To remove a directory .
Syntax: $rmdir directoryname
Ex: $rmdir cse_B
$ls cseB
No such file or directory.
ls:
To list files in a directory.
Syntax: $ls [-options]
Options:
-X displays multicolumnar outpt.
-F marks exe with *,directory with / and symoliclinks with @.
-a shows all file including .,..
$ls
A b c file1
File2 file3 switch.sh w1.sh
cp:
To copy a file or group of files.
Syntax: $cp [-options] sourcefile destinationfile
Ex: $cp fil1 fil2
Options -i interactive copying
-r copying directory structures
mv:
To move or rename a file or group of files.
Syntax:1:$mv oldname newname
Ex:$mv file2 file1
Syntax:2 $mv files destinationdirectory
Ex: $mv file1 file2 ppk
rm:
To delete files.
Syntax: $rm [-options] filename
Ex: $rm file3
Options:* deletes all files of a directory.
-i interactive deletion
cat:
To create files.
Syntax: $cat>filename
Ex: $cat>myfile
123
456
789
[ctrl+d}
To display files
Syntax: $cat filename
Ex: $cat myfile
123
456
789
more:
Displays the contents of a file on the screen one page at a time.
wc:
To count no. of lines, words, characters in a file.
Syntax: $wc [-options] filename
Ex: $wc myfile
4 3 9 myfile
Options: –l counts only no. of lines
-w counts only no. of words
-c counts only no. of characters
lp:
To print the contents of the specified files to the default printers.
Syntax: $lp [-options] filenames
find:
Recursively checkes for the given files by names or by matching one or more file attributes
Syntax: $find path_list selection_criteria
$find / -name a.out –print
/home/raju/scripts/a.out
/home/Andrew/scripts/reports/a.out
unlink:
Deletes the name from the filesystem
Syntax: $unlink filename
Ex: $unlink file1
‗ file1‘ deleted
Process Utilities :
ps:
To display the attributes of a process.
Syntax: $ps [-options]
Ex: $ps
PID TTY TIME CMD
495 tty00 23:12:10 sh
748 tty01 12:10:10 ps
Options :
-e :shows a list of running processes includes system&user.
-f :shows entire details of user process
-u :shows processes of specified user
Disk Utilities:
df: Disk Free
To find out free disk space.
Syntax: $df
(/dev/root): 612286 blocks 524153 files
Do1(/dev/dsk/dev): 510064 blocks 676613 files
java (/dev/dsk/dev2): 6453518 blocks 614547 files
Sort:
Sorts the contents of afile in ASCII code characters
Syntax: $sort [-opt] filename
$sort –t \| +1 shortlist
5423|barry wood |chairman |admin |08/30/56|160000
9876|bill johnson |director |production |03/12/50|130000
2233|charless harris |g.m. |sales |12/12/52| 90000
2365|john woodcock |director |personnel |05/11/47|120000
5678|Robert Dylan |d.g.m. |marketing |04/19/43| 85000
-n
$sort –t: +2 -3 –n group1
root:x:0:root
bin:x:l:root,bin,deamon
dialout:x:18:root,henry
lp:x:19:lp
adm:x:25:adm,deamon,listen
ftp:x:50:
users:x:200:henry,image,enquiry
-u
$cut –d”|” –f3 shortlist | sort –u |tee desigx.lst
chairman
d.g.m.
director
g.m.
nl:
Used to prefix line no. for each line in a file.
Syntax: $nl [-options] filename
$ nl desigx.lst
1 chairman
2 d.g.m.
uniq:
To search duplicate & non-duplicate lines in a file.
Syntax: $uniq [-options] filename
$cat dept.lst
01:accounts:6213
01:accounts:6213
02:admin:5423
03:marketing:6521
03:marketing:6521
03:marketing:6521
04:personnel:2365
05:production:9876
06:sales:1006
Options :
-u displays only non-repeated characters.
$uniq –u dept.lst
02:admin:5423
04:personnel:2365
05:production:9876
06:sales:1006
cut:
To extract a particular columns/columns ina file.
Syntax: $cut [-options] filename
-c
$cut –c1-4 group1
root
bin:
user
adm
dial
lp:x
ftp:
-f
$cut –d: -f1,3 gorup1
root:0
bin:1
users:200
adm:25
dialout:18
lp:19
ftp:50
paste:
To combine different text lines of 2 files together.
Syntax: $paste [-options] filename
$paste –d: group1 dept.lst
root:0 : accounts|6213
bin:1 : admin|5423
join:
For merging of two different files.
Syntax: $join [-options] filename1 filename2
$cat>file1
GIET COLLEGE
RJY
$cat>file2
CIET COLLEGE
tee:
It accepts input from standard input and copies output at 2 different locations.
Syntax: $tee [-options ] filename
$who |tee file1|wc –l
20
pg:
To view files pagewise.
Syntax: $pg [-options ] filename
Output: It displays the given file information that has longer pages
comm:
Prints lines that are common in 2 files.
Syntax: $comm [-options ] file1 file2
$comm file1 file2
COLLEGE
cmp:
To compare between 2 files
Syntax: $cmp [-options] file1 file2
$cmp file1 file2
Lines-1 Bytes-2
diff:
To display differences between 2 files by comparing line- by – line.
Syntax: $diff [-options ] file1 file2
$diff file1 file2
Lines-1 Bytes-2
tr:
To translate character set to another.
Syntax: $tr [-options ] string1 string2
$tr „G‟ „g‟ <file1
gIET COLLEGE
RJY
Back Up Utilities:
cpio:
Used to copy a file to any back up or retrieve data from the backup drive.
Syntax: $cpio [-options ] filename
-o to create back up on standard output
-i restoring file from backup
tar:Tape archiver
Options:
-c:counting occurrences
$grep –c director e mp*.lst
*(asterisk):
It refers immediately preceding character.
$grep “true*man” emp.lst
Trueman :executive
Truman :g.m.
fgrep
Search a file for a fixed-character string.
Syntax
fgrep [-b] [-c] [- h] [- i] [-l] [-n] [-s] [- v] [- x] [ -e pattern_list] [- f pattern-file]
[pattern] [ file]
Context addressing
$sed –n „/from: /p‟ $HOME/mbox
From: Praveen ppraveen576@gmail.com
From: Monica monicamady@vicky.com
From: Sudheer sudher9025@gamil.com