Download - Unix commands
Unix Fundamentals and command references
Solaris
Linux
HP-UX
AIX
Commands
uname - It shows system identification information
showrev - System information with Host ID
# pwd – It shows the present working directory
Unix file types
ls - List of directories and files
ls continues
ls continues …
cal - It shows calendar
date - it shows the current date
Date format :
mm dd hh mm yy . s
mkdir – to create a new directory
cd - to change the directory
rmdir or rm –r - to remove the directory
mv – move or rename the directory or file
mv continues … ( if destination directory already exists “ mv “ moves source directory to destination directory ).
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.
“ 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.
“ file “ is a command which tells you the property of file orDirectory.
“ more “ command displays the file contents page wise.
“ less “ command displays the file content like “ more “ command but, it has to be closed with “ q “.
“ touch “ is the command which creates zero length files or it puts time stamp on the file or files which are already exist.
“ head “ command displays the file contents with “ – “option
“ tail “ command displays file contents like “ head “with “ - , + “ option.
“ sort “ command displays file contents in ascending and descending order.
“ wc - word count “ command displays words, lines, chars, bytes, mem size and all.
“ which “ command shows the location of the commands, which are set in environment variable “ PATH “
“ df – Disk free “ command shows the disk space level
“ clear “ command clears the screen
“ tty “ the terminal command shows the pseudo terminals.
“ echo “ command show the given value or shows the value of the environment varriables.
“ 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
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
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
“ 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
“ grep “ continues …
“ grep “ continues ….
“ grep “ continues ..
“ grep “ continues ..
“ grep “ continues ….
“ grep “ continues….
“ grep “ continues …
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
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
“ egrep Example :
“ egrep “ continues…
“ egrep continues …
Pgrep The “ process grep “ command finds and displays the process ID along with It’s parent process ID.
“ find “ is a command to find a file or directory in the system globally.
FIND
“ find “ continues …
“ find “ continues …
“ find “ continues …
“ find “ continues ..
“ w “ is a command which shows the particular user’sInformation in an elaborate manner.
“ SU “ command can be used to switch over from one user to an other user physically.
“ who “ command shows a respective user’s information
“ who “ continues …
“ id “ command shows user’s ID and primary group ID
“ finger “ command displays the user information along with user’s status
“ Link “ is a command which creates link between source and destination file. The following example shows the symbolic link.
“ Hard Link “ creates link between source and destination.
Unix File permissions
Changing file permissions in symbolic mode
“ chmod “ continues …
“ chmod “ continues in octal mode …
“ chmod “ continues in octal mode…
“ umask “ continues …
Korn Shell
The Default korn shell variables
Customizing Korn Shell Variable
To change the shell environment from Bourn shell to Korn shell :
To change the prompt ..
To change the prompt variable…
“ History command …
“ alias command …”
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
Remote Login using TELNET and RLOGIN
Using RLOGIN …
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
Example
To see the table of content
To create tar archive
To extract from the tar archive
CompressTo compress the tar archive
Example for compress archive
Uncompressing tar archive
gzip
To create gzip archive
To extract the tar archive by gunzip
Unix Administration
Solaris
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
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
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
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
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
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
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
Example :
Example :
Example :
Example :
Example :
Example :
Scheduled Process Control
Viewing current process status
Re-scheduling the process
Administering the active process