# useradd deepak
-bash: useradd: command not found
# whereis useradd
useradd: /usr/sbin/useradd /usr/share/man/man8/useradd.8.gz
# which useradd
You can use find command ultimately to look out for the missing command or file (As all the command are executable files)
# find / -name useradd -type f
So now once you got the location of the command, add the path to the PATH variable
# export PATH=/usr/sbin:$PATH
But again running this export command will be session dependent so once you change the session you will again have to export the new PATH variable
# vi /root/.bash_profileSo now every time your system reboots this command will be executed and the PATH variable will be updated.
Permanent Fix:To fix this issue permanently so that this issue does not comes up again. You can add the default location of all the directories in the PATH variable which contains all the executable files in Red Hat Linux in your .bash_profile file.
NOTE: The following commands are tested on RedHat and CentOS
First find the full path of the executable file using the below command or any of the command shown above
# which useradd
Then run the below command
$ rpm -qf /usr/sbin/useradd
As you see the package responsible for useradd binary file is shadow-utils
# yum whatprovides */useradd
2:shadow-utils-18.104.22.168-13.el6.i686 : Utilities for managing accounts and shadow
: password files
Repo : base
Filename : /etc/default/useradd
Filename : /usr/sbin/useradd
# yum -y install shadow-utils
Follow the below links for more tutorials
Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
How to configure Samba 4 Secondary Domain Controller
How to secure Apache web server in Linux using password (.htaccess)
How to register Red Hat Linux with RHN (Red Hat Network )
Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
What is the difference between "su" and "su -" in Linux?
What is swappiness and how do we change its value?
How to log iptables messages in different log file
What are the s and k scripts in the etc rcx.d directories
How to check all the currently running services in Linux
How to auto start service after reboot in Linux
What is virtual memory, paging and swap space?