?
Solved

Su and Sudo in inux

Posted on 2013-12-08
6
Medium Priority
?
472 Views
Last Modified: 2013-12-08
I have been reading about the difference between Su and Sudo command in linux
it says with Sudo, if the user is in the Sudoers file, he will enter the password and he will be able to run a single command. with Su the user will enter the root password and will be able to run any command.

So if I know the root password, then I do not need to run Sudo at all…correct ?
anyone to clear the confusion on this ?

Thanks
0
Comment
Question by:jskfan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 500 total points
ID: 39704396
the su command requires you knowing root password (in your case) where you want to run  different commands as root, while sudo requires you to enter different password and run specific commands as root.

Please see link below for how to use sudo

http://www.gratisoft.us/sudo/sudoers.man.html
0
 
LVL 88

Assisted Solution

by:rindi
rindi earned 1000 total points
ID: 39704481
With su you are changing to the root user, and therefore after that you can do everything. With sudo you are only elevating the current user's security, it is similar to UAC in windows where you have to agree to running administrative tasks before you are allowed to run them, it's a kind of safety measure so you are warned before you do anything destructive.

On Ubuntu you can't su before you have set a password for root.
0
 

Author Comment

by:jskfan
ID: 39704545
so if you are logged in as root , you do not need to run sudo ?
if you are logged in as regular user, then you type  su to run something  as root, you will stay logged in as root for the rest of the commands that you will run , until you specifically type again su to switch to regular user ???

 if you type sudo to run a command, then after that command is executed , your privileges will go back to the regular user ????

is this correct ?
0
Quick Cloud Training

Looking for some quick training on the cloud in 2 hours or less? Check out these how-to guides in AWS, Linux, OpenStack, Azure, and more!

 
LVL 21

Assisted Solution

by:Mazdajai
Mazdajai earned 500 total points
ID: 39704603
>>So if I know the root password, then I do not need to run Sudo at all…correct ?

Yes you do not need sudo if you are root. But it is often recommended to login as regular user, sudo to root unless if you need root rights.

For example - sudo su -  allows user to switch to root without exposing the root password. User enter their own password and become root. If the system is being managed or use a large number of users, utilizing sudo is highly recommended.

Take a look of the /etc/sudoers to understand more.
0
 
LVL 88

Accepted Solution

by:
rindi earned 1000 total points
ID: 39704638
"so if you are logged in as root , you do not need to run sudo ?"

Correct, then you already have all the rights on the system.

"if you are logged in as regular user, then you type  su to run something  as root, you will stay logged in as root for the rest of the commands that you will run , until you specifically type again su to switch to regular user ???"

Not exactly. Using "su", you login as root for that terminal session, and you stay logged in as root for that terminal session. To go back to the original user, you type "exit".

"if you type sudo to run a command, then after that command is executed , your privileges will go back to the regular user ????"

Correct, but sudo allows you to streamline the settings in the sudoers file. For example you can limit what applications a user is allowed to run using sudo, and there is usually also a timeout set which allows you to use sudo again for a certain period of time after the first sudo command without requiring the user password. Or you can also allow users to run sudo without even requiring his password.
0
 

Author Closing Comment

by:jskfan
ID: 39705215
Thank you
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question