1 introduction to unix. d.s assoc.prof m.tech incharge kiet

145
1 INTRODUCTION TO UNIX INTRODUCTION TO UNIX . . D.S D.S Assoc.prof Assoc.prof M.Tech Incharge M.Tech Incharge KIET KIET

Upload: flora-griffin

Post on 18-Jan-2018

233 views

Category:

Documents


0 download

DESCRIPTION

3. On The basic of the idea implied while working on the3 MULTICS, Ken Thomson, a researched started working on different projects. He came across an abounded PDP7 machine on which he and Dennis Richie develop an operating system called UNICS (Unified information and computing system) during the latter part of 1969 in assembling language in PDP.7 and do it is not portable. so achieve portability ken Thomson consider implementing the system in a higher level language. He worked on developing a higher level language c in 1973 At The same time many researches in ‘AT & T’ Bell laboratories interested in the unix project around 1970 UNICS become UNIX.

TRANSCRIPT

Page 1: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

1

INTRODUCTION TO UNIXINTRODUCTION TO UNIX

..

D.SD.SAssoc.profAssoc.prof

M.Tech Incharge M.Tech Incharge KIETKIET

Page 2: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

2

Unix introduction Unix introduction

• Unix was introduced to the world by bell labs in the late 1970.

• From the beginning it was intended to be a powerful operation system that could be ported to a variety of hardware environments.

• The bell laboratories contribution in 19765-1970 AT and T worked on a joint project called MULTICS(multiplexed information computer systems) which intend to develop multi user operating system as the progress was not satisfied.

Page 3: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

3

..• On The basic of the idea implied while working on the3 MULTICS, Ken Thomson , a researched started working on different projects.

• He came across an abounded PDP7 machine on which he and Dennis Richie develop an operating system called UNICS (Unified information and computing system) during the latter part of 1969 in assembling language in PDP.7 and do it is not portable. so achieve portability

• ken Thomson consider implementing the system in a higher level language. He worked on developing a higher level language c in 1973

• At The same time many researches in ‘AT & T’ Bell laboratories interested in the unix project around 1970 UNICS become UNIX.

Page 4: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

4

..• The results of the research and the developing more at the

bell laboratories where I published in the form of UNIX

programmers manual in the late 1971.

• Actually 95% of this unix system was written C language and

the remaining 5% is in assembly language.

• The details of the unix implementation in ‘c’ was made public

through a paper publication in 1974. this paper was quit

poplars and its authors ken Thomson and Dennis retches' later

awards with the prestigious ACM Tuning awards

Page 5: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• Features of UNIX OS:1. MALTIUSER CAPABILITY2. Time sharing3. Command interpreter4. Portability5. Multitasking and back ground processing6. Hierarchical file system7. Simple command structure8. File security and protection9. Communication10.System administration11.Job accounting12.Tools and utility13.Shell and shell programming

6

Page 6: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..14. Availability of rdbms15. Graphics

1.Multiuser capability: the unix multiuser system user can give different programs they can share data base like one user can enter the date , one user can update the data, one user can generate the reports at the same time.

2.Time sharing: Unix operator on the prepares of time sharing executed by the scheduler of users program is loaded in to the memory from the disk and scheduler provides and time like for each user.

7

Page 7: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

9

..6. Hierarchical file system: The Unix provides an excellent

multiple file system. The directory in Unix can have sub directories ad files co-existing.

7. Simply command system: The Unix system commands or user friendly commands are entered in lower case.

• The commands are easy to remember, and an ordinary user has to know and only 15 to 20 commands.

• The command such as ls, cut, pwd,l pr, chmod, mkdir,r mdir, rm, cp, mv a.re used to handle the file and directories.

8. File security and protection : Unix provides production to users files and directories from unauthorized user use in the particular file .

• Login and passed word are provided by Unix and prevents unauthorized people from going access to the system it self.

Page 8: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

10

9. communication: 9. communication: Unix as a verity of communication Unix as a verity of communication software bundles, a user can communicate from Unix software bundles, a user can communicate from Unix environment to users, under Unix provides communication environment to users, under Unix provides communication capabilities form a computer in one city or country to another capabilities form a computer in one city or country to another authorized users though telephone lines, microwave links and authorized users though telephone lines, microwave links and satellite communication.satellite communication.

10. System administration: 10. System administration: Unix provides excellent features Unix provides excellent features for monitoring and controlling the use of multiuser system .for monitoring and controlling the use of multiuser system . .System administration relates to the various activities .System administration relates to the various activities needed to controlled .needed to controlled .

11. Job Accounting: 11. Job Accounting: Unix also provides for maintenance of Unix also provides for maintenance of job accounting of various users of the system in terms of job accounting of various users of the system in terms of monitoring the CPU time used, lines printed, and utilized, monitoring the CPU time used, lines printed, and utilized, terminal log on time …etcterminal log on time …etc

Page 9: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

11

..12.Tools and Utilizing: there are 100’s of tools available in Unix

and the no’s are their even, user can create tools of their own as per their convince.

13. Shell and shell programming: the command interpreter of Unix is called shell .There are how types of popular shell’s available, in Unix one is Bourn shell and other is ‘c’ shell.

14. Availability of RDBMS: The RDBMS function is under multiuser system enable data addition modification deletion and access simultaneously by multiple users in the system.

15. Graphic: powerful graphics work stations used for engineering design and 3d graphics prepare Unix as the operating system.

Page 10: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

12

..STRUCTURE OF UNIX

Page 11: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

13

Page 12: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

14

KERNEL: KERNEL: Kernel is the heart of Unix system. This kernel is Kernel is the heart of Unix system. This kernel is relatively a small pieces of code that is embedded on the relatively a small pieces of code that is embedded on the hardware.hardware.

>>Actually it is a collection of programs that are mostly written In Actually it is a collection of programs that are mostly written In ‘c’.‘c’.>>Every Unix system has a kernel that gets automatically lorded Every Unix system has a kernel that gets automatically lorded on to the memory as soon as the system is booted.on to the memory as soon as the system is booted.>>As the kernel sits on the hardware, it can directly communicate As the kernel sits on the hardware, it can directly communicate with hardware.with hardware.>>In fact the kernel is the only component that can communicate In fact the kernel is the only component that can communicate witch the hardware directly.witch the hardware directly.>>It is the kernel that manages all the system resources like It is the kernel that manages all the system resources like memory and input output devices, allocates time between user memory and input output devices, allocates time between user and process in the case f multiuser environment decides process and process in the case f multiuser environment decides process manages inter process communication and perform many other manages inter process communication and perform many other taskstasks

Page 13: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

15

..ShellShell: : The shell is the part of Unix that is most visible the The shell is the part of Unix that is most visible the user it receives and interpreters the commends entered by the user it receives and interpreters the commends entered by the user.user.> shell Is a program that sits on the kernel and acts as an agent or > shell Is a program that sits on the kernel and acts as an agent or interface between the user and kernel and hence the hardware.interface between the user and kernel and hence the hardware.

>shell presents a command line for prompt($,%) , at which the >shell presents a command line for prompt($,%) , at which the user can type in any unix command after accepting the command, user can type in any unix command after accepting the command, the shell generates a readly executable simply command line by the shell generates a readly executable simply command line by parsing it.parsing it.> the shell as certain programing capabilities of its own.> the shell as certain programing capabilities of its own.>the shell programming can be written generally shell script. >the shell programming can be written generally shell script.

C shellC shellborn shellborn shelland korn shelland korn shell

Page 14: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

16

Born-shell: Born-shell: this is the most common shell available on this is the most common shell available on Unix system and the first manger shell this shell is widely Unix system and the first manger shell this shell is widely used it has named “Stephen Bourne” at AT and T bell used it has named “Stephen Bourne” at AT and T bell laboratories.laboratories.CC-shell: -shell: the c-shell was developed by “Bill joy”, the c-shell was developed by “Bill joy”, the shell at part of the BSD release it is call c-shell the shell at part of the BSD release it is call c-shell because its syntax and usage is very similarly to the because its syntax and usage is very similarly to the c- programming languagec- programming languageKORN-shell:KORN-shell: this shell was developed by devid this shell was developed by devid korn at ‘AT’ and ‘T’ Bell laboratories. Basically it is korn at ‘AT’ and ‘T’ Bell laboratories. Basically it is vuilt on the born cell, it also incorporates certain vuilt on the born cell, it also incorporates certain features of c-shellfeatures of c-shell

Page 15: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

17

VI EDITORVI EDITOR.

Page 16: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..

• The vi editor is available on almost all Unix systems. vi can be used from any type of terminal because it does not depend on arrow keys and function keys--it uses the standard alphabetic keys for commands.

• vi (pronounced "vee-eye") is short for "vi"sual editor. It displays a window into the file being edited that shows 24 lines of text. vi is a text editor, not a "what you see is what you get" word processor. vi lets you add, change, and delete text, but does not provide such formatting capabilities as centering lines or indenting paragraphs.

• This help note explains the basics of vi:• opening and closing a file• moving around in a file• elementary editing

18

Page 17: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• What is vi?• The default editor that comes with the UNIX

operating system is called vi (visual editor). [Alternate editors for UNIX environments include pico and emacs, a product of GNU.]

