Examine root’s user profile and PATH characteristics.
Become root:
sudo su -
Enter the command:
ifconfig
as root, and you’ll see your IP address (among other things). Just to be sure, run:
whoami
And while you’re at it, check your (root’s) group memberships:
groups
Now leave root:
exit
At the login prompt, log in as studenth:
login: studenth password: student
Now compare studenth’s characteristics
Type the commands:
ifconfig whoami groups
What do you get?
A Standard User
You’re currently logged in as studenth.
Your default permissions and environment are MUCH more restrictive than root’s.
And your PATH is different.
Finding that command
Enter the command:
whereis ifconfig
What do you get?
Running ifconfig as studenth
ifconfig won’t run directly for studenth because the command (actually, the program run by the command) isn’t in the PATH of studenth.
ifconfig WILL run if you specify its location:
/sbin/ifconfig
Now try this with useradd
Still logged in as studenth, first find the useradd command (program):
whereis useradd
Now type the command using its full path.
Explain what you get.
Make sure you correctly called the command from its real location.
Why it doesn’t work
studenth was not CREATED as a root-group user.
studenth does NOT have the same rights as root.
Add to your PATH
Now we’re going to add to studenth’s PATH environment variable:
set PATH=${PATH}:/sbin
Check the result using echo:
echo $PATH
Run this command:
ifconfig
Does it work for you now?