📄 linux-commands.html
字号:
remove it with <B><TT>rm -rf</TT></B> later on.If you have only a single partition that makes up your filesystem then youhave very little to worry about in this area.</P><A NAME="rm"></A><H4><A NAME="10">rm</A></H4><P>The <B>rm</B> command is used for <B>r</B>e<B>m</B>oving files. You useit just like the <B>del</B> or <B>delete</B> command in MS-DOS. Let's sayyou want to remove a file called <TT>foobar</TT> in your currentdirectory. To do that, simply type <B><TT>rm foobar</TT></B>. Note thatthere is no "Recycle Bin" like in Windows 95. So when you deletea file, it's gone for good.</P><P>To delete something in some other directory, use the full path as thefile name. For example, if you want to delete a file called"windows" that's in the directory /usr/local/src/, you wouldtype <B><TT>rm /usr/local/src/windows</TT></B>.</P><P>To remove an entire directory and its contents, type <B><TT>rm -rf/directory</TT></B> where "/directory" is the path to thedirectory that you want to delete. If you're wondering, the "rf"stands for "recursive" and "force". Be very carefulwith this command, as it can wreak havoc easily if misused.</P><!-- Editing section started on June 9, 1999 --><!-- Last updated ~ Wed Jun 9 22:07:27 PDT 1999 --><A NAME="Editing"></A><H3><A NAME="11">Editing</A></H3><P>If you haven't figured out how important a text editor is, you soonwill. Graphical interfaces can't shield you forever, and those utilitieshave their limits. Besides, if you're reading this page, I'm inclined tothink that you want to be able to customize beyond the capabilities ofgraphical utilities. You want to work at the command prompt. I know youdo.</P><P>The basic syntax to invoke these text editors is the same. Type thename of the editor followed by the file you want to edit, separated by aspace in between. Non-existent files will be blank. Blank files will beblank as well.</P><A NAME="emacs"></A><H4><A NAME="12">emacs</A></H4><P>To use GNU Emacs (or its counterpart, XEmacs), there are really onlytwo commands you need to know. Heck, they're the only ones <I>I</I>know.</P><P>While you're editing a certain file with <B>emacs</B> or <B>xemacs</B>,you can save it with the <B><TT>[Ctrl]-x [Ctrl]-s</B></TT> keystrokes. Then toexit, type <B><TT>[Ctrl]-x [Ctrl]-c</TT></B>.</P><A NAME="pico"></A><H4><A NAME="13">pico</A></H4><P>The instructions for using <B>pico</B> are located on the screen. Yousave the file by using the <B><TT>[Ctrl]-o</TT></B> keystroke (forwrite-<I>o</I>ut) and exit with <B><TT>[Ctrl]-x</TT></B>.</P><P>As a permanent solution, you probably don't want to use <B>pico</B>. Itlacks real power. Since I am such a wuss, however, I still have the badhabit of using <B>pico</B> once in a while. Why? By pressing<B><TT>[Ctrl]璲</TT></B> I can get entire paragraphs wrapped into a nicejustified block. I don't know how to do that with the other texteditors.</P><A NAME="vim"></A><H4><A NAME="14">vim</A></H4><P>Most modern distributions include <B>vim</B>, derived from theinfamously arcane Unix editor, <B>vi</B>. (It stands for <B>vi</B>I<B>m</B>proved, as a matter of fact.)</P><P>Using <B>vim</B> is different in that there are several modes in whichyou use it. To do actual editing of the files, press <B><TT>[ESC]i</TT></B> (both separately). Then to save it, press <B><TT>[ESC] :w</TT></B>. Escape, the colon, and "w" should be keyed in oneafter the other. Finally, to quit, type <B><TT>[ESC] : q</TT></B>. Thesame rules apply as in previous <B>vim</B> commands.</P><P>You can use "w" and "q" at the same time to enableyourself to write to the file and then quit right afterwards. Just press<B><TT>[ESC] : w q</TT></B>.</P><P>If you don't have <B>vim</B> installed, try <B>vi</B> instead.</P><!-- Editing section initial entry completed at ~ Wed Jun 9 22:07:27 PDT 1999 --><A NAME="MonitoringYourSystem"></A><H3><A NAME="15">Monitoring Your System</A></H3><P>An important part of system administration (especially with your ownsystem) is being able to know what's going on.</P><!-- Section on `tail' added ~ Wed Jun 9 20:15:33 PDT 1999 --><A NAME="tail"></A><H4><A NAME="16">tail</A></H4><P>The program <B>tail</B> allows you to follow a file as it is growing. Mostoften, I use it to follow <TT>/var/log/messages</TT>. I do that by typing<TT><B>tail -f /var/log/messages</B></TT>. Of course, you can use anythingelse, including the other logs in <TT>/var/log/</TT>. Another file you may wantto keep an eye out for is <TT>/var/log/secure</TT>.</P><P>If you want to leave that running all the time, I recommend having some sortof terminal program in X, logged in as root through <B>su</B>.</P><P>Another program you may want to look at is <B>head</B>. It monitors the topof the file specified, instead of the bottom.</P><!-- Done with `tail' section. --><A NAME="top"></A><H4><A NAME="17">top</A></H4><P>This program shows a lot of stuff that goes on with your system. In the program, you can type:</P><OL><LI><B>M</B> for memory usage information</LI><LI><B>P</B> for CPU information</LI><LI><B>q</B> to quit</LI></OL><!-- This paragraph added on ~ Wed Jun 9 20:12:02 PDT 1999 --><P>Once you try it, you can see that <B>top</B> shows you the memory usage, uptime, load average, CPU states, and processes.</P><!-- Done with paragraph --><A NAME="w"></A><H4><A NAME="18">w</A></H4><P>Typing <B><TT>w</TT></B> will tell you who is logged in. This can behelpful if you're the only one who uses your computer and you see someonelogged in that's not supposed to be.</P><P>Another alternative is <B>who</B>.</P><A NAME="ShuttingDownAndRebooting"></A><H3><A NAME="19">Shutting Down and Rebooting</A></H3><P>To shut down your system, type <B><TT>shutdown -h now</TT></B>, whichtells the <B>shutdown</B> program to begin system halt immediately. Youcan also tell it to halt the system at a later time, I think, but you'llhave to consult the <B>shutdown</B> manual page for that (<B><TT>manshutdown</TT></B>).</P><P>To do a reboot, you can either type <B><TT>reboot</TT></B> or<B><TT>shutdown -r</TT></B>. You can also use the famous Ctrl-Alt-Deletecombination to reboot, which you might already be familiar with.</P><P>Shutting down and restarting properly (as described above) will preventyour filesystem from being damaged. Filesystem damage is the most obviousof the consequences, but there are probably other things out there that Idon't know about. The point is, shut down your system properly.</P><P>There are (rare!) cases in which the machine might lock up entirely,and prevent you from being able to access a command prompt. Only then willyour last resort be to do a forced reboot (just pressing the restartbutton on the case).</P><A NAME="books"></A><H3><A NAME="20">Related Books</A></H3><OL><LI><A HREF="http://www.amazon.com/exec/obidos/ASIN/1565924266/joshslinuxguide">Learning the VI Editor</A> - a book to teach you how to use the standard text editor for all Unix systems.<LI><A HREF="http://www.amazon.com/exec/obidos/ASIN/1565921526/joshslinuxguide">Learning GNU Emacs</A> - another book on another powerful text editor. It's good especially if you program or simply prefer Emacs.<LI><A HREF="http://www.amazon.com/exec/obidos/ASIN/0136805965/joshslinuxguide">Linux System Administration Handbook</A> - for those who are using their Linux box as a server</OL><HR><P><B><FONT SIZE="-1">Copyright © 1997-1999 <AHREF="mailto:jgo@local.net">Joshua Go (jgo@local.net)</A>. Allrights reserved. Permission to use, distribute, and copy this document ishereby granted. You may modify this document as long as credit to me isgiven.</FONT></B></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -