Useradd and adduser
SolvedHello everyone,
I installed Debian 10.12.0 on my machine, but the adduser and useradd commands are not found.
Thank you in advance!
2 answers
-
Hello,
I installed Debian 10.12.0 on my machine, but the adduser and useradd commands are not found.
Short answer
It's probably because you are not root.
Detailed answer
apt-file
When it seems like you are missing a command, you can search for which package provides it with apt-file, and then check if it is installed with dpkg -l.
Installing apt-file:
apt update apt install apt-file sudo apt-file update
Examples:
apt-file search useradd | grep bin/useradd
passwd: /usr/sbin/useraddapt-file search adduser | grep bin/adduser
adduser: /usr/sbin/adduserInterpretation:
So, you need to have the passwd and adduser packages installed (and if necessary, install them with apt install). In reality, these two packages are already installed, as the command will show you:
dpkg -l | egrep "passwd|adduser"
The PATH environment variable
The next step is to ensure that the directories containing them (specifically /usr/sbin) are in your PATH; otherwise, you need to type the absolute path of the command (e.g., /usr/bin/adduser) to be able to execute it. To see the current value of PATH, just run:
Example:
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gamesHere, we see that /usr/sbin is not in the PATH. This is normal, since we are not root (and the FHS states that /sbin and /usr/sbin contain executables for administering the machine). We could very well run /usr/bin/adduser toto but it will fail, because like any command that affects the way the system is administered, it requires root privileges.
Running a command as root
To become root, run:
su -
You can verify that /usr/sbin is now in your PATH:
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin... and thus you will be able to run:
adduser toto
PATH and sudo
sudo is a command that allows you to run an administrator command from a user profile. It is installed by default on Ubuntu and can be installed on Debian.
If sudo is installed and you are using it with a user authorized to do so (typically, belonging to the sudo user group), the PATH is implicitly corrected so that it matches root's PATH. You can therefore call the adduser command without having to specify its absolute path.
sudo adduser toto
Good luck
-
Hello
Check out this tutorial to fix a problem.
They're a bit stingy, they probably didn't use adduser. You have to type useradd manually on the keyboard.
https://debian-facile.org/doc:systeme:useradd