Results 1 to 4 of 4
ok well i am just trying to learn the linux filesystem in the shell so i have been pretty much just been running
Code:
cd /randomdirectory
then running
Code:
ls ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-20-2011 #1
sudo and cd
ok well i am just trying to learn the linux filesystem in the shell so i have been pretty much just been running
then runningCode:cd /randomdirectory
to see whats in the directory well i tried looking in the /proc and /root directory and i get permission denied.Code:ls -l
so i try
and i get command not found how can i swith to the directory?Code: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.
- 10-20-2011 #2
First you switch to a root level of privileges
(that's a small eye) and then you do your cd.Code:sudo -i
Also Take the Linux Filesystem Tour | TuxRadar LinuxIf we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
The Fifth Continent reborn
- 10-20-2011 #3
"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:
elija's suggestion works because "sudo -i" launches a new shell as the user: it's essentially the same as running "sudo bash". This creates a shell that runs as that user, so you can cd as that user:Code:[alex@niamh ~]$ which cd which: no cd in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl)
I personally prefer to avoid this (it falls into the same pitfalls that the su command does) because it can be a security risk.Code:[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.
- 10-20-2011 #4
There's another option for you, as well.
You can use su -c to perform root functions one at a time.
Enter your admin password, good to go. And, it avoids the security risk that Cabhan mentioned, as it doesn't save the password for any amount off time.Code:su -c 'ls -l /root
Jay
New users, read this first.
New Member FAQ
Registered Linux User #463940
I do not respond to Private Messages asking for Linux help. Please, keep it on the public boards.


Reply With Quote