• The UNIX vi editor is a full screen editor and has two modes of operation:

• Command mode commands which cause action to be taken on the file, and

• Insert mode in which entered text is inserted into the file. • In the command mode, every character typed is a command that does

something to the text file being edited; a character typed in the command mode may even cause the vi editor to enter the insert mode. In the insert mode, every character typed is added to the text in the file; pressing the <Esc> (Escape) key turns off the Insert mode.

• While there are a number of vi commands, just a handful of these is usually sufficient for beginning vi users.

19

Page 18: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

20

..The Following commands are mostly used in vi

Page 19: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

The Following commands are mostly used in vi The Following commands are mostly used in vi

h – backspaceh – backspace→ cursor moves to left→ cursor moves to leftl (or) spacebar l (or) spacebar → moves cursor right→ moves cursor right5l 5l → moves 5 characters to right→ moves 5 characters to rightk k → moves cursor up→ moves cursor up10k 10k → moves 10 lines up→ moves 10 lines upjj → moves cursor down → moves cursor down

scrolling:scrolling:contrl+fcontrl+f → scrolls full page forward → scrolls full page forward5 contrl+f 5 contrl+f → scrolls five full pages forward→ scrolls five full pages forwardcontl+b contl+b → scrolls full page back→ scrolls full page backcontl+d contl+d → half page forward→ half page forwardcontl+u contl+u → half page backward→ half page backward

Page 20: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

22

Word navigation:Word navigation:bb→ moves back to begin of word → moves back to begin of word 4b4b → → moves back 4words to begin moves back 4words to beginee → → moves forward to end of word moves forward to end of wordww → → moves forward moves forward 8w8w → moves forward to beginning of 8 words → moves forward to beginning of 8 wordso (or) | o (or) | → moves to beginning of lines→ moves to beginning of lines30| 30| → moves to column 30→ moves to column 30^ ^ → moves to first word in line→ moves to first word in line$ $ → moves to end of line→ moves to end of line1G1G → moves to beginning of file → moves to beginning of file40 40 → moves to line 40→ moves to line 40GG → moves to end of file → moves to end of fileX, dd X, dd → deleting options→ deleting optionsxx → deletes a single character → deletes a single character4x 4x → delete 4 characters→ delete 4 charactersJJ → joining lines → joining lines

Page 21: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

23

dwdw → → deletes one worddeletes one word3dw3dw → deletes 3 words → deletes 3 wordsdGdG → deletes form current curser position to end of file → deletes form current curser position to end of filechch → change previous character → change previous character4ch4ch → change previous 4 character → change previous 4 character4c2h4c2h → change previous 8 character → change previous 8 characterc2jc2j → change current line and text two lines → change current line and text two linescwcw → change form current character to next word → change form current character to next wordc) c) → change form cursor to beginning of next sentence→ change form cursor to beginning of next sentencec{c{→ change backward to beginning of paragraph → change backward to beginning of paragraph cc cc → change current line→ change current linerrs } s } → replace the current character ,.→ replace the current character ,.m m

Page 22: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

24

Line mode:-Line mode:-

::ww → → save file and remain in editing mode: x → save file and exit editing mode→ save file and exit editing mode::wq wq → save and exit→ save and exit::w n2 w. pl w n2 w. pl → like save as in → like save as in :w! n2wpl :w! n2wpl → as above but over write existing→ as above but over write existing:e! :e! → this option is used to loads lost saved addition → this option is used to loads lost saved addition of current file.of current file.

Page 23: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

ScreenScreen ManipulationManipulation: The: The following commands allow the following commands allow the vi editor screen (or window) to move up or down several lines vi editor screen (or window) to move up or down several lines and to be refreshed. and to be refreshed. ^f ^f move forward one screenmove forward one screen ^b ^b move backward one screenmove backward one screen ^d ^d move down (forward) one half screenmove down (forward) one half screen ^u ^u move up (back) one half screenmove up (back) one half screen ^l ^l redraws the screenredraws the screen ^r ^r redraws the screen, removing deleted linesredraws the screen, removing deleted lines

25

Page 24: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

Cursor Movement:Cursor Movement:h move left (backspace)j move downk move upl move right (spacebar)

..

26

Page 25: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

Deleting Text:Deleting Text:

x :x :delete single character under cursordelete single character under cursor     Nx :Nx :delete N characters, starting with character under cursordelete N characters, starting with character under cursor     dw :dw :delete the single word beginning with character under delete the single word beginning with character under cursorcursor     dNw :dNw :delete N words beginning with character under cursor; delete N words beginning with character under cursor;   e.g., d5w deletes 5 words  e.g., d5w deletes 5 words     D :D :delete the remainder of the line, starting with current delete the remainder of the line, starting with current cursor positioncursor position * * dd :dd :delete entire current linedelete entire current line     Ndd Ndd oror dNd : dNd :delete N lines, beginning with the current line; delete N lines, beginning with the current line;   e.g., 5dd deletes 5 lines  e.g., 5dd deletes 5 lines

27

Page 26: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

28

File handling utilities:File handling utilities: pwd, cat, cc, ls, mv, cp, touch, unlink, mkdir, rmdir, cd, pwd, cat, cc, ls, mv, cp, touch, unlink, mkdir, rmdir, cd, ln, od, gzip, more, mv, rm, script, chmod, chgrp, man, ln, od, gzip, more, mv, rm, script, chmod, chgrp, man, chgroup. Echo,printfchgroup. Echo,printf

process utilities: process utilities: ps, kill, at, nice, who, w, ulimit.ps, kill, at, nice, who, w, ulimit.

Text processing utilities: Text processing utilities: head, tail, nl, sort, uniq, cut, paste, tr, join, tee, comm, head, tail, nl, sort, uniq, cut, paste, tr, join, tee, comm, cmp,diff, find, grep, awk.cmp,diff, find, grep, awk.

Networking utilities:Networking utilities:ftp, rlogin, telnet, finger, arpftp, rlogin, telnet, finger, arp

Page 27: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

29

Disk utilities:Disk utilities:df, du, mount, umount,df, du, mount, umount,

Back up utilities:Back up utilities:cpio, tarcpio, tar

Page 28: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

30

File handling utilities: File handling utilities:

1. cc 1. cc :- :- This command is used to c compiler or it compiles This command is used to c compiler or it compiles the code of the file the code of the file

Syntax: Syntax: cc [option] file namecc [option] file nameoption : option : option –f → no floating point requireoption –f → no floating point require

-fp→ hardware floating point using -fp→ hardware floating point using

Example:Example:

cc f1.ccc f1.c (compilation ) (compilation )./a.out←./a.out←

Description: Description: when you invoke Gcc, it normally does when you invoke Gcc, it normally does preprocessor compilation, assembly and linking.preprocessor compilation, assembly and linking.

Page 29: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

31

Man command:Man command:namename: man-an interface to the on-line reference manuals: man-an interface to the on-line reference manualssyntax: man [option] key wordsyntax: man [option] key wordDescription: man is the system’s manual pager. Each Description: man is the system’s manual pager. Each page argument given to man is normally the name of a page argument given to man is normally the name of a program, utility or function. The manual page program, utility or function. The manual page associated with each of these arguments is then found associated with each of these arguments is then found and displayed.and displayed.Exicutions:Exicutions:$ man rmdir$ man rmdir

.

Page 30: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

32

echo command: echo command: name: name: echo- display a line of textecho- display a line of textsyntax: echo[option]..[string]syntax: echo[option]..[string]Description: Description: --n n → → do not output the trailing newlinedo not output the trailing newline-e -e → → enable interpretation of backslash escapesenable interpretation of backslash escapes-E -E → → disable interpretation of backslash escapes.disable interpretation of backslash escapes.Exicutions: Exicutions: $ echo hai mca student$ echo hai mca student A. Hai mca student A. Hai mca student$echo hai mca students >f1$echo hai mca students >f1$cat f1$cat f1A. Hai mca studentsA. Hai mca students

.2

Page 31: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

33

3.PRINTF COMMAND3.PRINTF COMMAND: Fermat and print data: Fermat and print datasyntax: syntax: printf FORMAT[ARGUMENT]printf FORMAT[ARGUMENT] printf [option].printf [option].Description:Description:

The printf command is an alternative to the echo command. In The printf command is an alternative to the echo command. In addition to displaying simple massage, it can also format the output.addition to displaying simple massage, it can also format the output.The printf command does not insert a new line(\n) unless it is used The printf command does not insert a new line(\n) unless it is used explicitly. It accepts all escape sequences like \n, \c, \a, \t used by echo.explicitly. It accepts all escape sequences like \n, \c, \a, \t used by echo.Exicutions:Exicutions:Q. $printf haiQ. $printf haiA. Hai$printfA. Hai$printfQ. $ printf hai mcaQ. $ printf hai mcaA hai $printfA hai $printfQ $ printf ‘hai mca’Q $ printf ‘hai mca’A hai mca $printfA hai mca $printf

Page 32: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

34

4.SCRIPT4.SCRIPT Command: Command:NAME: NAME: script- make typescript of terminal sessionscript- make typescript of terminal sessionSYNTAX: SYNTAX: script [-option] argument.script [-option] argument.

