LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 03-03-2019, 03:37 PM   #1
whois1230
Member
 
Registered: Sep 2018
Posts: 214

Rep: Reputation: Disabled
Sudo not working even when installed


Hello, I installed sudo but it is not working:
Code:
user@debian:~$ sudo ufw status
[sudo] password for user: 
user is not in the sudoers file.  This incident will be reported.
I tried editing /etc/sudoers with the
Code:
gedit
command and also
Code:
gedit visudo
and I added the username, but it didn't work.
 
Old 03-03-2019, 04:38 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Most likely, the line you added to the sudoers file does not do what you want it to do. And I doubt that gedit visudo is the right command for changing the sudoers file.

Last edited by berndbausch; 03-03-2019 at 04:39 PM.
 
Old 03-03-2019, 04:39 PM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,685

Rep: Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713
You really need to check the man pages for sudo. NOTHING should ever edit the sudoers file other than visudo, and that should only work for root.

Make sure that you read the man pages about the sudoers file format. Visudo should check the format and warn you if you have wrong syntax, but it cannot detect incorrect logic.

Installation of sudo does not automatically configure sudo, so after installation it will only work for root (which really does not need it, but allows you to configure the users and commands you need.


Finally, there is a log file for sudo and debian has it (by default, I believe) log to /var/auth. Whenever you bring a problem here it is wise to check the log files first and include any log data that pertains.

I do hope that this helps.
 
Old 03-03-2019, 04:46 PM   #4
Mechanikx
Member
 
Registered: Jul 2018
Distribution: Slackware
Posts: 351

Rep: Reputation: 258Reputation: 258Reputation: 258
Quote:
Originally Posted by whois1230 View Post
Hello, I installed sudo but it is not working:
Code:
user@debian:~$ sudo ufw status
[sudo] password for user: 
user is not in the sudoers file.  This incident will be reported.
I tried editing /etc/sudoers with the
Code:
gedit
command and also
Code:
gedit visudo
and I added the username, but it didn't work.
You shouldn't edit the sudoers file directly in case you type something incorrectly. It's recommended to use 'visudo'.

If you want to use gedit instead of vi to edit this file:

Code:
EDITOR=gedit visudo
Note the environment variable EDITOR will only be set to gedit for your current session.

It would be helpful if you could post the change you made to the sudoers file.

I have the following:

Quote:
root ALL=(ALL) ALL
Mechanikx ALL=(ALL) ALL
And 'sudo' works.
 
Old 03-03-2019, 05:00 PM   #5
whois1230
Member
 
Registered: Sep 2018
Posts: 214

Original Poster
Rep: Reputation: Disabled
I found a guide on the web that helped me https://www.vultr.com/docs/how-to-us...os-and-freebsd After creating a new user account, sudo started working. I deleted the user account and rebooted my computer and it still works.
 
Old 03-03-2019, 05:03 PM   #6
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
What do you mean you installed sudo? What distribution are you using? Are you sure it was not already installed?

Assuming that your 'installation' did not cause any problems, you do not need to edit the sudoers file. In fact gedit or any other editor should never be used to modify the sudoers file. In fact the beginning of the file states
Quote:
# This file MUST be edited with the 'visudo' command as root.
and that is exactly what must be done. But you do not need to do that I strongly suspect.

You probably are not a member of the sudo group. Check that with
Code:
grep <your username> /etc/group
If there is not a sudo line in the return, you are not a member of the group. Become a member of the group with AS ROOT
Code:
passwd <your username> sudo
Now you are a member of the sudo group and can use sudo. You may have to log out and then log back in for it to take effect.
 
Old 03-03-2019, 05:12 PM   #7
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by agillator View Post
What do you mean you installed sudo? What distribution are you using? Are you sure it was not already installed?
The OP installed Debian and supplied a root password during installation (I reckon anyway). In this case, sudo is not installed during the installation process.

https://wiki.debian.org/sudo

Last edited by hydrurga; 03-03-2019 at 05:14 PM.
 
Old 03-03-2019, 05:24 PM   #8
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
I see. I did not know Debian did not install sudo, I thought it did. The rest of my post should still be valid, though, assuming his installation had no problems and his attempt to edit sudoers did not was unsuccessful. As some above suggested he really should remove his edits if they are there.
 
Old 03-03-2019, 05:28 PM   #9
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
I'll also note that there were responses posted while I was composing mine and checking to make sure I was giving valid information, so I did not see his response that is just above mine.
 
Old 03-03-2019, 05:53 PM   #10
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by agillator View Post
I see. I did not know Debian did not install sudo, I thought it did. The rest of my post should still be valid, though, assuming his installation had no problems and his attempt to edit sudoers did not was unsuccessful. As some above suggested he really should remove his edits if they are there.
From Squeeze onwards, it does install and configure sudo if you leave the root password blank on installation.

I am not knowledgeable about Debian but I assume that the idea is that if you enter a root password then you don't want to use the common modern distro paradigm of running your distro as an ordinary user and sudoing when you need admin privileges or, perhaps more likely, you will be setting up your users and their rights manually in your own time.

Or something like that. I only know about this behaviour because I was caught out myself setting up a Debian install a couple of years ago.
 
Old 03-03-2019, 08:53 PM   #11
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,349
Blog Entries: 28

Rep: Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145
Sudo is not something you install. It's something you configure.

Debian expects you to use su to assume root privileges. See man su and man sudo for more.
 
1 members found this post helpful.
Old 03-04-2019, 01:24 AM   #12
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by frankbell View Post
Sudo is not something you install. It's something you configure.

Debian expects you to use su to assume root privileges. See man su and man sudo for more.
Codswallop, if I may so. From the Debian wiki I linked to earlier (my emphasis):

Quote:
As of DebianSqueeze, if you give root an empty password during installation, sudo will be installed and the first user will be able to use it to gain root access (currently, the user will be added to the sudo group). The system will also configure gksu and aptitude to use sudo. You should still verify group membership after logging in as the installed user.
Straight from the horse's mouth, as they say.

This is not, and shouldn't be, an argument about the use of sudo. This should be about helping the OP and explaining the situation, not expounding our personal opinions.

Last edited by hydrurga; 03-04-2019 at 01:28 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I just installed Linux Mint 18.3 and Netflix won't play on Chrome (even with user agent switcher installed) - please help! dream_seeker Linux - Newbie 4 06-01-2018 08:52 AM
Not able to run this command "sudo apt-get install libdevil-dev" even after trying "apt-get -f install" getting below error message srihariu1 Linux - Embedded & Single-board computer 2 04-26-2018 06:33 AM
sudo: effective uid is not 0, is sudo installed setuid root? awladnas Linux - Newbie 10 08-30-2014 06:03 PM
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
Can't use sudo, only account that's not root is not a sudo'ers [Ubuntu 9.10] randyriver10 Linux - Desktop 1 01-09-2010 07:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration