AIX Basics

Share Embed Donate


Short Description

unix basics...

Description

‡ UNIX Structure

  

M 

2

M    

‡ Kernel ± The Kernel interfaces directly with the hardware devices and controls their access. ± It also controls the processes that are started by users.

‡ Shell is a command interpreter and acts as an interface between user and kernel. ± Also the Shell is a programming language. ± We can write Shell scripts to automate tasks.



M    

‡ Logging In       ‡ Logging In    



 

=

M    

‡ Passwd ± Passwd command is used to change the user password. 

 

    !    "  #    $

Œ

M    

‡ Command Format ± The general format of an AIX command is ± command option (s) argument (s)



% & %



  



M    

‡ Date,Cal commands    ' (  ) *  +,-.) /   +) / - 0) / '-.1.2'  )3 4+56/*  ) 3 4 + 5 6 / *) ) )))3)4 )+)5)6)/)*3 3 D

M    

‡ Clear,echo and banner ± The Clear command clears the terminal window.

      )   )   7    

å

M    

‡ Who, Finger commands ± The Who and Finger commands are used to find information about the users.

    8+ +4+ 9 : 8+ 64    9 : 8+ 64  9

; 9

 ? #    ) @03)x -    0

'79-  ? #

Ô

M    

‡ write ± write provides a conversation like communication with each user alternatively sending and recieving messages.

 9

 70)     x   % 

A     x   %   ? x 

  @0 )3 ÔÔ

x



 

9

 

  ":1 M    

‡ wall ± The wall command writes to all terminals and useful to notify all users of a system event.



.%

7 )3  0>

‡ talk ± The talk command allows two users to hold a conversation.

 = %   -  . =<  @0  0  +)3>>>  =B709@0  = =9  =9 Ô2

 %  M    

‡ Files and Directories ± A file is a collection of data.

 M    Ô

  

 MM        M    

‡ File Structure ± AIX has a Hierarchial File Structure.

Ô=

M    

‡ File Structure ± AIX has a Hierarchial File Structure.

Ԍ

M    

‡ File Structure ± AIX has a Hierarchial File Structure.

Ô

M    

‡ File Structure ± AIX has a Hierarchial File Structure.

ÔD

M    

‡ pwd command ± The print working directory prints your current directory

  : :

Ôå

M    

‡ list command

ls [ directory ]

± The list command is used to list the contents of a directory.

  77  >  ? >>>> 77  >  &  3 ?)   )4(  + 4+ 7 ??)  + )8 / +4 

Ô 

M    

‡ cd command

cd [ directory ]

± The cd command changes our current directory.

2

  

 % 

 : :

7  

 

%0 0

 >>

% 0

M    

‡ mkdir command

mkdir [ directory ]

± The mkdir command creates one or more new directories.

 = : : :



  

 : :

 %  

 =   = & :):3



    

M    

‡ rmdir command

rmdir [ directory ]

± The rmdir command removes a directory.

  : : :          0   & :):3

22

M    

‡ rmdir command

rmdir [ directory ]

± The rmdir command removes a directory.

  : : :          0

2

[M M  MM 

M    

‡ display directory info ± The istat command displays the i-node information for a particular file or dir. ± Every file has an associated § 

± When a file is accessed the filename is matched with the corresponding i-node number and the data is located. name

i-node

SubdirÔ

=

myfile

Ô



Type

mode

links User Group Date

=

dir

DŒŒ

2

jim

staff

jan Ô  Ԍ

ŒÔ2

Ô

file

==

Ô

jim

staff

jan Ô  Ԍ

 

Size

loc

 % 0 

2=

M    

   0 A+ % :/



M    

‡ cat, pg and more commands ± The cat command lists a file but if the file is longer than one screen space it scrolls down to the end of the file. ± The pg command displays the file one page at a time. ± The more command also works the same way but you can scroll one line at a time by pressing ÿ  and one screen at a time by pressing the  .

      

>   %>    



M    

‡ wc command wc [-c] [-l] [-w] filename ± The wc command counts the number of lines,words and bytes in a named file. ± This command is very useful when comparing files.

 ?  7$  + +4**5 7$ 

"M ! M M °

± If no options are used the order will be lines,words and characters



M    

‡ link command

ln source_file target_file

± The ln command allows one file to have more than one name. ± Both copies have the same i-node.

  : : 

Ô

 7: : ):0D

M    

‡ print command

qprt filenameÔ filename2

± To queue files to the printer we use the qprt command. ± The qchk command displays the current status of a print queue. ± To cancel a print job use the qcan command.

 B > > B& )  x 0 ?    B= E   Q )>  KL 



M    

‡ Standard files and Redirection ± Three files are automatically opened for each process. ± standard input ( ) x default is keyboard ---- stdin < ± standard output (Ô) ± ± standard error (2)

