ubuntu 下sudo cd 会报command not found

Categories: ubuntu
Tags: No Tags
Comments: Comments Off
Published on: 2010 年 12 月 09 日

ubuntu 下sudo cd 会报command not found
通过which cd命令发现
cd:      aliased to set olddir=$cwd ; chdir !*
如果确实需要运行cd,可以先输入sudo -s,然后就可以运行cd了,不过发现变成root@hostname了,也就是说变成root登陆了.


cd is a shell built-in command. It cannot be run in a child process. The child process simply cannot change the working directory of its parent shell process.

Redirection also does not work with sudo for the same reason (redirection being a shell "thing")

sudo 'ls /root/restricted >/root/out.txt'

sudo: ls /root/restricted >/root/out.txt: command not found

Comments are closed.

Welcome , today is 星期三, 2017 年 10 月 18 日