⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0291-0295.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311623:SAMS TEACH YOURSELF LINUX IN 24 HOURS:Basic System Administration</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311623 //-->

<!-- TITLE=SAMS TEACH YOURSELF LINUX IN 24 HOURS //-->

<!-- AUTHOR=BILL BALL, STEPHEN SMOOGEN //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=20 //-->

<!-- PAGES=0291-0312 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->











<P><CENTER>

<a href="../ch19/0289-0290.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0296-0298.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-291"><P>Page 291</P></A>





<H3><A NAME="ch20_ 1">

Part V</A></H3>



<H2>

Administering Your System



</H2>



<P><b>Hour</b>

</P>



<OL START=20>

<LI>          Basic System Administration

<LI>          Handling Files

<LI>          Red Hat Tools

<LI>          Archiving

<LI>          Scheduling

</OL>



<A NAME="PAGENUM-292"><P>Page 292</P></A>











<A NAME="PAGENUM-293"><P>Page 293</P></A>







<H3><A NAME="ch20_ 2">

Hour 20

</A></H3>



<H2>

<A NAME="ch20_ 3">

Basic System Administration

</A>

</H2>



<P>This hour introduces you to the basics of system administration. You'll

learn how to use the su command, get information about your system, how

to manage other users, and how to use file tools to keep Linux running in

top form. Although much of what's discussed in this hour consists of

commonsense guidelines, you'll also get some valuable tips on squeezing the best

performance out of Linux. You'll also use this knowledge in the next four

hours, which cover handling files, the Red Hat control panel, archiving,

and scheduling.

</P>



<P>Even if you're the only person who uses your computer, you should still

learn basic system administration, or sysadmin, skills, for at least some of

the following reasons:

</P>



<UL>

<LI>     To back up or restore your system, or at the least, important files

<LI>     To conserve disk space

<LI>     To install new software or upgrade your Linux system

<LI>     To teach someone else about Linux, such as a coworker,

friend, spouse, or child

<LI>     To troubleshoot problems

</UL>





<A NAME="PAGENUM-294"><P>Page 294</P></A>









<P>Here's a good reason that you should never run your system as the root operator:

Always running as root can be dangerous because you have access to all files on the system,

and can delete, move, or copy them all. You can wipe out your system (remember the

warning in Hour 5, &quot;Manipulation and Searching Commands,&quot; about the

rm command) with this command:

</P>



<!-- CODE SNIP //-->

<PRE>

# rm -fr /*

</PRE>

<!-- END CODE SNIP //-->



<P>If you run Linux from your own account, this problem won't happen, because

rm will complain with &quot;Permission denied,&quot; and quit. But what if you're logged in under a

user other than root, and you need to do things to your system as the root operator? This is

where the su command comes into play.

</P>



<H3><A NAME="ch20_ 4">

Running as the Root Operator with the su Command

</A></H3>



<P>The su command, although commonly called the superuser command, allows you to

run a command as any user on your system. Found under the

/bin directory, su has seven different command-line options. Several of the most common are covered here.

Although you'll most likely use su to become root, this command can be handy if you want to

become another user and troubleshoot such problems as email or printing. Using the

su command is easy, for example:

</P>





<!-- CODE SNIP //-->

<PRE>

# su

Password:

su: incorrect password

</PRE>

<!-- END CODE SNIP //-->



<P>By default, the su command will allow you to become the root operator if you call it

without a username. You'll be asked to enter a password, and

su will complain and quit if you enter the wrong one. If you enter the right password, you'll be logged in as root. To return

to your shell, use your shell's exit command, as follows:

</P>



<!-- CODE //-->

<PRE>

$ su

Password:

# whoami

root

# exit

exit

$ whoami

bball

</PRE>

<!-- END CODE //-->



<P>This shows that after you execute the exit

command, you're returned to your normal user status. Another handy feature of the

su command is the -s command-line option to run a different shell. If you want to try a different shell without using the

chsh command to permanently change your shell, you can use the following:

</P>



<!-- CODE SNIP //-->

<PRE>

$ printenv | SHELL

SHELL=/bin/bash

$ su -s /bin/ksh

</PRE>

<!-- END CODE SNIP //-->



<A NAME="PAGENUM-295"><P>Page 295</P></A>





<!-- CODE SNIP //-->

<PRE>

Password:

# printenv | fgrep SHELL

SHELL=/bin/ksh

# exit

$

</PRE>

<!-- END CODE SNIP //-->



<P>This shows that although the default shell is

bash, you can temporarily use the pdksh, or public domain Korn shell. But unless you specify your own username, you'll run the

new shell as the root operator. A better approach is

</P>



<!-- CODE SNIP //-->

<PRE>

$ su -s /bin/ksh yourusername

</PRE>

<!-- END CODE SNIP //-->



<P>Finally, you can also use the su command to execute a command when you use the

-c command-line option. This can be handy to do tasks only permitted to the root

operator, for example:

</P>



<!-- CODE SNIP //-->

<PRE>

# su -c &quot;mount -t msdos /dev/hdc1 /mnt/flash&quot;

Password:

</PRE>

<!-- END CODE SNIP //-->



<P>This command line mounts the /dev/hdc1 device, a SunDisk flash card with a DOS

filesystem, at the /mnt/flash directory mount point. If you need to temporarily mount or

unmount diskettes, CD-ROMs, or other devices, you'll find this a convenient approach. Hour

21, &quot;Handling Files,&quot; covers mounting and unmounting other filesystems.

</P>



<P>If you're using Linux in the console mode (not running X11), you can use the console

keys (Alt-F1 and so on), to run a virtual console as the root operator to do root operator

tasks. But this is a bad convenience, as you may be tempted to run as root all the time. At

least using the su command makes you think about why you're running as root. Be careful!

</P>



<P>The next section introduces you to tools you can use to determine how your system

is working.

</P>



<H3><A NAME="ch20_ 5">

Getting Disk Space Information

</A></H3>



<P>When you installed Linux, you installed your system onto a partition, designated by

a specific device, such as /dev/hda1, /dev/sdb1, and so on. Hopefully, you made the partition

large enough to accommodate your present and future needs. But how do you check

to see how much room you have left on disk, or for that matter, how many disks you have?

Although Linux can support up to 4 terabytes, and maximum file sizes up to 2 gigabytes, not

many of us are wealthy enough to own, or even need, that much storage. Even though disk

storage is getting cheaper, it is still at a premium when you have a lot of software installed or

need the work space.

</P>



<H4><A NAME="ch20_ 6">

Getting Filesystem Statistics with the df Command

</A></H4>





<P><CENTER>

<a href="../ch19/0289-0290.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0296-0298.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->









</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -