执行sudo命令时command|执行sudo命令时command not found的解决办法
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
文章图片
image
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
runwhereis 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 havesudo
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
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"
【执行sudo命令时command|执行sudo命令时command not found的解决办法】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
文章图片
image
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
推荐阅读
- CVE-2020-16898|CVE-2020-16898 TCP/IP远程代码执行漏洞
- 字符串拼接成段落,换行符(\n)如何只执行n-1次
- 你命令我爱你吧(原创)
- 常用git命令总结
- 用Go构建区块链——3.持久化和命令行
- 《读_Head_First_有感》_“命令模式”
- R语言|R语言 函数
- locate搜索
- Linux|Linux 服务器nginx相关命令
- linux笔记|linux 常用命令汇总(面向面试)