DESCRIPTION: DESCRIPTION: Script makes a typescript of everything printed Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the record of an interactive session as proof of an assignment, as the typescript file can be printed out later with LPR() . typescript file can be printed out later with LPR() . Executions: Executions: Q $scriptQ $scriptA Script started, file is typescripotA Script started, file is typescripotQ $ dateQ $ dateA Fri oct 1 09:32:17 IST 2010A Fri oct 1 09:32:17 IST 2010Q cat f1Q cat f1A hai A hai hellohello$cat typescript$cat typescriptscript started on Friday 01 dec 2013 09:31:45 am ISTscript started on Friday 01 dec 2013 09:31:45 am IST

Page 33: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

35

..5.Passaword:Passwd-change user passwordSyntax: passwd [options][LOGIN]Description: The Passwd command changes passwords for user

accounts. A normal user may only change the password for his/her own account, while the super user may change the password for any account. Passwd also changes account information, such as the full name of the user, the user’s login shell, or his/her password expiry date and interval.

Password changes:• The user is first prompted for his/her old password, if one is

present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed.

Page 34: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

36

..Exicutions: – Enter wrong password $ passwd ←Change password for ds(current) UNIX passwordDsPasswd: Authentication token manipulation errorPasswd: password unchanged $ passwdChanging password for ds(current) UNIX password:SrinivaskietEnter new UNIX password:KietRetype new UNIX PASSWORD:KietBad: new password is too simple Passwd: Authentication token manipulation errorPasswd: password unchanged

Page 35: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

37

•Change password:Change password:$ passwd$ passwdchanging password for rajeshchanging password for rajesh(current) UNIX password:(current) UNIX password:srinivaskietsrinivaskietenter new UNIX password:enter new UNIX password:kiet123kiet123Retype new UNIX password:Retype new UNIX password:kiet123kiet123passwd: password updated successfullypasswd: password updated successfully

Page 36: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

38

6.Uname6.Uname commend commenduname-uname-print system informationprint system informationsyntax syntax : uname [option]: uname [option]description:description:print certain system information. With no option, same as –sprint certain system information. With no option, same as –s--aa-all-allprint all information, in the following order, except omit –p and –print all information, in the following order, except omit –p and –I if unknown:I if unknown:-s →-s →kernel-name-print the kernel namekernel-name-print the kernel name--nn-- → → node name- print the network node hostnamenode name- print the network node hostname--rr-- → → kernel release- print the kernel versionkernel release- print the kernel version--m →m → machine- print the machine hardware name machine- print the machine hardware name-p- → -p- → processor- print the processor type or “unknown- I, hard processor- print the processor type or “unknown- I, hard ware platformware platform-o → -o → operating system –print the operating systemoperating system –print the operating system

Page 37: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

39

Executions: Executions: $ uname$ unameLinuxLinux$uname –a$uname –aLinux kiet-laptop 2.6.28-11generic#42-Ubuntu SMP Fri Apr 17 Linux kiet-laptop 2.6.28-11generic#42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009 i686 GNU/Linux01:57:59 UTC 2009 i686 GNU/Linux$ uname –n$ uname –nkiet laptopkiet laptop$uname –s$uname –sLinuxLinux$ uname –r$ uname –r2.6.28-11-GENERIC2.6.28-11-GENERIC$uname -v$uname -v#42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009#42-Ubuntu SMP Fri Apr 17 01:57:59 UTC 2009$ uname –m$ uname –mi686i686$ uname –p$ uname –punknownunknown

Page 38: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

40

7.Stty command:7.Stty command:stty- change and print terminal line settingsstty- change and print terminal line settingssyntax: syntax: stty[-F DEVICE][--file=DEVICE][SETTING]stty[-F DEVICE][--file=DEVICE][SETTING]stty[-F DEVICE][--File=device][-a|--all]stty[-F DEVICE][--File=device][-a|--all]stty[-F DEVICE][--file=DEVICE][-g|--save]stty[-F DEVICE][--file=DEVICE][-g|--save]Description:Description: print or change terminal characteristics. print or change terminal characteristics.-a -a → → allall print all current settings in human-readable form print all current settings in human-readable form-g–-g–→→savesaveprint all current settings in a stty- readable formprint all current settings in a stty- readable formexicutions:exicutions:$stty speed 38400baud; line=0$stty speed 38400baud; line=0$stty –a$stty –a$stty -g$stty -g

Page 39: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

41

..

8.Pwd command:

This command is used to print name of current/working

directory

Syntax: pwd [option][arguments]

Description: The command used to determine the current

directory is print working directory (pwd). It has no options

and no attributes. When executed, it prints the absolute path

name for the current directory.

Executions:

$pwd

/home/kietmca

Page 40: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

42

9.Cat command: concatenate files and print on the standard outputSyntax: cat [option][file]Description: concatenate File(s), or standard input, to standard output.-e → equivalent to –Ve-E → show ends-Display$ at end of each line-n → number all output lines-s → squeeze-blank-suppress repeated empty output lines-t → equivalent to -vT -T → display TAB characters as ^lx

..

Page 41: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

43

..• Executions: $ cat>aHaiWelcome to mca $cat ahaiWelcome to mca $cat>>aKietmca $cat aHai welcome to mcakietmca

Page 42: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

44

$ cat –e aHai$Welcomemca$Kietmca$ $cat –n a1 hai2 welcomemca3kietmca10.Cc command cc- this command is used to c and c++ compiler(gcc)Syntax: cc[option] filenameDescription: when you invoke GCC, it normally does

preprocessing , compilation, assembly and linking. The” overall options” allow you to stop this process at an

intermediate stage. For example, the –c option says not to run the linker. Then the output consists of object files output by the assembler.

..

Page 43: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

45

..EXECUTIONS: $cc hello.c

$ ./a.out

11.Ls command:This command is used to display the list of directory contentsSyntax: ls[option]..[file]Description: • List information about the Files( the current directory by

default). Sort entries alphabetically .• mandatory arguments to long options are mandatory for short

options too. -l → use a long listing format-a- → all-do not ignore entries starting with

Page 44: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..-r → reverse- reverse order while sorting-t → sort by modification time-i → print the index number of each file-p → append/indicator to directorieslist subdirectories recursivelyExecutions:$lsF1 f2 f3 f4 f5 dir1$ls-l-rwr r-x-wx 1 kietmca kiet 54 2013 -17-12 12:50 f1$ls –ld$ls –d$ls –n$ls –tKietmca f1 f2 f3 f4

46

Page 45: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

.. 12. mv command:This command is used to move (rename)filesSyntax: mv[option].. . Source destmv[ option]…source…directorymv[option]… -t directory sourceDescription:This command is used to move either an individual file, a list of

files, or a directory. After a move, the old file name is gone and the new file name is found at the destination. This is the difference between a move and a copy after a copy, the file is physically duplicated; it exists in two places. The move format appears the first argument is the name of the file to be moved. The second argument is its destination or , in the case of a rename, its new name.

47

Page 46: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..Executions: $ mv ab$cat bHai how are u$cat cKiet$mv – I bc$ mv –f a dir$ ls –l dir total 0rwr r-x-wx 1 kietmca kiet 54 2013 -17-12 12:50 f1

48

Page 47: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

13.Cp command13.Cp commandThis command is used to copy files and directoriesSyntax:

cp[option].. . Source destcp[ option]…source…directorycp [option]… -t directory source

Description: The copy (cp) utility creates a duplicate of a file, or a directory. If the source is a file, the new file contains an exact copy of the data in the source file. If the source is a directory, all of the files in the directory are copied to the destination, which must be a directory. If the destination file already exists, its contents are replaced by the source file contents. The cp command copies both text and binary files.

49

Page 48: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• Exicutions: $ lsF1 f2 $cp f1 f2 $cat a Hai How are u $cat bHaiHow are u

50

Page 49: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

14. Touch:14. Touch:This command is used to change file timestampsSysntax

touch [option].. File Description: Update the access and modification times of each FILE to

the current time.Afile argument that does not exist is created empty.A file argument string of –is handled specially and causes touch to

change the times of the file associated with standard output-a – change only the access time-c- do not create any files -r use this files times instead of current timeExicutions:$ ls-l$ touch a b

51

Page 50: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

15.Ln command15.Ln commandThis command is used to links between filesSyntax :

ln[option]..target link_name (1st formln[option]…TARGET (2nd form)ln[option].. TARGET.. DIRECTORY (3rd form)

Description:Link has three options: symbolic, interactive, and force

Symbolic: the default link type is hard. To create a symbolic link, the symbolic option(-s) is used.

Interactive: if the destination file already exists, its contents are destroyed unless we request to be warned by using the interactive flag(-i). When the interactive flag is on link asks if we want to destroy the existing file. This is similar to the message we get when the permissions don’t allow us to write the file.

52

Page 51: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..Executions: $cat aHelloKiet$ls A$ln a b$ cat bHello kiet

53

Page 52: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

16. Unlink command:16. Unlink command:This command is used to call the unlink function to remove the

specified fileSyntax: unlink FILE

unlink [option]Description: call the unlink function to remove the specified FILE.Executions: $lsA b$unlink b$ls a

54

Page 53: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

17.mkdir17.mkdirThis command is used to make a directoriesSyntax: mkdir[option] directoryDescription :Create the Directory, if they do not already exist.Mandatory arguments to long options are mandatory for short

options too.-m- mode-set file mode (as in chmod), not a=rwx-umask-p –parents- no error if existing, make parent directories as neededExecutions: $mkdir kietmca$cd kietmca$kiet@kiet-virtual machine:-/kietmca$

55

Page 54: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

18.rmdir18.rmdirThis command is used to remove empty directoriesSyntax : [option]..directory..Description:Remove the Directory , if they are empty-p- parentsRemove directory and its ancestorsExicutions: $rmdir kietmca$rmdir –p kietmca1/kietmca2/kietmca3

56

Page 55: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

19. cd19. cdThis command is used to change the current working directorySyntax: cd [path name]Description: There are no options for the cd command. The

pathname is an argument to cd. The pathname can be relative or absolute. When used with an argument, cd changes to the directory specified as argument.

Execution : $pwd/home/kietmca$cd/home/kietmca/mca$ cd ..$pwd$/home/kietmca$cd ~$pwd 57

Page 56: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

20. gzip command20. gzip commandThis command is used to compress and decompress the

fileSyntax: gzip [option] orgumentDescription: reduse the size of the named fileExecuation :$ls –l$gzip -f file name$gzip –d file name

58

Page 57: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

od commandod commandThis command is used to convert the information to octal digitsSyntax: od [option] filename Description: Example: $ od f102101010203040302

59

Page 58: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

60

Page 59: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

SORTING TWO FILESSORTING TWO FILES : :

 NAME• sort - sort lines of text files• SYNOPSIS• sort [OPTION]... [FILE]...• DESCRIPTION• Write sorted concatenation of all FILE(s) to standard output.• Ordering options:• Mandatory arguments to long options are mandatory for short

options• too.

61

Page 60: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..  -d, --dictionary-order• consider only blanks and alphanumeric characters• EXAMPLE•  [student@localhost SIRI]$ cat>a2• orange• banana• apple• strawberry• melon• peach• kiwi• [10]+ Stopped cat >a2• [student@localhost SIRI]$ sort a2• apple• banana• kiwi• melon• orange• peach• strawberry 62

Page 61: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

.. [student@localhost SIRI]$ cat>a3• amazing• abide• alum• aspiration• admire• [11]+ Stopped cat >a3 [student@localhost SIRI]$ sort -d a3• abide• admire• alum• amazing• aspiration

63

Page 62: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

FINDING FILE(find) FINDING FILE(find) • NAME• find - search for files in a directory hierarchy•  • SYNOPSIS• find [path...] [expression]•  • DESCRIPTION• This manual page documents the GNU version of find. find searches the• directory tree rooted at each given file name by evaluating the given• expression from left to right, according to the rules of precedence• (see section OPERATORS), until the outcome is known (the left hand side• is false for and operations, true for or), at which point find moves on• to the next file name.• If no paths are given, the current directory is used. If no• expression is given, the expression -print is used.• find exits with status 0 if all files are processed successfully,• greater than 0 if errors occur.

64

Page 63: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE [student@localhost SIRI]$ ls• a A a1 ani Anitha a.out count err fruits list stu [student@localhost SIRI]$ find ani22• find: ani22: No such file or directory [student@localhost SIRI]$ ls stu• a ani calc countwords err list mul• a1 ani22 count cpfiles fruits listfiles multiplication [student@localhost SIRI]$ find ani22• find: ani22: No such file or directory [student@localhost SIRI]$ cd stu [student@localhost SADA]$ ls• a ani calc countwords err list mul• a1 ani22 count cpfiles fruits listfiles multiplication [student@localhost SADA]$ find ani22• ani22 [student@localhost SADA]$ 65

Page 64: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

DISPLAYING FILE CONTENT BY PAGE WISEDISPLAYING FILE CONTENT BY PAGE WISE  • NAME

• more - file perusal filter for crt viewing• SYNOPSIS• more [-dlfpcsu] [-num] [+/ pattern] [+ linenum] [file ...]• DESCRIPTION• More is a filter for paging through text one screenful at a time. This• version is especially primitve. Users should realize that less(1) pro-• vides more(1) emulation and extensive enhancements.• EXAMPLE • [student@localhost SIRI]$ more a3• operating• system• is• a• set• of• Programs

66

Page 65: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• programs• that• acts• as• interface• user• of• computer• and• the• computer• hardware• There• are• different• types• of• --More--(56%)• operating• systems• in 67

Page 66: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

UNIQUENESS OF FILEUNIQUENESS OF FILE• NAME• uniq - remove duplicate lines from a sorted file• SYNOPSIS• uniq [OPTION]... [INPUT [OUTPUT]]• DESCRIPTION• Discard all but one of successive identical lines from INPUT (or stan-• dard input), writing to OUTPUT (or standard output).• Mandatory arguments to long options are mandatory for short

options• too.• -c, --count• prefix lines by the number of occurrences• -d, --repeated• only print duplicate lines 

68

Page 67: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE• [student@localhost SIRI1]$ cat a3• amazing• abide• alum• aspiration• admire• Alum• [student@localhost SIRI1]$ uniq a3• amazing• abide• alum• aspiration• admire• alum

69

Page 68: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI1]$ uniq -c a3• 1 amazing• 1 abide• 1 alum• 1 aspiration• 1 admire• 1 alum

70

Page 69: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

DISPLAYING CALENDERDISPLAYING CALENDER• NAME• cal - displays a calendar• SYNOPSIS• cal [-smjy13] [[month] year] • DESCRIPTION• Cal displays a simple calendar. If arguments are not

specified, the cur-• rent month is displayed. The options are as follows:• -1 Display single month output. (This is the default.)• -3 Display prev/current/next month output.• -s Display Sunday as the first day of the week. (This is

the default.)• -m Display Monday as the first day of the week.

71

Page 70: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• -j Display Julian dates (days one-based, numbered from January 1).

• -y Display a calendar for the current year.•  • EXAMPLE• [student@localhost SANA]$ cal• cal• December 2008• Su Mo Tu We Th Fr Sa• 1 2 3 4 5 6• 7 8 9 10 11 12 13• 14 15 16 17 18 19 20• 21 22 23 24 25 26 27• 28 29 30 31

72

Page 71: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SANA]$ cal -y• 2008• January February March• Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa• 1 2 3 4 5 1 2 1• 6 7 8 9 10 11 12 3 4 5 6 7 8 9 2 3 4 5 6 7 8• 13 14 15 16 17 18 19 10 11 12 13 14 15 16 9 10 11 12 13 14 15• 20 21 22 23 24 25 26 17 18 19 20 21 22 23 16 17 18 19 20 21 22• 27 28 29 30 31 24 25 26 27 28 29 23 24 25 26 27 28 29• 30 31• April May June• Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa• 1 2 3 4 5 1 2 3 1 2 3 4 5 6 7• 6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14• 13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21• 20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28• 27 28 29 30 25 26 27 28 29 30 31 29 30•  • July August September• Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa• 1 2 3 4 5 1 2 1 2 3 4 5 6• 6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13• 13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20• 20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27• 27 28 29 30 31 24 25 26 27 28 29 30 28 29 30• 31• October November December• Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa• 1 2 3 4 1 1 2 3 4 5 6• 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13• 12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20• 19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27• 26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31• 30

73

Page 72: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

DISPLAYING TERMINAL TYPEDISPLAYING TERMINAL TYPE::• NAME• tty - print the file name of the terminal connected to standard input•  • SYNOPSIS• tty [OPTION]...•  • DESCRIPTION• Print the file name of the terminal connected to standard input.•  • -s, --silent, --quiet• print nothing, only return an exit status•  • --help display this help and exit•  • --version• output version information and exit

74

Page 73: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE •  • [student@localhost SANA]$ tty• tty• /dev/pts/21• [student@localhost SANA]$

75

Page 74: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

TEXT PROCESSING UTILITIESTEXT PROCESSING UTILITIES• NAME• nl - number lines of files•  • SYNOPSIS• nl [OPTION]... [FILE]...•  • DESCRIPTION• Write each FILE to standard output, with line numbers added. With no• FILE, or when FILE is -, read standard input.•  • Mandatory arguments to long options are mandatory for short options• too.

• -b, --body-numbering=STYLE• use STYLE for numbering body lines

• -d, --section-delimiter=CC• use CC for separating logical pages

76

Page 75: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI1]$ nl a3• 1 amazing• 2 abide• 3 alum• 4 aspiration• 5 admire• 6 alum• 7 admire• 8 amaze

77

Page 76: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

CMP COMMANDCMP COMMAND• NAME• cmp - compare two files•  • SYNOPSIS• cmp [-l | -s] file1 file2 [skip1 [skip2]]•  • DESCRIPTION• The cmp utility compares two files of any type and writes the results to• the standard output. By default, cmp is silent if the files are the• same; if they differ, the byte and line number at which the first differ-• ence occurred is reported.•  • Bytes and lines are numbered beginning with one.•  • The following options are available:•  • -l Print the byte number (decimal) and the differing byte values• (octal) for each difference.

78

Page 77: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI1]$ cat ani3• Unix• is• the• multiuser• os• [student@localhost SIRI1]$ cat a3• amazing• abide• alum• aspiration• admire• alum• admire

79

Page 78: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLE:EXAMPLE:

• [student@localhost SIRI1]$ cmp a3 ani3• a3 ani3 differ: byte 1, line 1• [student@localhost SIRI1]$ cmp -l a3 ani3• 1 141 125• 2 155 156• 3 141 151• 4 172 170• 5 151 12• 6 156 151• 7 147 163• 8 12 40• 9 141 12• 10 142 164

80

Page 79: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

COMM COMMANDCOMM COMMAND• NAME• comm - compare two sorted files line by line•  • SYNOPSIS• comm [OPTION]... LEFT_FILE RIGHT_FILE•  • DESCRIPTION• Compare sorted files LEFT_FILE and RIGHT_FILE line by

line.•  • -1 suppress lines unique to left file•  • -2 suppress lines unique to right file•  • -3 suppress lines that appear in both files•  

81

Page 80: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE•  • [student@localhost SIRI1]$ cat a1• apple• kiwi• carrot• lemon• orange• chillies• [student@localhost SIRI1]$ cat a2• chilly• cabbage• potato• orange• aplle• kiwi• [student@localhost SIRI1]$ sort a2• aplle• cabbage• chilly• kiwi• orange

82

Page 81: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• potato• [student@localhost SIRI1]$ sort a1• apple• carrot• chillies• kiwi• lemon• orange• [student@localhost SIRI1]$ comm a1 a2• apple• chilly• cabbage• kiwi• carrot• lemon• orange• chillies• potato• orange• aplle• kiwi• [student@localhost SIRI1]$ comm a2 a1• apple• chilly• cabbage• kiwi• carrot• lemon• orange• chillies• potato• orange• aplle 83

Page 82: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

diff COMMANDdiff COMMAND• NAME• diff - find differences between two files•  • SYNOPSIS• diff [options] from-file to-file•  • DESCRIPTION• In the simplest case, diff compares the contents of the two files from-• file and to-file. A file name of - stands for text read from the stan-• dard input. As a special case, diff - - compares a copy of standard• input to itself.•  • If from-file is a directory and to-file is not, diff compares the file• in from-file whose file name is that of to-file, and vice versa. The• non-directory file must not be -.•  • If both from-file and to-file are directories, diff compares corre-• sponding files in both directories

84

Page 83: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE

• [student@localhost SIRI1]$ cat a2• cat a2• chilly• cabbage• potato• orange• aplle• kiwi• [student@localhost SIRI1]$ cat a1• apple• kiwi• carrot• lemon• orange• chillies

85

Page 84: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI1]$ diff a1 a2• 1,4c1,3• < apple• < kiwi• < carrot• < lemon• ---• > chilly• > cabbage• > potato• 6c5,6• < chillies• ---• > aplle• > kiwi• [student@localhost SIRI1]$ diff a2 a1• 1,5c1• < chilly• < cabbage• < potato• < orange• < aplle• ---• > apple• 6a3,6• > carrot• > lemon• > orange• > chillies

86

Page 85: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

uniq uniq • NAME• uniq - remove duplicate lines from a sorted file•  • SYNOPSIS• uniq [OPTION]... [INPUT [OUTPUT]]• DESCRIPTION• Discard all but one of successive identical lines from INPUT (or stan-• dard input), writing to OUTPUT (or standard output).•  • Mandatory arguments to long options are mandatory for short options• too.•  • -c, --count• prefix lines by the number of occurrences•  • -d, --repeated• only print duplicate lines 87

Page 86: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE

   • [student@localhost SIRI1]$ cat a3• amazing• abide• alum• aspiration• admire• alum• Admire

• [student@localhost SIRI1]$ uniq a3• amazing• abide• alum• aspiration• admire• alum• admire• amaze

88

Page 87: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI1]$ uniq -c a3• 1 amazing• 1 abide• 1 alum• 1 aspiration• 1 admire• 1 alum• 1 admire• 1 amaze• 1 arrogant• 1 admire• 1 admit• 1 admn• [student@localhost SIRI1]$ uniq -d a3• [student@localhost SIRI1]$

89

Page 88: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

Tee commandTee command

• NAME• tee - read from standard input and write to standard

output and files • SYNOPSIS• tee [OPTION]... [FILE]...• DESCRIPTION• Copy standard input to each FILE, and also to standard

output.• -a, --append• append to the given FILEs, do not overwrite• -i, --ignore-interrupts• ignore interrupt signals•  

90

Page 89: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE  • [student@localhost SIRI1]$ ls

• a a1 a2 a3 a4 ani2 ani3 ani4 asc• [student@localhost SIRI1]$ cat a2• chilly• cabbage• potato• orange• aplle• kiwi

91

Page 90: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI1]$ cat a2|tee a5• chilly• cabbage• potato• orange• aplle• kiwi• [student@localhost SIRI1]$ cat a5• chilly• cabbage• potato• orange• aplle• kiwi• [student@localhost SIRI1]$ cat a2• chilly• cabbage• potato• orange• aplle

92

Page 91: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

WCWC COMMAND COMMAND• NAME• wc - print the number of bytes, words, and lines in files•  • SYNOPSIS• wc [OPTION]... [FILE]...• DESCRIPTION• Print byte, word, and newline counts for each FILE, and a total line if• more than one FILE is specified. With no FILE, or when FILE is -, read• standard input.• -c, --bytes• print the byte counts• -m, --chars• print the character counts•  • -l, --lines• print the newline counts•  • -L, --max-line-length• print the length of the longest line

93

Page 92: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ cat fruits• apple• orange• banana• cherry• pineapple• strawberries• watermelon• melon• grapes• lemons• pomegranate• tarbuja• tomato• anitha• student@localhost SIRI]$ wc fruits• 16 16 131 fruits• [student@localhost SIRI]$ wc -c fruits• 131 fruits• [student@localhost SIRI]$ wc -m fruits• 131 fruits• [student@localhost SIRI]$ wc -l fruits• 16 fruits• [student@localhost SIRI]$ wc -L fruits• 12 fruits• [student@localhost SIRI]$ 94

Page 93: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

grep, egrep, fgrepgrep, egrep, fgrep• PATTERN MATCHING OR SERCHING:•  • NAME• grep, egrep, fgrep - print lines matching a pattern•  • SYNOPSIS• grep [options] PATTERN [FILE...]• grep [options] [-e PATTERN | -f FILE] [FILE...]•  • DESCRIPTION• Grep searches the named input FILEs (or standard input if no files are• named, or the file name - is given) for lines containing a match to the• given PATTERN. By default, grep prints the matching lines.•  • In addition, two variant programs egrep and fgrep are available. Egrep• is the same as grep -E. Fgrep is the same as grep -F.

95

Page 94: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• -a, --text• Process a binary file as if it were text; this is equivalent to• the --binary-files=text option.•  • -B NUM, --before-context=NUM• Print NUM lines of leading context before matching lines.• Places a line containing -- between contiguous groups of• matches.•  • -C NUM, --context=NUM• Print NUM lines of output context. Places a line containing --• between contiguous groups of matches.•  • -b, --byte-offset• Print the byte offset within the input file before each line of• output.

96

Page 95: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE • [student@localhost SADA]$ cd Anitha• [student@localhost SADA]$ cat an1• hai• this• is• unix• lab• [student@localhost SIRI]$ grep -c i an1• 4• [student@localhost SIRI]$ grep -c unix an1• 1• [student@localhost SIRI]$ grep -c inix an1• 0• [student@localhost SIRI]$ cat>an2• hai• this• is• unix

97

Page 96: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ grep -f an1 an2• hai• this• is• unix• [student@localhost SIRI]$ cat a1• 123456789• [student@localhost SIRI]$ cat>an3• hai• welcom• to• unix•  • [2]+ Stopped cat >an3• [student@localhost SIRI]$ grep -f an2 an3• hai• unix• [student@localhost SIRI]$ grep -f an1 an3• hai• unix• [student@localhost SIRI]$ grep -l unix lab an1 an3• grep: lab: No such file or directory• an1• an3• [student@localhost SIRI]$ grep -l hai unix an1 an3• grep: unix: No such file or directory• an1• an3• [student@localhost SIRI]$ 98

Page 97: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

FGREPFGREP• [student@localhost SIRI]$ cat an1• hai• this• is• unix• lab• [student@localhost SIRI]$ cat an2• hai• this• is• unix• [student@localhost SIRI]$ cat an3• hai• welcom• to• unix• [student@localhost SIRI]$ fgrep -v this an1 an2 an3• an1:hai• an1:is• an1:unix• an1:lab• an2:hai• an2:is• an2:unix• an3:hai• an3:welcom• an3:to• an3:unix 99

Page 98: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ fgrp -v hai an1 an2 an3• -bash: fgrp: command not found• [student@localhost SIRI]$ fgrep -v hai an1 an2 an3• an1:this• an1:is• an1:unix• an1:lab• an2:this• an2:is• an2:unix• an3:welcom• an3:to• an3:unix• [student@localhost SIRI]$ fgrep -f an1 an2 an3• an2:hai• an2:this• an2:is• an2:unix• an3:hai• an3:unix• [student@localhost SIRI]$ fgrep -l hai an1 an2 an3• an1• an2• an3

