+ All Categories
Transcript
Page 1: Linux Command Suumary

Linux Commands Summary

Page 2: Linux Command Suumary

Course Objective

To introduce the Unix Operating System Concept.

To introduce standard Unix commands.

To introduce VI editor.

Page 3: Linux Command Suumary

References

Text Book Reference Brain W. Kernighan and Rob Pike, The UNIX

Programming Environment. A Practical Guide to Linux® Commands, Editors, an

d Shell Programming - Mark Sobell's

Web Reference Unix Tutorial For Beginners Introduction to Unix http://www.cis.uab.edu/cs344/spring2005/

Page 4: Linux Command Suumary

What is Unix Operating System

Unix OS is a Program Unix OS provides

interface between users and bare hardware

Unix OS manages resources: CPU(s), memory, disks, other I/O devices.

Operating System

users

Page 5: Linux Command Suumary

Why do we need Operating System ?

To Interact with Computer Hardware

End User

Computer Hardware

Operating-System

Utilities

ApplicationPrograms

OS Designer

System Programmer

Application Programmer

E.g. compiler, libraries, shell

E.g. database, web servers

Page 6: Linux Command Suumary

Evolution of Unix OS

Page 7: Linux Command Suumary

Flavors of Unix

AIX (Advanced IBM Unix) HP-UX ( Hewlett Packard Unix) BSD ( Berkeley Software Distribution. ) SCO UNIX SOLARIS LINUX, etc

Page 8: Linux Command Suumary

System Architecture

HARDWARE

KERNELDATABASE

UNIX

COMMANDS

COMPILERS

OTHER

APPLICATIONS

PACKAGES

SHELLSHELL

SHELLSHELL

UserUser

UserUserUserUser

UserUser

Page 9: Linux Command Suumary

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

Page 10: Linux Command Suumary

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

Page 11: Linux Command Suumary

Structure of Unix File System

Page 12: Linux Command Suumary

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 ..

Page 13: Linux Command Suumary

How Unix Session Works.

USER TYPES COMMAND

SHELL EXECUTESUTILITY TO CARRYOUT COMMAND

SHELL ASKS FOR A COMMAND

USER INTERACTS WITH UTILITY

SHELL PROMPTS FOR NEXT COMMAND

USER TYPES CONTROL-D

LOGOUT

LOGIN

Page 14: Linux Command Suumary

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

Page 15: Linux Command Suumary

Unix Command Structure

Unix Command line structure command [options] [arguments]

Refer the following word Doc for Detail Command

Page 16: Linux Command Suumary

Concept of stdin, stdout and stderr

Operating System

AnotherComputer

program running

stdout

stderr

stdinKeyboard

A Computerprogram running

stdout

stderr

stdin

Monitor

Page 17: Linux Command Suumary

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

Page 18: Linux Command Suumary

Regular Expressions

What is it?String of ordinary and metacharacter which can be

used to match more than one type of pattern.Uses character set

* , [], ^, $, {}, etc.

Page 19: Linux Command Suumary

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.

Page 20: Linux Command Suumary

Editor in Unix

Need for editor in UnixTypes 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)

Page 21: Linux Command Suumary

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

Page 22: Linux Command Suumary

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 comparison with the same letter in upper case

Keystrokes could have more than one meaning A letter (of the same case) has different implementation

across different modes.

Page 23: Linux Command Suumary

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

Page 24: Linux Command Suumary

vi Operating modes.

Command mode

Insert mode

i, I , o, O, a, A ..

esc

Last line mode

Enter :

:q

Page 25: Linux Command Suumary

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]

Page 26: Linux Command Suumary

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.

Page 27: Linux Command Suumary

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.

Page 28: Linux Command Suumary

Customizing vi.

The set command :set all :set nu

The abbr command :abbr itl “Infosys Technologies Ltd”

The map command :map ^X :wq

Page 29: Linux Command Suumary

System Variables.

PATH Search path referred by Unix for any command. echo $PATH

HOME Indicates the home directory for the user. echo $HOME

Page 30: Linux Command Suumary

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 : set

set command.

Page 31: Linux Command Suumary

File Permission - Absolute Mode.

r w x r w x r w x

4 2 1 4 2 1 4 2 1

Owner Group Other

Group OthersOwner

rwxrwxrwxPermission Value

R 4

W 2

x 1

- No Permission

Page 32: Linux Command Suumary

Summary

BackgroundFeatures of UnixUnix System ArchitectureUnix File SystemGeneral Unix commands and utilitiesProcessesRegular ExpressionsVi EditorModes of operation

Page 33: Linux Command Suumary

File Permission – Symbolic Mode.

Who User Class Meaning U User Owner of file G Group Group to which owner

belongs O Other All other Users

Who Meaning r Sets read permission w Sets write permission x Sets exec permission

Symbolic mode user class specification

Symbolic mode permissions

Page 34: Linux Command Suumary

Examples of chmod

Syntax. chmod [0-7][0-7][0-7] filename

(Absolute Mode) chmod [ugo][+-][rwx] filename

(Symbolic Mode)

$ chmod a=rw temp$ ls -l temp-rw-rw-rw- 1 alex pubs 57 Jul 12 16:47 temp

Page 35: Linux Command Suumary

Unmasking File Permission

umask Stands for user creation mask. Sets default permissions for a newly created file and

directory. The value can be changed.

Example 6 6 6 - System wide default

permissions - 0 2 2 - Denial ‘mask’ set by UMASK 6 4 4 - Resultant permissions that will

be set on all files created (-rw-r—

r--)

Page 36: Linux Command Suumary

Top Related