24

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.

M.O.
  • 515

4 Answers4

44

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.

DopeGhoti
  • 76,081
  • When making sudo mkdir rtlwifi it returns mariel is not in the sudoers file. This incident will be reported. – M.O. Dec 27 '16 at 17:41
  • cant edit but the sudo is part of the first code obviously – M.O. Dec 27 '16 at 17:43
  • 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 '16 at 17:44
  • could you be more specific on how to write that on terminal please? – M.O. Dec 27 '16 at 17:48
  • googled info and it appears there is no wheel group created, but in visudo there is some piece of code really similar to what the wheel one would look like # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL. Do I need to create a wheel group? How do I add my user name to the sudo group? – M.O. Dec 27 '16 at 18:02
  • 3
    The sudo group serves the same purpose. – DopeGhoti Dec 27 '16 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 '16 at 18:32
  • 4
    If you can log in as root, why not just install the firmware as root? Forget sudo. – Carl Dec 28 '16 at 03:20
  • @ivanivan: it is enough to launch a new login shell to get the changes in effect (just for that session though). – mike3996 Dec 28 '16 at 13:45
  • 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 '16 at 13:58
  • @progo - no, all login sessions must end first – ivanivan Dec 28 '16 at 15:23
  • @ivanivan: maybe wheel is a special case but usually a group gets activated right once I do a new login in my gentoo box. – mike3996 Dec 28 '16 at 17:35
  • @progo Probably you are using a FreeBSD-based distribution. Debian isn't based in FreeBSD, which may explain the difference. – Ismael Miguel Dec 28 '16 at 20:02
  • @IsmaelMiguel: or maybe it's systemd that is once again doing things difficult for you folks. In Gentoo it's still optional – mike3996 Dec 29 '16 at 06:42
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.

GAD3R
  • 66,769
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.

user4556274
  • 8,995
  • 2
  • 33
  • 37
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.

apricot boy
  • 1,153
  • 7
  • 11