203737588 unix commnads doc

Upload: srinath0253

Post on 02-Jun-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 203737588 Unix Commnads Doc

    1/29

    Man ual command.man manThis is help command, and will explains you about online manual pages you can alsouse man in conjunction with any command to learn more about that command for example.

    man lswill explain about the ls command and how you can use it.

    man -k pattern command will search for the pattern in given command.

    Bannercommand.banner prints characters in a sort of ascii art poster, for example to print wait in big letters. I willtypebanner waitat unix command line or in my script. This is how it will look.

    # # ## # ###### # # # # ## # # # # ## ## # ###### # ### ## # # # ## # # # # #

    Calcommandcal command will print the calander on current month by default. If you want to print calander ofaugust of 1!". That#s eightht month of 1!".cal $ 1!"will print following results.

    August 1965S M Tu W Th F S1 2 3 4 5 6 78 9 10 11 12 13 1415 16 17 18 19 20 2122 23 24 25 26 27 28

    29 30 31

    Clearcommand

    clearcommand clears the screen and puts cursor at beginning of first line.

    Calendarcommandcalendarcommand reads your calendar file and displays only lines with current day.%or example in your calendar file if you have this

    12/20 Test new software1/15 Test new!" e$e!o%e 3270 %rou&t

    1/20 'nsta!! (e(or" on )* 9000 (a&h+ne

    &n dec '(th the first line will be displayed. you can use this command with your crontab file orin your login files.

    Nohupcommand.nohup command if added in front of any command will continue running the command orprocess even if you shut down your terminal or close your session to machine. %or exmaple, if I

  • 8/10/2019 203737588 Unix Commnads Doc

    2/29

    want to run a job that takes lot of time and must be run from terminal and is calledupdate)entries)tonight .nohup update)entries)tonightwill run the job even if terminal is shut down in middle of this job.

    Tty commandTty command will display your terminal. *yntax istty options

    &ptions -l will print the synchronous line number.

    -s will return only the codes+ ( a terminal, 1 not a terminal, ' invalid options good

    for scripts

    File Management commands.

    cat,cd,cp, file,head,tail, ln,ls,mkdir,more,mv,pwd,rcp,rm, rmdir, wc.

    Pwdcommand.pwdcommand will print your home directory on screen, pwd means print working directory.

    /u0/ss,/sanee%

    is output for the command when I usepwdin u(ssbsandeep directory.

    Lscommandls command is most widely used command and it displays the contents of directory.

    options

    lswill list all the files in your home directory, this command has many options.

    ls -lwill list all the file names, permissions, group, etc in long format.

    ls -awill list all the files including hidden files that start with . . ls -lt will list all files names based on the time of creation, newer files bring first.

    ls -%xwill list files and directory names will be followed by slash.

    ls -/will lists all the files and files in the all the directories, recursively.

    ls -/ 0 morewill list all the files and files in all the directories, one page at a time.

    Mkdircommand.mkdir sandeepwill create new directory, i.e. here sandeep directory is created.

    Cd command.cd sandeepwill change directory from current directory to sandeep directory.se pwd to check your current directory and ls to see if sandeep directory is there or not.2ou can then use cd sandeepto change the directory to this new directory.

    Headcommand.head filenameby default will display the first 1( lines of a file.

    http://www.sikh-history.com/computers/unix/commands.html#catcommand%23catcommandhttp://www.sikh-history.com/computers/unix/commands.html#cdcommand%23cdcommandhttp://www.sikh-history.com/computers/unix/commands.html#cpcommand%23cpcommandhttp://www.sikh-history.com/computers/unix/commands.html#cpcommand%23cpcommandhttp://www.sikh-history.com/computers/unix/commands.html#filecommand%23filecommandhttp://www.sikh-history.com/computers/unix/commands.html#headcommand%23headcommandhttp://www.sikh-history.com/computers/unix/commands.html#tailcommand%23tailcommandhttp://www.sikh-history.com/computers/unix/commands.html#tailcommand%23tailcommandhttp://www.sikh-history.com/computers/unix/commands.html#lncommand%23lncommandhttp://www.sikh-history.com/computers/unix/commands.html#lscommand%23lscommandhttp://www.sikh-history.com/computers/unix/commands.html#mkdircommand%23mkdircommandhttp://www.sikh-history.com/computers/unix/commands.html#morecommand%23morecommandhttp://www.sikh-history.com/computers/unix/commands.html#mvcommand%23mvcommandhttp://www.sikh-history.com/computers/unix/commands.html#mvcommand%23mvcommandhttp://www.sikh-history.com/computers/unix/commands.html#pwdcommand%23pwdcommandhttp://www.sikh-history.com/computers/unix/commands.html#rcpcommand%23rcpcommandhttp://www.sikh-history.com/computers/unix/commands.html#rcpcommand%23rcpcommandhttp://www.sikh-history.com/computers/unix/commands.html#rmcommand%23rmcommandhttp://www.sikh-history.com/computers/unix/commands.html#rmdircommand%23rmdircommandhttp://www.sikh-history.com/computers/unix/commands.html#wccommand%23wccommandhttp://www.sikh-history.com/computers/unix/commands.html#cdcommand%23cdcommandhttp://www.sikh-history.com/computers/unix/commands.html#cpcommand%23cpcommandhttp://www.sikh-history.com/computers/unix/commands.html#filecommand%23filecommandhttp://www.sikh-history.com/computers/unix/commands.html#headcommand%23headcommandhttp://www.sikh-history.com/computers/unix/commands.html#tailcommand%23tailcommandhttp://www.sikh-history.com/computers/unix/commands.html#lncommand%23lncommandhttp://www.sikh-history.com/computers/unix/commands.html#lscommand%23lscommandhttp://www.sikh-history.com/computers/unix/commands.html#mkdircommand%23mkdircommandhttp://www.sikh-history.com/computers/unix/commands.html#morecommand%23morecommandhttp://www.sikh-history.com/computers/unix/commands.html#mvcommand%23mvcommandhttp://www.sikh-history.com/computers/unix/commands.html#pwdcommand%23pwdcommandhttp://www.sikh-history.com/computers/unix/commands.html#rcpcommand%23rcpcommandhttp://www.sikh-history.com/computers/unix/commands.html#rmcommand%23rmcommandhttp://www.sikh-history.com/computers/unix/commands.html#rmdircommand%23rmdircommandhttp://www.sikh-history.com/computers/unix/commands.html#wccommand%23wccommandhttp://www.sikh-history.com/computers/unix/commands.html#catcommand%23catcommand
  • 8/10/2019 203737588 Unix Commnads Doc

    3/29

    If you want first "( lines you can use head -"( filename or for 34 lines head -34 filenameand soforth.

    Tailcommand.tail filenameby default will display the last 1( lines of a file.If you want last "( lines then you can use tail -"( filename.

    Morecommand. more command will display a page at a time and then wait for input which isspacebar. %or example if you have a file which is "(( lines and you want to read it all. *o youcan use

    more filename

    Wccommandwc command counts the characters, words or lines in a file depending upon the option.

    Options

    wc -l filename will print total number of lines in a file.

    wc -w filenamewill print total number of words in a file.

    wc -c filename will print total number of characters in a file.

    Filecommand.%ile command displays about the contents of a given file, whether it is a text 5scii or binaryfile. To use it typefile filename. %or example I have cal.txt which has ascii characters about calander of currentmonth and I have resume1.doc file which is a binariy file in microsoft word. I will getfile resume.doc

    resu(e1o&- ata

    file cal.txt&a!t.t- as&++ te.t

    Cpcommand.cp command copies a file. If I want to copy a file named oldfile in a current directory to a filenamed newfile in a current directory.cp oldfile newfileIf I want to copy oldfile to other directory for example tmp thencp oldfile tmpnewfile. seful options available with cp are p and r. -p options preserves themodification time and permissions, -r recursively copy a directory and its files, duplicating thetree structure.

  • 8/10/2019 203737588 Unix Commnads Doc

    4/29

    !cp command.rcp command will copy files between two unix systems and works just like cp command -p and-i options too.%or example you are on a unix system that is called Cheetah and want to copy a file which is incurrent directory to a system that is called lionin/usr/john/directory then you can use rcpcommandrcp filename lion+usrjohn

    2ou will also need permissions between the two machines. %or more infor typeman rcpatcommand line.

    M"command.mv command is used to move a file from one directory to another directory or to rename a file.

    Some examples:

    mv oldfile newfilewill rename oldfile to newfile.

    mv -i oldfile newfilefor confirmation prompt.

    mv -f oldfile newfile will force the rename even if target file exists.

    mv 6 usrbajwawill move all the files in current directory to usrbajwa directory.

    Lncommand.Instead of copying you can also make links to existing files using ln command.If you want to create a link to a file called coolfile in usrlocalbin directory then you can enterthis command.ln mycoolfile usrlocalbincoolfile

    Some examples:

    ln -s fileone filetwo will create a symbolic link and can exist across machines.

    ln -noption will not overwrite existing files.

    ln -f will force the link to occur.

    !mcommand.To delete files use rm command.

    Options:

    rm oldfilewill delete file named oldfile.

    rm -foption will remove write-protected files without prompting.

    rm -roption will delete the entire directory as well as all the subdirectories, very

    dangerous command.

    !mdircommand.rmdir command will remove directory or directories if a directory is empty.

  • 8/10/2019 203737588 Unix Commnads Doc

    5/29

  • 8/10/2019 203737588 Unix Commnads Doc

    6/29

  • 8/10/2019 203737588 Unix Commnads Doc

    7/29

  • 8/10/2019 203737588 Unix Commnads Doc

    8/29

    -c listcut the column positions identified in list.

    -f list will cut the fields identified in list.

    -s could be used with -f to suppress lines without delimiters.

    Paste 9ommand.paste command merge the lines of one or more files into vertical columns separated by a tab.for example if a file named testfile contains

    th+s +s f+rst!+ne

    and a file named testfile' containsth+s +s testf+!e2

    then running this commandpaste testfile testfile' H outputfilewill put this into outputfileth+s +s f+rst!+ne th+s +s testf+!e2

    it contains contents of both files in columns.

    who ( paste- - will list users in two columns.Options:

    -d#char# separate columns with char instead of a tab.

    -s merge subseDuent lines from one file.

    #ortcommand.sort command sort the lines of a file or files, in alphabetical order. for example if you have a filenamed testfile with these contents

    aaa

    1234"uerwer?wwwwe

    Then runningsort testfilewill give us output of1234aaa?wwwerwwe

    "uer

    Options:

    -b ignores leading spaces and tabs.

    -cchecks whether files are already sorted.

    -dignores punctuation.

    -iignores non-printing characters.

    -nsorts in arithmetic order.

  • 8/10/2019 203737588 Unix Commnads Doc

    9/29

    -ofileput output in a file.

    BmE-mFskips n fields before sorting, and sort upto field position m.

    -r reverse the order of sort.

    -uidentical lines in input file apear only one time in output.

    0ni1command.uniD command removes duplicate adjacent lines from sorted file while sending one copy of eachsecond file.Examples

    sort names ( uni1 d will show which lines appear more than once in names file.

    Options:

    -c print each line once, counting instances of each.

    -dprint duplicate lines once, but no uniDue lines.

    -uprint only uniDue lines.

    2wkand awk command.awk is more like a scripting language builtin on all unix systems. 5lthough mostly used for textprocessing, etc.7ere are some examples which are connected with other commands.

    3)amples4d% t ( awk 5B3&6N *tot78+ 9: 77 ;total; *tot7tot'9?

  • 8/10/2019 203737588 Unix Commnads Doc

    10/29

    -n suppress default output.

    for more information about sed, enter man sedat command line in your system.

    ieditor.vi command launches a vi sual editor. To edit a file typevifilenamevi editor is a default editor of all nix systems. It has several modes. In order to write charactersyou will need to hit ito be in insert mode and then start typing. ;ake sure that your terminal hascorrect settings, vt1(( emulation works good if you are logged in using pc.&nce you are done typing then to be in command mode where you can writesearch you need tohit +w filename to writeand in case you are done writing and want to exit+wL will write and exit.

    options:

    i for insert mode.o Iinserts text at the curson

    o 5 appends text at the end of the line.

    o a appends text after cursor.

    o & open a new line of text above the curson.

    o oopen a new line of text below the curson.

    + for command mode.

    o MescapeHto invoke command mode from insert mode.

    o +Lshto run unix commands.

    o xto delete a single character.

    o ddto delete an entire lineo nddto delete n number of lines.

    o d:to delete from cursor to end of line.

    o yyto copy a line to buffer.

    o Nto paste text from buffer.

    o nyycopy n number of lines to buffer.

    o 4sAstring2Astring/ Agto replace string5 with stringO in whole file.

    o Pto go to last line in file.

    o 1Pto go to the first line in file.

    o wto move forward to next word.

    o bto move backwards to next word.

    o :to move to the end of line.o Qjoin a line with the one below it.

    stringto search string in file.

    nto search for next occurence of string.

    #hell and programming

    *hell programming,bourne shell, ksh, csh, echo,line,sleep, test,cc compiler.

    http://www.sikh-history.com/computers/unix/commands.html#shellprog%23shellproghttp://www.sikh-history.com/computers/unix/commands.html#shcommand%23shcommandhttp://www.sikh-history.com/computers/unix/commands.html#kshcommand%23kshcommandhttp://www.sikh-history.com/computers/unix/commands.html#cshcommand%23cshcommandhttp://www.sikh-history.com/computers/unix/commands.html#echocommand%23echocommandhttp://www.sikh-history.com/computers/unix/commands.html#echocommand%23echocommandhttp://www.sikh-history.com/computers/unix/commands.html#linecommand%23linecommandhttp://www.sikh-history.com/computers/unix/commands.html#linecommand%23linecommandhttp://www.sikh-history.com/computers/unix/commands.html#sleepcommand%23sleepcommandhttp://www.sikh-history.com/computers/unix/commands.html#testcommand%23testcommandhttp://www.sikh-history.com/computers/unix/commands.html#cccommand%23cccommandhttp://www.sikh-history.com/computers/unix/commands.html#cccommand%23cccommandhttp://www.sikh-history.com/computers/unix/commands.html#shellprog%23shellproghttp://www.sikh-history.com/computers/unix/commands.html#shcommand%23shcommandhttp://www.sikh-history.com/computers/unix/commands.html#kshcommand%23kshcommandhttp://www.sikh-history.com/computers/unix/commands.html#cshcommand%23cshcommandhttp://www.sikh-history.com/computers/unix/commands.html#echocommand%23echocommandhttp://www.sikh-history.com/computers/unix/commands.html#linecommand%23linecommandhttp://www.sikh-history.com/computers/unix/commands.html#sleepcommand%23sleepcommandhttp://www.sikh-history.com/computers/unix/commands.html#testcommand%23testcommandhttp://www.sikh-history.com/computers/unix/commands.html#cccommand%23cccommand
  • 8/10/2019 203737588 Unix Commnads Doc

    11/29

  • 8/10/2019 203737588 Unix Commnads Doc

    12/29

  • 8/10/2019 203737588 Unix Commnads Doc

    13/29

    Linecommand.line command in shell programming.

    #leepcommand.

    sleep command in shell programming.

    Test 9ommand.test command in shell programming.

    CC compilerc programming language compiler.

    *ince nix is itself written in 9 programming language, most nix operating systems come withc compiler called cc.

    Communications

    cu,ftp,login,rlogin,talk,telnet, vacationand write.

    Cucommand.

    cu command is used for communications over a modem or direct line with another nix system.*yntax iscu options destination

    &ptions -bnprocess lines using n-bit characters 4 or $.

    -cname*earch 9N#s device file and select local area network that matches name.

    -dNrints diagnostics.

    -e sends even parity data to remote system

    -llinecommunicate on this device lineWdevtty((1, etc

    -nprompts for a telephone number.

    -snset transmission rate to ne.g 1'((,'G((,!((, ON*

    Xestination telnois the telephone number of the modem to connect to.

    systemis call the system known to uucp.

    aadris an address specific to Y5.

    http://www.sikh-history.com/computers/unix/commands.html#cucommand%23cucommandhttp://www.sikh-history.com/computers/unix/commands.html#ftpcommand%23ftpcommandhttp://www.sikh-history.com/computers/unix/commands.html#ftpcommand%23ftpcommandhttp://www.sikh-history.com/computers/unix/commands.html#logincommand%23logincommandhttp://www.sikh-history.com/computers/unix/commands.html#rlogincommand%23rlogincommandhttp://www.sikh-history.com/computers/unix/commands.html#rlogincommand%23rlogincommandhttp://www.sikh-history.com/computers/unix/commands.html#talkcommand%23talkcommandhttp://www.sikh-history.com/computers/unix/commands.html#telnetcommand%23telnetcommandhttp://www.sikh-history.com/computers/unix/commands.html#vacationcommand%23vacationcommandhttp://www.sikh-history.com/computers/unix/commands.html#vacationcommand%23vacationcommandhttp://www.sikh-history.com/computers/unix/commands.html#writecommand%23writecommandhttp://www.sikh-history.com/computers/unix/commands.html#writecommand%23writecommandhttp://www.sikh-history.com/computers/unix/commands.html#cucommand%23cucommandhttp://www.sikh-history.com/computers/unix/commands.html#ftpcommand%23ftpcommandhttp://www.sikh-history.com/computers/unix/commands.html#logincommand%23logincommandhttp://www.sikh-history.com/computers/unix/commands.html#rlogincommand%23rlogincommandhttp://www.sikh-history.com/computers/unix/commands.html#talkcommand%23talkcommandhttp://www.sikh-history.com/computers/unix/commands.html#telnetcommand%23telnetcommandhttp://www.sikh-history.com/computers/unix/commands.html#vacationcommand%23vacationcommandhttp://www.sikh-history.com/computers/unix/commands.html#writecommand%23writecommand
  • 8/10/2019 203737588 Unix Commnads Doc

    14/29

  • 8/10/2019 203737588 Unix Commnads Doc

    15/29

    acation command.vacation command is used when you are out of office. It returns a mail message to senderannouncing that you are on vacation. to disable this feature, type mail F ; ; .syntax isvacation options

    &ptions -dwill append the date to the logfile.

    -%userwill forward mail to user when unable to send mail to mailfile.

    -l logfilewill record in the logfile the names of senders who received automatic reply.

    -m mailfile will save received messages in mailfile.

    Writecommand will initiate an interactive conversation with user. *yntax is

    write user tty

    back to top of communications commandsback to top of page

    #torage commandscompressuncompress,cpio,dump,pack,tar, mt.

    Compresscommand.9ompress command compresses a file and returns the original file with .= extension, touncompress thisfilename.R file use uncompressfilename command. syntax for compresscommand iscompress options files

    ptions

    -bn limit the number of bits in coding to n.

    -cwrite to standard output do not change files.

    -f compress conditionally, do not prompt before overwriting files. -vNrint the resulting percentage of reduction for files.

    0ncompresscommand.ncompress file uncompresses a file and return it to its original form.

    http://www.sikh-history.com/computers/unix/commands.html#communications%23communicationshttp://www.sikh-history.com/computers/unix/commands.html#top%23tophttp://www.sikh-history.com/computers/unix/commands.html#compresscommand%23compresscommandhttp://www.sikh-history.com/computers/unix/commands.html#compresscommand%23compresscommandhttp://www.sikh-history.com/computers/unix/commands.html#uncompresscommand%23uncompresscommandhttp://www.sikh-history.com/computers/unix/commands.html#cpiocommand%23cpiocommandhttp://www.sikh-history.com/computers/unix/commands.html#cpiocommand%23cpiocommandhttp://www.sikh-history.com/computers/unix/commands.html#cpiocommand%23cpiocommandhttp://www.sikh-history.com/computers/unix/commands.html#dumpcommand%23dumpcommandhttp://www.sikh-history.com/computers/unix/commands.html#packcommand%23packcommandhttp://www.sikh-history.com/computers/unix/commands.html#packcommand%23packcommandhttp://www.sikh-history.com/computers/unix/commands.html#packcommand%23packcommandhttp://www.sikh-history.com/computers/unix/commands.html#tarcommand%23tarcommandhttp://www.sikh-history.com/computers/unix/commands.html#mtcommand%23mtcommandhttp://www.sikh-history.com/computers/unix/commands.html#communications%23communicationshttp://www.sikh-history.com/computers/unix/commands.html#top%23tophttp://www.sikh-history.com/computers/unix/commands.html#compresscommand%23compresscommandhttp://www.sikh-history.com/computers/unix/commands.html#uncompresscommand%23uncompresscommandhttp://www.sikh-history.com/computers/unix/commands.html#cpiocommand%23cpiocommandhttp://www.sikh-history.com/computers/unix/commands.html#dumpcommand%23dumpcommandhttp://www.sikh-history.com/computers/unix/commands.html#packcommand%23packcommandhttp://www.sikh-history.com/computers/unix/commands.html#tarcommand%23tarcommandhttp://www.sikh-history.com/computers/unix/commands.html#mtcommand%23mtcommand
  • 8/10/2019 203737588 Unix Commnads Doc

    16/29

    syntax isuncompress filename.Zthis uncompresses the compressed file to its original name.

    &ptions -c write to standard output without changing files

    Cpiocommand.cpio command is useful to backup the file systems. It copy file archives in from or out to tape ordisk, or to another location on the local machine. Its syntax iscpio %lags Eoptions

    It has three flags,iI oI p cpio -i EoptionsF EpatternsF

    o cpio -icopy in files who names match selected patterns.

    o If no pattern is used all files are copied in.

    o It is used to write to a tape.

    cpio -o

    o 9opy out a list of files whose name are given on standard output.

    cpio -p

    o copy files to another directory on the same system.

    &ptions

    o -areset access times of input files.

    o -5append files to an archive must use with -o.

    o -b swap bytes and half-words. Jords are G bytes.

    o -Oblock input or output using "1'( bytes per record.

    o -c/ead or write header information as 5scii character.

    o -d create directories as needed.

    o -l link files instead of copying.

    o -ofile direct output to a file.

    o -r rename files interactively.

    o -/IDreassign file ownership and group information to the user#s login IX.

    o -Cprint a dot for each file read or written.o -s swap bytes.

    o -*swap half bytes.

    o -vprint a list of filenames.

    3)amples

  • 8/10/2019 203737588 Unix Commnads Doc

    17/29

    o find . -name K6.oldK -print 0 cpio -ocvO H devrst$ will backup all 6.old files to a

    tape in devrst$o cpio -icdv KsaveKK M devrst$will restore all files whose name contain KsaveK

    o find . -depth -print 0 cpio -padm mydirwill move a directory tree.

    $umpcommand is useful to backup the file systems.dump command copies all the files in filesystem that have been changed after a certain date. It isgood for incremental backups. This information about date is derived from varadmdumpdatesand etcfstab .syntax for 7N-[ dump isusrsbindump Eoption Eargument ...F filesystemF

    ptions (- This number is dump level. ( option causes entire filesystem to be dumped.

    bblocking factor taken into argument.

    ddensity of tape default value is 1!((.

    fplace the dump on next argument file instead of tape.

    This example causes the entire file system mnt to be dumped on devrmtc(t(d(O

  • 8/10/2019 203737588 Unix Commnads Doc

    18/29

    Examples:

    tar cvf devrmt( bin usrbincreates an archive of bin and usrbin, and store on the tape indevrmt(.tar tvf devrmt(will list the tape#s content in a devrmt( drive.tar cvf - #find . -print# H backup.tarwill creates an archive of current directory and store it in file/ackup.tar.

    Functions:

    c creates a new tape.

    r append files to a tape.

    t print the names of files if they are stored on the tape.

    x extract files from tape.

    Options:

    b n use blocking factor of n.

    l print error messages about links not found.

    Y follow symbolic links.

    v print function letter x for extraction or a for archive and name of files.

    Mt command

    ;t command is used for tape and other device functions like rewinding, ejecting, etc. It givecommands to tape device rather than tape itself. ;t command is O*X command and is seldomfound in system C unix versions.syntax is

    mt E-t tapenameF command EcountF

    mt for 7N-[ accept following commands eofwrite count

  • 8/10/2019 203737588 Unix Commnads Doc

    19/29

    back to top of storage commandsback to top of page

    #ystem #tatus

    at, chmod,chgrp, chown,crontab,date, df,du, env, finger,ps,ruptime, shutdwon,stty, who.

    2t command.at command along with crontab command is used to schedule jobs.at options time [ddate] [+increment] is syntax of at command.for example if I have a script named usersloggedin which contains.

    #@/,+n/shwho w& !e&ho Bare tota! nu(,er of %eo%!e !ogge +n at th+s t+(eB

    and I want to run this script at $+(( 5;. *o I will first type at $+(( ]ltAenterHusersloggedin ]ltAenterHI will get following output at $+(( 5;

    30are tota! nu(,er of %eo%!e !ogge +n at th+s t+(e

    &ptions+ -ffile will execute commands in a file.

    -mwill send mail to user after job is completed.

    -lwill report all jobs that are scheduled and their jobnumbers.

    -rjobnumberwill remove specified jobs that were previously scheduled.

    Chmodcommand.chmod command is used to change permissions on a file.for example if I have a text file with calender in it called cal.txt.initially when this file will be created the permissions for this file depends upon umaskset inyour profile files. 5s you can see this file has !!! or -rw-rw-rw attributes.

    ls -la cal.txt

    rwrwrw 1 ss, .+e$ 135 e& 3 16-14 &a!t.t

    In this line above I have -rw-rw-rw- meaning respectively that owner can read and write %ileImem/er o% the owner5s group can read and write this %ile and anyone else connected to this

    system can read and write this %ile.I ne)t ss/ is owner o% this %ile d)ide" is the group o% this

    %ileI there are

  • 8/10/2019 203737588 Unix Commnads Doc

    20/29

  • 8/10/2019 203737588 Unix Commnads Doc

    21/29

    crontabfile *o a create a file with the scheduled jobs as above and then typecrontabfilename.This will scheduled the jobs.

    $atecommand.Xate displays todays date, to use it type dateat prompt.

    Sun e& 7 14-23-08 ST 1997is similar to what you should see on screen.

    $%command.df command displays information about mounted filesystems. It reports the number of free diskblocks. Typically a Xisk block is "1' bytes or 1' Vilobyte.syntax isdf options name

    &ptions -bwill print only the number of free blocks.

    -ewill print only the number of free files.

    -fwill report free blocks but not free inodes.

    -% typewill report on an umounted file system specified by type.

    -k will print allocation in kilobytes.

    -lwill report only on local file systems.

    -nwill print only the file system name type, with no arguments it lists type of all

    filesystems

    $ucommand.du command displays disk usage.

    3n"command.env command displays all the variables.

    Fingercommand.finger command.

  • 8/10/2019 203737588 Unix Commnads Doc

    22/29

    P# commandps command is probably the most useful command for systems administrators. It reportsinformation on active processes.ps options

    options. -a Yists all processes in system except processes not attached to terminals.

    -eYists all processes in system. -fYists a full listing.

    -jprint process group IX and session IX.

    !uptimecommand.ruptime command tells the status of local networked machines.ruptime options

    options. -ainclude user even if they#ve been idle for more than one hour.

    -lsort by load average.

    -rreverse the sort order.

    -tsort by uptime.

    -i sort by number of users.

    #hutdowncommand.*hutdown command can only be executed by root. To gracefully bring down a system, shutdownommand is used.

    options. -gnuse a grace-period of n seconds default is !(.

    -ik tell the init command to place system in a state k.

    o ssingle-user state default

    o (shutdown for power-off.

    o 1like s, but mount multi-user file systems.

    o "stop system, go to firmware mode.

    o !stop system then reboot.

    -ysuppress the default prompt for confirmation.

    #tty commandstty command sets terminal input output options for the current terminal. without options sttyreports terminal settings.stty options modes M device

    options -areport all options.

    -greport current settings.

  • 8/10/2019 203737588 Unix Commnads Doc

    23/29

    ;odes (hang up phone.

    nset terminal baud.

    erase keyname, will change your keyname to be backspace key.

    Who commandwho command displays information about the current status of system.

    who options fileJho as default prints login names of users currently logged in.

    &ptions -ause all options.

    -b/eport information about last reboot.

    -d report expired processes.

    -7print headings.

    -preport previously spawned processes.

    -u report terminal usage.

    2d"ance uni) command concepts

    Nut advance commands utilities, redirection, etc here.

    cal H cal.txtTo create a new file called cal.txt that has calendar for current month. H signredirects output from stdout screen to a file.

  • 8/10/2019 203737588 Unix Commnads Doc

    24/29

    C#C3 < 0ni) $ata Manipulation

    Xata ;anipulation 9ommands under nixo Yine oriented nature of commands

    o %ilters

    o

  • 8/10/2019 203737588 Unix Commnads Doc

    25/29

    o 7ow do we remove the $4 headers that vary in length from ' to " linesS

    o Jith exvi we could delete the headers by hand $4 times.

    o Je can place the editing commands in a script file ex*cr1 as shown below+o 1/EE@G/1o w t(%o ?

    o Then execute with Kex dat(1 M ex*cr1K

    o %inally after testing we could place this in a shell script loopo #@/,+n/sho # She!! s&r+%t for a%%!"+ng e+t+ng s&r+%t to re(o$e heaers fro(

    ata setso for f +n atC // These &o((ents are not %art of

    the f+!eo o // atC +s e.%ane to the !+sto // of a!! f+!es that (at&h the

    %atterno e. Hf e.S&r1 // for ea&h f+!e we a%%!" e.S&r1o ($ t(% Hfout // an then ($ t(% to at>>outo one

    o otes on this example

    11 *hell script is in a file sh*cr1

    11 it can be excuted with Ksh sh*cr1K or by first changing the mode as in

    chmod Bx sh*cr1 then just issue the command Ksh*cr1K

    /egular expressions - pattern used to match strings

    0ni) !egular 3)pressions

    !egular 3)pression Matches

    . matches any single characterr1r' matches r1followed by r'

    r6 matches =ero or more occurrences of the pattern r

    r10 r' matches if either r1or r'matches

    rS matches =ero or one occurrence of the pattern r

    rB matches oneor more occurrences of the pattern r

    r matches r, the parentheses are just for grouping

    E ... F matches any single character contained between the brackets

    E^ ... F matches any single character not contained between the brackets

    El-=F matches the range of characters from l to =

    ^ matches the start of a line

    : matches the end of a line

    @>n, m @? matches n to m occurences of the previous pattern

    @x matches the single character x, @ W Duote

  • 8/10/2019 203737588 Unix Commnads Doc

    26/29

    o city, *tate 5bbreviation RIN

    o *ocial-security number

    o Telephone number

    o Xollar amounts

    o blank lines

    o entire lines

    o one or more spaces

    Testing examples of regular expressions with grep .O. *hells filename expansions do not really use regular expressions

    o 6 matches any string not Vleene closure

    *

  • 8/10/2019 203737588 Unix Commnads Doc

    27/29

    5JV

    o 5ho, Jeinberger, and Vernighan of Oell Yabs

    o 5nother tool for manipulating files

    o 5JV treats a file as Ka collection of lines of fieldsK

    o where *

  • 8/10/2019 203737588 Unix Commnads Doc

    28/29

    o for set!counter " test!counter" incr!counter action

    for i W %A i HW 1A i-- print :i 5verage 7J grades su( 0 for Q+ 2 + JF ==+R su( = H+ a$erage su( /QJF 1R

    5ssociative 5rrays

    5/PC, 5/P9,

  • 8/10/2019 203737588 Unix Commnads Doc

    29/29

    PU*A4 457012330 200041 5 )APV' :PUWJ P 1 UF 1JF-

    S) 435 V 5 MA 108< PS P PS 01 )P 003 SJ'J