+ All Categories
Home > Technology > Unix commands

Unix commands

Date post: 13-Dec-2014
Category:
Upload: bhaskarbalapuram
View: 558 times
Download: 9 times
Share this document with a friend
Description:
 
Popular Tags:
127
Unix Fundamentals and command references Solaris Linux HP-UX AIX
Transcript
Page 1: Unix commands

Unix Fundamentals and command references

Solaris

Linux

HP-UX

AIX

Page 2: Unix commands

Commands

Page 3: Unix commands

uname - It shows system identification information

Page 4: Unix commands

showrev - System information with Host ID

Page 5: Unix commands

# pwd – It shows the present working directory

Page 6: Unix commands

Unix file types

Page 7: Unix commands

ls - List of directories and files

Page 8: Unix commands

ls continues

Page 9: Unix commands

ls continues …

Page 10: Unix commands

cal - It shows calendar

Page 11: Unix commands

date - it shows the current date

Date format :

mm dd hh mm yy . s

Page 12: Unix commands

mkdir – to create a new directory

Page 13: Unix commands

cd - to change the directory

Page 14: Unix commands

rmdir or rm –r - to remove the directory

mv – move or rename the directory or file

Page 15: Unix commands

mv continues … ( if destination directory already exists “ mv “ moves source directory to destination directory ).

Page 16: Unix commands

cp - It copies directories and files from one location to another location.

“ cp “command copies only files from one location to another location. “ cp - r “ Can be used to copy directories.

Page 17: Unix commands

“ cat “ command is used to create or read the contents of the files.

To append some more content with the existing file “ >> “ can be used.

Page 18: Unix commands

“ file “ is a command which tells you the property of file orDirectory.

Page 19: Unix commands

“ more “ command displays the file contents page wise.

Page 20: Unix commands

“ less “ command displays the file content like “ more “ command but, it has to be closed with “ q “.

Page 21: Unix commands

“ touch “ is the command which creates zero length files or it puts time stamp on the file or files which are already exist.

Page 22: Unix commands

“ head “ command displays the file contents with “ – “option

Page 23: Unix commands

“ tail “ command displays file contents like “ head “with “ - , + “ option.

Page 24: Unix commands

“ sort “ command displays file contents in ascending and descending order.

Page 25: Unix commands

“ wc - word count “ command displays words, lines, chars, bytes, mem size and all.

Page 26: Unix commands

“ which “ command shows the location of the commands, which are set in environment variable “ PATH “

Page 27: Unix commands

“ df – Disk free “ command shows the disk space level

Page 28: Unix commands

“ clear “ command clears the screen

Page 29: Unix commands

“ tty “ the terminal command shows the pseudo terminals.

Page 30: Unix commands

“ echo “ command show the given value or shows the value of the environment varriables.

Page 31: Unix commands

“ grep “ is the command which displays the line with the matching pattern. It can be executed with more options.

Searches for the expression as a complete word, ignoring

those matches that are substrings of larger words.

- w

Counts the lines that contain the pattern- c

Inverts the search to display lines that do not match the

pattern

- v

Precedes each line with the relative line number in the file- n

Lists the names of files with matching lines- l

Searches for both uppercase and lowercase characters- i

DefinitionOption

Page 32: Unix commands

The “ grep “ command supports several regular expressionMeta characters to further define a search pattern. This table describes some of the regular expression meta characters. Regular expression meta characters:

Matches all lines ending

with “pattern”

’pattern$’End of line

anchor$

Matches all lines beginning

with “pattern”

’^pattern’Beginning of

line anchor^

ResultExamplePurposeMetacharacter

Page 33: Unix commands

Additional regular expression meta characters:

Matches

Lowercase

Alphanumeric

characters or

nothing at all

’[a-z]*’Matches the

preceding

item zero or

more times

*

Matches lines

containing a

“p,” followed by

Five characters,

and followed

by an “n”

’p.....n’Matches one

character.

ResultExamplePurposeMetacharacter

Page 34: Unix commands

“ grep “ continues …

Matches lines that

do not contain “a”

through “m” and

followed by“attern”

’[^am]

attern’

