Presentation is loading. Please wait.

Presentation is loading. Please wait.

(c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands1 Faisal Akkawi Department of Computer Science Illinois Institute of Technology.

Similar presentations


Presentation on theme: "(c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands1 Faisal Akkawi Department of Computer Science Illinois Institute of Technology."— Presentation transcript:

1 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands1 Faisal Akkawi akkawi@cs.iit.edu Department of Computer Science Illinois Institute of Technology Chicago, IL 60616

2 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands2 Topics Handling Files and Directories Text Editors Compiling and Linking Handling Processes Archiving and Compressing Files Other Useful Commands

3 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands3 Handling Files and Directories ls : list files cp : copy files mv : move files rm : remove files mkdir : make directories cd : change directories rmdir : remove directories pwd : print working directory chmod : change permission mode umask : set file-creation mode mask

4 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands4 ls command Syntax ls [-Options] [name...] Description Lists contents of directory. Frequently Used Options -aList all entries, including. and.. -dDo not list contents of directories -lLong listing -FMark directories with a '/', etc. Examples ls -alF

5 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands5 cp command Syntax cp [-Options] file1 [file2...] target Description File1 is copied to target. Frequently Used Options -fForce remove existing file -iAsk before removing existing file -rCopy directory trees Examples cp p1.c p2.c cp p1.c p2.c mydir

6 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands6 mv command Syntax mv [-Options] file1 [file2...] target Description File1 is moved to target. Frequently Used Options -f Removes existing files without prompting the user -i Asks before removing existing file Examples mv p*.c mydir

7 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands7 rm command Syntax rm [-f] [-i] file... rm -r [-f] [-i] dirname... [file...] Description Removes files or directories. Frequently Used Options -fRemoval of files without prompting the user -iInteractive removal -rRecursive removal Examples rm -f p*.o rm -r mydir

8 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands8 mkdir command Syntax mkdir [-m mode] [-p] dirname... Description Creates the specified directories. Options -mSpecifies the mode to be used -pCreate missing intermediate directories Examples mkdir -m 700 letter mkdir abc mkdir -p./abc/def/ghi

9 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands9 cd command Syntax cd [directory] Description Change working directory. If directory is not specified, the value of shell parameter $HOME is used as the new working directory. Examples cd cd./abc/def/ghi cd..

10 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands10 rmdir command Syntax rmdir [-p] [-s] dirname... Description Removes directories. Options -pRemove the directory dirname and its parent directories which become empty. -sSuppress the message when –p is in effect Examples rmdir letter

11 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands11 pwd command Syntax pwd Description Prints the path name of the working (current) directory. Examples pwd

12 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands12 chmod command Syntax chmod [-R] mode file... chmod [-R] [ugoa]{+|-|=}[rwxXstl] file... Description Changes the permissions mode of a file or directory. Examples chmod 444 file1 chmod ugo+rw p*.c chmod 700 mydir

13 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands13 umask command – I Syntax umask [ooo] Description Sets file-creation mode mask to ooo. The three octal digits refer to read/write/execute permissions for owner, group, and others, respectively. The value of each specified digit is subtracted from the corresponding ‘digit’ specified by the system for the creation of a file. If ooo is omitted, the current value of the mask is printed.

14 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands14 umask command – II Examples umask 022 removes group and others write permission (files normally created with mode 777 become mode 755; files created with mode 666 become mode 644).

15 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands15 Text Editors pico - Simple, easy-to-use text editor vi - Text editor based on an underlying line editor ex emacs - Powerful and extensible - Hard to learn

16 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands16 pico Layout is very similar to the pine mailer

17 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands17 vi vi Modes: Command mode : Normal and initial mode. Other modes return to command mode upon completion. ESC (escape) is used to cancel a partial command. Input mode : Entered by setting any of the following options: a A i I o O c C s S R. Arbitrary text may then be entered. Input mode is normally terminated with ESC character. Last line mode : Reading input for : / ? or !.Terminates by typing a carriage return

18 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands18 Compiling and Linking cc - C compiler - Default behavior is ANSI/ISO C make - Allows programmer to maintain, update, and regenerate groups of computer programs.

19 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands19 cc command – I Syntax cc [-Options]... file... Description *.c are assumed to be C source programs. *.o are compiled object files. a.out is the default output program name. Frequently Used Options -cProduce an object file -OInvoke optimizer

20 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands20 cc command – II -o outName the final output file out. -Dname Define the name to the C macro processor -IdirSeek dir for include files Examples cc p1.c

21 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands21 make command Syntax make [-f makefile] [-eiknpqrsStuwdDPBNMOg] [names] Frequently Used Options -f makefile Description file is makefile -nPrint commands, but do not execute them. -uBuild all targets regardless of whether they are up-to-date or not. Examples make make –f Project1.mak

22 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands22 Handling Processes ps : Prints information about active processes kill : Sends a signal to a process ipcs : Reports IPC facilities status ipcrm : Removes IPC resource id

23 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands23 ps command Syntax ps [-Options] Description Prints information about active processes. Frequently Used Options -A Every process now running -e Same as -A -f Full listing -l Long listing Examples ps -ef

24 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands24 kill command Syntax kill [-signal] pid... kill –l (the letter ‘L’ in lowercase) Description Sends a signal to the specified processes. The value of signal may be numeric or symbolic. Signal 15 is the default signal. kill –l lists the defined signals. Examples kill 389 kill –3 401 402 kill -HUP 99999

25 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands25 ipcs command Syntax ipcs [-Options] Description Prints information about active IPC facilities. Without options, information is printed for message queues, shared memory, and semaphores that are currently active in the system. Frequently Used Options -qMessage queues -mShared memory segments -sSemaphores Examples ipcs -q

26 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands26 ipcrm command Syntax ipcrm [-Options] Description Removes messages, semaphore or shared memory identifiers. Frequently Used Options -q msqid Removes the message queue id -m shmid Removes the shared memory segment id -s semid Removes the semaphore id Examples ipcrm -q 231

27 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands27 Archiving and Compressing tar : Tape archiver compress, uncompress, zcat : Compresses and expands data using adaptive Lempel-Ziv coding gzip : Compresses data using Lempel-Ziv coding gunzip, gzcat : Decompresses files created by gzip, zip, compress, or pack pack, unpack, pcat : Compresses and expands files using Huffman codes

28 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands28 tar command - I Syntax tar key [arguments] [name...] Description Saves and restores multiple files on a single file. The key argument controls tar's actions. Frequently Used Functions cCreate xExtract from the tape tList files on the tape

29 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands29 tar command - II Frequently Used Modifiers vVerbose fNext argument is the name of the archive Examples tar cvf my.tar./mydir1./mydir2 tar tvf my.tar tar xvf my.tar

30 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands30 compress command Syntax compress [ -f ] [ -v ] [ -c ] [ -V ] [ -d ] [ -b bits ] [ name... ] Description Compresses and expands data Compressed file name is *.Z Frequently Used Options -cWrite output on standard output -dUncompress -vVerbose Examples compress my.tar compress -d my.tar.Z

31 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands31 uncompress command Syntax uncompress [ -f ] [ -v ] [ -c ] [ -V ] [ name... ] Description Uncompresses files Same as compress –d Frequently Used Options -cWrite output on standard output -vVerbose Examples uncompress my.tar.Z

32 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands32 zcat command Syntax zcat [ name... ] Description Uncompresses files Same as uncompress –c Writes the uncompressed data on standard output Examples zcat my.tar.Z > my.tar

33 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands33 gzip command Syntax gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name... ] Description Compresses and expands data Suffix.gz Frequently Used Options -cWrite output on standard output -dUncompress -hHelp -rRecursive -vVerbose