---- stdout > x default is screen ---- stderr 2>

± These defaults can be changed by redirection.

  >

x 

     x    7) x  Œ

M    

‡ Pipes ± A pipe is a sequence of one or more commands where the i  of one command becomes the i § of the next command.

  7R& )4 ‡ Filters ± A filter is a command that reads from i §, processes it and then writes it to i 

 & R R&

-M ŒÔ

M    

‡ Tee ± The tee command reads i § and sends the data to both i  and a file.

 & R: : >R&

  MM   

,



" ,

: : > Œ2

M    

‡ command grouping ± Multiple commands can be entered on the same line seperated by a semi-colon.

 &C >S  ‡ Line continuation ± \ can be used to continue a command on a seperate line. ± A µ>¶ prompt id issued by the shell to indicate line continuation.

 : : 0:  :  )T : :9 : :  >

Œ

M    

‡ Shell Variables ± Variables represent data whose value may change. ± Shell variables define your environment...HOME,TERM,PATH etc., ± Shell variable names are case sensitive. ± The convention is that UPPERCASE are used for system-defined variables and lowercase are used for user-defined variables.



x

 00

U!-#â    8.Uâ         ' I ')I 'U#;;â    .#C-â   $ Œ=

M    

‡ Setting and Referencing Shell Variables 'U#;;I::7:7 x  %    %  7  0I 0 

x  %  7 

0

x   %  7 

0I 0  0   0

ŒŒ

M    

‡ Commmand substitution   . 3!)343++) /  I   . 3!)343++) /

Œ

M    

‡ Quoting Metacharacters ± µ µ Single Quotes

Ignores all metacharacters between the quotes.

VU!-# U!-# ± ³ ³ Double Quotes

