Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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
share|improve this answer
    
How do I apply those $PATH settings to any and every once at once? –  Zeno Jan 6 '12 at 18:56
    
You can modify /etc/profile. PATH= $PATH:/sbin:/bin:/usr/local/bin:/usr/local/sbin/ –  Eric Jan 6 '12 at 18:58
    
Thanks. Should I just give every user those path values, even though they can't use adduser etc? –  Zeno Jan 6 '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 6 '12 at 19:01

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".

share|improve this answer
    
Hm but I was logging into SSH directly with root. –  Zeno Jan 6 '12 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.