sudo cd 为什么不能工作

sudo cd 为什么不能工作

因为 cd 是 shell 内置的, 而 sudo 只能对可执行的文件起作用,也就是说在硬盘中根本没有 cd 这个文件(命令)

怎么解决呢,可以通过使用 sudo sh -c 'cd dirname' 或者 sudo -s 之后进入 root shell 之后在执行 cd dirname

This entry was posted in Linux and tagged , . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>