[CentOS-docs] becoming root

John jses27 at gmail.com
Sun Apr 6 01:41:05 UTC 2008


On Sun, 2008-04-06 at 02:11 +0100, Ned Slider wrote:
> Hi List,
> 
> I've just drafted a FAQ/mini-HOWTO on becoming root as this is a topic I 
> see come up time and time again.
> 
> Perhaps someone with a reasonable understanding could check it for 
> technical correctness, and if anyone would like to offer comments/feedback??
> 
> Any suggestions as to where might be an appropriate home for this on the 
> Wiki?
> 
> Regards,
> 
> Ned
> (attached below)
> 
> --------------------
> 
> *How to become root*
> 
> Many commands can only be run as the root user so to run these commands 
> we need to become "root". To do this, we use the su command (substitute 
> user).
> 
> The su command takes the following format:
> 
> su - <user>
> 
> but most commonly we will use su to become the root user:
> 
> su - root
> 
> If no username is specified, then the root user is assumed, so the above 
> is often shortened to:
> 
> su
> 
> or
> 
> su -
> 
> but the above are NOT the same thing.
> 
> Often a user will become root using just 'su', try to run a command (eg, 
> ifconfig), and get a 'command not found' error:
> 
> su
> Password:
> ifconfig
> bash: ifconfig: command not found
> 
> The reason is that regular system users and the root user have different 
> PATHS (you can view a users PATH with 'echo $PATH'). When you type a 
> Linux command, the shell with search the users PATH to try to locate the 
> command to run. It starts searching each directory on the PATH until a 
> match is found. Commands for regular users are mostly located in 
> /usr/local/bin, /usr/bin, and /bin. However, root commands are mostly 
> located in /usr/local/sbin, /usr/sbin, and /sbin and root's PATH 
> reflects this difference.
> 
> When you become root by using 'su -', you also adopt root's PATH whereas 
> using just 'su' retains the original users PATH, hence why becoming root 
> using just 'su' and trying to run a command located in /usr/local/sbin, 
> /usr/sbin, or /sbin results in a 'command not found' error.
> 
> So you either need to specify the full PATH to the command if you just 
> used 'su' (eg, /sbin/ifconfig) or use the full 'su -'.

Ever noticed in Red Hats Docs the full path to the command in question??
machine at you]#/usr/sbin/mii-tool
And boy is Ubunto and Debian confusing.
It sounds good.
And it is better than the Debian way I think. just my two cents.

> 
> _______________________________________________
> CentOS-docs mailing list
> CentOS-docs at centos.org
> http://lists.centos.org/mailman/listinfo/centos-docs
-- 
~/john

OpenPGP Sig:BA91F079



More information about the CentOS-docs mailing list