AIX Command Summary

Command Summary

Startup, Logoff and Shutdown

<Ctrl>d (exit)               logoff the system (or the current shell).
shutdown                    shuts down the system by disabling all processes. If in single-user mode, may want  to use -F option for fast shutdown. -r option will reboot system. Requires user to be root.

Directories

mkdir make directory
cd  change directory. Default is $HOME directory.
rmdir remove a directory (beware of files starting with ".")
rm remove file; -r option removes directory and all files and
subdirectories recursively.
pwd print working directory
ls list files
-a (all)
-l (long)
-d (directory information)
-r (reverse alphabetic)
-t (sort by time changed)
-C (multi column format)
-R (recursive listing)
-F (places / after each directory name & * after each exec file) 

Files - Basic
cat list file contents (concatenate).
Can open a new file with redirection, for example, cat > newfile.
Use <Ctrl>d to end input.
chmod change permission mode for files or directories.
•chmod =+- files or directories
•(r,w,x = permissions and u, g, o, a = who )
•can use + or - to grant or revoke specific permissions.
•can also use numerics, 4 = read, 2 = write, 1 = execute.
•can sum them, first is user, next is group, last is other.
•for example, "chmod 746 file1" is user = rwx, group = r, other =rw.

chown change owner of a files; for example. chown owner file
chgrp change group of a files
cp copy file
del delete files with prompting (rm for no prompting)
mv move and rename file
pg list file contents by screen (page)
h (help)
q (quit)
<cr> (next pg)
f (skip 1 page)
l (next line)
d (next 1/2 page)
$ (last page)
p (previous file)
n (next file)
. (redisplay current page)
. Current Directory
.. Parent Directory
/string (find string forward), ?string (find string backward), --
(move backward - pages), +- (move forward - pages)
rm remove (delete) files (-r option removes directory and all files and
subdirectories)
head print first several lines of a file
tail print last several lines of a file
wc report the number of lines (-l), words (-w), characters (-c) in a file.
No options gives lines, words, and characters.
su switch user
id displays your user ID environment how it is currently set
tty displays the device that is currently active. Very useful for
Xwindows where there are several pts devices that can be
created. It's nice to know which one you have active. who am i
will do the same.

Files - Advanced
awk programmable text editor / report write
banner display banner (can redirect to another terminal 'nn' with
'>/dev/ttynn')

 cal calendar (cal [month] year)
cut cut out specific fields from each line of a file
diff differences between two files
find find files anywhere on disk. Specify location by path (will search
all subdirectories under specified directory).
-name fl (file names matching fl criteria)
-user ul (files owned by user ul)
-size +n (or -n) (files larger (or smaller) than n blocks)
-mtime +x (-x) (files modified more (less) than x days ago)
-perm num (files whose access permissions match num)
-exec (execute a command with results of find command)
-ok (execute a command interactively with results of find
command)
-o (logical or) -print (display results. Usually included)
find syntax: find path expression action
•for example, find / -name "*.txt" -print
•or find / -name "*.txt" -exec li -l {} /;
(executes li -l where names found are substituted for {})
; indicates end-of-command to be executed and / removes
usual
interpretation as command continuation character)
grep search for pattern, for example, grep pattern files. Pattern can
include regular expressions.
-c (count lines with matches, but don't list)
-l (list files with matches, but don't list)
-n (list line numbers with lines)
-v (find files without pattern)
expression metacharacters
•[ ] matches any one character inside.
•with a - in [ ] will match a range of characters.
•&and. matches BOL when &and. begins the pattern.
•$ matches EOL when $ ends the pattern.
•. matches any single character. (same as ? in shell).
•* matches 0 or more occurrences of preceding character.
(Note: ".*" is the same as "*" in the shell).
sed stream (text) editor. Used with editing flat files.
sort sort and merge files
-r (reverse order); -u (keep only unique lines)
Editors
ed line editor
vi screen editor
INed LPP editor
emacs screen editor +
Shells, Redirection and Pipelining
< (read) redirect standard input; for example, command < file reads input
for command from file.
> (write) redirect standard output; for example, command > file writes
output for command to file overwriting contents of file.
>> (append) redirect standard output; for example, command >> file appends
output for command to the end of file.
2> redirect standard error (to append standard error to a file, use
command 2>> file) combined redirection examples:
•command < infile > outfile 2> errfile
•command >> appendfile 2>> errfile < infile
; command terminator used to string commands on single line
| pipe information from one command to the next command.
for example, ls | cpio -o > /dev/fd0 will pass the results of the ls
command to the cpio command.
/ continuation character to continue command on a new line.
Will be prompted with > for command continuation.
tee reads standard input and sends standard output to both standard
output and a file. For example, ls | tee ls.save | sort results in ls
output going to ls.save and piped to sort command.
Metacharacters
* any number of characters ( 0 or more)
? any single character
[abc] [ ] any character from the list
[a-c] [ ] match any character from the list range
 ! not any of the following characters (for example, leftbox !abc right
box)
; command terminator used to string commands on a single line
& command preceding and to be run in background mode
# comment character
/ removes special meaning (no interpretation) of the following
character
removes special meaning (no interpretation) of character in
quotes
" interprets only $, backquote, and / characters between the
quotes.
' used to set variable to results of a command;
for example, now='date' sets the value of now to current results of
the date command.
$ preceding variable name indicates the value of the variable.
Variables
= set a variable (for example, d=day sets the value of d to day).
Can also set the variable to the results of a command by the '
character;
for example, now=date sets the value of now to the current result
of the date command.
HOME home directory
PATH path to be checked
SHELL shell to be used
TERM terminal being used
PS1 primary prompt characters, usually $ or #
PS2 secondary prompt characters, usually >
$? return code of the last command executed
set displays current local variable settings
export exports variable so that they are inherited by child processes
env displays inherited variables
echo echo a message (for example, echo HI or echo $d).
Can turn off carriage returns with /c at the end of the message.
Can print a blank line with /n at the end of the message.

Tapes and Diskettes
format AIX command to format a diskette
backup backs up individual files.
-i reads file names form standard input
-v list files as backed up;
for example, backup -iv -f/dev/rmto file1, file2
-u backup file system at specified level;
for example, backup -level -u filesystem
Can pipe list of files to be backed up into command;
for example, find . -print | backup -ivf/dev/rmt0 where
you are in directory to be backed up.
restore restores commands from backup
-x restores files created with backup -i
-v list files as restore
-T list files stored of tape or diskette
-r restores filesystem created with backup -level -u;
for example, restore -xv -f/dev/rmt0
cpio copies to and from an I/O device. Destroys all data previously on
tape or diskette. For input, must be able to place files in the same
relative (or absolute) path name as when copied out (can
determine path names with -it option). For input, if file exists,
compares last modification date and keeps most recent (can
override with -u option).
-o (output)
-i (input)
-t (table of contents)
-v (verbose)
-d (create needed directory for relative path names)
-u (unconditional to override last modification date)
for example, cpio -o > /dev/fd0
file1
file2
<Ctrl-d>
or cpio -iv file1 < /dev/fd0
tar alternative utility to backup and restore files
pax alternative utility to cpio and tar commands
 Transmitting
mail send and receive mail. With userid sends mail to userid. Without
userid, displays your mail. When processing your mail, at the ?
prompt for each mail item, you can:
d - delete
s - append
q - quit
enter - skip
m - forward
mailx upgrade of mail
uucp copy file to other UNIX systems (UNIX to UNIX copy)
uuto/uupick send and retrieve files to public directory
uux execute on remote system (UNIX to UNIX execute)
System Administration
df display filesystem usage
installp install program
kill (pid) kill batch process with ID or (pid) (find using ps);
kill -9 (PID) will absolutely kill process
mount associate logical volume to a directory;
for example, mount device directory
ps -ef shows process status (ps -ef)
umount disassociate filesystem from directory
smit system management interface tool
Miscellaneous
banner displays banner
date displays current date and time
newgrp change active groups
nice assigns lower priority to following command
(for example, nice ps -f)
passwd modifies current password
sleep n sleep for n seconds
stty show and or set terminal settings
touch create a zero length files

xinit initiate X-Windows
wall sends message to all logged-in users
who list users currently logged in (who am i identifies this user)
man,info displays manual pages
System Files
/etc/group list of groups
/etc/motd message of the day, displayed at login.
/etc/passwd list of users and sign-on information. Password shown as !.
Can prevent password checking by editing to remove !.
/etc/profile system-wide user profile executed at login. Can override variables
by resetting in the user's .profile file.
Shell Programming Summary
Variables
var=string set variable to equal string. (NO SPACES).
Spaces must be enclosed by double quotes.
Special characters in string must be enclosed by single quotes to
prevent substitution.
Piping (|), redirection (<, >, >>), and & symbols are not
interpreted.
$var gives value of var in a compound
echo displays value of var; for example, echo $var
HOME = home directory of user
MAIL = mail file name
PS1 = primary prompt characters, usually $ or #
PS2 = secondary prompt characters, usually >
PATH = search path
TERM = terminal type being used
export exports variables to the environment
env displays environment variables settings
${var:-string} gives value of var in a command. If var is null, uses string instead.
$1 $2 $3... positional parameters for variable passed into the shell script
$* used for all arguments passed into shell script $# number of arguments passed into shell script
$0 name of shell script
$$ process ID (pid)
$? last return code from a command
Commands
# comment designator
&& logical-and. Run command following && only if command
preceding && succeeds (return code = 0).
|| logical-or. Run command following || only if command preceding
||fails (return code < > 0).
exit n used to pass return code nl from shell script. Passed as variable
$? to parent shell
expr arithmetic expressions
Syntax: expr expression1 operator expression2
operators: + - /* (multiply) / (divide) % (remainder)
for loop for n (or: for variable in $*); for example:
do
command
done
if-then-else if test expression
then command
elif test expression
then command
else
then command
fi
read read from standard input
shift shifts arguments 1-9 one position to the left and decrements
number of arguments
test used for conditional test, has two formats.
if test expression (for example, if test $- -eq 2)
if [ expression ]
(for example, if [ $# -eq 2 ]) (spaces req'd)
integer operators:
-eq (=)
-lt (<)
-le (=<)
-ne (<>)

-gt (>)
-ge (=>)
string operators:
=
!= (not eq.)
-z (zero length)
file status (for example, -opt file1)
-f (ordinary file)
-r (readable by this process)
-w (writable by this process)
-x (executable by this process)
-s (non-zero length)
while loop           while test expression
                             do
                            command
                            done
Miscellaneous
sh execute shell script in the sh shell
-x (execute step by step - used for debugging shell scripts)


vi Editor

Entering vi
vi file edits the file named file
vi file file2 edit files consecutively (via :n)
.exrc file that contains the vi profile
wm=nn sets wrap margin to nn
Can enter a file other than at first line by adding + (last line), +n
(line n), or +/pattern (first occurrence of pattern).
vi -r lists saved files
vi -r file recover file named file from crash
:n next file in stack
:set all show all options
:set nu display line numbers (off when set nonu)
:set list display control characters in file
:set wm=n set wrap margin to n
 :set showmode set display of INPUT when in input mode
Read, Write, Exit
:w write buffer contents
:w file2 file2 write buffer contents to file2
:w >> file2 write buffer contents to end of file2
:q quit editing session
:q! quit editing session and discard any changes
:r file2 read file2 contents into buffer following current cursor
:r! com read results of shell command com following current cursor
:! exit shell command (filter through command)
:wq or ZZ write and quit edit session
Units of Measure
h, l character left, character right
k or <Ctrl>p move cursor to character above cursor
j or <Ctrl>n move cursor to character below cursor
w, b word right, word left
&hat., $ beginning, end of current line
<CR> or + beginning of next line
- beginning of previous line
G last line of buffer
Cursor Movements
Can precede cursor movement commands (including cursor arrow) with number of times to
repeat; for example, 9--> moves right 9 characters.
0 move to first character in line
$ move to last character in line
&and. move to first nonblank character in line
fx move right to character x
Fx move left to character x
tx move right to character preceding character x
Tx move left to character preceding character x
; find next occurrence of x in same direction
, find next occurrence of x in opposite direction
w tab word (nw = n tab word) (punctuation is a word)
W tab word (nw = n tab word) (ignore punctuation)
b backtab word (punctuation is a word)
B backtab word (ignore punctuation)
e tab to ending char. of next word (punctuation is a word)
E tab to ending char. of next word (ignore punctuation)
( move to beginning of current sentence
) move to beginning of next sentence
{ move to beginning of current paragraph
} move to beginning of next paragraph
H move to first line on screen
M move to middle line on screen
L move to last line on screen
<Ctrl>f scroll forward 1 screen (3 lines overlap)
<Ctrl>d scroll forward 1/2 screen
<Ctrl>b scroll backward 1 screen (0 line overlap)
<Ctrl>u scroll backward 1/2 screen
G go to last line in file
nG go to line n
<Ctrl>g display current line number
Search and Replace
/pattern search forward for pattern
?pattern search backward for pattern
n repeat find in the same direction
N repeat find in the opposite direction
Adding Text
a add text after the cursor (end with <esc>)
A add text at end of current line (end with <esc>)
 i add text before the cursor (end with <esc>)
I add text before first nonblank char in current line
o add line following current line
O add line before current line
<esc> return to command mode
Deleting Text
<Ctrl>w undo entry of current word
@ kill the insert on this line
x delete current character
dw delete to end of current word (observe punctuation)
dW delete to end of current word (ignore punctuation)
dd delete current line
d erase to end of line (same as d$)
d) delete current sentence
d} delete current paragraph
dG delete current line thru end-of buffer
d&and. delete to the beginning of line
u undo last change command
U restore current line to original state before modification
Replacing Text
ra replace current character with a
R replace all characters overtyped until <esc> is entered
s delete current character and append test until <esc>.
s/s1/s2 replace s1 with s2 (in the same line only)
S delete all characters in the line and append text
cc replace all characters in the line (same as S)
ncx delete n text objects of type x; w, b = words, ) = sentences, } =
paragraphs, $ = end-of-line, &and.=beginning of line) and enter
append mode
C replace all characters from cursor to end-of-line.
Moving Text
p paste last text deleted after cursor (xp will transpose 2 characters)
P paste last text deleted before cursor
nYx yank n text objects of type x w, b = words, ) = sentences, } =
paragraphs, $ = end-of-line, and no x indicates lines. Can then
paste them with "p" command. Yank does not delete the original.
"ayy can use named registers for moving, copying, cut/paste with "ayy
for register a (use registers a-z). Can then paste them with "ap
command.
Miscellaneous
. repeat last command
J join current line w/next line

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值