I'm trying to make a script where it makes a test user with a home dir and the rights he needs but everytime I run the script I get the following error:/home/thomas/Scripts/CreateUser.sh: line 2: useradd: command not foundpasswd: user 'password' does not exist/home/thomas/Scripts/CreateUser.sh: line 4: mkhomedir_helper: command not foundchmod: cannot access /home/Test/: No such file or directoryScript:#!/bin/bashuseradd Test passwd passwordmkhomedir_helper Testchmod 700 /home/Test/I'm new to linux so I don't know why this happens, any solutions?
Useradd command not found
linux;shell script;opensuse;useradd
Your script should look like:#!/bin/bash/usr/sbin/useradd -m -d /home/Test/ -s /bin/bash Test echo -e password\npassword | passwd Testchmod 700 /home/Test/The reason for your error is that /usr/sbin is most likely not in the $PATH variable of the account you're running the script with.