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
Solved

Su and Sudo in inux

Posted on 2013-12-08
6
456 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
6 Comments
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 125 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 250 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 21

Assisted Solution

by:Mazdajai
Mazdajai earned 125 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 250 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get maximum transfer speed over LAN 4 103
Reset Root Password on CentOS 6 4 69
linux SFTP 8 60
linux - yum package installation issue 2 54
This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

809 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