📄 appendix-d.html
字号:
<TD VALIGN="TOP"><TT>cd ..</TT>
<TD>Moves one directory up the directory tree.
<TR>
<TD VALIGN="TOP"><TT>cd ~</TT>
<TD>Moves to your home directory from wherever you currently are. This is the same as issuing <TT>cd</TT> by itself.
<TR>
<TD VALIGN="TOP"><TT>cd directory name</TT>
<TD>Changes to a specific directory. This can be a directory relative to your current location or can be based on the root directory by placing a forward slash (<TT>/</TT>) before the directory name.These examples can be combined. For example, suppose you were in the directory <TT>/home/dsp1234</TT> and you wanted to go to <TT>tng4321</TT>’s home account. You could perform the following command, which will move you back up the directory one level and then move you down into the <TT>tng4321</TT> directory:<TT>cd ../tng4321</TT>
</TABLE>
<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077"><I>chgrp</I>
</FONT></H4>
<P>The <TT>chgrp</TT> 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 <<I>new group</I>> <<I>file</I>>
</PRE>
<!-- END CODE SNIP //-->
<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077"><I>chmod</I>
</FONT></H4>
<P>The <TT>chmod</TT> 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 <TT>u</TT> for user, <TT>g</TT> for group, <TT>o</TT> for other, and <TT>a</TT> for all. There are three basic types of permissions that you can change: <TT>r</TT> for read, <TT>w</TT> for write, and <TT>x</TT> for execute. These three permissions can be changed using the plus (<TT>+</TT>) and minus (<TT>-</TT>) 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 (<TT>+</TT>) sign to a minus (<TT>-</TT>) 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>
<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 <TT>4</TT>, <TT>2</TT>, and <TT>1</TT>, where <TT>4</TT> equals read, <TT>2</TT> equals write, and <TT>1</TT> 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 <TT>700</TT>, 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 <TT>4</TT>, and the value for writable is <TT>2</TT>. The sum of these two is <TT>6</TT>. The next set of permissions, the group, only gets readable, so that is <TT>4</TT>. The settings for others, like the group, are <TT>4</TT>. Therefore, the command would be chmod <TT>644 test1</TT>.</P>
<P>The format for the command, using either method, is the same. You issue the <TT>chmod</TT> 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 ALIGN="LEFT"><A NAME="Heading16"></A><FONT COLOR="#000077"><I>chown</I>
</FONT></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 ALIGN="LEFT"><A NAME="Heading17"></A><FONT COLOR="#000077"><I>chroot</I>
</FONT></H4>
<P>The <TT>chroot</TT> command makes the <TT>/</TT> directory (called the root directory) be something other than <TT>/</TT> on the filesystem. For example, when working with an Internet server, you can set the root directory to equal <TT>/usr/ftp</TT>. Then, when someone logs on using FTP (which goes to the root directory by default), he or she will actually go to the directory <TT>/usr/ftp</TT>. 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 <TT>cd /etc</TT>, the <TT>ftp</TT> program would try to put him or her in the root directory and then in the <TT>etc</TT> directory off of that. Because the root directory is <TT>/usr/ftp</TT>, the <TT>ftp</TT> program will actually put the user in the <TT>/usr/ftp/etc</TT> directory (assuming there is one).</P>
<P>The syntax for the command is</P>
<!-- CODE SNIP //-->
<PRE>
chroot <original filesystem location> <new filesystem location>
</PRE>
<!-- END CODE SNIP //-->
<H4 ALIGN="LEFT"><A NAME="Heading18"></A><FONT COLOR="#000077"><I>cp</I>
</FONT></H4>
<P>The <TT>cp</TT> command is an abbreviation for copy; therefore, this command enables you to copy objects. For example, to copy the file <TT>file1</TT> to <TT>file2</TT>, 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:
</P>
<!-- CODE SNIP //-->
<PRE>
cp <original object name> <new object name>
</PRE>
<!-- END CODE SNIP //-->
<H4 ALIGN="LEFT"><A NAME="Heading19"></A><FONT COLOR="#000077"><I>dd</I>
</FONT></H4>
<P>The <TT>dd</TT> command converts file formats. For example, to copy a boot image to a disk (assuming the device name for the disk is <TT>/dev/fd0</TT>), you would issue the command</P>
<!-- CODE SNIP //-->
<PRE>
dd if=<filename> of-/dev/fd0 obs=18k
</PRE>
<!-- END CODE SNIP //-->
<P>where <TT>filename</TT> would be something like <TT>BOOT0001.img</TT>, of is the object format (what you are copying to), and <TT>obs</TT> is the output block size.</P>
<H4 ALIGN="LEFT"><A NAME="Heading20"></A><FONT COLOR="#000077"><I>env</I>
</FONT></H4>
<P>The <TT>env</TT> 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 <TT>env</TT> 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 ALIGN="LEFT"><A NAME="Heading21"></A><FONT COLOR="#000077"><I>fc</I>
</FONT></H4>
<P>The <TT>fc</TT> 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 <TT>FCEDIT</TT>. If there is no value for this variable, the command looks at the <TT>EDITOR</TT> variable. If it is not there, the default is used, which is <TT>vi</TT>.</P>
<H4 ALIGN="LEFT"><A NAME="Heading22"></A><FONT COLOR="#000077"><I>fg</I>
</FONT></H4>
<P>Processes can be run in either the background or the foreground. The <TT>fg</TT> 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 ALIGN="LEFT"><A NAME="Heading23"></A><FONT COLOR="#000077"><I>file</I>
</FONT></H4>
<P>The <TT>file</TT> 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 <TT>nquota</TT> to see what kind of file it is:</P>
<!-- CODE SNIP //-->
<PRE>
file nquota
nquota: perl commands text
</PRE>
<!-- END CODE SNIP //-->
<H4 ALIGN="LEFT"><A NAME="Heading24"></A><FONT COLOR="#000077"><I>find</I>
</FONT></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>
<P>The <TT>find</TT> 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 <TT>find</TT> command searches for files ending with <TT>.pl</TT> 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 ALIGN="LEFT"><A NAME="Heading25"></A><FONT COLOR="#000077"><I>grep</I>
</FONT></H4>
<P>The <TT>grep</TT> (global regular expression parse) command searches the object you specify for the text that you specify. The syntax of the command is <TT>grep <text> <file></TT>. 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 <TT>grep</TT> 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 <TT>grep</TT> command to take the output of the <TT>ps</TT> command and take out all instances of the word root (the <TT>-v</TT> means everything but the text that follows). The same command without the <TT>-v</TT> (<TT>ps -ef |grep root</TT>) returns all of the instances that contain the word root from the process listing.</P>
<H4 ALIGN="LEFT"><A NAME="Heading26"></A><FONT COLOR="#000077"><I>groff</I>
</FONT></H4>
<P><TT>groff</TT> is the front end to the <TT>groff</TT> document formatting program. This program, by default, calls the <TT>troff</TT> program.</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -