system.html
来自「Shall高级编程」· HTML 代码 · 共 4,156 行 · 第 1/5 页
HTML
4,156 行
><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>tset -r</B></TT> <TTCLASS="COMPUTEROUTPUT">Terminal type is xterm-xfree86. Kill is control-U (^U). Interrupt is control-C (^C).</TT> </PRE></TD></TR></TABLE> </P></DD><DT><ANAME="SETSERIALREF"></A><BCLASS="COMMAND">setserial</B></DT><DD><P>Set or display serial port parameters. This command must be run by <ICLASS="FIRSTTERM">root</I> and is usually found in a system setup script.</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> 1 # From /etc/pcmcia/serial script: 2 3 IRQ=`setserial /dev/$DEVICE | sed -e 's/.*IRQ: //'` 4 setserial /dev/$DEVICE irq 0 ; setserial /dev/$DEVICE irq $IRQ</PRE></TD></TR></TABLE></P></DD><DT><ANAME="GETTYREF"></A><BCLASS="COMMAND">getty</B>, <ANAME="AGETTYREF"></A><BCLASS="COMMAND">agetty</B></DT><DD><P>The initialization process for a terminal uses <BCLASS="COMMAND">getty</B> or <BCLASS="COMMAND">agetty</B> to set it up for login by a user. These commands are not used within user shell scripts. Their scripting counterpart is <BCLASS="COMMAND">stty</B>.</P></DD><DT><ANAME="MESGREF"></A><BCLASS="COMMAND">mesg</B></DT><DD><P>Enables or disables write access to the current user's terminal. Disabling access would prevent another user on the network to <AHREF="communications.html#WRITEREF">write</A> to the terminal.</P><DIVCLASS="TIP"><TABLECLASS="TIP"WIDTH="90%"BORDER="0"><TR><TDWIDTH="25"ALIGN="CENTER"VALIGN="TOP"><IMGSRC="common/tip.png"HSPACE="5"ALT="Tip"></TD><TDALIGN="LEFT"VALIGN="TOP"><P>It can be quite annoying to have a message about ordering pizza suddenly appear in the middle of the text file you are editing. On a multi-user network, you might therefore wish to disable write access to your terminal when you need to avoid interruptions.</P></TD></TR></TABLE></DIV></DD><DT><ANAME="WALLREF"></A><BCLASS="COMMAND">wall</B></DT><DD><P>This is an acronym for <SPANCLASS="QUOTE">"<AHREF="communications.html#WRITEREF">write</A> all,"</SPAN> i.e., sending a message to all users at every terminal logged into the network. It is primarily a system administrator's tool, useful, for example, when warning everyone that the system will shortly go down due to a problem (see <AHREF="here-docs.html#EX70">Example 18-1</A>).</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>wall System going down for maintenance in 5 minutes!</B></TT> <TTCLASS="COMPUTEROUTPUT">Broadcast message from bozo (pts/1) Sun Jul 8 13:53:27 2001... System going down for maintenance in 5 minutes!</TT> </PRE></TD></TR></TABLE> </P><DIVCLASS="NOTE"><TABLECLASS="NOTE"WIDTH="90%"BORDER="0"><TR><TDWIDTH="25"ALIGN="CENTER"VALIGN="TOP"><IMGSRC="common/note.png"HSPACE="5"ALT="Note"></TD><TDALIGN="LEFT"VALIGN="TOP"><P>If write access to a particular terminal has been disabled with <BCLASS="COMMAND">mesg</B>, then <BCLASS="COMMAND">wall</B> cannot send a message to that terminal.</P></TD></TR></TABLE></DIV></DD></DL></DIV><DIVCLASS="VARIABLELIST"><P><B><ANAME="STATISTICSSYS1"></A>Information and Statistics</B></P><DL><DT><ANAME="UNAMEREF"></A><BCLASS="COMMAND">uname</B></DT><DD><P>Output system specifications (OS, kernel version, etc.) to <TTCLASS="FILENAME">stdout</TT>. Invoked with the <TTCLASS="OPTION">-a</TT> option, gives verbose system info (see <AHREF="moreadv.html#EX41">Example 15-5</A>). The <TTCLASS="OPTION">-s</TT> option shows only the OS type.</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>uname</B></TT> <TTCLASS="COMPUTEROUTPUT">Linux</TT> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>uname -s</B></TT> <TTCLASS="COMPUTEROUTPUT">Linux</TT> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>uname -a</B></TT> <TTCLASS="COMPUTEROUTPUT">Linux iron.bozo 2.6.15-1.2054_FC5 #1 Tue Mar 14 15:48:33 EST 2006 i686 i686 i386 GNU/Linux</TT></PRE></TD></TR></TABLE></DD><DT><ANAME="ARCHREF"></A><BCLASS="COMMAND">arch</B></DT><DD><P>Show system architecture. Equivalent to <BCLASS="COMMAND">uname -m</B>. See <AHREF="testbranch.html#CASECMD">Example 10-26</A>.</P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>arch</B></TT> <TTCLASS="COMPUTEROUTPUT">i686</TT> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>uname -m</B></TT> <TTCLASS="COMPUTEROUTPUT">i686</TT></PRE></TD></TR></TABLE></DD><DT><ANAME="LASTCOMMREF"></A><BCLASS="COMMAND">lastcomm</B></DT><DD><P>Gives information about previous commands, as stored in the <TTCLASS="FILENAME">/var/account/pacct</TT> file. Command name and user name can be specified by options. This is one of the GNU accounting utilities.</P></DD><DT><ANAME="LASTLOGREF"></A><BCLASS="COMMAND">lastlog</B></DT><DD><P>List the last login time of all system users. This references the <TTCLASS="FILENAME">/var/log/lastlog</TT> file.</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>lastlog</B></TT> <TTCLASS="COMPUTEROUTPUT">root tty1 Fri Dec 7 18:43:21 -0700 2001 bin **Never logged in** daemon **Never logged in** ... bozo tty1 Sat Dec 8 21:14:29 -0700 2001</TT> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>lastlog | grep root</B></TT> <TTCLASS="COMPUTEROUTPUT">root tty1 Fri Dec 7 18:43:21 -0700 2001</TT> </PRE></TD></TR></TABLE> </P><DIVCLASS="CAUTION"><TABLECLASS="CAUTION"WIDTH="90%"BORDER="0"><TR><TDWIDTH="25"ALIGN="CENTER"VALIGN="TOP"><IMGSRC="common/caution.png"HSPACE="5"ALT="Caution"></TD><TDALIGN="LEFT"VALIGN="TOP"><P>This command will fail if the user invoking it does not have read permission for the <TTCLASS="FILENAME">/var/log/lastlog</TT> file.</P></TD></TR></TABLE></DIV></DD><DT><ANAME="LSOFREF"></A><BCLASS="COMMAND">lsof</B></DT><DD><P>List open files. This command outputs a detailed table of all currently open files and gives information about their owner, size, the processes associated with them, and more. Of course, <BCLASS="COMMAND">lsof</B> may be piped to <AHREF="textproc.html#GREPREF">grep</A> and/or <AHREF="awk.html#AWKREF">awk</A> to parse and analyze its results.</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>lsof</B></TT> <TTCLASS="COMPUTEROUTPUT">COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME init 1 root mem REG 3,5 30748 30303 /sbin/init init 1 root mem REG 3,5 73120 8069 /lib/ld-2.1.3.so init 1 root mem REG 3,5 931668 8075 /lib/libc-2.1.3.so cardmgr 213 root mem REG 3,5 36956 30357 /sbin/cardmgr ...</TT> </PRE></TD></TR></TABLE> </P><P>The <BCLASS="COMMAND">lsof</B> command is a useful, if complex administrative tool. If you are unable to dismount a filesystem and get an error message that it is still in use, then running <ICLASS="FIRSTTERM">lsof</I> helps determine which files are still open on that filesystem. The <TTCLASS="OPTION">-i</TT> option lists open network socket files, and this can help trace intrusion or hack attempts.</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>lsof -an -i tcp</B></TT> <TTCLASS="COMPUTEROUTPUT">COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME firefox 2330 bozo 32u IPv4 9956 TCP 66.0.118.137:57596->67.112.7.104:http ... firefox 2330 bozo 38u IPv4 10535 TCP 66.0.118.137:57708->216.79.48.24:http ...</TT> </PRE></TD></TR></TABLE> </P></DD><DT><ANAME="STRACEREF"></A><BCLASS="COMMAND">strace</B></DT><DD><P><BCLASS="COMMAND">S</B>ystem <BCLASS="COMMAND">trace</B>: diagnostic and debugging tool for tracing <ICLASS="FIRSTTERM">system calls</I> and signals. This command and <BCLASS="COMMAND">ltrace</B>, following, are useful for diagnosing why a given program or package fails to run . . . perhaps due to missing libraries or related causes.</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>strace df</B></TT> <TTCLASS="COMPUTEROUTPUT">execve("/bin/df", ["df"], [/* 45 vars */]) = 0 uname({sys="Linux", node="bozo.localdomain", ...}) = 0 brk(0) = 0x804f5e4 ...</TT> </PRE></TD></TR></TABLE> </P><P>This is the Linux equivalent of the Solaris <BCLASS="COMMAND">truss</B> command.</P></DD><DT><ANAME="LTRACEREF"></A><BCLASS="COMMAND">ltrace</B></DT><DD><P><BCLASS="COMMAND">L</B>ibrary <BCLASS="COMMAND">trace</B>: diagnostic and debugging tool that traces <ICLASS="FIRSTTERM">library calls</I> invoked by a given command.</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>ltrace df</B></TT> <TTCLASS="COMPUTEROUTPUT">__libc_start_main(0x804a910, 1, 0xbfb589a4, 0x804fb70, 0x804fb68 <unfinished ...>: setlocale(6, "") = "en_US.UTF-8"bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale"textdomain("coreutils") = "coreutils"__cxa_atexit(0x804b650, 0, 0, 0x8052bf0, 0xbfb58908) = 0getenv("DF_BLOCK_SIZE") = NULL ...</TT> </PRE></TD></TR></TABLE> </P></DD><DT><ANAME="NMAPREF"></A><BCLASS="COMMAND">nmap</B></DT><DD><P><BCLASS="COMMAND">N</B>etwork <BCLASS="COMMAND">map</B>per and port scanner. This command scans a server to locate open ports and the services associated with those ports. It can also report information about packet filters and firewalls. This is an important security tool for locking down a network against hacking attempts.</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING"> 1 #!/bin/bash 2 3 SERVER=$HOST # localhost.localdomain (127.0.0.1). 4 PORT_NUMBER=25 # SMTP port. 5 6 nmap $SERVER | grep -w "$PORT_NUMBER" # Is that particular port open? 7 # grep -w matches whole words only, 8 #+ so this wouldn't match port 1025, for example. 9 10 exit 0 11 12 # 25/tcp open smtp</PRE></TD></TR></TABLE></P></DD><DT><ANAME="NCREF"></A><BCLASS="COMMAND">nc</B></DT><DD><P>The <BCLASS="COMMAND">nc</B> (<ICLASS="FIRSTTERM">netcat</I>) utility is a complete toolkit for connecting to and listening to TCP and UDP ports. It is useful as a diagnostic and testing tool and as a component in simple script-based HTTP clients and servers.</P><P> <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>nc localhost.localdomain 25</B></TT> <TTCLASS="COMPUTEROUTPUT">220 localhost.localdomain ESMTP Sendmail 8.13.1/8.13.1; Thu, 31 Mar 2005 15:41:35 -0700</TT></PRE></TD></TR></TABLE> </P><DIVCLASS="EXAMPLE"><HR><ANAME="ISCAN"></A><P><B>Example 16-5. Checking a remote server for <ICLASS="FIRSTTERM">identd</I></B></P><TABLEBORDER="0"
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?