Important UNIX AIX command for Admins

Thursday, May 15, 20082comments

AIX command

Some file commands are:

cp - Used to copy the contents of one file to another file.
Syntax: %cp original file name new file name
Example: %cp file1 file2

mv - Used to rename a file by moving the contents of the file to
another file.
Syntax: %mv original file name new file name
Example: %mv file1 file3

mv - Used to move a file from one directory to another directory.
This is a useful command for reorganizing the files in your
directories.
Syntax: %mv file name(s) directory name
Example: %mv file3 file4 Cprogs
The two files, file3 and file4, moved from the current working
directory to the directory Cprogs.

rm - Used to delete or remove a file permanently.
Syntax: %rm original file name
Example: %rm file1

*******************************************************************************

%rm -i file1

cat - Used to display the contents of a file at the shell prompt.
Syntax: %cat file name
Example: %cat file3

pg - Used to display the contents of a file with more than one
screenfull worth of text, one screen at a time.
Syntax: %pg file name
Example: %pg file3
To resume display after each screen is displayed, hit the
RETURN key.

more - Like pg, used to display a file one page at a time.
Syntax: %more file name
Example: %more file3
To resume display after each screen is displayed, hit the


*****************************************

To find out the directory you are currently in, type:


%pwd

which stands for "print working directory", and the system will display the pathname of the working directory.


**********************************************8

Whenever you create a directory, "mkdir" automatically places two entries into the directory: "." and ".." "." is the directory itself and is synonymous with the path name of the working directory. ".." is the parent directory and is synonymous with the pathname of the parent of the working directory. These directory entries are only visible if you include an option with the list directory command:


%ls - a
Some directory commands are:

mkdir - Used to create a directory.
Syntax: %mkdir ./directory name
Example: %mkdir ./fortprogs

cd - Used to change current working directory to another directory.
Syntax: %cd /directory name
Example: %cd /projects/fortprogs
%cd .. (Moves up one directory level)
%cd . (Change to current directory)

rmdir - Used to remove a directory. The directory must be empty.
Syntax: %rmdir ./directory name
Example: %rmdir ./fortprogs

pwd - To display to the screen the current working directory.
Syntax: %pwd

*****************************************
nohup
put this command at the beginning to make a background process continue after you break the logon connection;

Ctrl-c
get prompt back

Ctrl-d
end of input; same as logout when in shell

df (AIX) / bdf (HP-UX)
show disk space usage for the machine
Ex : df –g –--to view diskspace in GB - Blocks

diff
compare two files;

find
recursively search for files;
Ex : find . –name “” –print –searches file in current dir according to name and prints its full path

grep
search a bunch of files for a string;

logout or exit
end your Unix session

man
look up a manual page; man ls will tell about the options to the ls command, for example; main online documentation for Unix;

more
make the output stop after each screen; Spacebar displays next screen, Ctrl-b displays the previous screen, q quits

passwd
change your password; passwords on the ACCC Unix systems may be up to 8 characters long and must have at least three letters and two characters which are not letters;

sort
sort the lines of a file;

powermt display dev=all / powermt display (summary)
The powermt utility is used to configure and restore paths to logical devices, validate and check logical device serial numbers, display information about HBAs and PowerPath
devices, and set load-balancing and failover policies.


ls dev -Cc disk OR lspv
to display the disk configured an respective lv’s

sappfpar pf=CRT_DVEBMGS01_mdecctst check
to check the physical memory.

lsdev –Cc tape
shows tape configured

cfgmgr
Configures devices and optionally installs device software by running the programs specified in the Configuration Rules object class

rmdev
remove device

lsvg
displays vg’s configured

lsvg –l
displays lv and fs on

topas (AIX) /top (HP-UX)

displays the processes running, CPU utilization ..etc (same as task manager in WINDOWS machine)

smitty (AIX) /sam (HP-UX)

tool to perform system management tasks like user creation, creating file systems, volume groups , logical volumes ,configuring tape drives ..etc.

How to Create a Soft Link in AIX

If a soft link for ABC has to be created in a target path then:-

1)Create a folder ABC in the source Path

2)Don’t create the folder ABC in the Target path

3)Execute the command

ln –s

Source path -> It’s the path where the Soft link of ABC appears and there is no directory named as ABC in this path.

Target path -. It’s the path where the actual directory ABC occurs.

Eg:

If we have to create a soft link for nuc in /usrsap/R3P/SYS/exe

1) Create a Folder nuc in /sapmnt/R3P/exe

2) Don’t create the Folder nuc in /usrsap/R3P/SYS/exe.

3) Execute the command:-

ln –s /sapmnt/SID/exe/nuc /usrsap/SID/SYS/exe/nuc

After executing this command a short link will appear in usrsap/SID/SYS/exe.

********************************************************************

ls – command to list the files in an AIX directory

Useful options
ls –l : Lists files in a directory in long format.
ls -a : Show files starting with '.' too - .file – where I am , .. – the parent directory.
ls -A : Show files starting with '.' but not '.' or '..'
ls -c : Displays/sorts by modification time [must be used with either option l and/or t ]
ls -d : Do not show subdirectory listings
ls -i : Display the i-node number of each file
ls -t : Put the listing in time order
ls -r : Put the listing in reverse order - usually used with a -t
ls -u : Must be used with either options l and/or t - displays/sorts by last-access time

********************************************************************

bootinfo -b reports last device the system booted from
bootinfo -k reports keyswitch position
1=secure, 2=service, 3=normal

bootinfo -r reports amount of memory (/ by 1024)
bootinfo -s (disk device) reports size of disk drive
bootinfo -T reports type of machine
ie rspc,rs6ksmp,rspc or chrp
bootinfo -y reports your hardware arquitecture (32bits or 64 bits)

bootinfo -K reports if the kernel in memory is 32bits or 64 bits

********************************************

grep Command

Syntax

grep [ -E -F ] [ -i ] [ -h ] [ -H ] [ -L ] [ -r -R ] [ -s ] [ -v ] [ -w ] [ -x ] [ -y ] [ [ [ -b ] [ -n ] ] [
-c -l -q ] ] [ -p [ Separator ] ] { [ -e PatternList ... ] [ -f PatternFile ... ] PatternList ... } [ File ...
]

Description

The grep command searches for the pattern specified by the Pattern parameter and writes each matching line to
standard output. The patterns are limited regular expressions in the style of the ed or egrep command. The grep
command uses a compact non-deterministic algorithm.

