https://stackoverflow.com/questions/23714097/sudo-chown-command-not-found
export PATH="$PATH:/usr/sbin"
sudo & chown command not found?
Ask Question
Asked
Active 6 years, 4 months ago
Viewed 14k times
11
2
I have a rails project which I think has been created as root. I want to change the permissions so that the owner is not root but my user.
I found a command here on stackoverflow to achieve this.
sudo chown -R $(username):$(username) Directoryname
So to change it so that my user owns it I am running this:
sudo chown -R $(Jack):$(Jack) APIClient
However I get the error:
sudo: chown: command not found
If i just run chown without sudo I get:
zsh: command not found: chown
Does anyone have any idea how I can fix this? I think it may be to do with my zsh but not sure.
Thanks for any help.
ruby-on-rails command-line terminal
share improve this question follow
edited May 17 '14 at 18:40
asked May 17 '14 at 17:16
jckly
74311 gold badge88 silver badges2020 bronze badges
I think you can do it with command "chmod" too. isn't it? – SSR May 17 '14 at 17:46
Take a look this link : cyberciti.biz/faq/how-to-use-chmod-and-chown-command – SSR May 17 '14 at 17:47
@SSR I've seen that link but like above running any of those gives me chown command not found?? – jckly May 17 '14 at 17:53
-
3
run
whereis sudo chown
and check if you have these paths added to your$PATH
variable (you can display it by runningecho $PATH
) – kaman May 17 '14 at 18:54 -
2
You probably have
sudo
path already added since it's (or at least should be)in the same directory aswhereis
. You probably need to add/usr/sbin
dir and I assume you run osx so justecho "export PATH=$PATH:/usr/sbin" >> ~/.bash_profile
(you may need to close and open your terminal again to see any effect) – kaman May 17 '14 at 19:28
show 3 more comments
1 Answer
ActiveOldestVotes
18
So @kaman helped me fix the problem in the comments above.
Turns out I didn't have the links to chown in my $PATH variable.
To fix this I added the following to my .zshrc
file. However as kaman has put in the comments above If you're running bash just put it in the .bash_profile
export PATH="$PATH:/usr/sbin"
Thanks kaman and hope this helps anyone else who gets the same error.
share improve this answer follow
answered May 17 '14 at 19:40
jckly
74311 gold badge88 silver badges2020 bronze badges
- I did this change, but then PING stopped working. Any thoughts? – Craig London Jul 22 '16 at 19:51