Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

HOWTO enable SUDO

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
craigevil
Posts: 5391
Joined: 2006-09-17 03:17
Location: heaven
Has thanked: 28 times
Been thanked: 39 times

HOWTO enable SUDO

#1 Post by craigevil »

Debian unlike other distros like Ubuntu does not come with sudo enabled by default. That said it is easy enough to set it up.

How to setup sudo:

1) Use visudo to edit your sudoers file
2) Add your user to the sudo group

Code: Select all

adduser foo sudo
3) Or you can use gksu, or kdesu on KDE.

Or you can follow the simple steps here:
Debian Reference Chapter 1. - http://www.debian.org/doc/manuals/debia ... figuration

Other helpful sudo links:
Another more detailed sudo howto http://forums.debian.net/viewtopic.php?f=16&t=45390
Visudo Manual - http://www.gratisoft.us/sudo/visudo.man.html
Add a User To Group - http://www.cyberciti.biz/faq/ubuntu-add-user-to-group/
Proper way to open apps as root in X - http://forums.debian.net/viewtopic.php?f=16&t=53366
sudo - Debian Wiki - http://wiki.debian.org/sudo

HOWTO - get kdesu back to normal in KDE4 - http://forums.debian.net/viewtopic.php?f=16&t=40158
This one is actually pretty easy. In a terminal here is what you do:
Anywhere you see ## just after that is instructions you do NOT have to type the text directly AFTER the ## signs,
what you have to type will either be BEFORE the ## on a line or the line will have NO ## signs.

Code: Select all

   ##first type in:
    su

    ##after you hit enter you will see
    Password:         ##<----------- type in your root password here.

    ##Now you will see your prompt change from a $ to a # sign

    ##Don't worry, almost done now...

    ##type:

    ln -s /usr/lib/kde4/libexec/kdesu /usr/bin/kdesu

    ##hit enter, then type:
    exit

    ##You are now back to your regular user in your terminal. Lets test that puppy out!

    kdesu dolphin

    ##The normal kdesu dialog should pop up asking for roots password with the explanation that the program 
    ##dolphin needs root permissions. You can just cancel the dialog box since it was only a test to see if the link
    ##worked.
Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian Sid Kernel: 5.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: HOWTO enable SUDO

#2 Post by phenest »

Personally, I use an alias:

Code: Select all

alias sudo='su -c'
All one has to remember is to put all the commands following sudo within quotes.
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

el chapulín
Posts: 78
Joined: 2012-09-07 08:34

Re: HOWTO enable SUDO

#3 Post by el chapulín »

So you can pretend you're using sudo...? :shock:

Deb-fan
Posts: 1047
Joined: 2012-08-14 12:27
Been thanked: 4 times

Re: HOWTO enable SUDO

#4 Post by Deb-fan »

^ :lol:

Hey, it's opensource ... diff strokes, for diff folks. One of the kickbutt things about gnu/nix. Free to do with it what you will/can. :D
Most powerful FREE tech-support tool on the planet * HERE. *

sej7278
Posts: 225
Joined: 2011-06-11 17:03

Re: HOWTO enable SUDO

#5 Post by sej7278 »

i'd rather use "su -" to become root rather than all the sudo crud from n00buntu.

at least with su you have to know the root password, a little more secure than using your own password with sudo.

User avatar
craigevil
Posts: 5391
Joined: 2006-09-17 03:17
Location: heaven
Has thanked: 28 times
Been thanked: 39 times

Re: HOWTO enable SUDO

#6 Post by craigevil »

I have exactly two apps installed that use sudo, apper and PeerGuardian. Other than that I never use sudo, I use either kdesu or su.

But many new user coming from other distros especially the *buntus are used to using sudo, hence the howto.
Raspberry PI 400 Distro: Raspberry Pi OS Base: Debian Sid Kernel: 5.15.69-v8+ aarch64 DE: MATE Ram 4GB
Debian - "If you can't apt install something, it isn't useful or doesn't exist"
My Giant Sources.list

User avatar
debil
Posts: 1336
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: HOWTO enable SUDO

#7 Post by debil »

craigevil wrote:But many new user coming from other distros especially the *buntus are used to using sudo, hence the howto.
IOW, so they can keep on sticking to a bad habit they're just used to?
Q: Why is the Eunux kernel so bloated?
A: It was made in the image of its founder.

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: HOWTO enable SUDO

#8 Post by nadir »

There is another how-to in the how-to-section, a bit old:
http://forums.debian.net/viewtopic.php?f=16&t=45390
As i don't use sudo i can't say if it is further info or just superfluous chat by me.
If the latter: ignore.

I think linking to this one:
http://forums.debian.net/viewtopic.php?f=16&t=53366
here might be of use too. Ups: craigevil linked to that one above himself. I really seem to get old ...
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

Re: HOWTO enable SUDO

#9 Post by kedaha »

debil wrote:
craigevil wrote:But many new user coming from other distros especially the *buntus are used to using sudo, hence the howto.
IOW, so they can keep on sticking to a bad habit they're just used to?
Although new users who have taken the trouble to read Debian documentation on the subject may be excused for sticking to the habit having read that it is common practice:
debian-reference/ch01.en.html#_sudo_configuration
For the typical single user workstation such as the desktop Debian system on the laptop PC, it is common to deploy simple configuration of sudo
Or may consider it better (safer) for the reasons given here: wiki.debian.org/sudo:
Using sudo is better (safer) than opening a session as root for a number of reasons...
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

el chapulín
Posts: 78
Joined: 2012-09-07 08:34

Re: HOWTO enable SUDO

#10 Post by el chapulín »

kedaha wrote:Or may consider it better (safer) for the reasons given here: wiki.debian.org/sudo:
Using sudo is better (safer) than opening a session as root for a number of reasons...
This applies to the scenario of sudo vs running an x session as the root user - in such a case sudo is obviously infinitely safer and the better practice.

User avatar
debil
Posts: 1336
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: HOWTO enable SUDO

#11 Post by debil »

kedaha wrote:
debil wrote:
craigevil wrote:But many new user coming from other distros especially the *buntus are used to using sudo, hence the howto.
IOW, so they can keep on sticking to a bad habit they're just used to?
Although new users who have taken the trouble to read Debian documentation on the subject may be excused for sticking to the habit having read that it is common practice:
debian-reference/ch01.en.html#_sudo_configuration
For the typical single user workstation such as the desktop Debian system on the laptop PC, it is common to deploy simple configuration of sudo
Well, lo and behold, shoot me in the head.
kedaha wrote:Or may consider it better (safer) for the reasons given here: wiki.debian.org/sudo:
Using sudo is better (safer) than opening a session as root for a number of reasons...
And here are the reasons listed:
http://wiki.debian.org/sudo wrote: Nobody needs to know the root password (sudo prompts for the current user's password). Extra privileges can be granted to individual users temporarily, and then taken away without the need for a password change.
It's obvious that one needs to know root passwd, especially on a single-user system.
http://wiki.debian.org/sudo wrote: It's easy to run only the commands that require special privileges via sudo; the rest of the time, you work as an unprivileged user, which reduces the damage that mistakes can cause.
Unless you're in the habit of spamming sudo in front of various commands. Just in case. Nothing can be done when PEBCAK.
http://wiki.debian.org/sudo wrote: Auditing/logging: when a sudo command is executed, the original username and the command are logged.
When using su, the commands get logged in root's $SHELL history. Again, especially in a single-user install, what's the point? <-- Rhetorically, that is. I guess it's a case of YMMV again.
Q: Why is the Eunux kernel so bloated?
A: It was made in the image of its founder.

kedaha
Posts: 3521
Joined: 2008-05-24 12:26
Has thanked: 33 times
Been thanked: 77 times

Re: HOWTO enable SUDO

#12 Post by kedaha »

debil wrote:
kedaha wrote:Or may consider it better (safer) for the reasons given here: wiki.debian.org/sudo:
Using sudo is better (safer) than opening a session as root for a number of reasons...
And here are the reasons listed:
http://wiki.debian.org/sudo wrote: Nobody needs to know the root password (sudo prompts for the current user's password). Extra privileges can be granted to individual users temporarily, and then taken away without the need for a password change.
It's obvious that one needs to know root passwd, especially on a single-user system.
If it is a self-administered system, I agree with you. But I certainly don't think, for example, a secretary using a workstation for secretarial work in an office needs to know the root password, or anyone else for that matter including the boss.
DebianStable

Code: Select all

$ vrms

No non-free or contrib packages installed on debian!  rms would be proud.

User avatar
debil
Posts: 1336
Joined: 2008-05-11 08:55
Location: Mazes of Menace, surrounded by brown puddings

Re: HOWTO enable SUDO

#13 Post by debil »

kedaha wrote:
debil wrote:And here are the reasons listed:
http://wiki.debian.org/sudo wrote: Nobody needs to know the root password (sudo prompts for the current user's password). Extra privileges can be granted to individual users temporarily, and then taken away without the need for a password change.
It's obvious that one needs to know root passwd, especially on a single-user system.
If it is a self-administered system, I agree with you. But I certainly don't think, for example, a secretary using a workstation for secretarial work in an office needs to know the root password, or anyone else for that matter including the boss.
Agreed. If it's a multi-user environment, sudo has its uses, in its restricted, proper way of usage. That is, not username ALL=(ALL:ALL) ALL style, which would be a quick road to disaster.
Q: Why is the Eunux kernel so bloated?
A: It was made in the image of its founder.

el chapulín
Posts: 78
Joined: 2012-09-07 08:34

Re: HOWTO enable SUDO

#14 Post by el chapulín »

kedaha wrote:If it is a self-administered system, I agree with you. But I certainly don't think, for example, a secretary using a workstation for secretarial work in an office needs to know the root password, or anyone else for that matter including the boss.
Does a secretary using a workstation need any kind of root access, whether it's a root password or sudo...?

sej7278
Posts: 225
Joined: 2011-06-11 17:03

Re: HOWTO enable SUDO

#15 Post by sej7278 »

debil wrote:Agreed. If it's a multi-user environment, sudo has its uses, in its restricted, proper way of usage. That is, not username ALL=(ALL:ALL) ALL style, which would be a quick road to disaster.
yes that's my main gripe with sudo - its NEVER configured properly to allow only certain users to run certain commands.

without that being done (i.e. n00buntu default) its hideously insecure and prone to PEBKAC errors. n00buntu seem to do it purely to stop people logging into X as root.

hkoster1
Posts: 1264
Joined: 2006-12-18 10:10

Re: HOWTO enable SUDO

#16 Post by hkoster1 »

Yet another way of configuring sudo (with thanks to our lamented long lost Telemachus):

With root privileges, edit a user file like /etc/sudoers.d/mysudo with content

Code: Select all

Cmnd_Alias NET = /sbin/ifconfig, /sbin/ifup, /sbin/ifdown, \
                 /sbin/ip, /sbin/route
Cmnd_Alias APT = /usr/bin/aptitude, /usr/bin/apt-get, \
                 /usr/bin/dpkg, /usr/sbin/dpkg-reconfigure
<username>      ALL = NOPASSWD: NET, APT
then change the file privileges with

Code: Select all

# chmod 0440 /etc/sudoers.d/mysudo
Then you're all set.

Have fun!
Real Debian users don't do chat...

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: HOWTO enable SUDO

#17 Post by nadir »

hkoster1 wrote: (with thanks to our lamented long lost Telemachus):
Yeah, looks so. But then, short ago: http://forums.debian.net/viewtopic.php? ... 2c#p453683
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

Post Reply