Linux ‘su’ these are popular real life examples

Using ‘su’ command-If user only uses ‘su’ command and want to use ‘su’ as ‘sudo’ then it can be done. (here root password is assumed to have been configured because user is familiar with ‘su’). The given Linux su command examples are good to read.

To achieve same sudo functionality to execute any single command user has to use ‘-c’ option of ‘su’. Here is a command given below how to do it. Read additional ‘su’ information here.

Whereas with ‘sudo’ command is highly useful when you did not set any password for root directory.

$ su -c apt-get install vlc

After hitting enter user will be prompted for password and obviously it’s for root password because we’re using ‘su’ command.

If you have already configure the password, then after dollar prompt just type ‘su’ to enter into root directory. But it needs password.

linuxandubuntu@sandy:~$ su

The Linux command ‘su’ is used to switch from one account to another. User will be prompted for the password of the user switching to.

$ su linuxandubuntu

Users can also use it to switch to root account. If user types only ‘su’ without any option then It will be considered as root and user will be prompted to enter root user password.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.