Addgroup Command Not Found – How to Resolve

pathsudo

I'm following this tutorial to setup a new sftp user on a webserver running on debian, but when I get to step 3

sudo addgroup filetransfer

I can't go on because the terminal gives me the following error

Addgroup: command not found

I installed the adduser package with apt-get install and the server says it's already installed. I also tried to use the command groupadd but nothing changes.
What am I doing wrong?
Thanks everyone!

EDIT: the result of sudo bash -c 'echo $PATH' as asked in the questions below

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Best Answer

It looks like your environment doesn't include the /usr/sbin directory that holds such system programs.

The quick fix should be to use /usr/sbin/adduser instead of just adduser.

Two alternative solutions are:

  1. Change the PATH in .bashrc and/or .bash_profile so that /usr/sbin is included in the list. For example, here is my setting:

    export PATH="$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/local/games:/usr/games"
    
  2. Edit the sudoers configuration (with sudo visudo -f /etc/sudoers.d/securepath) and add this line to the empty file:

    # Extend the PATH for sudo commands
    Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    

Either would be sufficient.

Related Question