Ignore all metachar., except for $,` and \

U!-# : : ± \Backslash

Ignore the special meaning of the following character

TU!-# U!-# ŒD

M    

‡ Process ± A program or a command that is actually running on a system is referred to as a process. ± Every process has a Process ID (PID). ± PID Ô is always assigned to the §§ process which is the first process that is started during the boot process. ± A PPID is the parent PID. ± The variable $$ shows the PID of the current shell.

      

A< ) + ) 5 ) 6

A< ) + )

 43+3 Œå

M    

‡ The Login Process ± When a user logs into a system a new process is started with a PID that is randomly allocated by the Kernel. ± The program usr/bin/ksh is loaded into this process.

„[ ,

°

Œ 

M 

M    

‡ Variables and Processes ± w §  iare part of the process environment Processes cannot access or change variables from another process.

I4 =  

I  ?  4 ± Each program runs in its own process environment.Variable x is not known in the subshell. ± To pass variables into a subshell we need to execute the export command. 

M    

‡ Exporting variables I4 0I5 0 S0 4 5 =  0 5 0I  ? 0 5 Ô

 M M 



 M M

M    

‡ Shell Script ± A shell script is a collection of commands stored in a text file. ± Any text editor can be used to create a shell script. ± Here we start ksh and pass the script name as an argument.

    0  

÷ 

=  x   0-8 )) / )34 : :

2

M    

‡ Invoking Shell Script ± The shell uses the PATH variable to find executable programs. ± The directory in which the script is stored must be defined in the path variable.

    0    





  x   0-8 )) / )34 : :



M    

‡ Invoking Shell Script ± Each Shell Script is executed in a subshell. ± Variables defined in a shell script cannot be passed back to the parent shell. ± If the script is invoked with a .(dot) it runs in the current shell.

    0  



>  x   0-8 )) / )34 : :

=

M    

‡ Exit Codes ± A command returns an exit value to the parent process. ± The environment variable $? contains the exit value of last command.

-,.



 MMM 

M

::0 =::0  P



M    

‡ ps command ± The ps command displays process status information.

? FA..W>>>!--8"< 9

) + >>>0 >>>  9 ) 5) +>>>0 >>>  ?

x

2F;; 

?

x

 0 7%0 0

& 

x

; 

& +x 

  +

  M    

‡ Types of Processes ± Processes that are started from and require interaction with the terminal are called -    iii. ± Processes that can run independently are called     iii

&>x

D

7 =

M    

‡ Terminating Processes

= =



) )x ?*) +x

.    =   M    

‡ Termination Signals ' - 





     

)

A   ? 

3

E  B=0  ?T

*

X

+

.   Y K L 34 $  &C: K L 34 > $

D

M    

‡ Job control 97 x ;97 K LC &C: >



 ?D

x ' 97

G

x 97

7G

x 977 =

=

x =

G

 97

M    

‡ Daemons ± A daemon is a never ending process that controls a system resource (printer queue). ± It starts when the system is started and runs until the system is down. ± For example qdaemon tracks print job requests and the printers available to handle them.

D2

M    

‡ User Environment ± Login Files ± The first file that the OS uses at login time is the /etc/environment file which contains variables specifying the basic environment for all processes. ± The second file is the /etc/profile file which controls systemwide default variables. ± The third file is the .profile file which resides in a user¶s login login directory and enables the user to customize their working environment.

D

M    

‡ User Environment ± Login Files M



M 

M



M

M / #+0 M D=

      

      

   M M    

‡ sample /etc/environment  ::%  Z18C"A",.  0 7  Z% %  7 >#

  Z  0  7% 0    Z D > 8.UI::7:::7::7::7:M :7 .[I#'.+#8 %  7  07 Z%70   >   ZU!-#0>U% 

 7 Z    >   0;!,"8-#  = )) .-!F.I ) -8A;I:: :  :;!,"8-# -8A;-',IKW!FU8\#"#1-8A;L .#C-?7 3 + ;!,"8-#-8A;-8A;-',.#C-.-!F.

D

M    

‡ sample .profile  >  8.UI:7::7:U!-#:7 ' IV1 x .      700 > x U   0   >

.#C-

x .  0  >

.#C-

x 8       



'

x  00    

#"\

x    X 



M    

‡ sample .kshrc  >= Z



  0

&% Z     IV ?  IV?  IV>> ± The difference between .profile and .kshrc is that .kshrc is read each time a subshell is spawned whereas .profile is read once at login.



M    

‡ ksh features-Aliases ± The alias command invoked with no arguments prints the list of aliases in the form name=value. ± The unalias command will cancel the alias named and removes it from the alias list.   IV?    IV ?    0IV? IV ? IV? IV&?     =  å

M    

‡ ksh features-History ± The last Ô2å commands are stored in $HOME/.sh_history. ± The r command allows you to recall previously entered commands. & x ): :  3 & 4& + 

  5





"   3 ???]& 9 34+ )3 )3+ 

åÔ

M    

‡ AIX Utilities ‡ find command (find path expression) ± Searches one or more dir structures recursively for files meeting certain specified criteria and displays those filenames or executes commands against them.

>&  ? >: :

>: :

å2

M    

‡ Executing commands with find ± The exec command executes a command on each of the files found.

>& V Q & & ^_TS ???]& 9 4+ )3 3+  ???& 9 45+ )3)3 > ?]& 9  ) )3 3 ) ± The command following ±exec (ls) is executed for each file name found. ± \; is hard coded with the find command and is required for use with ±exec and ±ok.

å

M    

‡ Interactive command execution ± The ok option causes command execution on an interactive basis.

>&  TQ&= ^_TS  >>>>: : P0  >>>>: :  P0  >>>>: P

å=

M    

‡ Additional Options

åŒ

?0

 x  0  x 0

?D

 x ? x x

?  

 ?

?

 x

x

  

    % 

? ?

x x

 70  

x x

 7 =   7 = B 7 =

   0 

   0 

M    

‡ find examples >& VQ &0&D)& & ^_TS ???]& 9 3+4+ )3 3+ > ??]& 9 4+43  )3 )> >& 544&  4& >:  :  >&  &&   >: :  >:  :& V0 &)> :% :0 :: 7:0

å

M    

‡ find with the ±links option : &0& = R  &  )6&???& 3   +5)* ) +: :  )6&???& 3   +5)* ) +: : 0 )6&???& 3   +5)* ) +: : 0)

 ,

  

  ‡ The ±links +Ô option lists the files that have more than one link associated with them.

åD

M    

‡ grep command (grep [options] pattern [fileÔ file2....]) ± Searches for lines matching specified pattern and also displays the name of the file containing the pattern.

/  U 

U1/ 3))?4+

&R   + 4 3)+4  *+4++:   ?=

åå

M    

‡ grep with regular expressions ± When * is used with the grep command ti will match zero or more occurences of the previous character.

\      >

x

Q x K 8L

x

K ?L x

å 

0    D     #   8 0 7 

`

x

80   



x

80   D M    

‡ grep examples &R   + 4 3)+4  *+4++:   ?= V`H  H = 9

 

®,  M 4+4?34 4

V+  8% H0

)+?45)+

V`K)  >4  77>6

       >4 >)  77>6    R > 70 >O  77>6  >4 >)

 

M    

‡ head and tail commands ± head command can be used to view the first few lines of a file or files. ± tail command displays a file beginning at a specified point and displaying a specified number of lines.

 ?+ >x

 + 

  ?)  0    &: :>x  0   0   

 =

M    

‡ xargs ± The xargs command reads a group of commands from stdin and runs an AIX command with that group of arguments. ± Here cat passes xargs the list of files and allows xargs to pass them to rm. ± The ±t flag echoes the constructed command line to stderr.

       )  3  4    R &

    ) 3 4

 Œ

M    

