📄 appendix-b.html
字号:
</TD></TR>
</TABLE>
<A NAME="PAGENUM-616"><P>Page 616</P></A>
<H4>
chgrp
</H4>
<P>The chgrp command is used to change the group associated with the permissions of the file
or directory. The owner of the file (and, of course, root) has the authority to change the
group associated with the file. The format for the command is simply
</P>
<!-- CODE SNIP //-->
<PRE>
chgrp <new group> <file>
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="1739_ 26">
chmod
</A></H4>
<P>The chmod command is used to change the permissions associated with the object (typically
a file or directory). What you are really doing is changing the file mode. There are two ways
of specifying the permissions of the object. You can use the numeric coding system or the
letter coding system. If you recall, there are three sets of users associated with every object: the
owner of the object, the group for the object, and everybody else. Using the letter coding system,
they are referred to as u for user, g for group, o for other, and
a for all. There are three basic types of permissions that you can change:
r for read, w for write, and x for execute. These three
permissions can be changed using the plus (+) and minus
(-) signs. For example, to add read and execute to owner and group of the file
test1, you would issue the following command:
</P>
<!-- CODE SNIP //-->
<PRE>
chmod ug+rx test1
</PRE>
<!-- END CODE SNIP //-->
<P>To remove the read and execute permissions from the user and group of the
test1 file, you would change the plus (+) sign to a minus
(-) sign:
</P>
<!-- CODE SNIP //-->
<PRE>
chmod ug-rx test1
</PRE>
<!-- END CODE SNIP //-->
<P>This is called making relative changes to the mode of the file.
<P>Using the numeric coding system, you always have to give the absolute value of the
permissions, regardless of their previous permissions. The numeric system is based upon three sets
of base two numbers. There is one set for each category of user, group, and other. The values
are 4, 2, and 1, where 4 equals read, 2 equals write, and
1 equals execute. These values are added together to give the set of permissions for that category. With the numeric coding you
always specify all three categories. Therefore, to make the owner of the file
test1 have read, write, and execute permissions, and no one else to have any permissions, you would use the value
700, like this:
</P>
<!-- CODE SNIP //-->
<PRE>
chmod 700 test1
</PRE>
<!-- END CODE SNIP //-->
<P>To make the same file readable and writable by the user, and readable by both the group
and others, you would follow the following mathematical logic: For the first set of permissions,
the user, the value for readable is 4, and the value for writable is
2. The sum of these two is 6. The next set of permissions, the group, only gets readable, so that is
4. The settings for others, like the group, are 4. Therefore, the command would be
chmod 644 test1.
</P>
<A NAME="PAGENUM-617"><P>Page 617</P></A>
<P>The format for the command, using either method, is the same. You issue the
chmod command followed by the permissions, either absolute or relative, followed
by the objects for which you want the mode changed:
</P>
<!-- CODE SNIP //-->
<PRE>
chmod <permissions> <file>
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="1739_ 27">
chown
</A></H4>
<P>This command is used to change the user ID (owner) associated with the permissions of
the file or directory. The owner of the file (and, of course, root) has the authority to change
the user associated with the file. The format for the command is simply
</P>
<!-- CODE SNIP //-->
<PRE>
chown <new user id> <file>
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="1739_ 28">
chroot
</A></H4>
<P>The chroot command makes the / directory (called the root directory) be something other
than / on the filesystem. For example, when working with an Internet server, you can set the
root directory to equal /usr/ftp. Then, when someone logs on using FTP (which goes to the
root directory by default), he or she will actually go to the directory
/usr/ftp. This protects the rest of your directory structure from being seen or even changed to by this anonymous guest
to your machine. If the person were to enter cd
/etc, the ftp program would try to put him or her in the root directory and then in the
etc directory off of that. Because the root directory
is /usr/ftp, the ftp program will actually put the user in the
/usr/ftp/etc directory (assuming there is one).
</P>
<P>The syntax for the command is
<!-- CODE SNIP //-->
<PRE>
chroot <original filesystem location>
<new filesystem location>
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="1739_ 29">
cp
</A></H4>
<P>The cp command is an abbreviation for copy; therefore, this command enables you to
copy objects. For example, to copy the file file1 to
file2, issue the following command:
</P>
<!-- CODE SNIP //-->
<PRE>
cp file1 file2
</PRE>
<!-- END CODE SNIP //-->
<P>As the example shows, the syntax is very simple:
<!-- CODE SNIP //-->
<PRE>
cp <original object name> <new object
name>
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="1739_ 30">
dd
</A></H4>
<P>The dd command converts file formats. For example, to copy a boot image to a disk
(assuming the device name for the disk is /dev/fd0), you would issue the command
</P>
<!-- CODE SNIP //-->
<PRE>
dd if=<filename> of-/dev/fd0 obs=18k
</PRE>
<!-- END CODE SNIP //-->
<P>where filename would be something like
BOOT0001.img, of is the object format (what you
are copying to), and obs is the output block size.
</P>
<A NAME="PAGENUM-618"><P>Page 618</P></A>
<H4><A NAME="1739_ 31">
env
</A></H4>
<P>The env command is used to see the exported environment variables. The result of the
command is a two-column list where the variable's name is on the left and the value associated
with that variable is on the right. The command is issued without any parameters. Hence,
typing env might get you a list similar to this one:
</P>
<!-- CODE //-->
<PRE>
svr01:/home/dpitts$ env
HOSTNAME=svr01.mk.net
LOGNAME=dpitts
MAIL=/var/spool/mail/dpitts
TERM=vt100
HOSTTYPE=i386
PATH=/usr/local/bin:/usr/bin:/bin:.:/usr/local/java/bin
HOME=/home2/dpitts
SHELL=/bin/bash
LS_OPTIONS=--8bit --color=tty -F -b -T 0
PS1=\h:\w\$
PS2=>
MANPATH=/usr/local/man:/usr/man/preformat:/usr/man:/usr/lib/perl5/man
LESS=-MM
OSTYPE=Linux
SHLVL=1
</PRE>
<!-- END CODE //-->
<H4><A NAME="1739_ 32">
fc
</A></H4>
<P>The fc command is used to edit the history file. The parameters passed to it, if there are
any, can be used to select a range of commands from the history file. This list is then placed in
an editing shell. The editor that it uses is based upon the value of the variable
FCEDIT. If there is no value for this variable, the command looks at the
EDITOR variable. If it is not there, the default is used, which is
vi.
</P>
<H4><A NAME="1739_ 33">
fg
</A></H4>
<P>Processes can be run in either the background or the foreground. The
fg command enables you to take a suspended process and run it in the foreground. This is typically used when
you have a process running in the foreground and for some reason, you need to suspend it
(thus allowing you to run other commands). The process will continue until you either place it
in the background or bring it to the foreground.
</P>
<H4><A NAME="1739_ 34">
file
</A></H4>
<P>The file command tests each argument passed to it for one of three things: the filesystem
test, the magic number test, or the language test. The first test to succeed causes the file type to
be printed. If the file is text (it is an ASCII file), it then attempts to guess which language.
The following example identifies the file nquota as a text file that contains Perl commands. A
magic number file is a file that has data in particular fixed formats. Here is an example for
checking the file nquota to see what kind of file it is:
</P>
<!-- CODE SNIP //-->
<PRE>
file nquota
nquota: perl commands text
</PRE>
<!-- END CODE SNIP //-->
<A NAME="PAGENUM-619"><P>Page 619</P></A>
<H4><A NAME="1739_ 35">
find
</A></H4>
<P>Did you ever say to yourself, "Self, where did I put that file?" Well now, instead of talking
to yourself and having those around you wonder about you, you can ask the computer. You
can say, "Computer, where did I put that file?" Okay, it is not that simple, but it is close. All
you have to do is ask the computer to find the file.
<P>The find command will look in whatever directory you tell it to, as well as all
subdirectories under that directory, for the file that you specified. After it has found this list, it will then
do with the list as you have asked it to. Typically, you just want to know where it is, so you ask
it, nicely, to print out the list. The syntax of the command is the command itself, followed by
the directory you want to start searching in, followed by the filename (metacharacters are
acceptable), and then what you want done with the list. In the following example, the
find command searches for files ending with .pl in the current directory (and all subdirectories). It
then prints the results to standard output.
</P>
<!-- CODE SNIP //-->
<PRE>
find . -name *.pl -print
./public_html/scripts/gant.pl
./public_html/scripts/edit_gant.pl
./public_html/scripts/httools.pl
./public_html/scripts/chart.no.comments.pl
</PRE>
<!-- END CODE SNIP //-->
<H4><A NAME="1739_ 36">
grep
</A></H4>
<P>The grep (global regular expression parse) command searches the object you specify for
the text that you specify. The syntax of the command is
grep <text> <file>. In the following example, I am searching for instances of the text
httools in all files in the current directory:
</P>
<!-- CODE //-->
<PRE>
grep httools *
edit_gant.cgi:require `httools.pl';
edit_gant.pl:require `httools.pl';
gant.cgi: require `httools.pl'; # Library containing reuseable code
gant.cgi: &date; # Calls the todays date subroutine from httools.pl
gant.cgi: &date; # Calls the todays date subroutine from httools.pl
gant.cgi: &header; # from httools.pl
</PRE>
<!-- END CODE //-->
<P>Although this is valuable, the grep command can also be used in conjunction with the
results of other commands. For example, the following command
</P>
<!-- CODE SNIP //-->
<PRE>
ps -ef |grep -v root
</PRE>
<!-- END CODE SNIP //-->
<P>calls for the grep command to take the output of the
ps command and take out all instances of the word root (the
-v means everything but the text that follows). The same command
without the -v (ps -ef |grep root) returns all of the instances that contain
the word root from the process listing.
</P>
<H4><A NAME="1739_ 37">
groff
</A></H4>
<P>groff is the front end to the groff document formatting program. This program, by
default, calls the troff program.
</P>
<A NAME="PAGENUM-620"><P>Page 620</P></A>
<H4><A NAME="1739_ 38">
gzip
</A></H4>
<P>gzip is GNU's version of the zip compression software. The syntax can be as simple as
</P>
<!-- CODE SNIP //-->
<PRE>
gzip <filename>
</PRE>
<!-- END CODE SNIP //-->
<P>but many times also contains some parameters between the command and the filename to
be compressed.
</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -