Solved

Su and Sudo in inux

Posted on 2013-12-08
6
464 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 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

739 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