‡ xargs more examples ± Here we create a list of files to be printed and queue them up for printing through xargs.

    &B  B   ) 3  R &&A^_ %^_^_> 

%    >  ± Here { } is called a placeholder and the ±I flag tells xargs to insert each line of the ls directory listing where { } appears.

 

M    

‡ xargs,find and grep ± Using xargs is more efficient and easier to remember than the find commanad

>&0&  3 R &

 >:  >: )>: 3 >&0R && U & U >: 4>: 6>: 

 D



M    

‡ which,whereis,whence ± which command takes a list of program names and looks for the files that are executed when these names are given as a command. ± whereis also takes a list of program names but only searches in some standard locations. ± Whence is a ksh-specific command which also searches for ksh aliases.

 ::7:  ::7:  ::7:  å

M    

‡ file command ± The file command can be used to determine the type of a file. ± It also tells us under what OS version it is compiled.  ::7:% ::7:% 7 CA''0 :5 79          ::7 ::7 0

  

M    

‡ diff (Differential File Comparator) ± The diff command works only with text files and and reports the differences between the two files.   > 

 

   ????    43 >  & %  

  $   : :Q   %     

 ) > 34>

ÔÔ

M    

‡ While loop "M 

     I  KK& *LL     &R?   R?   I   5 

ÔÔD

M    

‡ command search order ‡ The shell looks for a in the following order.

Qualified pathname Reserved word

if,then,else,while...etc.,

alias built-in command

cd,pwd,umask,read...etc.,

Function path variable ÔÔå

M    

‡ X Window ± The X-window is a N/W based graphics system. ± It enables us to work with multiple items simultaneously. ± It provides the capability to manage local and remote displays. ± X window uses a client/server environment. ± So the graphic application can run on one system, yet display its output on another system. ± X window is platform independent. ± It allows a keyboard and display attached to one system to use programs running on a completely different system.

ÔÔ 

M    

‡ X Window ± The X-window is a N/W based graphics system. :, 

9 ; Ô2

M 

9„!"M 

9 ;

MM

9 ;

M 

„! M    

‡ X Window ± X window function is split into terminal and application support. ± Typically the application support runs on a UNIX system and the terminal system can run on any system. ± The system providing application support is called client and the one providing terminal support is called server. ± In most cases both will be on the same system. ± Client is the application that is running and needs to display graphics to a user. ± Clients recieve keyboard and mouse input from the associated x server. ± X servers respond to requests from clients and to actions from users.

Ô2Ô

M    

‡ X Clients ± X clients are the aplications which the users run under the X window systemcommon X clients are

Ô22

xterm

x

Standard terminal emulator

aixterm

x

IBM AIX terminal emulator

xclock

x

displays a clock

xcalc

x

displays a calculator

xwd

x

dumps the image of an x window

mwm

x

motif window manager

M    

‡ X Clients ± standard X client command line options are ,  

x

specifies the color for window background

,  

x

specifies the color for window border

," 

x

specifies window border in pixels

,  m m

x

Identifies the host server name and the X server display number where the command is to run.

,  

x

specifies the color for the window foreground

, 

x

specifies the normal sized text fontset.

Ô2

M    

‡ X Server ± Each X server controls one keyboard. one mouse and one or more screens. ± Allows simultaneous access by several clients ± Performs basic graphic operations ± Provides information such as fonts and colors ± Routes keyboard and mouse I/P to the correct clients

Ô2=

M    

‡ Starting AIXwindow ± The  command is used to start the AIXwindows environment. ± If the workstation is not an X Station then  will execute the § § command. ± By default startx starts three clients §  ,  and . ± Any errors occuring during will be logged in a file / #+0 MMM. ± We use to close AIXwindows and return to command prompt. ± Some windows like aixterm accept and display information while some like xclock and xcalc simply display information.

Ô2Œ

M    

‡ The aixterm Window ± An aixterm can be started in two ways ± In SHELL x § ± Display ´

  and select §  ± To create an additional aixterm window enter § at the command prompt. ± The aixterm window can be closed by ± Type § or 

Ô2

M    

‡ Running a Client on Another System ± With AIXwindows it is possible to run a client on a remote system in the network yet display the application window on your screen. ± we need to tell the client process where to display its window. ± AIXwindows uses the DISPLAY environment variable to indicate the name of the server where it should display its output. ± To override this value we need to specify a value using the M   8 Q7 = 0 8 Q  %0 8 Q   =Q  - Q=07 2 0 

Ô 2

M    

‡ Customizing AIXwindows

---

.mwmrc

± Root menu,window menu and mouse options can be customized in the .mwmrc file. ± DO NOT MODIFY SYSTEM-WIDE FILE which can be found in /usr/lpp/XÔÔ/defaults/MotifÔ.2/system.mwmrc. ± To customize we need to copy this file to our HOME dir and modify it as it will override the system-wide version.

Ô

M    

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF