Adduser command not working in Linux
Solution 1:
Thats because its not native to all linux distros, useradd
is the native command. adduser
is a user-friendly version that implements Perl:
Useradd is built-in Linux command that can be found on any Linux system. However, creating new users with this low-level is a tedious task.
Adduser is not a standard Linux command. It’s essentially a Perl script that uses the useradd command in the background. This high-level utility is more efficient in properly creating new users on Linux. Default parameters for all new users can also be set through the adduser command.
Retrieved: https://linuxhandbook.com/useradd-vs-adduser/
If you are on a Debian based distro (Ubuntu, etc) you can install it with the folowing:
sudo apt-get update
sudo apt-get install adduser
If that doesn't work, check if useradd
is installed correctly.
Otherwise, if you are not on a Debian-based system (Redhat, etc) you probably just want to stick with useradd... I don't think they support adduser
.
If you are on a Debian system and the installation doesn't work you might have an issue with your path variables. You can learn more about this here https://youtu.be/Jp0WWDSJ3Ac
Solution 2:
If "useradd" is not working, check your PATH variable.
Check for presence of useradd under /usr/sbin/useradd. It should be present by default.
$ echo PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Assign "/usr/sbin" to the path.
$ $PATH=/usr/local/bin:/usr/bin:/usr/sbin:/bin:/usr/local/games:/usr/games
$ export PATH
now "useradd" should work.
$ useradd -help|more
Usage: useradd [options] LOGIN
useradd -D
useradd -D [options]