su

From ALT Linux Wiki
(Redirected from Root)
Stub.png
Under construction.
This page is not finished yet and may lack substantial information.


Question: How to switch to superuser mode (switching to root)?

Answer: In the terminal need to enter the next command (Warning! Need to introduce the hyphen!):

su -

Explanations: when you switching to superuser mode with using su command, just command prompt call with root rights occurs. With that, user EnvironmentVariables, in particular, $PATH, remains the same as at user. That is a variable $PATH will not have catalogs /sbin, /usr/sbin and without pointing full name, the commands a route, lilo, mkswap and others will not accessible. Moreover, $HOME variable will indicate to user catalog and any program, which the user will launch as root, will save own settings with root rights in user catalog, what can call problems in future.

To avoid this, need to use su -. In this mode su will run command prompt as login shell and it will behave like if to the system will login a root.

For issuance limited rights of superuser need to use utility sudo.

Also due pseudonym works the next command:

su-
$ alias su-
alias su-='su -'

Restriction of launch

Problem

When you trying switch to administrator in the terminal appears next error:

$ su -
bash: /bin/su: Access denied

Fix

Normally, user need to will include to group wheel (system makes that automatic at system installation for first user, also you can set up that in Control center). Other modes you can set up via utility control:

$ /usr/sbin/control su
wheelonly
$ ls -l `which su`
-rws--x--- 1 root wheel 22316 авг 25  2012 /bin/su
$ groups | grep wheel
cas wheel uucp proc cdrom floppy cdwriter audio radio sambashare vboxusers camera xgrp scanner
$ su -
Password: 
#

Also you can set access to su for everyone users:

control su public

(you need to login to first user or in console Ctrl+ALT+F2 via root.)

Errors arising with incorrect using su

The user , who run su incorrect, can get many errors - programs can't save configuration, settings doesn't works, arbitrary errors about writing is appears.

Recommend to check home folder to availability of files which belong to root via command:

$ find $HOME -user root

If your system in good condition, then list of files will is empty.

Links