34 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands34 gunzip command Syntax gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name... ] Description Uncompresses files (Same as gzip –d ) Automatically detects input format Frequently Used Options -cWrite output on standard output -hHelp -rRecursive -vVerbose

35 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands35 gzcat command Syntax gzcat [ -fhLV ] [ name... ] Description Uncompresses files (Same as gunzip –c) Writes the uncompressed data on standard output Examples gzcat myfile.gz > myfile

36 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands36 pack command Syntax pack [ - ] [ -f ] name... Description Compresses files Suffix.z Directories cannot be compressed Options -fForce packing Examples pack myfile

37 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands37 unpack command Syntax unpack name... Description Expands files created by pack Each.z files is replaced by its expanded version The new file has the.z suffix stripped from its name Examples unpack myfile.z

38 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands38 pcat command Syntax pcat name... Description Uncompresses files created by pack Files are unpacked and written to the standard output Examples pcat myfile.z pcat myfile pcat myfile.z > myfile

39 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands39 Other Useful Commands grep : search files for a pattern man : on-line reference manuals wc : word, line and byte or character count

40 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands40 grep command - I Syntax grep [-E| -F] [-c| -l| -q] [-insvx] pattern_list [file...] Description Searches the input files, selecting lines matching oneor more patterns Frequently Used Options -iCase-insensitive search -lWrite file names only -nDisplay line number

41 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands41 grep command - II Examples grep -i unix p1.c grep -n UNIX *.c *.h ps –ef | grep mary

42 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands42 man command Syntax man [-Options] [-M path] [-T macropackage] [ -s section] name... man [-M path] -k keyword... Description On-line reference manuals Frequently Used Sections 1User commands and application programs 2System calls 3Library functions Examples man -s 1 mkdir man mkdir man -k pipe

43 (c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands43 wc command Syntax wc [ -c|-m ] [ -lw ] [ file... ] Description Counts lines, words, and characters Options -cCount the number of bytes -mCount the number of characters -lCount the number of newline characters -wCount the number of words Examples wc -l *.h *.c


Download ppt "(c) Faisal Akkawi & Munki Lee 2001Basic UNIX Commands1 Faisal Akkawi Department of Computer Science Illinois Institute of Technology."

Similar presentations


Ads by Google