Red Hat Linux 9 Professional Secrets [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Red Hat Linux 9 Professional Secrets [Electronic resources] - نسخه متنی

Naba Barkakati

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید








Becoming root


You have to be logged in as

root to perform the system administration tasks. The

root user is the super user and the only account with all the privileges needed to do anything in the system.








Secret


The common wisdom is that you should not normally log in as

root . That’s because when you’re

root , one misstep and you could easily delete all the files—especially when typing commands. Take, for example, the command

rm *l that you may type to delete all files with the

l extension. Unfortunately, if you accidentally press the spacebar after the asterisk (

* ), the shell takes the command to be

rm * l and, because

* matches any file name, deletes everything in the current directory. That sort of thing can happen, and the damage from any mistakes are much bigger when you are logged in as

root .

You should log in as a normal user and become

root when needed. Another advantage of this approach of becoming root when necessary is that there will be an entry in the

/var/log/messages file every time a user becomes root (only those who know the

root password can become root). Those entries in the

/var/log/ messages file can server as audit trail of who became super user when and did what.












Using the su - Command


If you are logged in as a normal user and need to become root, type the following command at a terminal window or console:

su -

Then enter the root password in response to the prompt. From this point on, you’re root. Do whatever you have to do. To return back to your usual self, type:

exit

It’s that easy to switch between being a normal user and root.





Caution

You should always type

su - to become root rather than typing

su . The

su - command changes the environment to root’s default environment settings whereas

su alone retains the current user’s environment, which may contain unsafe settings for environment variables.



Becoming Root for the GUI Utilities


If you use any of Red Hat’s GUI utilities to perform a system administration chore, it’s even easier. Typically, the utility pops up a dialog box that prompts you for the root password (see Figure 12-1). Just type the root password and press Enter. The GUI utility should then start. If you don’t want to use the utility, click Cancel.


Figure 12-1: Providing the Root Password for GUI Tools That Need Root Privileges.


Recovering from a Forgotten Root Password


To perform system administration tasks, you have to know the root password. What happens if you forget the root password? There is a way to recover from a forgotten root password. Just reboot the PC and you can reset the root password. Simply follow these steps:



  1. Reboot the PC (select Reboot as you log out of the GUI screen) or power up as usual. Soon, you see the graphical GRUB screen with the names of operating systems you can boot. (If you have a GRUB password, press p and enter the GRUB password now.)



  2. Press a (just the letter “a”). GRUB prompts you for commands to add to its default boot command.



  3. Press the spacebar, type the following word, and then press Enter:

    single

    This causes Linux to start up as usual, but run in a single-user mode that does not require you to log in. After Linux starts, you see the following command-line prompt:

    sh-2.05b#



  4. Use the

    passwd command to change the root password as follows:

    sh-2.05b# passwd
    Changing password for user root.
    New password: (type the new root password)

    Type the new root password that you want to use (it won’t appear onscreen), and then press Enter. Linux asks for the password again, like this:

    Retype new password:  (retype the new root password)

    Type the password again, and press Enter. If you enter the same password both times, the

    passwd command changes the password and displays the following message:

    passwd: all authentication tokens updated successfully



  5. Now, type exit or reboot to reboot the PC. After Linux starts, it displays the familiar login screen. Now, you should be able to log in as

    root with the new password.





    Caution

    Make sure that your Red Hat Linux PC is physically secure. As this procedure shows, anyone who can physically access your Red Hat Linux PC can simply

    reboot , set a new root password, and do whatever they want with the system. Having a password for the GRUB bootloader can provide an extra level of protection.





/ 341