Root and User Modes

If you are new to YDL and have some more or less basic questions.

Root and User Modes

Postby aguilarojo » 15 Jul 2009, 22:50

    Over the years various YDL users and others have written in asking, "What is a root password and how to acquire one?"

This question will be explored in some depth here.

A brief discussion regarding the concept of root versus user/s mode may be useful.

Root mode:
In Linux and Unix, the root mode is reserved for programming, and traditional systems functions such as installing/copying/destroying directories and files, as well as starting/stopping daemons and modifying how the operating system functions and what it executes at different times -- such as the execution of daemons via cron and so on. An example of what root mode is for is the configuration of Wifi or other network such as building a printer network which a user may want to implement with his PS3, or other computer using YDL. Also setting up video configurations and other settings within YDL and other Linux or Unix variants require root mode access. Root mode is also known as the System Administration mode.

Occasionally as you try to start a program such as Network Configuration (system-config-network) or Security Level and Firewall (system-config-securitylevel) you may receive a system a message that requires the System Administrator's password, this is the same password you choose for root. Another function of root mode is to allow programming or software development in one of a variety of languages such as C, C++ and others. For instance, suppose you want a sophisticated statistics package such as R http://www.r-project.org/. As iit is not standard within YDL you'll have to go to the website, download the latest source version and then compile it within YDL - the process of compilation is completed as root.

User mode:
The user mode and user password is unique to each individual user allowed access to use YDL with a unique user id and password. The purpose of the user mode is to use applications and generate files with the applications within YDL. For instance, using Openoffice to create a resume or using Rhythmbox to listen to music or Gimp to make drawings or artwork are all user functions and activities which do not require modification of operating system functions or execution of reserved operating system commands.

Recognizing user or root mode within Linux/Unix, including YDL:

Unix and Linux use a variety of shell environments, the standard one used in YDL known as bash is one of the possible shells one can use.
The following example below demonstrates how one can move between different shells within YDL, specifically from bash --> csh --> ksh --> shell or just sh. Although I'm using YDL 6.2, earlier versions of YDL will behave simillarly.

Code: Select all
[aguila@arakus ~]$ csh
[aguila@arakus ~]$ ksh
$ sh
sh-3.2$ su
Password:
[root@arakus aguila]# csh
[aguila@arakus aguila]# sh
sh-3.2# ksh
#


User mode is represented by $. Root mode is represented by #.

You'll notice my use of the superuser or su command to switch into root mode. You'll also notice that YDL is requesting the Password for root mode. Entering root this way is useful if I'm going to do a lot of significant work as root. However, if I'm just going to spend a small amount of time in root and intend to return to user mode as quickly as possible, let's say I just want to search for something to install it using yum and return to user mode to do something else then the best approach is to use the sudo command.

Using sudo means first changing what is known as the sudo file which contains a definition of who has superuser or root access. Remember superuser, root and System Administration access are all the same thing. There is one way to access the sudo file to make changes and that is to use a special program called visudo which is a variant of the vi/vim editor. Visudo however only does one thing, it accesses the sudo file. I suggest that you become familiar working with practicing on working with text files you are familiar with which vi or vim can open. There is a program which can help you learn called vimtutor. Do the following:

Code: Select all
# vimtutor


Go through the various lessons and get familiar with changing files within vim and then proceed to invoking visudo.

Code: Select all
$ su -
# visudo


What follows is that portion of the sudo file which needs to be modified:

Code: Select all
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
aguila  ALL=(ALL)       ALL


Note that under root I entered the my username on my system; of course, you can choose your own. Saving the changes within visudo means that you can now do:

Code: Select all
[aguila@arakus ~]$ sudo yum info "*astro*"
Password:
Loading "installonlyn" plugin
Available Packages
Name   : astronomy-menus
Arch   : noarch
Version: 1.0
Release: 2.el5
Size   : 9.3 k
Repo   : extras
Summary: Astronomy menu for the Desktop
Description:
Astronomy submenu for the Education menu, for better usability of the
Fedora Astronomy packages.

Name   : astronomy-menus-toplevel
Arch   : noarch
Version: 1.0
Release: 2.el5
Size   : 9.5 k
Repo   : extras
Summary: Toplevel astronomy menu for the Desktop
Description:
Astronomy submenu for the Education menu, for better usability of the
Fedora Astronomy packages.

This package places the submenu at the Application menu root, which
may make sense if there are no other Education packages, such as in
Fedora Astronomy Live Media Spin.

Name   : javastroke
Arch   : ppc
Version: 0.5.1
Release: 21.el5
Size   : 8.8 k
Repo   : extras
Summary: Optional java files
Description:
Java interface for stroke and example application

[aguila@arakus ~]$



Note that sudo forces YDL to refer to the newly modified sudo file and it finds my user name there. Next it asks for my user password which I enter, then yum is executed. After yum finishes I'm immediately returned into user mode. Yum cannot function in user mode at all which demonstrates quite neatly the advantage of being able to move quickly between root and user modes as a result of using sudo.

Everything on the Earth has a purpose.
Every disease an herb to cure it.
And every person has a mission.
This is the Indian Theory of Existence.
-- Morning Dove, Salish (1888-1936)
User avatar
aguilarojo
ydl guru
ydl guru
 
Posts: 227
Joined: 06 May 2009, 14:50
Location: New York City

Return to Beginner

Who is online

Users browsing this forum: No registered users and 54 guests