|
开源主力军
 
|
1#
发表于 2005-9-30 14:59 只看该作者
[原创]进来—Solaris9基础知识(下载地址
Sun Certified System Administrator 9 Fundamental Book
Course ID:SA-119
Powered By 红头发(Syuu)
Preface
这本教程是根据Sun官方的Students Book SA-119(Solaris9 Fundamental)制作而成.其中有2部分偶省略了:"Using the vi Editor"和"Performing Remote Connections and File Transfers".原因是我打算专门改写1本关于vi editor的教程;至于"Performing Remote Connections And File Transfers"这部分嘛,是因为Students Book SA-239(Solaris9  art I)里完全有的,避免重复,省略~
希望这个教程对大家有所帮助.如有错误和不完善的地方请大家指正.我还将继续把Students Book SA-239/299(Solaris9  art I/II)写完.预祝大家在Solaris9学习的道路上,顺利!
红头发(Syuu)
Sept.11.2003
PS:感谢支持我的朋友们...SINCERELY!
Modules 1
Using the Desktop in the Solaris9 Operating Environment
4 main hardware components of a computer:
1.the RAM
2.the CPU
3.the input/output (I/O) devices
4.the hard disk or some other storage device
the Solaris Operating Environment:
1.SunOS 5.x operating system
2.Open Network Computing (ONC+) software
3.the Solaris CDE graphical user interface (GUI)
the 3 main components of the SunOS operating system:
1.the kernel
2.the shell
3.the directory hierarchy
in the Solaris OE, a user’s password:
1.must be six to eight characters in length
2.should contain at least two alphabetic characters and must contain at least one numeric or special character, such as a semicolon ( , an asterisk (*), or a dollar sign ($)
3.must differ from the user’s login name
4.must differ from the previous password by at least three characters
5.can contain spaces
6..cannot be the reverse of the user’s login name
(these password requirements do not apply to the system administrator’s root account password or to any password that is created for a regular user by the root user)
Modules 2
Using Command-Line Features and Help Resources
the following is an example of the format for commands:
command option(s) argument(s)
you can use more than one option with a command. you can list multiple options separately or combined after one dash (-)
to display the operating system information, enter the following:
$ uname
SunOS
$ uname -a
SunOS host1 5.9 Generic sun4u sparc SUNW,Ultra-5_10
$ uname -s
SunOS
$ uname -r
5.9
to display the date and time, enter the following:
$ date
Tue May 28 14:31:55 MDT 2002
to display the calendar, enter the following:
$ cal
May 2002
S M Tu W Th F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
$ cal 12 2002
December 2002
S M Tu W Th F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
to clear the terminal window, enter the following:
$ clear
you can enter multiple commands on a command line by using a semicolon (
eg.$ date;uname
Thu May 30 15:24:03 MDT 2002
SunOS
CTRL-C:terminates the command currently running
CTRL-D:indicates end-of-file or exit
CTRL-U:erases all characters on the current command line
CTRL-W:erases the last word on the command line
CTRL-S:stops output to the screen
CTRL-Q:restarts output to the screen after you have pressed CTRL-S
by default, the keyword lookup feature for searching man pages is not enabled. to enable this feature the root user must execute the catman -w command
#catman -w
#catman -w -M /usr/dt/man
#catman -w -M /usr/openwin/share/man
if the catman -w command has not been run, the user will see No such file or directory error messages when the man -k <keyword> command is executed
Modules 3
Viewing Directories and Files
to display the current working directory, enter the pwd command
to display hidden files, enter the ls -a command
use the ls -l command to view detailed information about the contents of a directory
eg.$ ls -l
total 2
-rw-rw---- 1 syuu staff 1319 Mar 14 10:12 dante
drwxr-xr-x 4 noko staff 512 Mar 14 10:12 dir2
to obtain detailed directory information for the dir1 directory, enter the ls -ld command.
$ ls -ld dir1
drwxr-xr-x 5 user1 staff 512 Feb 22 14:51 dir1
to view a recursive list of the contents of the dir1 directory, enter ls -R dir1
there are two ways to display file types:
1.use the ls -F command
2.use the file command
the symbols used in the ls -F output:
1./:directory
2.*:executable
3.null:plain text file/ASCII
4.@:symbolic link
(a symbolic link is a special type of file that points to another file or directory)
the format for the file command is:
file <filename(s)>
.:current or working directory
..:parent directory, the directory directly above the current working directory
(Directories always contain a link to their parent directory (..) and a link to themselves (.))
you can return to your home directory from any directory by entering the cd command without an argument
you can also use the tilde (~) to represent your home directory in a relative path. the tilde (~) in the following example represents the syuu's home directory
eg.$ cd ~/dir1/fruit
$ pwd
/export/home/dir1/fruit
the cat command displays the contents of one or more text files on the screen. the cat command displays the entire contents of the file without pausing:
cat <filename>
(do not use the cat command to read binary files. using the cat command to read binary files can cause a terminal window to freeze)
the format for the more command is:
more <filename(s)>
(do not use the more command to read binary files. using the more command to read binary files can cause a terminal window to freeze)
the head command displays the first 10 lines of a file. you can change the number of lines displayed by using the -n option. the -n option displays n lines starting at the beginning of the file.
the format for the head command is:
head -n <filename(s)>
the tail command displays the last 10 lines of a file. you can change the number of lines displayed by using the -n or +n options. the -n option displays n lines from the end of the file. the +n option displays from line n to the end of the file
the format for the tail command is:
tail -n <filename> or tail +n <filename>
the wc command displays the number of lines, words, and characters contained in a file.the format for the wc command is:
wc -option(s) <filename(s)>
options for the wc command:
-l:the line count
-w:the word count
-c:the byte count
-m:the character count
using the wc command without options displays the number of lines, words, and characters contained in the file
Modules 4
Changing the Solaris Operating Environment Directory Contents
use the cp command to copy the contents of a file to another file.the format for the cp command when copying files is:
cp -option <source(s)> <target>
the source is a file. the target is either a file or a directory
eg.copy the feathers file to a new file named feathers_6:
$ cp feathers feathers_6
$ ls
feathers_6 file2 fruit feathers tutor.vi
use the cp command with the -i option to prevent overwriting existing files when copying either a single file or multiple files
use the cp command with the -r option to copy a directory and its contents to another directory. if the destination directory does not exist,the cp command creates a new directory with that name. if you do not use the -r option, you receive the error message
the format for the cp command when copying directories is:
cp -option <source(s)> <destination>
options for the cp command:
-i:prevents you from accidentally overwriting existing files or directories
-r:includes the contents of a directory, including the contents of all subdirectories, when you copy a directory
use the mv command to move a file to a different directory. the -i option prevents you from accidentally overwriting the existing files the format for the mv command is:
mv -i <source> <target>
the source is the old file or directory name. the target is the new file or directory name
use the touch command to create an empty file. you can create multiple files on the same command line. if the file name or directory name already exists, the touch command updates the modification time and access time to the current date and time
the format for the touch command is:
touch <filename>
use the mkdir command with a directory_nameto create a single directory. if the directory_name includes a path name, use the mkdir
command with the -p option. the command used with the -p option creates all of the non-existing parent directories that do not yet exist in the path to the new directory. the formats for the mkdir command include:
mkdir <directory_name>
mkdir -p <directory_names>
use the mv command to rename files and directories
use the rm command to remove a file or multiple files on the same command line.
the format for the rm command is:
rm -option <filename>
the -i option prompts you for confirmation before removing any file
the rm command with the -r option is used to remove directories that contain files and subdirectories.to remove a directory you are currently working in, you must change to the parent directory of that directory
use the rmdir command to remove empty directories
the format for the rmdir command is:
rmdir <directory(s)>
use the rm command with the -r option to remove directories that contain files and subdirectories
the format for the rm command is:
rm -option(s) <directory(s)>
options for the rm command:
-r:includes the contents of a directory and the contents of all subdirectories when you remove a directory
-i:prevents accidental removal of existing files or directories
a symbolic link is a pointer that contains the path name to another file or directory. the link makes the file or directory easier to access if it has a long path name. a symbolic link file is identified by the letter l in the file type field. this can be viewed with the ls -l command output
use the ln -s command to create a symbolic link file. you can use either relative or absolute path names to create a symbolic link file
the format for the ln -s command is:
ln -s <source_file> <target_file>
the source_file variable refers to the file you use to create the link to,while the target_file variable refers to the symbolic link name. when creating a symbolic link, the source_file might or might not already exist. if the source_file does not exist, a symbolic link that points to a non-existing file is created
use the rm command to remove a symbolic link file in the same manner as you would remove a standard file
Modules 5
Searching Files and Directories
the grep command searches the contents of one or more files for a character pattern
the format for the grep command is:
grep option(s) <pattern> <filename(s)>
options for the grep command:
-i:ignores case
-l:lists the names of files with matching lines
-n:precedes each line with the relative line number in the file
-v:inverts the search to display lines that do not match the pattern
-c:counts the lines that contain the pattern
-w:searches for the expression as a word, ignoring those matches that are substrings of larger words
regular expression metacharacters:
1.^
example:’^pattern’
result:matches all lines beginning with “pattern”
2.$
example:’pattern$’
result:matches all lines ending with “pattern”
3..
example:’p.....n’
result:matches lines containing a “p,” followed by five characters, and followed by an “n”
4.*
example:’[a-z]*’
result:matches lowercase alphanumeric characters or nothing at all
5.[ ]
example:’[^a-m]attern’
result:matches lines not containing “a” through “m” and followed by “attern”
the egrep command searches the contents of one or more files for a pattern using extended regular expression metacharacters
extended regular expression metacharacters:
1.+
example:’[a-z]+ark’
result:matches one or more lowercase letters followed by “ark” (for example, “airpark,” “bark,” “dark,” “landmark,” “shark,” “sparkle,” “trademark”)
2.x|y
example:’apple|orange’
result:matches for either expression
3.( | 
example:’(1|2)+’ ’search(es|ing)+’
result:matches for one or more occurrences (for example, “1” or “2”, “searches”, or “searching”)
the format for the egrep command is:
egrep -option(s) <pattern> <filename(s)>
the fgrep command searches a file for a literal string or a group of characters. the fgrep command reads all regular expression characters literally. regular expression metacharacters have no special meaning to the fgrep command, for example a ? character is interpreted as a question mark and a $ character is interpreted as a dollar sign
the format for the fgrep command is:
fgrep option(s) <string> <filename(s)>
eg.to search for all lines in the file containing a literal asterisk (*) character,enter the following:
$ fgrep ’*’ /etc/system
the find command recursively descends the directory hierarchy in the path name list, seeking those files that match the criteria
the format for the find command is:
find pathname(s) <expression(s)> <action(s)>
expressions for the find command:
1.-name <filename>:finds files matching the specified filename. metacharacters are acceptable if placed inside " "
2.-size [+|-]n:finds files that are larger than +n, smaller than -n, or exactly n. the n represents 512-byte blocks
3.-atime [+|-]n:finds files that have been accessed more than +n days, less than -n days, or exactly n days
4.-mtime [+|-]n:finds files that have been modified more than +n days ago, less than -n days ago, or exactly n days ago
5.-user <loginID>:finds all files that are owned by the loginID name
6.-type:finds a file type, for example, f (file) or d (directory)
7.-perm:finds files that have certain access permission bits
actions for the find command:
1.-exec <command> {} \;:runs the specified command on each file located. a set of braces, {}, delimits where the file name is passed to the command from the preceding expressions. a space, backslash, and semicolon ( \ delimits the end of the command. There must be a space before the backslash (\)
2.-ok <command> {} \;:requires confirmation before the find command applies the command to each file located. this is the interactive form of the -exec command
3.-print:instructs the find command to print the current path name to the terminal screen. this is the default
4.-ls:displays the current path name and associated statistics,such as the inode number, the size in kilobytes, protection
mode, the number of hard links, and the user
eg.to search for a file called dante starting in your home directory, enter the following:
$ find ~ -name dante
to search for and delete files called core starting at your home directory,enter the following:
$ find ~ -name core -exec rm {} \;
(no output is returned regardless if any core files are found)
to look for all files that have not been modified in the last two days starting at the current directory, enter the following:
$ find . -mtime +2
to find files larger than 10 blocks (512-byte blocks) starting at your home directory, enter the following:
$ find ~ -size +10
to search for files that end with the characters es starting at your home directory, enter the following:
$ find ~ -name ’*es’
Modules 6
Using the vi Editor
<omitted>
Modules 7
Using Basic File  ermissions
you can use the ls -l command and the ls -n command to view the permissions for a given file or directory
there are 3 types of permissions in the owner, group, and other permission sets. these permissions are represented by the characters r (read), w (write), and x (execute). the presence of a character, such as r indicates that permission is granted. the dash (-) symbol in place of a character indicates that the permission is denied
read:
1.access for a file:you can display file contents and copy the file
2.access for a directory:you can list the directory contents with the ls command
write:
1.access for a file:you can modify the file contents
2.access for a directory:if you also have execute access, you can add and delete files in the directory
execute:
1.access for a file:you can execute the file if it is an executable. you can execute a shell script if you also have read and execute
permissions
2.access for a directory:you can use the cd command to access the directory. if you also have read access, you can run the ls -l command on the directory to list contents
you can modify the permissions set for files or directories by using the chmod command. either the owner of the file or directory or the root user can use the chmod command to change permissions.the chmod command can modify permissions specified in either symbolic mode or octal mode
the format for the chmod command in symbolic mode is:
chmod <symbolic_mode> <filename>
<symbolic_mode>:
1.<who>
2.<op>
3.<permission(s)>
<who>:
1.u wner (user) permissions
2.g:group permissions
3.o ther permissions
4.a:all permissions (owner, group, other)
<op>:
1.+:add permissions
2.-:remove permissions
3.=:assign permissions absolutely
<permission(s)>:
1.r:read
2.w:write
3.x:execute
eg.to remove the read permission for the group, enter the following:
$ chmod g-r dante
to add an execute permission for the owner (user) and a read permission for the group and other, enter the following:
$ chmod u+x,go+r dante
(there is no space in u+x,go+r)
the format for the chmod command in octal mode is:
chmod <octal_mode> <filename>
the octal_mode option consists of three octal numbers, 0 to 7, that represent a combination of permissions for the file or directory
assigned octal values for permissions:
1.read:4
2.write:2
3.execute:1
the chmod command automatically fills in any missing digits to the left with zeros
eg.to change group permission to read and execute only, enter the following:
$ chmod 755 dante
every new file or directory created has a set of default permissions assigned to it. you create and modify these permissions with the umask utility
in the Solaris OE, the default umask value is 022
to view the umask value, enter the umask command:
$ umask
022
(depending on the shell, the umask value appears as either 0022 (sh), 022 (ksh), or 22 (csh))
the Solaris OE automatically assigns initial permission values at file and directory creation:
1.the initial permission value specified by the system for a file creation is 666 (rw-rw-rw-)
2.the initial permission value specified by the system for a directory creation is 777 (rwxrwxrwx)
you can calculate the default permissions for new files and directories by subtracting the umask value from the initial value specified by the system in symbolic mode
eg.the initial permissions for a new file in symbolic mode are:
rw-rw-rw-(666)
use the default umask value of 022 to remove (or deny) write permission for group and other.the result in octal mode is:
644
you can change the umask value to a new value on the command line
eg.change the umask value to 027 and verify the new value, enter the following:
$ umask 027
$ umask
027
the new umask value affects only those files and directories that are created from this point forward. however, if the user logs out of the system, the new value (027) is replaced by the old value (022) on subsequent logins because the umask value was changed using the command line
Modules 8
Using Commands Within the Korn Shell
do not use these metacharacters when creating file and directory names. these characters hold special meaning to the shell
the tilde and plus (~+) characters represent the current working directory.the tilde and dash (~-) characters represent the previous working directory
the dash (-) character in the shell represents the previous working directory
the asterisk (*) character is often referred to as a wild card character that represents any zero or more characters except the leading period (.) of a hidden file
eg.to list all files and directories that end with the number 3, followed by zero or more other characters, enter the following:
$ ls *3
file.3 file3
the question mark (?) character represents any single character except the leading period (.) of a hidden file
the square bracket ([]) characters represent a set or range of characters for a single character position.a set of characters is any number of specific characters, for example,[acb]. the characters in a set do not generally need to be in any order.for example, [abc] is the same as [cab]
a range of characters is a series of ordered characters. a range lists the first character, a hyphen (-), and the last character, for example, [a-z] or[0-9]
there are 2 types of quotation marks that mask the special meaning of metacharacters:
1.single forward quotation marks (’ ’)
2.double quotation marks (" ")
single forward quotation marks instruct the shell to ignore all enclosed metacharacters.double quotation marks instruct the shell to ignore all enclosed metacharacters except the following three characters: $ ‘ \
a backslash (\) character in front of a metacharacter prevents the shell from interpreting the next character as a metacharacter.
eg.to ignore the special meaning of the dollar sign metacharacter, enter the following:
$ echo ’$SHELL’
$SHELL
to interpret the special meaning of the dollar sign metacharacter, enter the following:
$ echo "$SHELL"
/bin/ksh
to ignore the special meaning of the dollar sign metacharacter when you use double quotes, enter the following:
$ echo "\$SHELL"
$SHELL
to execute and display the output for the date command, enter the following:
$ echo “Today’s date is ‘date‘”
Today’s date is Tue May 2 14:10:05 MDT 2002
$ echo “The user is currently in the $(pwd) directory.”
The user is currently in the /export/home/syuu directory.
echo:writes arguments to the standard output
standard input(default:keyboard)---shell---standard output(default:screen)/standard error(default:screen)
you can redirect input to and output from commands by using redirection metacharacters. there are three redirection metacharacters, the greater than (> character, the less than (< character, and the pipe (|) character
stdin:0
stdout:1
stderr:2
process a file as standard input instead of reading input from the keyboard
<command> < <filename> or <command0> < <filename>
eg.to use the noko file as input for the mailx command, enter the following:
$ mailx user1 < ~/noko
a command using the greater than (> metacharacter to direct standard output to a file instead of printing the output to the screen. if file does not exist, the system creates it. if the file exists, the redirection overwrites the contents of the file
<command> > <filename> or <command1> > <filename>
eg.to list all the current processes running on the system and redirect that list of processes into a file called process_list, enter the following:
$ ps -ef > process_list
a command using two greater than (>> metacharacters to direct standard output to the end of existing content in a file. if the file does not exist, the system creates it
<command> >> <filename>
eg.to append That’s my process file to the end of the my_file file,enter the following:
$ ps > my_file; cat my_file
PID TTY TIME CMD
663 pts/5 0:01 ksh
(the semicolon ( is a shell metacharacter that allows multiple commands on a single command line)
a command using the file descriptor number (2) and the greater than (> metacharacter to redirect any standard error messages
<command> 2> <filename>
eg.$ find /etc -type f -exec grep PASSREQ {} \; -print 2> /dev/null
# PASSREQ determines if login requires a password.
PASSREQ=YES
/etc/default/login
(the -print expressions cause the current path name to print to the screen)
a command redirecting standard output to a file and standard error to the same file. the syntax 2>&1 instructs the shell to redirect stderr (2) to the same file that receives stdout (1)
<command1> > <filename> 2>&1
eg.to print standard output and standard error to the dat file, enter the following:
$ ls /var /test 1> dat 2>&1
$ more dat
/test: No such file or directory (stderr)
/var: (stdout)
adm (stdout)
……
a command using the pipe (|) character to redirect standard output to the standard input of another command
<command> | <command>
command history is shared among all Korn shells for a given user
the history command displays previously executed commands. by default, the history command displays the last 16 commands to standard output.the format for the history command is:
history option
-r:in reverse order
-n:display the command history without line numbers
-X(numeric):display the current command and the four commands preceding it
eg.to display the most recent cd command to the most recent ls command,enter the following:
$ history cd ls
31 cd
32 man lp
33 date
34 ls
……
the Korn shell stores command history in a file specified by the HISTFILE variable. the default file is$HOME/.sh_history. you can use the HISTSIZE variable to specify the number of commands to store in this buffer. if this variable is not set, then the shell stores the most recent 128 commands
the r command is an alias built into the Korn shell that enables you to repeat a command
eg.to re-execute a command by line number using the r command, enter the line number, for example, 160:
$ history
155 history
156 cat dante
157 history
158 date
159 cal
160 ls
161 cd
r 160
you can also use the r command to re-execute a command beginning with a particular character, or string of characters
eg.to repeat the most recent occurrence of a command beginning with the letter “c,” replace dir1 with dir2, and execute the modified command, enter the following:
$ history
...
100 cd
101 cat dante
102 ls
103 cd ~/dir1
104 history
$
$ r c
cd ~/dir1
$ r dir1=dir2
cd ~/dir2
use the vi editor to turn on and enable the shell history editing feature with one of the following commands:
$ set -o vi or $ export EDITOR=/bin/vi or $ export VISUAL=/bin/vi
(all 3 commands turn on vi command-line editing for the shell. to verify this, you can use the set -o command)
you can access a command in the history buffer, edit the command with the vi editor, and execute the modified command by following these steps:
1. verify that the built-in vi editor is enabled
$ set -o | grep -w vi
vi on
2. type the history command to view the command history list
$ history
3. press ESC to access the command history list use the following keyboard keys to move the cursor through the
command history
a.k:moves the cursor up one line at a time
b.j:moves the cursor down one line at a time
c.l:moves the cursor to the right
d.h:moves the cursor to the left
(you cannot use the arrow keys to move the cursor within the command history)
4. use the vi commands to edit any previously executed command
5. to execute a modified command, press Enter
you can modify 3 initialization files in your home directory to customize your working environment.
1.when you log in, the Korn shell looks for an environmental initialization file called .profile. the .profile file contains the ENV variable.you can choose and set any name for the ENV variable.the shell executes the commands in the .profile file first and the commands in the ENV variable next
2.in addition, the shell can be directed to a file that has been customized specifically for the Korn shell. this file is typically named .kshrc. then the shell prompt ($) appears on the screen, and the Korn shell waits for commands
3.the Common Desktop Environment (CDE) reads another initialization file, the .dtprofile file, upon execution. you can modify this configuration file to customize the desktop environment
the .profile file is an initialization file that you define in your home directory. the login shell executes the .profile file when you log in. you can customize environment variables and terminal settings in the .profile file to modify your working environment. you can also instruct the system to initiate applications in the .profile file
(the /etc/profile file is a separate systemwide file that the system administrator maintains. this file sets up tasks that the Korn shell executes for every user who logs in)
the .kshrc file in your home directory contains shell variables and aliases. the system executes the .kshrc file every time it starts a ksh subshell.you typically set the following items in the .kshrc file:
1.shell prompt definitions (PS1, PS2)
2.alias definitions
3.shell functions
4.history variables
5.shell options (set -o option)
when you make changes to your individual initialization files, the changes take effect the next time you log in. however, if you want the changes to take effect immediately, you can source the .profile file and the .kshrc file using the dot (.) command
$ . ~/.profile
$
$ . ~/.kshrc
(sourcing or reading the .profile file and the .kshrc file only updates the current shell)
the.dtprofile, resides in your home directory. the .dtprofile file determines generic and customized settings for the CDE. your variable settings in the .dtprofile file can overwrite any default CDE settings.
(if the DTSOURCEPROFILE variable is set to true, then the dtlogin causes the shell to read the .profile file. if this variable does not exist or it is not set to true, then the .profile file is not read by the shell)
each time you log in to the CDE, the shell reads the .dtprofile file and then your .profile file and your .kshrc file. the shell reads the .profile and .kshrc files again when you open a console window. the shell also reads the .kshrc file when you open a terminal window in the CDE
Modules 9
Performing Basic Process and Job Control
the desktop login daemon (dtlogin) provides a graphical prompt that you use to log in
every process is assigned a unique process identification number (PID),which the kernel uses to track and manage the process. you can use PID to identify and control processes
generally the UID and GID associated with a process are the same as the UID and GID of the user who started the process
when one process creates another, the first process is considered to be the parent of the new process. the new process is called the child process.while the child process runs, the parent process waits. when the child finishes its task, it informs the parent process. the parent process then terminates the child process. if the parent process is an interactive shell, a prompt appears, ready for a new command
you use the process status (ps) command to list the processes that are scheduled to run on the system.for each process, the ps command displays the PID, the terminal identifier (TTY), the cumulative execution time (TIME), and the command name (CMD)
the format for the ps command is:
ps options
options for the ps command:
1.-e:prints information about every process on the system,including the PID, TTY, TIME, and CMD
2.-f:generates a full (verbose) listing, which adds fields including the UID, parent process identification number (PPID), and process start time (STIME)
output for the ps -ef command:
1.UID:the user name of the owner of the process
2.PID:the unique process identification number of the process
3.PPID:the parent process identification number of the process
4.C:the central processing unit (CPU) utilization for scheduling. this value is obsolete
5.STIME:the time the process started ( hh:mm:ss)
6.TTY:the controlling terminal for the process. note that system processes (daemons) display a question mark (?),indicating the process started without the use of a terminal
7.TIME:the cumulative execution time for the process
8.CMD:the command name, options, and arguments
to search for a specific process, you can combine the ps and grep commands using the pipe (|) character
eg.to find active processes with names that contain the string lp, enter the following:
$ ps -e | grep lp
you can use the pgrep command to search for specific processes by name.by default, the pgrep command displays the PID of every process that matches the criteria you specify on the command line.the format for the pgrep command is:
pgrep options <pattern>
options for the pgrep command:
1.-x:displays the PIDs that match the pattern exactly.
2.-n:displays only the most recently created PID that contains the pattern
3.-U <uid>:displays only the PIDs that belong to the specified user. this option uses either a user name or a UID
4.-l:displays the name of the process along with the PID
5.-t <term>:displays only those processes that are associated with a terminal in the term list
eg.to display the PID of any process with a name that contains the string lp,enter the pgrep command as follows:
$ pgrep lp
to display the PID and name of any process associated with a terminal window, enter the pgrep command with the -lt options
$ pgrep -lt pts/2
697 ksh
(the dtmail process only appears if you have the CDE mail process running; it does not run by default)
a signal is a message that you can send to a process. processes respond to signals by performing the action that the signal requests. signals are identified by a signal number and by a signal name, and each signal has an associated action
some of the available signals:
1.signal number:1
signal name:SIGHUP
event:hang up
definition:a hang-up signal that drops a telephone line or terminal connection.this signal also causes some programs to re-initialize themselves without terminating
default response:exit
2.signal number:2
signal name:SIGINT
event:interrupt
definition:an interrupt signal you generate from your keyboard, usually using CTRL-C
default response:exit
3.signal number:9
signal name:SIGKILL
event:kill
definition:a signal that kills a process. a process cannot ignore this signal
default response:exit
4.signal number:15
signal name:SIGTERM
event:terminate
definition:a signal that terminates a process in an orderly manner. some processes ignore this signal. this is the default signal that kill and pkill send
default response:exit
you use the kill command to send a signal to one or more processes. you can use the kill command only on processes that you own. the root user can use the kill command on any process. the kill command sends signal 15, the terminate signal, by default. this signal causes the process to terminate in an orderly manner.the format for the kill command is:
kill <-signal> <PID(s)>
eg.to terminate the dtmail process using the kill command,enter the following:
$ pgrep -l mail
215 sendmail
12047 dtmail
$ kill 12047
you can force processes that do not respond to signal 15 to terminate by using signal 9 with the kill command. to terminate a process using signal 9, enter the following:
$ kill -9 <PID>
(use the kill -9 command only when necessary. when you use the kill -9 command on an active process, the process terminates instantly instead of performing an orderly shutdown. using signal 9 on processes that control databases or programs that update files could cause data corruption)
you use the pkill command to send signals to processes. the pkill command sends signal 15, the terminate signal, by default. the pkill command allows you to use process names to identify the process you want to terminate.the format for the pkill command is:
pkill <-options> <pattern>
to terminate a process using signal 9, enter the following:
$ pkill -9 -x <process_name>
a job is a process that the shell can manage. shells start and control jobs.because jobs are processes, each job has an associated PID. the shell also assigns each job a sequential job ID number
when you execute a command in a terminal window, the command occupies that terminal window until it completes. this type of job is called a foreground job
when you enter an ampersand (&) symbol at the end of a command line,the command runs without occupying the terminal window. the shell prompt is displayed immediately after you press Enter. this type of job is called a background job
if you press CTRL-Z for a foreground job, or use the stop command for a background job, the job stops. this is called a stopped job
job control commands:
1.jobs:lists all jobs that are currently running or are stopped in the background
2.bg %n:runs the current or specified job in the background ( n is the job ID)
3.fg %n:brings the current or specified job into the foreground ( n is the job ID)
4.CTRL-Z:stops the foreground job and places it in the background as a stopped job
5.stop %n:stops a job that is running in the background ( n is the job ID)
eg.to run the sleep command in the background, enter the following:
$ sleep 500 &
[1] 3028
(the sleep command suspends execution of a program for n seconds)
when a background job has finished and you press Enter, the shell displays a message indicating that the job is done.
[1] + Done sleep 500 &
you use the jobs command to display the list of jobs that are running or stopped in the background. For example:
$ jobs
[1] + Running sleep 500 &
you use the fg command to bring a background job to the foreground:
$ fg %1
sleep 500
you use the CTRL-Z keys and bg command to return a job to the background. The CTRL-Z keys suspend the job, and place it in the background as a stopped job. the bg command runs the job in the background
eg.$ sleep 500
^Z[1] + Stopped (SIGTSTP) sleep 500
$ jobs
[1] + Stopped (SIGTSTP) sleep 500
$ bg %1
[1] sleep 500&
$ jobs
[1] + Running sleep 500
to stop a background job, use the stop command and specify the job ID number of the job you want to stop
eg.$ jobs
[1] + Running sleep 500&
$ stop %1
$ jobs
[1] + Stopped (SIGSTOP) sleep 500&
$
you can terminate a job using the kill command
eg.to terminate the job running the sleep command, enter the following:
$ jobs
[1] + Stopped (SIGSTOP) sleep 500&
$ kill %1
[1] + Terminated sleep 500&
$ jobs
Modules 10
Performing Remote Connectionsand File Transfers
<omitted>
Modules 11
Creating Archives
the tar command archives files to and extracts files from a single file called a tar file. the default device for a tar file is a magnetic tape device. the format for the tar command is:
tar <function(s)> <archivefile> <filename(s)>
(you should use relative path names to archive files)
functions for the tar command:
1.c:creates a new tar file
2.t:lists the table of contents of the tar file
3.x:extracts files from the tar file
4.f:specifies the archive file or tape device. the default tape device is /dev/rmt/0. If the name of the archive file is “-”, the tar command reads from standard input when reading from a tar archive, or writes to standard output if creating a tar archive
5.v:executes in verbose mode, writes to standard output
6.h:follows symbolic links as standard files or directories
to create an archive on a tape, first verify that the system has a tape drive available. you can use the mt utility with the status option to print status information about the tape unit. you use the mt utility to send commands to a magnetic tape drive
eg.how to use the default tape device to archive your home directory. in this example, Syuu creates a tape archive of the Syuu home directory.
$ cd
$ mt -f /dev/rmt/0 status
<output will be your local tape device info>
$ tar cvf /dev/rmt/0 .
a ./ 0 tape blocks
a ./dante 106 tape blocks
a ./file2 1 tape blocks
<output omitted>
how to archive the file1, file2, and file3 files in an archive file called files.tar:
$ cd
$ tar cvf files.tar file1 file2 file3
a file1 2K
a file2 1K
a file3 1K
before you can create a file archive on a diskette, you must insert a diskette into the appropriate drive on the system. then you must run the volcheck command. this command informs the Volume Management program to check for media in a drive.the format for the volcheck command is:
volcheck -v device_pathname
if you use the volcheck -v command without a device path name, one of the following messages appears:
media was found or no media was found
(the device path name for a diskette is /dev/diskette. you can use the device path name to instruct Volume Management to check each device path name in sequence and determine if new media has been inserted in the drive)
eg.how to use the cp command to copy an archive file from your home directory to a diskette:
$ cd /floppy/floppy0
$ ls
$
$ cd
$ cp files.tar /floppy/floppy0
$ ls /floppy/floppy0
files.tar
to eject a diskette from the diskette drive do one of the following:
1.enter cd to change from the /floppy/floppy0 directory to your home directory
2.enter eject floppy
(you cannot eject removable devices while you are in the current working directory for the device. if you see an error message, such as Device busy, when trying to eject the diskette, you might still be in the working directory on the diskette. use the pwd command to see if you are in the /floppy/floppy0 directory. if you are in the /floppy/floppy0 directory, enter the cd command to return to your home directory. then enter the eject command)
to view the contents of the Syuu home directory on a tape, enter the following command:
$ tar tvf /dev/rmt/0
to view the contents of the files.tar archive file, enter the following command:
$ tar tf files.tar
to retrieve all the files from the tape archive, enter the following commands:
$ cd
$ tar xvf /dev/rmt/0
how to extract files from the files.tar archive file for placement into the current directory:
$ tar xvf files.tar
how to retrieve the archived file files.tar from a diskette:
$ volcheck -v /dev/diskette
$ cd /floppy/floppy0
$ ls
files.tar
$ cp files.tar /export/home/user1
$ cd
$ ls files.tar
files.tar
$ tar xvf files.tar
the jar command has syntax similar to the tar command, but the jar command compresses the named files in addition to archiving the files.the jar command copies and compresses multiple files into a single archive file.the format for the jar command is:
jar <option(s)> <destination> <filename(s)>
options for the jar command:
1.c:creates a new jar file
2.t:lists the table of contents of a jar file
3.x:extracts the specified files from the jar file
4.f:specifies the jar file to process (for example, /tmp/ file.jar). the jar command sends the data to the screen (stdout) if the f option is not used
5.v:executes in verbose mode
how to use the jar command to copy and compress multiple files into a single archive file called bundle.jar:
$ jar cvf /tmp/bundle.jar *
(the jar command does not back up symbolic links as links. the jar command resolves the symbolic link and copies the file’s contents)
Modules 12
Compressing, Viewing, and Uncompressing Files
you use the compress command to reduce the size of a file.the format for the compress command is:
compress <-v> <filename>
when you compress a file, the compress command replaces the original file with a new file with a .Z extension. the ownership and modification time of the original file remain the same, but the contents of the file change
-v:verbose output
(compressing a file that has already been compressed makes the file size larger, not smaller)
you use the zcat command to view files that were compressed with the compress command. the zcat command interprets the compressed data and displays the contents of a file as if it were not compressed. the zcat command does not change the contents of a compressed file.the format for the zcat command is:
zcat <filename>
(the command zcat <filename> is functionally identical to the uncompress -c <filename> command)
eg.how to view the contents of the compressed file called files.tar.Z:
$ zcat files.tar.Z | more
the uncompress command restores a compressed file back to its original state.the format for the uncompress command is:
uncompress <options> <filename>
-v:verbose
-c:send the contents of a compressed file to the screen (stdout), without changing the compressed (.Z) file
the gzip command reduces the size of files. when the gzip command successfully compresses a file, the file is replaced by a new file with the same name and a.gz extension. the files keep the same ownership modes, access, and modification times.the gzip command compresses regular files.the format for the gzip command is:
gzip <-v> <filename(s)>
-v:verbose
(The gzip command performs the same general function as the compress command, but the gzip command generally produces smaller files)
you use the gunzip command to restore a file that has been compressed with the gzip command.how to uncompresses the file1.gz file:
$ gunzip file1.gz
you use the gzcat command to view files that were compressed with either the gzip command or the compress command.the gzcat command does not change contents of the compressed file. the compressed file remains on the disk in compressed form.the format for the gzcat command is:
gzcat <filename>
(the gzcat filenamecommand is functionally identical to the gunzip -c filenamecommand)
the zip command compresses multiple files into a single archive file. the zip command adds the .zip extension to the file name of the compressed archive file if you do not assign a new file name with an extension.the format for the zip command is:
zip <-r> <target_filename> <source_filename(s)>
how to list the files in a zip archive:
$ unzip -l <zipfile>
the jar command and the zip command create compatible files.the unzip command can uncompress a jar file, and the jar command can uncompress a zip file
Fin
Bonus
伴随着小美的《亲爱的你怎么不在身边》,这本教程总算是写完了.新学期才搬完宿舍,网线迟迟没布好,在Chinaitlab消失也有一段时间了.真心希望这本教程对大家能有帮助.再次感谢Chinaitlab内外的朋友们.还是那句话:多年后回忆当初努力的日子里有你,你才是成功的...
Then goes to <SUN Certified System Administrator 9 Part I Book Vol.1>,pls!
|
|
|
【发表回复】【查看CU论坛原帖】【关闭】
|
ewebboy 回复于:2003-09-30 09:37:05 |
好东东!
|
gunguymadman007 回复于:2003-09-30 11:19:04 |
怎么是英文的 看不懂啊
|
yjj2597 回复于:2003-09-30 11:34:46 |
谢谢,辛苦了。
|
红头发 回复于:2003-09-30 12:41:33 |
up
|
jackylau 回复于:2003-09-30 19:15:14 |
我看怎么跟LINUX的基础知识是一样的?应该搞一点SUN的独到之处吧?
|
luyingxue 回复于:2003-09-30 19:26:28 |
复制+粘贴=本帖子!!!
居然是英文的????
|
红头发 回复于:2003-09-30 22:30:57 |
楼上的我先申明
这是笔记~!!!!!!!!!!
我1周的心血!!!!!!!!!
|
procrus 回复于:2003-09-30 22:47:49 |
辛苦了,好东西,顶
|
luyingxue 回复于:2003-09-30 23:05:27 |
不好意思啦。我不是很喜欢英文。因为最近都在看英文资料,而且也在翻译。所以我认为要是给别人看的最好是翻译过的。不然很多XDJM都没有兴趣的
|
红头发 回复于:2003-09-30 23:14:24 |
英文有什么不好啊``
中文翻译的话不太好翻译
这样顺便可以学习下英语
呵呵``
笔记继续中```
|
luyingxue 回复于:2003-10-01 09:02:27 |
收到!不过我还是决定把SA-119翻译一下,咱们这里还是有一些E文不太好的人。大家照顾一下。其实这也是学习英语的过程是不??:)
|
wugaih 回复于:2003-10-02 19:35:02 |
"下载地址我给了,见置顶帖子",我怎么找不到?
|
红头发 回复于:2003-10-02 20:55:51 |
楼上的看仔细点
|
luyingxue 回复于:2003-10-02 21:10:16 |
188已经翻译了一半了。过几天贴出来:)
|
红头发 回复于:2003-10-03 16:15:16 |
太好了哈哈~
|
rocazj 回复于:2003-10-05 21:22:37 |
1、直接看原文不好吗?
|
colacream 回复于:2003-10-06 00:14:56 |
Thanks for your contribution! 
|
flyingheat 回复于:2003-10-11 17:45:13 |
okokokokokokokokokokokokok
|
sunust 回复于:2003-11-03 11:31:33 |
up
|
|

|