Unix Module I Agenda Basics of UNIX Introduction
Unix – Module I
Agenda – Basics of UNIX § Introduction to UNIX Variants of Unix Operating System UNIX Operating System Concepts • Multiuser • Multitasking • Multiprocessing UNIX Operating System Architecture • Hardware • Kernel • Shell • Other Applications 2
Introduction to UNIX § It is an Operating System. § Evolved to provide simple, yet powerful utilities that could be pieced together in a flexible manner to perform a wide variety of tasks. § "Unics" at first -- UNiplexed Information and Computing System. § Unix history goes back to 1969. § Ken Thompson, Dennis Ritchie (the R in K&R) worked toward Dev of Unix at AT&T. § The name "Unix" was intended as a pun on Multics. 3
Variants Of Unix OS Paid/Proprietary Variants: Ø AIX Ø HP-UX - Hewlett-Packard for its HP 9000 series of business servers Ø Solaris - Sun Mic for the SPARC platform and the most widely used - IBM for use on its mainframe computers Free variants of Unix : Ø Red. Hat Linux – Red. Hat the most popular and fastest growing of all Ø Free. BSD - the most popular of the BSD systems Ø Open. BSD - becoming the most secure of all computer operating systems Ø Su. Se, Fedora, Ubuntu etc. 4
Hallmarks of Unix Ø Multi-user : Many people can share the resources of a single computer simultaneously. Ø Portable : UNIX was designed to be easily ported (moved from one hardware platform to another). It has been ported to everything from desktop computers to room sized supercomputers. Ø Multi-tasking : UNIX allows users to run multiple programs at once. Ø Text-based : Most of the operations are text based. Easy to handle. Ø Efficient : Result comes in milliseconds when command is issued. Ø Silent : When a script output doesn’t have anything to display it shuts up. Ø Free : Anyone out there can customize unix for them. 5
Evolution of Unix & like variants 6
Unix – OS Architecture Ø Hardware - The collection of physical parts or components of computer such as monitor, keyboard, hard disk, mouse, etc. Ø Kernel – The Core of the Unix OS Ø Shell - starts up the kernel when the user logs in and acts as an intermediary between users and the OS Ø Others - Standard utility programs and system configuration files are other components of the unix. 7
Files & Directory Management
Agenda - Files & Directory Management § Unix Directories Structure < • bin • usr • etc • home • dev • var • tmp> § Logging in (Terminal Type, Passwords, Exiting, Identity) § Unix Command Line Structure, Control Keys, stty, Getting help, § Directory Navigation and Control • Pwd • Cd • Mkdir • Rmdir • Ls § File Maintenance Commands • cp • mv • rm § File Permissions with options • chmod • chown • chgrp • ls 9
Directory structure What is the directory structure ? Similar to Windows partitioning as shown Directory /bin Description This is the root directory which should contain only the directories needed at the top level of the file structure. This is where the executable files are located. They are available to all user. /dev These are device drivers. /etc /lib Supervisor directory commands, configuration files, disk configuration files, valid user lists, groups, ethernet, hosts, where to send critical messages. Contains shared library files and sometimes other kernel-related files. /boot Contains files for booting the system. /home Contains the home directory for users and other accounts. /mnt Used to mount other temporary file systems, such as cdrom and floppy for the CD-ROM drive and floppy diskette drive, respectively Contains all processes marked as a file by process number or other information that is dynamic to the system. Holds temporary files used between system boots / here in this image /proc /tmp /usr /var /sbin /kernel . What in Windows? Used for miscellaneous purposes, or can be used by many users. Includes administrative commands, shared files, library files, and others Typically contains variable-length files such as log and print files and any other type of file that may contain a variable amount of data Contains binary (executable) files, usually for system administration. For example fdisk and ifconfig utlities. Contains kernel files 10
Login to Unix Machine & command line § Specifies how your computer and the host computer(Unix Machine) to which you are connected exchange information § § Widely used terminal type - "vt 100". § Sun workstations - "sun"; § X-Terminal(ex. Putty) - "xterms" or "xterm". The terminal type indicates to the Unix system how to interact with the session just opened. § uid/pwd are case sensitive : All user details are stored in /etc/passwd file. § An user is identified by userid and groupid, respectively. § Say “exit” to disconnect. § Commands are the programs that tells Unix to do something • command [options] [arguments] Ex. ls –lrt a. txt • Refer Manual for complete information on commands usage • man ls 11
Files & Directories Below are the basic navigation control commands and its dos equivalent command Command/Syntax cd [directory] ls [options] [directory or file] mkdir [options] directory pwd rmdir [options] directory Command What it will do list directory contents change directory list directory contents or file permissions Unix ls make directory dir md & mkdir change directory cd delete (remove) directory rmdir return to user's home directory cd location in path (present working directory) pwd make a directory print working (current) directory remove a directory ls – one of the most used commands in any day. Syntax ls [options] [argument] -a lists all files, including those beginning with a dot (. ). hidden files -d lists only names of directories, not the files in the directory -F indicates type of entry with a trailing symbol: 12 DOS cd & chdir rd & rmdir cd cd
File Maintenance & permissions In Unix almost everything is file n text based. To create, copy, remove and change permissions on files you can use the following commands. Syntax $command – <options> <arguments> Command/Syntax chgrp [options] group file What it will do change the group of the file chmod [options] file change file or directory access permissions chown [options] owner change the ownership of a file; can only be file done by the superuser copy file 1 into file 2; file 2 shouldn't already exist. cp [options] file 1 file 2 This command creates or overwrites file 2. mv [options] file 1 file 2 rm [options] file move file 1 into file 2 remove (delete) a file or directory (-r recursively deletes the directory and its contents) (-i prompts before removing files) chmod – to modify a file’s permission : chmod <options> filename chown – to change the ownership of a file : chown [options] user file Chgrp – To change the group they belong to : chgrp [options] group file 13
Commands in Unix
Agenda - Commands in Unix § Display Commands • Echo, • Cat, • More, • Less • pg - page through a file, • head • tail § Working with Files • Cmp, • Diff, • Cut, • paste - merge files, • touch - create a file, • wc • Soft link & hard link using ln- link to another file • Sort • Tee • Uniq • Strings • file – file type • tr § find command with options like exec • type • xargs …, - find files § Wild Chard and Meta character • grep • egrep § File Archiving, Compression and Conversion • tar - archive files, • uuencode/uudecode - encode a file 15
Agenda - continued § System Resources • df - summarize disk block and file usage with options • du - report disk space in use with options • top –understanding system utilization • ps - show status of active processes with options • kill - terminate a process with options • who • whereis • which • hostname/uname - name of machine • date bg • fg • crontab § Remote Connections • FTP • SFTP Commands, • rsync Commands • ssh, creating rsa • dsa keys with ssh specifications 16
Display Commands Below are the basic or mostly used display commands Command/Syntax What it will do cat [options] file concatenate (list) a file echo [text string] echo the text string to stdout head [-number] file display the first 10 (or number of) lines of a file more (or less or pg) [options] file page through a text file tail [options] file display the last few lines (or parts) of a file Examples % echo Hello Class or echo "Hello Class“ % cat filename % cat file 1 file 2 file 3 – To concatenate multiple file contents % head -40 filename or head -n 40 filename % tail -30 filename 17
Working With Files Below are the basic or mostly used display commands Command/Syntax What it will do cmp file 1 file 2 Compared contents of file 1 & file 2, indicates the location of the first difference b/w the files diff file 1 file 2 To find the diff lines alone between file 1& 2 head [-number] file display the first 10 (or number of) lines of a file more (or less or pg) [options] file page through a text file tail [options] file display the last few lines (or parts) of a file Examples % echo Hello Class or echo "Hello Class“ % cat filename % cat file 1 file 2 file 3 – To concatenate multiple file contents % head -40 filename or head -n 40 filename % tail -30 filename 18
Working With Files - Continued Below are the basic or mostly used display commands Command/Syntax What it will do touch <filename> Will create a 0 byte file named <filename> and exit paste <filename 1> <filename 2> Pastes contents of filenam 1 & filename 2 together cat <filename>| cut –d “delimiter” –f 1 To cut the contents based on a delimiter wc <filename> To get the number of lines, words or bytes in a file ln -s [target] [link name] Creates a soft link to an existing file/folder 19
Working With Files - Continued Below are the basic or mostly used display commands Command/Syntax What it will do sort <filename> Write sorted concatenation of all FILE(s) to standard output. tee <filename 1> <filename 2> read from standard input and write to standard output and files uniq [OPTION]. . . [INPUT [OUTPUT]] removes duplicate lines from a uniqed file $ strings <object filename> finds and displays the printable strings in a given executable, binary, or object file. $ echo 'I Lov. E linu. X. one is better Than 2' | tr "az" "A-Z" Translates from one to another character find To do an effective search of files/contents/folders etc 20
Soft & Hard linking 21
Wild Card & Meta characters grep : print lines matching a pattern egrep : egrep is extended version of grep or egrep is equal to grep -E. Egrep supports more regular expression patterns. fgrep : is a faster version of grep which does not support regular expressions and therefore is considered to be faster. fgrep is equal to grep -F. rgrep : is a recursive version of grep. Recursive in this case means that rgrep can recursively descend through directories as it greps for the specified pattern. rgrep is similar to grep -r. 22
File Archiving, Compression &Conversion pack: (. z) -Changes the ownership pack <filename> unpack<filename> pcat <filename. z) compress: (. Z) -Quicker than pack command compress <filename> uncompress<filename> zcat <filename. Z) gzip: (gz) - Mostly preferred - Reduces most size. -Keeps the same ownership modes, access and modification times. gzip <filename> gunzip<filename> tar: (. tar) - tar -cvf file. tar inputfile 1 inputfile 2 – to create a tar file(x – to extract, t – to tail) tar -xvzf file. tar. gz ( create a tar and the zip it) 23
System Resources Command/Syntax What it will do df –k/g/m To display free diskspace in KB/GB/MB, for all mount points/partitions du To display used diskspace on current directory top/topas Processes which are occupying top CPU/resources ps Displays all active processes kill [options] IDs To kill one or more processes who To list out who all are currently logged in to the server which To locate a program file with aliases/path hostname Displays fully qualified hostname/servername uname Displays the underlying OS and its version date/cal Date- to display the current date in gregorian format. Calendar to display the calendar of the current month 24
Thank You
- Slides: 25