Matches one

character not

in the pattern[^]

Matches lines

Containing

“Pattern” or

“pattern”

’[Pp]attern’

Matches one

character in

the pattern[ ]

ResultExamplePurposeMetacharacter

Page 35: Unix commands

“ grep “ continues …

Page 36: Unix commands

“ grep “ continues ….

Page 37: Unix commands

“ grep “ continues ..

Page 38: Unix commands

“ grep “ continues ..

Page 39: Unix commands

“ grep “ continues ….

Page 40: Unix commands

“ grep “ continues….

Page 41: Unix commands

“ grep “ continues …

Page 42: Unix commands

The egrep command searches the contents of one or more files for a pattern using extended regular expression metacharacters. Extended regular expression metacharacters include the regular expression metacharacters that the grep command uses, plus some additional metacharacters.

Egrep

Page 43: Unix commands

Matches lines

Containing the literal

character or

metacharacter it

follows

‘patte[r?]’Matches zero

or one

character

?

Matches for either

expression

’apple | orange’Matches either x or

yx | y

Matches one or more

lowercase letters

followed by “ark” (for

example, “airpark,”

“bark,” “dark,”

“landmark,” “shark,”

“sparkle,” “trademark”)

’[a-z]+ark’Matches one or

more of the

preceding

characters

+

ResultSamplePurposeMetacharacter

Egrep

Page 44: Unix commands

“ egrep Example :

Page 45: Unix commands

“ egrep “ continues…

Page 46: Unix commands

“ egrep continues …

Page 47: Unix commands

Pgrep The “ process grep “ command finds and displays the process ID along with It’s parent process ID.

Page 48: Unix commands

“ find “ is a command to find a file or directory in the system globally.

FIND

Page 49: Unix commands

“ find “ continues …

Page 50: Unix commands

“ find “ continues …

Page 51: Unix commands

“ find “ continues …

Page 52: Unix commands

“ find “ continues ..

Page 53: Unix commands

“ w “ is a command which shows the particular user’sInformation in an elaborate manner.

Page 54: Unix commands

“ SU “ command can be used to switch over from one user to an other user physically.

Page 55: Unix commands

“ who “ command shows a respective user’s information

Page 56: Unix commands

“ who “ continues …

Page 57: Unix commands

“ id “ command shows user’s ID and primary group ID

Page 58: Unix commands

“ finger “ command displays the user information along with user’s status

Page 59: Unix commands

“ Link “ is a command which creates link between source and destination file. The following example shows the symbolic link.

Page 60: Unix commands

“ Hard Link “ creates link between source and destination.

Page 61: Unix commands

Unix File permissions

Page 62: Unix commands
Page 63: Unix commands
Page 64: Unix commands
Page 65: Unix commands
Page 66: Unix commands
Page 67: Unix commands
Page 68: Unix commands

Changing file permissions in symbolic mode

Page 69: Unix commands

“ chmod “ continues …

Page 70: Unix commands

“ chmod “ continues in octal mode …

Page 71: Unix commands

“ chmod “ continues in octal mode…

Page 72: Unix commands
Page 73: Unix commands

“ umask “ continues …

Page 74: Unix commands

Korn Shell

Page 75: Unix commands

The Default korn shell variables

Page 76: Unix commands

Customizing Korn Shell Variable

To change the shell environment from Bourn shell to Korn shell :

Page 77: Unix commands

To change the prompt ..

To change the prompt variable…

Page 78: Unix commands

“ History command …

Page 79: Unix commands

“ alias command …”

Page 80: Unix commands

Using VI Editor

Identifying the Fundamentals of vi Editor operation

• Introducing the vi editor modes of operation

• The command mode

• The edit mode

• The last line mode

• Switching between the command and edit modes

• Introducing the vi command

Page 81: Unix commands
Page 82: Unix commands
Page 83: Unix commands
Page 84: Unix commands
Page 85: Unix commands
Page 86: Unix commands
Page 87: Unix commands
Page 88: Unix commands
Page 89: Unix commands
Page 90: Unix commands

Remote Login using TELNET and RLOGIN

Page 91: Unix commands

Using RLOGIN …

Page 92: Unix commands

File Archives

tar - c - to create tar archive - v - to get verbose - f - the out put device or directory - t - table of contents - x - extract from the tar archive

Page 93: Unix commands

Example

To see the table of content

To create tar archive

Page 94: Unix commands

To extract from the tar archive

Page 95: Unix commands

CompressTo compress the tar archive

Page 96: Unix commands

Example for compress archive

Page 97: Unix commands

Uncompressing tar archive

Page 98: Unix commands

gzip

To create gzip archive

Page 99: Unix commands

To extract the tar archive by gunzip

Page 100: Unix commands

Unix Administration

Solaris

Page 101: Unix commands

Solaris User Administration

Each user account consists of five main components:

• User name

• Password

• User’s home directory

• User’s login shell

• User initialization files

Page 102: Unix commands

Before you can add user accounts to the system, you mustdetermine the following information for each new user:

• Login name

• User identification (UID) number

• Group identification (GID) number

• Comment

• home directory

• Login shell

• Password aging

Managing User Accounts

Page 103: Unix commands

The Solaris Operating Environment stores user account and group account information in the following system files:

• /etc/passwd – Authorized system users have login account entries in the /etc/passwd file.

• /etc/shadow – All passwords are encrypted and maintained in a separate shadow file named

/etc/shadow.

• /etc/group – The /etc/group file defines the default system group accounts.

Storing User and Group Account information

Page 104: Unix commands

root:x:0:1:Super-User:/:/sbin/shdaemon:x:1:1::/:bin:x:2:2::/usr/bin:sys:x:3:3::/:adm:x:4:4:Admin:/var/adm:lp:x:71:8:Line Printer Admin:/usr/spool/lp:smtp:x:0:0:Mail Daemon User:/:uucp:x:5:5:uucp Admin:/usr/lib/uucp:nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucicolisten:x:37:4:Network Admin:/usr/net/nls:nobody:x:60001:60001:Nobody:/:noaccess:x:60002:60002:No Access User:/:nobody4:x:65534:65534:SunOS 4.x Nobody:/:

The “ /etc/passwd “ file format

Page 105: Unix commands

root:LXeoktCoMtwZN:6445::::::daemon:NP:6445::::::bin:NP:6445::::::sys:NP:6445::::::adm:NP:6445::::::lp:NP:6445::::::smtp:NP:6445::::::uucp:NP:6445::::::nuucp:NP:6445::::::listen:*LK*:::::::nobody:NP:6445::::::noaccess:NP:6445::::::nobody4:NP:6445::::::

The “ /etc/shadow “ file format

Page 106: Unix commands

root::0:rootother::1:bin::2:root,bin,daemonsys::3:root,bin,sys,admadm::4:root,adm,daemonuucp::5:root,uucpmail::6:roottty::7:root,tty,admlp::8:root,lp,admnuucp::9:root,nuucpstaff::10:daemon::12:root,daemonsysadmin::14:lister,toreynobody::60001:noaccess::60002:nogroup::65534:

The “ /etc/group “ file format

Page 107: Unix commands

The following command-line tools add, modify, and deleteuser accounts and group accounts on the local system:

• useradd – Adds a new user account

• usermod – Modifies a user’s account

• userdel – Deletes a user’s account

• groupadd – Adds (creates) a new group account

• groupmod – Modifies a group account

• groupdel – Deletes a group account

Command line User Account Administration

Page 108: Unix commands
Page 109: Unix commands

Example :

Page 110: Unix commands
Page 111: Unix commands

Example :

Page 112: Unix commands
Page 113: Unix commands

Example :

Page 114: Unix commands
Page 115: Unix commands

Example :

Page 116: Unix commands
Page 117: Unix commands

Example :

Page 118: Unix commands
Page 119: Unix commands

Example :

Page 120: Unix commands

Scheduled Process Control

Page 121: Unix commands
Page 122: Unix commands
Page 123: Unix commands

Viewing current process status

Page 124: Unix commands

Re-scheduling the process

Page 125: Unix commands

Administering the active process

Page 126: Unix commands
Page 127: Unix commands

Recommended