1

Recently installed CentOS and many commands are not working:

[root@zrebirth zeno]# quotacheck
bash: quotacheck: command not found
[root@zrebirth zeno]# adduser
bash: adduser: command not found
[root@zrebirth zeno]# warnquota
bash: warnquota: command not found
[root@zrebirth zeno]# edquota
bash: edquota: command not found

But they all exist, so they must not be linked:

/sbin/quotacheck
/usr/sbin/adduser
/usr/sbin/warnquota
/usr/sbin/edquota

I'm sure there are more. Is there a way I can quickly fix all of these (even the ones I don't know) without doing each one manually?

Zeno
  • 211
  • 1
  • 3
  • 17

2 Answers2

3

It appears that that you just need to modify your $PATH. The following article goes over how to do that.

Cyberciti

On my default CentOS install, it only has /bin as my path. Therefore if I want to type any other commands that are outside of the /bin path, I need to either fully enter the command such as "/sbin/command" or add those paths as well.

[blah~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
Eric
  • 1,383
  • 3
  • 17
  • 34
  • How do I apply those $PATH settings to any and every once at once? – Zeno Jan 06 '12 at 18:56
  • You can modify /etc/profile. PATH= $PATH:/sbin:/bin:/usr/local/bin:/usr/local/sbin/ – Eric Jan 06 '12 at 18:58
  • Thanks. Should I just give every user those path values, even though they can't use adduser etc? – Zeno Jan 06 '12 at 18:59
  • 1
    It's completely up to you. In my opinion leaving these paths out is another layer of security. If the user wants to use a command such as adduser or lets use the example rm. If they have to specifically put in /sbin/rm or something to that affect it makes them more aware of what they are doing. However there is also a convenience factor depending on how much you use them. I personally just type in all of the paths I need. – Eric Jan 06 '12 at 19:01
1

From centos documentation(http://wiki.centos.org/TipsAndTricks/BecomingRoot):

Commands for regular users are mostly located in /usr/local/bin, /usr/bin, and /bin. However, root commands are mostly located in /usr/local/sbin, /usr/sbin, and /sbin and root's PATH reflects this.When you become root by using 'su -', you also adopt root's PATH whereas using just 'su' retains the original users PATH, hence why becoming root using just 'su' and trying to run a command located in /usr/local/sbin, /usr/sbin, or /sbin results in a 'command not found' error. For a more detailed explanation, see the bash manual page (man bash), particularly the section on INVOCATION and login shells.

You need to use "su -" and not "su".

NoNoNo
  • 1,963
  • 14
  • 20