23

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

4 Answers 4

43

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.

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.
    – DopeGhoti
    Dec 27, 2016 at 17:44
  • 3
    The sudo group serves the same purpose.
    – DopeGhoti
    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
    – ivanivan
    Dec 27, 2016 at 18:32
  • 4
    If you can log in as root, why not just install the firmware as root? Forget sudo.
    – Carl
    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.
    – Paul Evans
    Dec 28, 2016 at 13:58
17

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

apt install sudo

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

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

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

1
  • 1
    This is what I would do also.
    – prosti
    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.

Not the answer you're looking for? Browse other questions tagged .