Linux Command Suumary


Published on

This presentation summarizes Useful Linux Commands.

Published in: Education, Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Linux Command Suumary

  1. 1. Linux Commands Summary
  2. 2. Course Objective To introduce the Unix Operating System Concept. To introduce standard Unix commands. To introduce VI editor.
  3. 3. References Text Book Reference Brain W. Kernighan and Rob Pike, The UNIX ProgrammingEnvironment. A Practical Guide to Linux® Commands, Editors, and ShellProgramming - Mark Sobells Web Reference Unix Tutorial For Beginners Introduction to Unix
  4. 4. What is Unix Operating System Unix OS is a Program Unix OS provides interfacebetween users and barehardware Unix OS managesresources: CPU(s),memory, disks, other I/Odevices.Operating Systemusers
  5. 5. Why do we need Operating System ?To Interact with Computer HardwareEnd UserComputer HardwareOperating-SystemUtilitiesApplicationProgramsOS DesignerSystem ProgrammerApplication ProgrammerE.g.compiler, libraries, shellE.g.database, webservers
  6. 6. Evolution of Unix OS
  7. 7. Flavors of Unix AIX (Advanced IBM Unix) HP-UX ( Hewlett Packard Unix) BSD ( Berkeley Software Distribution. ) SCO UNIX SOLARIS LINUX, etc
  9. 9. System Architecture Major components of Unix are : Kernel Monitors and controls hardware resources Allocates them among its users in an optimal manner Utilities Programming tools that do standard tasks extremely well. EX: cp, grep, awk, sed, bc, wc, more Shell Command Line Interpreter. Provides a processing environment for the user programs. User Applications Programs written by the user
  10. 10. Processing Environment• User Program– Set of instructions written by the user• Process– Instance of a program under execution• Shell– Provides a processing environment for the user programs
  11. 11. Structure of Unix File System
  12. 12. Absolute Path and Relative Path The Absolute Path The entire pathname starting from root(/) Example /home/oresoft/. The Relative Path The path relative to your present working directory Example cd ..
  14. 14. Login Sequence. /etc/passwd 1 /etc/shadow 2 /etc/group 3 /etc/profile 4 /etc/profile.d/*.sh 5 ~/.bash_profile 6 ~/.bashrc 7 /etc/bashrc 8
  15. 15. Unix Command Structure Unix Command line structure command [options] [arguments]Refer the following word Doc for Detail Command
  16. 16. Concept of stdin, stdout and stderrOperating SystemAnotherComputerprogram runningstdoutstderrstdinKeyboardA Computerprogram runningstdoutstderrstdinMonitor
  17. 17. Standard Files Standard Input (0) This file is opened by shell to accept information. Standard Output (1) This file is opened by shell to direct output Standard Error (2) This file is opened by shell for writing error messages
  18. 18. Regular ExpressionsWhat is it? String of ordinary and metacharacter which can be used tomatch more than one type of pattern. Uses character set * , [], ^, $, {}, etc.
  19. 19. The Shell Metacharacters. See Demo at/home/oresoft/Training/Linux/commands/shellChar * - Matches all filenames in current directory. ? - Matches a single character. [abc] - Matches a single character – either a, b or c. [!abc] - Matches a single character – which is not a, b or c. [a-c] – Matches a single character which is within the range of a and c. ^abc – Matches the pattern abc at the beginning of the line. abc$ - Matches the pattern abc at the end of the line.
  20. 20. Editor in Unix Need for editor in Unix Types of editor Line Editor ed : UC Berkeley ex : Powerful than ed, Bell Systems Full Screen Editor vi (stands for visual) vim – vi improved emacs (GNU)
  21. 21. The vi Editor. The important characteristic features are: Omnipresent Works on different Unix flavors Fast Various operations are very fast Powerful UNDO features Text in lines could be undone with very less effort
  22. 22. The vi Editor. The limitations are: Less user-friendly No graphical user interface Highly Case-sensitive Letter in small case has a different implementation in comparisonwith the same letter in upper case Keystrokes could have more than one meaning A letter (of the same case) has different implementation acrossdifferent modes.
  23. 23. The vi Editor. Modes of working: Command Mode Keys are interpreted as commands Insert Mode Keys are interpreted as data Escape Mode Keys are interpreted for saving/exiting purposes
  24. 24. vi Operating modes.Command modeInsert modei, I , o, O, a, A ..escLast line modeEnter::q
  25. 25. Vi editor commands To move around h, j, k, l, ^D, ^U, G, 0, ^, $, w, b Inserting/Deleting text i, a, I, A, r, R, o, O, dd, dw, c$, D, x, X. Changing/Replacing text. cc, cw, c$, ~, J, u, . , yy, yw, p, P File manipulation. :w, :wq, ZZ, :w!, :q, :q! , :![command]
  26. 26. Searching a pattern /pattern Searches forward for first occurrence of a pattern. ?pattern Searches backward for first occurrence of a pattern. n Repeats the last search. N Repeats the last search command in opposite direction.
  27. 27. Pattern Substitution. :s/ptn1/ptn2 Replaces first occurrence of ptn1 with ptn2. : s/ptn1/ptn2/g Replaces all occurrences in the current line. : m, n s/ptn1/ptn2/g Replaces all occurrences in lines m to n. : ., $ s/ptn1/ptn2/g Replaces all occurrences from current line to end of file.
  28. 28. Customizing vi. The set command :set all :set nu The abbr command :abbr itl ―Infosys Technologies Ltd‖ The map command :map ^X :wq
  29. 29. System Variables. PATH Search path referred by Unix for any command. echo $PATH HOME Indicates the home directory for the user. echo $HOME
  30. 30.  set command Used for display all the environment variables. Shows the current values of system variables. Also allows conversion of arguments into positional parameters. Syntax : setset command.
  31. 31. File Permission - Absolute Mode.r w x r w x r w x4 2 1 4 2 1 4 2 1Owner Group OtherGroup OthersOwnerrwxrwxrwxPermission ValueR 4W 2x 1- No Permission
  32. 32. Summary Background Features of Unix Unix System Architecture Unix File System General Unix commands and utilities Processes Regular Expressions Vi Editor Modes of operation
  33. 33. File Permission – Symbolic Mode.Who User Class MeaningU User Owner of fileG Group Group to which ownerbelongsO Other All other UsersWho Meaningr Sets read permissionw Sets write permissionx Sets exec permissionSymbolic mode user class specificationSymbolic mode permissions
  34. 34. Examples of chmod Syntax.chmod [0-7][0-7][0-7] filename (AbsoluteMode)chmod [ugo][+-][rwx] filename (SymbolicMode)$ chmod a=rw temp$ ls -l temp-rw-rw-rw- 1 alex pubs 57 Jul 12 16:47 temp
  35. 35. Unmasking File Permission umask Stands for user creation mask. Sets default permissions for a newly created file and directory. The value can be changed.Example6 6 6 - System wide default permissions- 0 2 2 - Denial ‗mask‘ set by UMASK6 4 4 - Resultant permissions that will beset on all files created (-rw-r—r--)