The grep command displays the name of the file containing the matched line if you specify more than one name in the
File parameter. Characters with special meaning to the shell ($, *, [, , ^, (, ), \ ) must be in quotation marks
when they appear in the Pattern parameter. When the Pattern parameter is not a simple string, you usually must
enclose the entire pattern in single quotation marks. In an expression such as [a-z], the - (minus sign) cml
specifies a range, according to the current collating sequence. A collating sequence may define equivalence classes
for use in character ranges. If no files are specified, grep assumes standard input.

Notes:
1 Paragraphs (under the -p flag) are currently limited to a length of 5000 characters.
2 Do not run the grep command on a special file because it produces unpredictable results.
3 Input lines should not contain the NULL character.
4 Input files should end with the newline character.
5 The newline character will not be matched by the regular expressions.
6 Although some flags can be specified simultaneously, some flags override others. For example, the -l option
takes precedence over all other flags. And if you specify both the -E and -F flags, the last one specified
takes priority.

Flags

-b
Precedes each line by the block number on which it was found. Use this flag to help find disk block numbers by
context. The -b flag cannot be used with input from stdin or pipes.
-c
Displays only a count of matching lines.
-E
Treats each pattern specified as an extended regular expression (ERE). A NULL value for the ERE matches every
line.

Note: The grep command with the -E flag is the same as the egrep command, except that error and usage messages
are different and the -s flag functions differently.

-e PatternList
Specifies one or more search patterns. This works like a simple pattern but is useful when the pattern begins
with a - (minus). Patterns should be separated by a new-line character. A NULL pattern can be specified by two
adjacent new-line characters or a quotation mark followed by a new-line character ("\n). Each pattern is
treated like a basic regular expression (BRE) unless the -E or -F flag is also specified. Multiple -e and -f
flags are accepted by grep. All of the specified patterns are used when matching lines, but the order of
evaluation is unspecified.
-F

Treats each specified pattern as a string instead of a regular expression. A NULL string matches every line.

Note: The grep command with the -F flag is the same as the fgrep command, except that error and usage messages
are different and the -s flag functions differently.

-f PatternFile
Specifies a file containing search patterns. Each pattern should be separated by a new-line character, and an
empty line is considered a NULL pattern. Each pattern is treated like a basic regular expression (BRE), unless
the -E or -F flag is also specified.
-h
Prevents the name of the file containing the matching line from being appended to that line. Suppresses file
names when multiple files are specified.
-H
If the -r or -R option is specified and a symbolic link referencing a file of type directory is specified on
the command line, grep will search the files of the directory referenced by the symbolic link and all the files
in the file hierarchy below it.
-i
Ignores the case (uppercase or lowercase) of letters when making comparisons.

-l
Lists just the names of files (once) which contain matching lines. Each file name is separated by a new-line
character. If standard input is searched, a path name of (StandardInput) is returned. The -l flag with any
combination of the -c and -n flags behaves like the -l flag only.
-L
If the -r or -R option is specified and a symbolic link referencing a file of type directory is specified on
the command line or encountered during the traversal of a file hierarchy, grep shall search the files of the
directory referenced by the symbolic link and all the files in the file hierarchy below it. If both -H and -L
are specified, the last option specified on the command line takes effect.
-n
Precedes each line with the relative line number in the file. Each file starts at line 1, and the line counter
is reset for each file processed.
-p[Separator]
Displays the entire paragraph containing matched lines. Paragraphs are delimited by paragraph separators, as
specified by the Separator parameter, which are patterns in the same form as the search pattern. Lines
containing the paragraph separators are used only as separators; they are never included in the output. The
default paragraph separator is a blank line.
-q
Suppresses all writing to standard output, regardless of matching lines. Exits with a zero status if an input
line is selected. The -q flag with any combination of the -c, -l and -n flags behaves like the -q flag only.
-r
Searches directories recursively. By default, links to directories are followed.
-R
Searches directories recursively. By default, links to directories are not followed.
-s
Suppresses error messages ordinarily written for nonexistent or unreadable files. Other error messages are not
suppressed.
-v
Displays all lines not matching the specified pattern.
-w
Does a word search.
-x
Displays lines that match the specified pattern exactly with no additional characters.
-y
Ignores the case of letters when making comparisons.
PatternList
Specifies one or more patterns to be used during the search. The patterns are treated as if they were specified
using the -e flag.
File

Specifies a name of a file to be searched for patterns. If no File variable is given, the standard input is
used.

Examples
1 To use a pattern that contains some of the pattern-matching characters *, ^, ?, [, ], \(, \), \{, and \},
enter:

grep "^[a-zA-Z]" pgm.s

This displays every line in pgm.s whose first character is a letter.
2 To display all lines that do not match a pattern, enter: grep -v "^#" pgm.s

This displays every line in pgm.s whose first character is not a # (pound sign).
3 To display all lines in the file1 file that match either the abc or xyz string, enter: grep -E "abcxyz" file1

4 To search for a $ (dollar sign) in the file named test2, enter:

grep \\$ test2

The \\ (double backslash) characters are necessary in order to force the shell to pass a \$ (single backslash,
dollar sign) to the grep command. The \ (single backslash) character tells the grep command to treat the
following character (in this example the $) as a literal character rather than an expression character. Use the
fgrep command to avoid the necessity of using escape characters such as the backslash.
5 To search recursively through /tmp to find files which have the word IBM without recursing through links
pointing to directories, type:

grep -R IBM /tmp
OR

grep -r -H IBM /tmp
6 To search recursively through /tmp to find files which have the word IBM and recurse through links as well,
type:

grep -r IBM /tmp
OR

grep -R -L IBM /tmp

Files

/usr/bin/grep
Contains the grep command.

Share this article :

+ comments + 2 comments

June 6, 2008 at 3:43 PM

Hi Everybody i am ashish , i am B.com Graduate from mumbai university and currently working in Tata interactive systems as a Sap Data support Executive in which i handel CRM and R3 i.e i maintain records of Client, prepare Quotaton , Contract so can anybody pls let me know is there any scope in it in future .Actually i work in tata interactive systems as a data entry in sap and only handels CRM and R3 and that to a part of it and pls i also need the information on Sap i.e what exactyly SAP is and whatever i am doing is valuable or not

Pls advice me that is there any scope for me in future

March 4, 2016 at 11:23 PM


Thanks for your informative article. Your post helped me a lot in understanding the career prospects in Mobile repairing....Mobile Repairing Institute in Delhi & Laptop Repairing Institutein Delhi

Post a Comment
 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. MY Blog - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger