Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Which sudo should I use?


  • Please log in to reply
10 replies to this topic

#1 wishmakingfairy

wishmakingfairy

  • Members
  • 212 posts
  • OFFLINE
  •  
  • Gender:Female
  • Local time:02:32 AM

Posted 26 November 2016 - 07:09 PM

Whenever I want to either install a bunch of things or modify some stuff I pretty much always do "sudo -s" so it stays in a root privilege until I'm done doing everything then just close out the terminal.

 

I've only just started one of those Unix / Linux courses that bleeping has in the offers. From what I can understand there is su for the root account to perform stuff. Then sudo allows the user to perform root privelages under their own account.

 

Am I wrong to be using sudo -s? or should I use other ones i've seen like -i , -u, etc...?

 

I honestly try to avoid using su unless I need to add an account to the sudoers file which I still struggle with when toying with plain debian.


Edited by wishmakingfairy, 26 November 2016 - 07:16 PM.

Using ubuntu and sharing how to as well as collecting how to scripts for common programs. Feel free to ask or share ^-^


BC AdBot (Login to Remove)

 


#2 pcpunk

pcpunk

  • Members
  • 5,876 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Florida
  • Local time:03:32 AM

Posted 26 November 2016 - 07:26 PM

Being a home user and dabble in linux repair for others, I only use "sudo" for simple stuff, and have never even used "su".  Here are a few links in case you didn't know about them.

"sudo"

https://help.ubuntu.com/community/RootSudo

"su"

http://manpages.ubuntu.com/manpages/precise/man1/su.1.html


Edited by pcpunk, 26 November 2016 - 07:27 PM.

sBCcBvM.png

Created by Mike_Walsh

 

KDE, Ruler of all Distro's

eps2.4_m4ster-s1ave.aes_pcpunk_leavemehere

 


#3 Viper_Security

Viper_Security

  • Members
  • 826 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:127.0.0.1
  • Local time:12:32 AM

Posted 26 November 2016 - 07:35 PM

I only use sudo when installing a program not readily available," sudo dpkg -i "***********".deb /sudo apt-get install "PACKAGE-NAME" or when messing with apt. "sudo apt-get update && sudo apt-get dist-upgrade"

 

if you use su you don't need to use sudo after it.

 

SUDo is Super-User Do,

 

SU is Super-User.

 

like an Admin account on windows.

 

I only use su when running specific programs.

 

sudo is fine, no need to append an -s to it,


Edited by Viper_Security, 26 November 2016 - 07:36 PM.

    IT Auditor & Security Professional

hQBT2G3.png


#4 MadmanRB

MadmanRB

    Spoon!!!!


  • Members
  • 3,074 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:No time for that when there is evil afoot!
  • Local time:03:32 AM

Posted 26 November 2016 - 11:50 PM

just use standard sudo, dont know why you want the -s command 


You know you want me baby!

Proud Linux user and dual booter.

Proud Vivaldi user.

 

ljxaqg-6.png


#5 Guest_hollowface_*

Guest_hollowface_*

  • Guests
  • OFFLINE
  •  

Posted 27 November 2016 - 02:23 AM

Su, and Sudo are two tools that do the same thing, allow you to avoid logging out to run code under another account. Kinda like how Chromium, and Mozilla Firefox are both web browsers. Sudo is quite feature rich, and so is also, to some degree, a security tool.

Some key points about Sudo and Su:
1. Some distros (sudo-distros) disable the root account (meaning no password is set for the root account). They of course still need to allow the user to run stuff as root, so they provide Sudo to access it. Ubuntu is an example of this.
2. When you use Su you are prompted for the account holder's password. When you use Sudo, you are prompted for your password.
3. You must be added to the sudo group to use Sudo. This is called being a sudoer.
4. Sudo can be configured to restrict what can be run.

It really depends on what you are doing, as to which Sudo options are appropriate. "sudo -s" preserves certain environmental variables that make it potentially dangerous to use with graphical applications, because it can lead to files that should be owned by you, being owned by someone else instead (eg: root). In general, I would suggest using "sudo -i" instead of "sudo -s" if you want to run a bunch of stuff as root.


Edited by hollowface, 27 November 2016 - 02:25 AM.


#6 wizardfromoz

wizardfromoz

  • Banned
  • 2,799 posts
  • OFFLINE
  •  
  • Gender:Male

Posted 27 November 2016 - 02:33 AM

Hi fairy

 

my comments highlighted between yours

 

 

Whenever I want to either install a bunch of things or modify some stuff I pretty much always do "sudo -s" so it stays in a root privilege until I'm done doing everything then just close out the terminal.

 

Can you give us an example of "a bunch of things or modify some stuff" ? sudo -s is the same as sudo --shell

 

I've only just started one of those Unix / Linux courses that bleeping has in the offers. From what I can understand there is su for the root account to perform stuff. Then sudo allows the user to perform root privelages under their own account.

 

Courses are good, lol. "sudo -i" will give you basically the same privileges as "su" without having to edit or enter the sudoers file.

 

Am I wrong to be using sudo -s? or should I use other ones i've seen like -i , -u, etc...?

 

As mentioned above.

 

I honestly try to avoid using su unless I need to add an account to the sudoers file which I still struggle with when toying with plain debian.

 

What environment are you under currently? Last I heard, you were in Ubuntu trying to paste a URL on the desktop, and then looking to try Linux Mint.

 

Todd C. Miller is the author and maintainer of the sudo manual

man sudo

He worked, last I heard, for Dell Security, and has been maintaining sudo as a sideline for over 20 years. I have his email address from two years ago when he was endorsing some comments I had on Bash scripts, so if we can't find your answer easily, I might try asking him?

 

:wizardball: Wizard

 

BTW - just read hollowface's comments, added whilst I was penning this, and would endorse same. A lot depends on which Distro, and "family" you are using, too, eg Debian, Debian-based, RPM, RPM-based, Arch, Gentoo, &c, as to how much you might need to use root privileges, and to what extent

 

Edited - added BTW


Edited by wizardfromoz, 27 November 2016 - 04:22 PM.


#7 wishmakingfairy

wishmakingfairy
  • Topic Starter

  • Members
  • 212 posts
  • OFFLINE
  •  
  • Gender:Female
  • Local time:05:32 PM

Posted 27 November 2016 - 05:49 AM

To answer the questions easily. I just do what I found works for when I want to do things in succession. For example, when I update and upgrade I just like to type apt-get upgrade and apt-get update. Believe me, I wish I knew a lot more about linux that everything I did didn't seem so hodgepodgy. My current primary hobby studies in life right now are coleopterology, lepidoptery, and linux. I just learn what i can between my busy work schedules. But learning and putting it into practice unfortunately are kind of spaced some days so I don't get to really get a full grasp of most of the inner workings until long after i've actually read and tried it a bit.

 

 

My primary family will pretty much always be debian based. Mint 99% of the time is  my go to, but I can't help but constantly go to other distros all the time since they all look enticing until they start killing over from bugs :P.


Using ubuntu and sharing how to as well as collecting how to scripts for common programs. Feel free to ask or share ^-^


#8 pcpunk

pcpunk

  • Members
  • 5,876 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Florida
  • Local time:02:32 AM

Posted 28 November 2016 - 09:57 PM

Well...you got this one Backwards

apt-get upgrade and apt-get update

Should be

sudo apt-get update && sudo apt-get upgrade

You may already be running as root, but I've never seen anyone use "and" either.  Perhaps you just made a typo.


sBCcBvM.png

Created by Mike_Walsh

 

KDE, Ruler of all Distro's

eps2.4_m4ster-s1ave.aes_pcpunk_leavemehere

 


#9 wishmakingfairy

wishmakingfairy
  • Topic Starter

  • Members
  • 212 posts
  • OFFLINE
  •  
  • Gender:Female
  • Local time:03:32 AM

Posted 28 November 2016 - 10:01 PM

Oh :P, I meant to type it out in the sense that I like to first type apt-get update, hit enter. After the update, type apt-get upgrade. But thinking about it, doesn't it keep you in root permissions after the first initial sudo? :P I think i overthought everything and just did some unnecessary stuff as always.


Edited by wishmakingfairy, 28 November 2016 - 10:02 PM.

Using ubuntu and sharing how to as well as collecting how to scripts for common programs. Feel free to ask or share ^-^


#10 wizardfromoz

wizardfromoz

  • Banned
  • 2,799 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:02:32 AM

Posted 28 November 2016 - 11:44 PM

Hi Fairy.

 

 

doesn't it keep you in root permissions after the first initial sudo?

 

Yes and No.

 

Once you have typed in and entered sudo mode, typical shutout is of five minutes duration (varies from Family to family, even Distro to Distro).

 

However certain commands have an elevated privilege which requires the use of sudo prefacing them even if they are immediately following another sudo command.

 

Example in the spoiler, highlighted part means I have to use sudo for it.

 

Spoiler

 

 

:wizardball: Wizard



#11 Viper_Security

Viper_Security

  • Members
  • 826 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:127.0.0.1
  • Local time:05:32 PM

Posted 29 November 2016 - 12:37 AM

To add to what pcpunk has said, after a new release (stable) comes out i do as said: Sudo apt-get update && sudo apt-get upgrade (&& sudo apt-get dist-upgrade)

                                                                                                                                   ^^                                                                        ^^                                                    ^^

but those are "run once" as wiz had said " However certain commands have an elevated privilege which requires the use of sudo prefacing them even if they are immediately following another sudo command. "

 

 

if you want to "stay" in root permissions you would: su

 

if you were in "su" you would only need: apt-get update && apt-get upgrade

 

or that's the way I've done it, but i only use su rarely in Parrot.

 

Normally sudo "command" will do just fine :)


    IT Auditor & Security Professional

hQBT2G3.png





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users