100

Page 99: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ fgrep -l welcom an1 an2• [student@localhost SIRI]$ fgrep -l welcom an1 an2 an3• an3• [student@localhost SIRI]$ fgrep -b unix an1 an2 an3• an1:12:unix• an2:12:unix• an3:16:unix• [student@localhost SIRI]$ fgrep -b this an1 an2 an3• an1:4:this• an2:4:this• [student@localhost SIRI]$ fgrep -b welcom an1 an2 an3• an3:4:welcom• [student@localhost SIRI]$

101

Page 100: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

AAHOHO W WEIGHNBERGEIGHNBERG K KERNIGAN ERNIGAN (AWK)(AWK)• NAME• gawk - pattern scanning and processing language• SYNOPSIS• gawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...• gawk [ POSIX or GNU style options ] [ -- ] program-text file ...• pgawk [ POSIX or GNU style options ] -f program-file [ -- ] file ...• pgawk [ POSIX or GNU style options ] [ -- ] program-text file ...• DESCRIPTION• Gawk is the GNU Projects implementation of the AWK programming lan-• guage. It conforms to the definition of the language in the POSIX• 1003.2 Command Language And Utilities Standard. This version in turn• is based on the description in The AWK Programming Language, by Aho,• Kernighan, and Weinberger, with the additional features found in the• System V Release 4 version of UNIX awk. Gawk also provides more recent• Bell Laboratories awk extensions, and a number of GNU-specific exten-• sions.•  • Pgawk is the profiling version of gawk. It is identical in every way• to gawk, except that programs run more slowly, and it automatically

102

Page 101: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

103

Page 102: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

cut cut COMMANDCOMMAND• NAME• cut - remove sections from each line of files•  • SYNOPSIS• cut [OPTION]... [FILE]...•  • DESCRIPTION• Print selected parts of lines from each FILE to standard output.•  • Mandatory arguments to long options are mandatory for short options• too.•  • -b, --bytes=LIST• output only these bytes•  • -c, --characters=LIST• output only these characters•  • -d, --delimiter=DELIM• use DELIM instead of TAB for field delimiter•  • -f, --fields=LIST• output only these fields; also print any line that contains no• Delimiter character, unless the -s option is specified•  • -n with -b: don’t split multibyte characters

104

Page 103: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE • [student@localhost SIRI]$ cat>an4• hai• welcome• to• UNIX• lab• and• be• a• great• programmer•  • [6]+ Stopped cat >an4• [student@localhost SIRI]$ cut -c 1-3 an4• hai• wel• to• UNI• lab• and• be• a• gre• pro 105

Page 104: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ cut -c 1-1 an4• h• w• t• U• l• a• b• a• g• p• [student@localhost SIRI]$ cut -b 1-2 an4• ha• we• to• UN• la• an• be• a• gr• pr• [student@localhost SIRI]$

106

Page 105: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

. . pastepaste• NAME• paste - merge lines of files• SYNOPSIS• paste [OPTION]... [FILE]...• DESCRIPTION• Write lines consisting of the sequentially corresponding lines from• each FILE, separated by TABs, to standard output. With no FILE, or• when FILE is -, read standard input.• Mandatory arguments to long options are mandatory for short options• too.•  • -d, --delimiters=LIST• reuse characters from LIST instead of TABs•  • -s, --serial• paste one file at a time instead of in parallel•  • --help display this help and exit•  • --version• output version information and exit

107

Page 106: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE• [student@localhost SIRI]$ cat an5• hai• how• are• you• and• wat• are• you• doing• now• [student@localhost SIRI]$ cat an4• hai• welcome• to• UNIX• lab• and• be• a• great• programmer

108

Page 107: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ paste an5 an4• hai hai• how welcome• are to• you UNIX• and lab• wat and• are be• you a• doing great• now programmer• [student@localhost SIRI]$ paste -d '|' an4 an5• hai|hai• welcome|how• to |are• UNIX |you• lab|and• and |wat• be|are• a |you• great|doing• programmer|now• [student@localhost SIRI]$ paste -s '|' an5 an4• paste: |: No such file or directory• hai how are you and wat are you doing now• hai welcome to UNIX lab and be a great programm• er•   

109

Page 108: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

. join COMMAND. join COMMAND• NAME• join - join lines of two files on a common field•  • SYNOPSIS• join [OPTION]... FILE1 FILE2•  • DESCRIPTION• For each pair of input lines with identical join fields, write a line• to standard output. The default join field is the first, delimited by• whitespace. When FILE1 or FILE2 (not both) is -, read standard input.•  • -a SIDE• print unpairable lines coming from file SIDE•  • -e EMPTY• replace missing input fields with EMPTY•  • -i, --ignore-case ignore differences in case when comparing fields•  • -j FIELD• (obsolescent) equivalent to ΓÇÿ-1 FIELD -2 FIELDΓÇÖ•  • -j1 FIELD• (obsolescent) equivalent to ΓÇÿ-1 FIELDΓÇÖ•  

110

Page 109: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE[student@localhost SIRI]$ join a ,b[student@localhost SIRI]$ join –d a b[student@localhost SIRI]$ join –s a b

111

Page 110: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

Tr command:Tr command:This command is used to translate or delete charactersSynopsis

tr[option]..[SET1]..[SET2]Description:Translate, squeeze, and/or delete characters form standardinput, writing to

standard output-c –complement- first complement SET1-d – delete characters in Set1, do not translate-s squeeze- repeats

replace each input sequence of a repeated character that is listed in SET1 with a single occuttence of that chatacter.

EXAMPLE:student@localhost SIRI]$ tr “ aeiou””AEIOU” f2Hai How ArE yOU

112

Page 111: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..student@localhost SIRI]$CAT AKIETMCAHELLOstudent@localhost SIRI]$tr –c ‘aeiou’’*’<A*ie**i***e**o*a****a***student@localhost SIRI]$ tr –s “[a-z]””#”<A####

student@localhost SIRI]$ tr –d ‘aeiou’ <AKTMCHLL

113

Page 112: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

HEADHEAD• NAME• head - output the first part of files•  • SYNOPSIS• head [OPTION]... [FILE]...•  • DESCRIPTION• Print first 10 lines of each FILE to standard output. With more than• one FILE, precede each with a header giving the file name. With no• FILE, or when FILE is -, read standard input.•  • Mandatory arguments to long options are mandatory for short options• too.•  • -c, --bytes=SIZE• print first SIZE bytes•  • -n, --lines=NUMBER• print first NUMBER lines instead of first 10•  • -q, --quiet, --silent• never print headers giving file names•  • -v, --verbose• always print headers giving file names

114

Page 113: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLE:EXAMPLE:• [student@localhost SIRI]$ head frooty

• tail :• NAME• tail - output the last part of files•  • SYNOPSIS• tail [OPTION]... [FILE]...•  • DESCRIPTION• Print the last 10 lines of each FILE to standard output. With more• than one FILE, precede each with a header giving the file name. With• no FILE, or when FILE is -, read standard input.•  • Mandatory arguments to long options are mandatory for short options• too.•  • --retry• keep trying to open a file even if it is inaccessible when tail• starts or if it becomes inaccessible later -- useful only with• -f  student@localhost SIRI]$ tail frooty

115

Page 114: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

sortsort• NAME• sort - sort lines of text files•  • SYNOPSIS• sort [OPTION]... [FILE]...•  • DESCRIPTION• Write sorted concatenation of all FILE(s) to standard output.•  • Ordering options:•  • Mandatory arguments to long options are mandatory for short options• too.•  • -b, --ignore-leading-blanks ignore leading blanks•  • -d, --dictionary-order• consider only blanks and alphanumeric characters•  • -f, --ignore-case• fold lower case to upper case characters•  • -g, --general-numeric-sort• compare according to general numerical value•  • -i, --ignore-nonprinting• consider only printable characters•  • -M, --month-sort• compare (unknown) 116

Page 115: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ sort frooty• anitha• apple• banana• cherry• grapes• lemons• Melon

• [student@localhost SIRI$ cat>num• 99• 11• 66• 10• 55• 90• [3]+ Stopped cat >num• [student@localhost SIRI]$ sort -n num• 10• 11• 55• 66• 90• 99 117

Page 116: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SIRI]$ sort -n months• aug• dec• feb• jan• june• may• [student@localhost SIRI]$ sort -d frooty• anitha• apple• banana• cherry• grapes• lemons• melon• orange

118

Page 117: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

DISK UTILITIESDISK UTILITIES

  • NAME• du - estimate file space usage•  • SYNOPSIS• du [OPTION]... [FILE]...•  • DESCRIPTION• Summarize disk usage of each FILE, recursively for directories.•  • Mandatory arguments to long options are mandatory for short

options• too.•  • -a, --all• write counts for all files, not just directories•  • -B, --block-size=SIZE use SIZE-byte blocks•  • -b, --bytes

119

