Using the [su] command

Last update on April 30, 2009 01:14 PM by jak58
Published by jak58

Using the ‘‘su’’ command




The ''su''


The "su" is defined as the "Super User" which has the ability to open a session with the ID (identifier) of an another user, or starting a new login shell.

Sign in as a different user ID with "su"


su toto

When you enter your password, you will be logged in as "foo" user, you are always in the same working directory as before and you get the default settings of the previous user (login shell, variables of the environment, various permissions)

Start a new shell connection with "su -"


su - toto

The use of the hyphen "-" forces the new shell connection to run with adjustment of variables environment and all the default settings according to user preferences.
For these reasons it is recommended if you log in as super user "root", use the command:

su --

rather than:

su

Back to previous shell


Type the "exit" command or combination of keys "Ctrl-d" to close the current shell and return to the previous one.

Comment: If the command line is not empty, use Ctrl-d which deletes the current character which hold the shell as root

Thanks to suspend the order can suspend the root shell and place it in the background.
The fg command allows to resume.

ccm @ debian: ~ $ su 
Password: 
debian: /home/ccm # suspend 

[1] + Stopped su 
ccm @ debian: ~ $ fg 
su 
debian: /home/ccm #

Notes


-If you type the command "exit" or "Ctrl-d" from the original login shell (initial), you are disconnected from the system (Unix - GNU / Linux).
-If you were logged in (in a shell) as root and you type the command "su user", the system will not require a password.
Best answers for « Using the command » in :
Command prompts for Windows Show Command prompts for Windows Some of these command below can cause harmful an undesirable functions, leading to the formatting of your hard disk and data loss, while others will not run under Windows XP. As for Windows Vista the Run Tab is not...
Command to detect your IP address! Show Command to detect your IP address! Command for Windows 2000 / XP / Vista Command for Windows 95/98 Command for Linux IP address (Internet Protocol) is a numerical identification to detect your computer on a network. It is used to...
Enable/disable a device from the command line Show Enable/disable a device from the command line Install Devcon Display all the devices in the system Enable/disable the device Other devices Here is a trick that allows you to enable / disable a device from the command line in XP....
Start/stop a service using command line ShowStart/stop a service using command line The netsh tool (netsh.exe) can automate the startup or shutdown of a service through the following command line: To start a service: Net start name_of_service To stop a service:...
[Windows XP] Repairing the network connection using command line Show[Windows XP] Repairing the network connection using command lines Under Windows XP there is a small feature allowing you to repair a network connection. Go to the Network Connections options in Control panel (Control Panel / Network...
Phpize: command not found Showphpize: command not found Though you have installed the PHP programming language on your computer, you will be required to install the extension pecl to be able to run its commands. Else, you will be face with the error message...
Network tests and diagnostics ShowTesting the IP configuration Before doing anything else, you are advised to check the computer's IP configuration. Windows systems offer a command-line tool, called ipconfig, that lets you find out your computer's IP configuration. The output of...
Linux - The shell ShowIntroduction to the shell The command interpreter is the interface between the user and the operating system, hence the name "shell". The shell therefore acts as an intermediary between the operating system and the user thanks to command lines...
UNIX system - The shell ShowIntroduction to the shell The command interpreter is the interface between the user and the operating system, hence its name "shell". The shell therefore acts as an intermediary between the operating system and the user using command lines...