Sei sulla pagina 1di 178

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

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. Option
-i -l -n -v

Definition
Searches for both uppercase and lowercase characters Lists the names of files with matching lines Precedes each line with the relative line number in the file Inverts the search to display lines that do not match the pattern

-c
-w

Counts the lines that contain the pattern


Searches for the expression as a complete word, ignoring those matches that are substrings of larger words.

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 Result

Beginning of line anchor

^pattern

Matches all lines beginning with pattern Matches all lines ending with pattern

End of line anchor

pattern$

Additional regular expression meta characters:


Metacharacter

Purpose
Matches one character

Example
p.....n

Result
Matches lines containing a p, followed by Five characters, and followed by an n Matches Lowercase Alphanumeric characters or nothing at all

Matches the preceding item zero or more times

[a-z]*

grep continues
Metacharacter Purpose
Matches one character in the pattern

Example

Result
Matches lines Containing Pattern or pattern

[]

[Pp]attern

[^]

Matches one character not in the pattern

[^am] attern

Matches lines that do not contain a through m and followed byattern

grep continues

grep continues .

grep continues ..

grep continues ..

grep continues .

grep continues.

grep continues

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.

Egrep
Metacharacter
+

Purpose
Matches one or more of the preceding characters

Sample
[a-z]+ark

Result
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


Matches for either expression

x|y

Matches either x or y

apple | orange

egrep Example :

egrep continues

egrep continues

Pgrep

The process grep command finds and displays the process ID along with Its parent process ID.

FIND

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

find continues

find continues

find continues

find continues ..

w is a command which shows the particular users Information 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 users information

who continues

id command shows users ID and primary group ID

finger command displays the user information along with users 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 -v -f -t -x - to create tar archive - to get verbose - the out put device or directory - table of contents - extract from the tar archive

To create tar archive

Example

To see the table of content

To extract from the tar archive

Compress
To 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 Users home directory Users login shell User initialization files

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

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.

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

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

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:

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

Example :

Example :

Example :

Example :

Example :

Example :

Solaris Package Administration

Scheduled Process Control

Viewing current process status

Re-scheduling the process

Administering the active process

Crontab for the root user

Solaris run level and Boot process

The Boot Process

Solaris syslog

Potrebbero piacerti anche