Solved

Su and Sudo in inux

Posted on 2013-12-08
6
437 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 87

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 87

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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.:
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now