Page 118: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE• EXAMPLE•  • [student@localhost SIRI1]$ du• 4 ./A• 44 .• [student@localhost SIRI1]$ du A• 4 A• [student@localhost SIRI1]$ ls• a A a1 a2 a3 a4 a5 ani2 ani3 ani4 asc• [student@localhost SIRI1]$ du a1• 4 a1• [student@localhost SIRI1]$ du ani2• 4 ani2• [student@localhost SIRI1]$ du a• 4 a

120

Page 119: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

Df COMMANDDf COMMAND• NAME• df - report filesystem disk space usage•  • SYNOPSIS• df [OPTION]... [FILE]...•  • DESCRIPTION• This manual page documents the GNU version of df. df displays the• amount of disk space available on the filesystem containing each file• name argument. If no file name is given, the space available on all• currently mounted filesystems is shown. Disk space is shown in 1K• blocks by default, unless the environment variable

POSIXLY_CORRECT is• set, in which case 512-byte blocks are used.• If an argument is the absolute file name of a disk device node contain-• ing a mounted filesystem, df shows the space available on that filesys-• tem rather than on the filesystem containing the device node (which

is• always the root filesystem

121

Page 120: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE• [student@localhost SIRI]$ df• Filesystem 1K-blocks Used Available Use% Mounted on• /dev/hda2 37848096 2213264 33712256 7% /• /dev/hda1 101089 9324 86546 10% /boot• none 126780 0 126780 0% /dev/shm• [student@localhost SIRI]$ df A• Filesystem 1K-blocks Used Available Use% Mounted on• /dev/hda2 37848096 2213264 33712256 7% /• [student@localhost SIRI]$ ls• a A a1 ani Anitha a.out count err fruits list student• [student@localhost SIRI]$ df a.out• Filesystem 1K-blocks Used Available Use% Mounted on• /dev/hda2 37848096 2213264 33712256 7% /• [student@localhost SIRI]$ df a1• Filesystem 1K-blocks Used Available Use% Mounted on• /dev/hda2 37848096 2213264 33712256 7% /• [student@localhost SIRI]$ df student• Filesystem 1K-blocks Used Available Use% Mounted on• /dev/hda2 37848096 2213264 33712256 7% /•  

122

Page 121: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

mount mount • NAME• mount - mount a file system• SYNOPSIS• mount [-lhV]•  • mount -a [-fFnrsvw] [-t vfstype] [-O optlist]• mount [-fnrsvw] [-o options [,...]] device | dir• mount [-fnrsvw] [-t vfstype] [-o options] device dir•  • DESCRIPTION• All files accessible in a Unix system are arranged in one big tree, the• file hierarchy, rooted at /. These files can be spread out over sev-• eral devices. The mount command serves to attach the file system found• on some device to the big file tree. Conversely, the umount(8) command• will detach it again.• The standard form of the mount command, is mount -t type device dir• This tells the kernel to attach the file system found on device (which• is of type type) at the directory dir. The previous contents (if any)• and owner and mode of dir become invisible, and as long as this file•  

123

Page 122: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

umount umount • NAME• umount - unmount file systems•  • SYNOPSIS• umount [-hV]• umount -a [-dflnrv] [-t vfstype] [-O options]• umount [-dflnrv] dir | device [...]• DESCRIPTION• The umount command detaches the file system(s) mentioned from the

file• hierarchy. A file system is specified by giving the directory where it• has been mounted. Giving the special device on which the file system• lives may also work, but is obsolete, mainly because it will fail in• case this device was mounted on more than one directory.•  • Note that a file system cannot be unmounted when it is busy – for• example, when there are open files on it, or when some process has its• working directory there, or when a swap file on it is in use. The• offending process could even be umount itself - it opens libc, and libc• in its turn may open for example locale files. A lazy unmount avoids• this problem.

124

Page 123: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

PROCESS UTILITESPROCESS UTILITES• ps • NAME• ps - report process status•  • SYNOPSIS• ps [options]•  • DESCRIPTION• ps gives a snapshot of the current processes. If you want a repetitive• update of this status, use top. This man page documents the /proc-based• version of ps, or tries to.•  • COMMAND-LINE OPTIONS• This version of ps accepts several kinds of options.• Unix98 options may be grouped and must be preceeded by a dash.• BSD options may be grouped and must not be used with a dash.• GNU long options are preceeded by two dashes.• Options of different types may be freely mixed.•  • Set the I_WANT_A_BROKEN_PS environment variable to force BSD syntax• even when options are preceeded by a dash. The PS_PERSONALITY environ-• ment variable (described below) provides more detailed control of ps• behavior.•   125

Page 124: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

SIMPLE PROCESS SELECTIONSIMPLE PROCESS SELECTION• Switch Description• -A select all processes• -N negate selection• -a select all with a tty except session leaders• -d select all, but omit session leaders• -e select all processes• T select all processes on this terminal• a select all processes on a terminal, includ-• ing those of other users• g really all, even group leaders (does nothing• w/o SunOS settings)• r restrict output to running processes• x select processes without controlling ttys• • PROCESS SELECTION BY LIST• Switch Description• -C select by command name• • -g select by session leader OR by group name• -p select by PID• -s select processes belonging to the sessions given• -t select by tty• -u select by effective user ID (supports names)• U select processes for specified users• p select by process ID• t select by tty•

126

Page 125: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

EXAMPLEEXAMPLE• [student@localhost SIRI]$ ps• PID TTY TIME CMD• 4079 pts/15 00:00:00 bash• 4193 pts/15 00:00:00 man• 4196 pts/15 00:00:00 sh• 4197 pts/15 00:00:00 sh• 4201 pts/15 00:00:00 nroff• 4204 pts/15 00:00:00 groff• 4206 pts/15 00:00:00 grotty• [student@localhost SANA]$ ps -el• ps -el• F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD• 4 S 0 1 0 0 75 0 - 342 schedu ? 00:00:03 init• 1 S 0 2 1 0 75 0 - 0 contex ? 00:00:00 keventd• 1 S 0 3 1 0 94 19 - 0 ksofti ? 00:00:00 ksoftirqd_C• 1 S 0 8 1 0 85 0 - 0 bdflus ? 00:00:00 bdflush• 1 S 0 4 1 0 75 0 - 0 schedu ? 00:00:00 kswapd• 1 S 0 5 1 0 75 0 - 0 schedu ? 00:00:00 kscand/DMA• 1 S 0 6 1 0 75 0 - 0 schedu ? 00:00:00 kscand/Norm• 1 S 0 7 1 0 75 0 - 0 schedu ? 00:00:00

127

Page 126: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

128

Page 127: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

BBACKUP UTILITIESACKUP UTILITIES• TAR• NAME• tar - The GNU version of the tar archiving utility•  • SYNOPSIS• tar [ - ] A --catenate --concatenate | c --create | d --diff --compare• | r --append | t --list | u --update | x -extract --get [ --atime-pre-• serve ] [ -b, --block-size N ] [ -B, --read-full-blocks ] [ -C,• --directory DIR ] [ --checkpoint ] [ -f, --file [HOSTNAME:]F ] [• --force-local ] [ -F, --info-script F --new-volume-script F ] [ -G,• --incremental ] [ -g, --listed-incremental F ] [ -h, --dereference ] [• -I, --ignore-zeros ] [ -j, -I, --bzip ] [ --ignore-failed-read ] • filename1 [ filename2, ... filenameN ]•  • directory1 [ directory2, ...directoryN ]

129

Page 128: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• DESCRIPTION• This manual page documents the GNU version of tar , an archiving pro-• gram designed to store and extract files from an archive file known as• a tarfile. A tarfile may be made on a tape drive, however, it is also• common to write a tarfile to a normal file. The first argument to tar• must be one of the options: Acdrtux, followed by any optional func-• tions. The final arguments to tar are the names of the files or direc-• tories which should be archived. The use of a directory name always• implies that the subdirectories below should be included in the• archive.•  • FUNCTION LETTERS• One of the following options must be used:•  • -A, --catenate, --concatenate• append tar files to an archive•  • -c, --create• create a new archive•  • -d, --diff, --compare• find differences between archive and file system•  •

130

Page 129: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• --delete• delete from the archive (not for use on mag tapes!)•  • -r, --append• append files to the end of an archive•  • -t, --list• list the contents of an archive•  • -u, --update• only append files that are newer than copy in archive•  • -x, --extract, --get• extract files from an archive

131

Page 130: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

cpio cpio • cpio - copy files to and from archives• SYNTAX:• cpio {-o|--create} [-0acvABLV] [-C bytes] [-H format] [-M

message] • DESCRIPTION• This manual page documents the GNU version of cpio.

cpio copies files• into or out of a cpio or tar archive, which is a file that

contains• other files plus information about them, such as

their file name,• owner, timestamps, and access permissions. The

archive can be another• file on the disk, a magnetic tape, or a pipe.

132

Page 131: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• cpio has three operating• modes.•  • In copy-out mode, cpio copies files into an archive. It

reads a list• of filenames, one per line, on the standard input,

and writes the• archive onto the standard output. A typical way to

generate the list• of filenames is with the find command; you should

give find the -depth• option to minimize problems with permissions on

directories that are• unwritable or not searchable.

133

Page 132: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• OPTIONS• -0, --null• In copy-out and copy-pass modes, read a list of filenames termi-• nated by a null character instead of a newline, so that files• whose names contain newlines can be archived. GNU find is one• way to produce a list of null-terminated filenames.•  • -a, --reset-access-time• Reset the access times of files after reading them, so that it• does not look like they have just been read.•  • -A, --append• Append to an existing archive. Only works in copy-out mode.• The archive must be a disk file specified with the -O or -F• (--file) option.•  • -b, --swap• In copy-in mode, swap both halfwords of words and bytes of half-• words in the data. Equivalent to -sS. Use this option to con-• vert 32-bit integers between big-endian and little-endian• machines.•  • -B Set the I/O block size to 5120 bytes. Initially the block size• is 512 bytes.•  • --block-size=BLOCK-SIZE• Set the I/O block size to BLOCK-SIZE * 512 bytes.•  • -c Identical to "-H newc", use the new (SVR4) portable format. If• you wish the old portable (ASCII) archive format, use "-H odc"• instead.

134

Page 133: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

NETWORKING UTILITIESNETWORKING UTILITIES• NAME• who - show who is logged on•  • SYNOPSIS• who [OPTION]... [ FILE | ARG1 ARG2 ]•  • DESCRIPTION• -a, --all• same as -b -d --login -p -r -t -T -u•  • -b, --boot• time of last system boot•  • -d, --dead• print dead processes•  • -H, --heading• print line of column headings•  • -i, --idle• add idle time as HOURS:MINUTES, . or old (de precated, use -u)

135

Page 134: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE•  • [student@localhost SIRI]$ who• student pts/0 Dec 31 13:03(192.168.2.88)• student pts/3 Dec 31 13:03 (192.168.2.19)• student pts/2 Dec 31 13:03 (192.168.2.54)• student pts/5 Dec 31 13:03 (192.168.2.81)• student pts/4 Dec 31 13:03 (192.168.2.8)• student pts/1 Dec 31 13:03 (192.168.2.79)• student pts/8 Dec 31 13:03 (192.168.2.2)• student pts/6 Dec 31 13:03 (192.168.2.76)• student pts/10 Dec 31 13:03 (192.168.2.98)• student pts/11 Dec 31 13:03 (192.168.2.7)• student pts/7 Dec 31 13:03 (192.168.2.80)• student pts/12 Dec 31 13:03 (192.168.2.220)• student pts/14 Dec 31 13:03 (192.168.2.3)

136

Page 135: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• [student@localhost SANA]$ who -H• NAME LINE TIME COMMENT• a52 pts/0 Jan 8 14:28 (192.168.2.3)• a38 pts/1 Jan 8 14:41 (192.168.2.17)• student pts/2 Jan 8 14:41 (192.168.2.7)•  • [student@localhost SANA]$ who -d• Jan 8 14:27 15 id=si term=0 exit=0• Jan 8 14:27 2884 id=l5 term=0 exit=0• pts/1 Jan 8 14:39 3511 id=1 term=0 exit=0•  • [student@localhost SANA]$ who -b• system boot Jan 8 14:27

137

Page 136: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

ww• w - show who is logged on and what they are doing•  • SYNOPSIS• w - [-husfV] [user]•  • DESCRIPTION• w displays information about the users currently on the

machine, and• their processes. The header shows, in this order, the current

time,• how long the system has been running, how many users

are currently• logged on, and the system load averages for the past 1, 5,

and 15 min-• utes.

138

Page 137: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

• [student@localhost SANA]$ w• w• 13:25:17 up 23 min, 24 users, load average: 0.07, 0.07, 0.03• USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT• student pts/0 192.168.2.88 1:02pm 5.00s 0.41s 0.40s -bash• student pts/3 192.168.2.19 1:03pm 0.00s 0.14s 0.13s -bash• student pts/2 192.168.2.54 1:03pm 22.00s 0.16s 0.00s man ulimit

139

Page 138: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

finger finger • finger - user information lookup program•  • SYNOPSIS• finger [-lmsp] [user ...] [user@host ...]•  • DESCRIPTION• The finger displays information about the system users.•  • Options are:•  • -s Finger displays the users login name, real name, terminal

name and• write status idle time, login time, office location and office• phone number.

140

Page 139: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• EXAMPLE•  • [student@localhost SANA]$ finger• Login Name Tty Idle Login Time Office Office Phone• a38 pts/1 1 Jan 8 14:41 (192.168.2.17)• a52 pts/0 Jan 8 14:28 (192.168.2.3)• student itstudent pts/2 Jan 8 14:41 (192.168.2.7)• [student@localhost student]$ finger student• Login: student Name: itstudent• Directory: /home/student Shell: /bin/bash• On since Thu Jan 8 14:41 (IST) on pts/2 from 192.168.2.7• Mail last read Thu Jan 8 09:23 2009 (IST)• No Plan.

141

Page 140: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

ftp ftp • ftp - Internet file transfer program•  • SYNOPSIS• ftp [-pinegvd] [host]• pftp [-inegvd] [host]•  • DESCRIPTION• Ftp is the user interface to the Internet standard File Transfer

Proto-• col. The program allows a user to transfer files to and from a

remote• network site.•  • Options may be specified at the command line, or to the

command inter-• preter.•  

142

Page 141: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• -p Use passive mode for data transfers. Allows use of ftp in environ-• ments where a firewall prevents connections from the outside world• back to the client machine. Requires that the ftp server support• the PASV command. This is the default now for all clients (ftp and• pftp) due to security concerns using the PORT transfer mode. The• flag is kept for compatibility only and has no effect anymore.•  • -i Turns off interactive prompting during multiple file transfers.•  • -e Disables command editing and history support, if it was compiled• into the ftp executable. Otherwise, does nothing.•  • -g Disables file name globbing.•  • -v Verbose option forces ftp to show all responses from the remote• server, as well as report on data transfer statistics.•  • -d Enables debugging.

143

Page 142: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• TELNET:•  • NAME• telnet - user interface to the TELNET protocol•  • SYNOPSIS• telnet [-8EFKLacdfrx] [-X authtype] [-b hostalias] [-e escapechar]• [-k realm] [-l user] [-n tracefile] [host [port]]•  • DESCRIPTION• The telnet command is used to communicate with another host using the• TELNET protocol. If telnet is invoked without the host argument, it• enters command mode, indicated by its prompt (telnet>). In this mode, it• accepts and executes the commands listed below. If it is invoked with• arguments, it performs an open command with those arguments.•  • The options are as follows:•  • -8 Specifies an 8-bit data path. This causes an attempt to negoti-• ate the TELNET BINARY option on both input and output.•  • -E Stops any character from being recognized as an escape character.•  • -F If Kerberos V5 authentication is being used, the -F option allows

144

Page 143: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• NAME• arp - manipulate the system ARP cache•  • SYNOPSIS• arp [-evn] [-H type] [-i if] -a [hostname]•  • arp [-v] [-i if] -d hostname [pub]•  • arp [-v] [-H type] [-i if] -s hostname hw_addr [temp]•  • arp [-v] [-H type] [-i if] -s hostname hw_addr [netmask nm] pub•  • arp [-v] [-H type] [-i if] -Ds hostname ifa [netmask nm] pub•  • arp [-vnD] [-H type] [-i if] -f [filename]•  • DESCRIPTION• Arp manipulates the kernels ARP cache in various ways. The primary• options are clearing an address mapping entry and manually setting up• one. For debugging purposes, the arp program also allows a complete• dump of the ARP cache.•  

145

Page 144: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• -v, --verbose• Tell the user what is going on by being verbose.•  • -n, --numeric• shows numerical addresses instead of trying to determine sym-• bolic host, port or user names.•  • -H type, --hw-type type, -t type• When setting or reading the ARP cache, this optional parameter• tells arp which class of entries it should check for. The• default value of this parameter is ether (i.e. hardware code• 0x01 for IEEE 802.3 10Mbps Ethernet). Other values might• include network technologies such as ARCnet (arcnet) , PROnet• (pronet) , AX.25 (ax25) and NET/ROM (netrom).•  • -a [hostname], --display [hostname]• Shows the entries of the specified hosts. If the hostname• parameter is not used, all entries will be displayed. The• entries will be displayed in alternate (BSD) style.•  • -d hostname, --delete hostname• Remove any entry for the specified host. This can be used if• the indicated host is brought down, for example.•  

146

Page 145: 1 INTRODUCTION TO UNIX. D.S Assoc.prof M.Tech Incharge KIET

..• REMOTE LOGIN:•  • NAME• rlogin - remote login• • SYNOPSIS• rlogin [-8EKLdx] [-e char] [-l username] host• DESCRIPTION• Rlogin starts a terminal session on a remote host host.• The standard Berkeley rhosts authorization mechanism is used. The• • options are as follows:• -8 The -8 option allows an eight-bit input data path at all times;• otherwise parity bits are stripped except when the remote sides• stop and start characters are other than ^S/^Q .• -E The -E option stops any character from being recognized as an• escape character. When used with the -8 option, this provides a• completely transparent connection.•  • -L The -L option allows the rlogin session to be run in ••  

147