[Solved] Can't get root access on Debian. Total Linux noob here

So I watched Qain's video on a surveillance setup and I thought it might be a fun little project.

I downloaded the latest version of Debian and installed it on an old laptop I had lying around but when I tried to apt-get update I got a bunch of "Could not open lock file" and an "are you root?" messages so I tried sudo, got command not found. Had a quick look on google and people were saying sudo isn't installed if you give root user a password while installing the OS but I didn't give root a password, I left it blank.

What gives? Can anyone provide any insight?

Use "su"

You should add a sudoers file and add your user to it though.

How do you use su? I tried su apt-get update and got No password entry for user apt-get. Then tried with my username before apt-get and it said cannot execute binary file

Also, how do you add a sudoers file and what is it?

su isnt sudo, su switches user.

su allows you to change what user you are working as. by default (with no user specified) it switches to root. This requires you to enter the root password when it asks.

This didnt work because su apt-get is you saying switch user to user apt-get which isnt a thing.
sudo works that way because sudo gives temporary root privileges.

you can also do su username for example if you are logged in as root and want to do something as a non-root user you can use su distracted6 and it will switch to that user.

Also see man su for the manual page for su.

Ooooohh ok, that makes sense now. Now when I just use su on its own it asks for a password and then says authentication failure with and without a password

Did you put in the password for the root user? You'll have set one when you installed Debian.

I left it blank because I thought that's what stopped sudo working. I'll reinstall and give a root password and see if it works

I dont know for Debian, but sudo normally needs setup in most distros. If you want to use sudo you can edit /etc/sudoers

The best way is to make it work only for users in a specific group, normal the wheel group.

You can check what groups your user has by running id if your not in the wheel group you can add it

su
gpasswd -a [user] wheel

replacing [user] with your username

then in the /etc/suders config the part youll want to look at is this. This specifies how sudo will work.

You'd make sure the second entry is uncommented.

##
## Runas alias specification
##

##
## User privilege specification
##
#root ALL=(ALL) ALL

## Uncomment to allow members of group wheel to execute any command
 %wheel ALL=(ALL) ALL

## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

## Uncomment to allow members of group sudo to execute any command
# %sudo ALL=(ALL) ALL

Thanks for that, I'll definitely have a look into that.

When it says sudo isn't a recognized command can I just install it as a package or something?

Yes just install sudo then set it up the way you like with the sudoers config.

Thanks for all your help mate, you're a legend

1 Like

If its all solved, you can prefix the topic title as [solved] for others to see. :)