Академический Документы
Профессиональный Документы
Культура Документы
Unix commands are the first thing needed by a unix sysadmin who are starting to work in unix
operating system . Unix operating systems comes with online manual system which can be
used to see the command details , syntax options and examples on while working on a unix
system. Unix manual can be accessed using man and it requires the man package installed
and MANPATH set to man directories. The manual page directories may differ in different unix
operating systems and man package may not be installed in all systems .
Following is a unix command tutorial with some of the most popular and useful commands
directory
File operation
Change read/write/execute
chmod mode file
mode of fil
chown chown [-R] [-h] owner[:group] file
move (rename ) file mv file1 file2 Rename file file1 as file2
Remove rm file Delete (remove) file f
Compare two files cmp file1 file2
Copy file file1 into file2 cp file1 file2
Sort Alphabetically sort file
Sort Numerically sort -n file
Split f into n-line pieces split [-n] f
match pattern grep pattern file Outputs lines that
Lists file differences diff file1 file2
head f Output beginning
head file
of file
Output end of file tail file
PROCESS
User admin
System Status
Environment Variable
Connectivity
backup and restore using tar tvf filename.tar — View the table of content of a tar
tar , TApeaRchive archive
tar xvf filename.tar — Extract content of a tar archive
tar cvf filename.tar file1 file2 file3 — Create a tar archive
called filename.tar using file1, file2,file3 .
tar can’t copy the special files , device files .Not suitable for
taking root backup.
backup and restore using cpio is mostly used in conjunction with other commands to
cpio , CopyInputOutput generate a list of files to be copied :
#ls | cpio -o > /dev/rmt/c0t0d0 — Copy the contents of a
directory into a tape archive:
#find . -depth -print | cpio -pd newdir — copy entire
directory to other place:
#find . -cpio /dev/rmt/c0t0d0 — Copy files in current
directory to a tape
cpio can copy special files and hence useful in taking root
backup containing device file.
Find files , directories
find files , directories Find command is used to find the files , directories and to run
commands on the list of files thus generated .By default, find
does not follow symbolic links.
find . -name *.log -print — Simple find to list log files
find . -name ‘*.log’ -exec rm {} \; — Simple find to find log
files and delete them .
find accepts a long list of options to find the files based on
different parameters such as create time , modified time , of
certain size etc. Please refer to man find for more option.