0% found this document useful (0 votes)
34 views

Unix

Unix

Uploaded by

vij
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Unix

Unix

Uploaded by

vij
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 180

Unix Fundamentals and command references

Solaris
Linux
HP-UX
AIX

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

Commands

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

uname - It shows system identification information

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

showrev - System information with Host ID

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

# pwd It shows the present working directory

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

Unix file types

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

ls - List of directories and files

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

ls continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

ls continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

cal - It shows calendar

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

10

date - it shows the current date

Date format :
mm dd hh mm yy . s

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

11

mkdir to create a new directory

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

12

cd - to change the directory

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

13

rmdir or rm r - to remove the directory

mv move or rename the directory or file

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

14

mv continues ( if destination directory already exists


mv moves source directory to destination directory ).

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

15

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.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

16

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.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

17

file is a command which tells you the property of file or


Directory.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

18

more command displays the file contents page wise.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

19

less command displays the file content like more


command but, it has to be closed with q .

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

20

touch is the command which creates zero length files or


it puts time stamp on the file or files which are already exist.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

21

head command displays the file contents with option

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

22

tail command displays file contents like head


with - , + option.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

23

sort command displays file contents in ascending and


descending order.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

24

wc - word count command displays words, lines, chars,


bytes, mem size and all.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

25

which command shows the location of the commands,


which are set in environment variable PATH

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

26

df Disk free command shows the disk space level

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

27

clear command clears the screen

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

28

tty the terminal command shows the pseudo terminals.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

29

echo command show the given value or shows the value


of the environment varriables.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

30

grep is the command which displays the line with the


matching pattern. It can be executed with more options.
Option

25-Jan-09

Definition

-i

Searches for both uppercase and lowercase characters

-l

Lists the names of files with matching lines

-n

Precedes each line with the relative line number in the file

-v

Inverts the search to display lines that do not match the


pattern

-c

Counts the lines that contain the pattern

-w

Searches for the expression as a complete word, ignoring


those matches that are substrings of larger words.
Vinay Kumar Eadara
NOVISYS, LLC

31

The grep command supports several regular expression


Meta characters to further define a search pattern. This table
describes some of the regular expression meta characters.
Regular expression meta characters:
Metacharacter

Purpose

Example

Beginning of
line anchor

^pattern

Matches all lines


beginning
with pattern

End of line
anchor

pattern$

Matches all lines


ending
with pattern

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

Result

32

Additional regular expression meta characters:


Metacharacter

25-Jan-09

Purpose

Example

Result

Matches one
character

p.....n

Matches lines
containing a
p, followed by
Five characters,
and followed
by an n

Matches the
preceding
item zero or
more times

[a-z]*

Matches
Lowercase
Alphanumeric
characters or
nothing at all

Vinay Kumar Eadara


NOVISYS, LLC

33

grep continues
Metacharacter

[]

Purpose
Matches one
character in
the pattern

Example

Result

[Pp]attern

Matches lines
Containing
Pattern or
pattern

[^]

25-Jan-09

Matches one
character not
in the pattern

[^am]
attern

Vinay Kumar Eadara


NOVISYS, LLC

Matches lines that


do not contain a
through m and
followed byattern

34

grep continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

35

grep continues .

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

36

grep continues ..

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

37

grep continues ..

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

38

grep continues .

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

39

grep continues.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

40

grep continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

41

Egrep

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.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

42

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

43

Egrep
Metacharacter

Purpose

Sample

Result

Matches one or
more of the
preceding
characters

[a-z]+ark

Matches one or more


lowercase letters
followed by ark (for
example, airpark,
bark, dark,
landmark, shark,
sparkle, trademark)

Matches zero
or one
character

patte[r?]

Matches lines
Containing the literal
character or
metacharacter it
follows

x|y

Matches either x or
y

apple | orange

Matches for either


expression

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

44

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

45

egrep Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

46

egrep continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

47

egrep continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

48

Pgrep

25-Jan-09

The process grep command finds and displays the


process ID along with Its parent process ID.

Vinay Kumar Eadara


NOVISYS, LLC

49

FIND

find is a command to find a file or directory in the


system globally.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

50

find continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

51

find continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

52

find continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

53

find continues ..

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

54

w is a command which shows the particular users


Information in an elaborate manner.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

55

SU command can be used to switch over from one user to


an other user physically.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

56

who command shows a respective users information

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

57

who continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

58

id command shows users ID and primary group ID

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

59

finger command displays the user information along with


users status

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

60

Link is a command which creates link between source and


destination file. The following example shows the symbolic link.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

61

Hard Link creates link between source and destination.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

62

Unix File permissions

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

63

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

64

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

65

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

66

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

67

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

68

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

69

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

70

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

71

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

72

Changing file permissions in symbolic mode

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

73

chmod continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

74

chmod continues in octal mode

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

75

chmod continues in octal mode

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

76

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

77

umask continues

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

78

Korn Shell

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

79

The Default korn shell variables

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

80

Customizing Korn Shell Variable

To change the shell environment from Bourn shell to


Korn shell :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

81

To change the prompt ..

To change the prompt variable

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

82

History command

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

83

alias command

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

84

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

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

85

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

86

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

87

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

88

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

89

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

90

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

91

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

92

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

93

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

94

Remote Login using TELNET and RLOGIN

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

95

Using RLOGIN

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

96

File Archives
tar
-c
-v
-f
-t
-x

25-Jan-09

- to create tar archive


- to get verbose
- the out put device or directory
- table of contents
- extract from the tar archive

Vinay Kumar Eadara


NOVISYS, LLC

97

To create tar archive

Example

To see the table of content

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

98

To extract from the tar archive

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

99

Compress
To compress the tar archive

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

100

Example for compress archive

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

101

Uncompressing tar archive

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

102

gzip
To create gzip archive

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

103

To extract the tar archive by gunzip

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

104

Unix Administration

Solaris

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

105

Solaris User Administration


Each user account consists of five main components:
User name
Password
Users home directory
Users login shell
User initialization files

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

106

Managing User Accounts


Before you can add user accounts to the system, you must
determine the following information for each new user:
Login name
User identification (UID) number
Group identification (GID) number
Comment
home directory
Login shell
Password aging

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

107

Storing User and Group Account information


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.

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

108

The /etc/passwd file format


root:x:0:1:Super-User:/:/sbin/sh
daemon: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/uucico
listen: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:/:

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

109

The /etc/shadow file format


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

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

110

The /etc/group file format


root::0:root
other::1:
bin::2:root,bin,daemon
sys::3:root,bin,sys,adm
adm::4:root,adm,daemon
uucp::5:root,uucp
mail::6:root
tty::7:root,tty,adm
lp::8:root,lp,adm
nuucp::9:root,nuucp
staff::10:
daemon::12:root,daemon
sysadmin::14:lister,torey
nobody::60001:
noaccess::60002:
nogroup::65534:

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

111

Command line User Account Administration


The following command-line tools add, modify, and delete
user accounts and group accounts on the local system:
useradd Adds a new user account
usermod Modifies a users account
userdel Deletes a users account
groupadd Adds (creates) a new group account
groupmod Modifies a group account
groupdel Deletes a group account

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

112

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

113

Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

114

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

115

Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

116

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

117

Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

118

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

119

Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

120

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

121

Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

122

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

123

Example :

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

124

Solaris Package Administration

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

125

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

126

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

127

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

128

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

129

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

130

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

131

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

132

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

133

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

134

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

135

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

136

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

137

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

138

Scheduled Process Control

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

139

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

140

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

141

Viewing current process status

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

142

Re-scheduling the process

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

143

Administering the active process

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

144

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

145

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

146

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

147

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

148

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

149

Crontab for the root user

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

150

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

151

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

152

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

153

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

154

Solaris run level and Boot process

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

155

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

156

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

157

The Boot Process

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

158

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

159

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

160

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

161

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

162

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

163

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

164

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

165

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

166

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

167

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

168

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

169

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

170

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

171

Solaris syslog

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

172

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

173

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

174

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

175

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

176

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

177

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

178

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

179

25-Jan-09

Vinay Kumar Eadara


NOVISYS, LLC

180

You might also like