Results 1 to 4 of 4
Thread: sudo and cd
Enjoy an ad free experience by logging in. Not a member yet? Register.
sudo and cd
so i try
sudo cd /root
oh btw i am running ubuntu 11.04 and i only have one user installed on the maching so su doesnt switch me to root.
First you switch to a root level of privilegesCode:
Also Take the Linux Filesystem Tour | TuxRadar Linux"I used to be with it, then they changed what it was.
Now what was it isn't it, and what is it is weird and scary to me.
It'll happen to you too."
The Fifth Continent
"cd" is not really a program: instead, it is an action taken by a shell. The reason that sudo complains is that sudo only understands programs:
[alex@niamh ~]$ which cd which: no cd in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl)
[alex@niamh ~]$ whoami alex [alex@niamh ~]$ sudo -i [root@niamh ~]# whoami root
Instead, you can try something like "sudo ls /root", and therefore use sudo in its generally intended way.
There's another option for you, as well.
You can use su -c to perform root functions one at a time.
su -c 'ls -l /root