26

I just finished installing Debian 8 (Jessie) and tried to make a directory in lib/firmware, because there was a file missing (rtl8723befw.bin) in the installation, and it says

mkdir: cannot create directory `rtlwifi`: Permission denied 

I tried putting sudo on the front, but then it returns:

bash: sudo: command not found 

When trying to install sudo with apt-get install sudo or even apt-get update it returns:

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? 

I am really at a loss of what to do. All the solutions that I seem to find for the latest error is to use sudo, but I don't even have that.

3
  • 1
    related unix.stackexchange.com/questions/106529/… Commented Dec 27, 2016 at 17:44
  • 2
    I never even use sudo. Always su -c. Commented Dec 28, 2016 at 8:31
  • Why did you try to use sudo if you set the root password? Commented Dec 28, 2016 at 17:13

4 Answers 4

47

If you do not have sudo installed, you will need to actually become root. Use su - and provide the root user's password (not your password) when asked. Once you have become root, you can then apt-get install sudo, log out of the root shell, and actually use sudo as you are trying to, now that it will have been installed.

Make sure that you add the appropriate users to the sudo or wheel group.  Run this command as root: usermod -aG {group} {user}.  Make sure to replace {group} with sudo or wheel and {user} with your username.

14
  • 5
    Become root again, and add yourself to the wheel group. Also use visudo to make sure that the configuration to allow anyone in the wheel group to use sudo is not commented out. Commented Dec 27, 2016 at 17:44
  • 3
    The sudo group serves the same purpose. Commented Dec 27, 2016 at 18:24
  • 3
    adduser yourusername sudo - note that group membership really doesn't change until you completely log out of all sessions/logins Commented Dec 27, 2016 at 18:32
  • 4
    If you can log in as root, why not just install the firmware as root? Forget sudo. Commented Dec 28, 2016 at 3:20
  • 1
    @Carl Because if you do that, one day you'll not log out of the root account. You'll be thinking of some other things. You'll use the root account thinking it's one of your logins. And you'll break something. That's the whole point of sudo. Commented Dec 28, 2016 at 13:58
19

Become root: run su, give your root password,
and then run:

apt install sudo 

To grant administrative privileges to Mariel, run the visudo command as root, and then edit your file as follows:

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

Or you can run usermod -aG group Mariel, with group replaced with sudo or wheel as defined by your operating system, as root.

Log in as user Mariel.  You will be able to run sudo without problems.

1
  • 1
    This is what I would do also. Commented Dec 28, 2016 at 15:28
8

As an alternative to given answers, if you do not know the root password to allow you to use su, you can boot to single user mode.

At the grub menu, press e to edit the boot command line. Near the end of the line beginning linux add the word single, and continue the boot. You will be placed at a root prompt and can reset the root password so that you can use su on the next normal boot.

3

You can use su -c as a quick and dirty replacement. If your su doesn't include -c, then just su to login as root. If you're working on some sort of odd embedded device that doesn't have su, try login root instead.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.