Can't cd to Desktop folder Mac commandline
25,251
Using the sudo command will grant access to any folder or file on the Mac.
The commands sudo cd ~
return and sudo cd Desktop
return only appeared to fail. In fact, both commands succeeded but exited without any output.
To demonstrate this try the command sudo -i "cd ~;pwd"
return which should print /var/root
in the terminal window.
In order to use the same commands interactively, do following:
sudo -i
returncd ~
returnpwd
return
Output
/var/root
Related videos on Youtube
Comments
-
superuser over 1 year
I am using OSX Lion and every time I tried to cd to my Desktop folder using "cd ~" and cd "Desktop" it stays in my home directory instead of going to Desktop. I've tried to perform the commands using sudo but it makes no difference.
Thanks.
-
Canadian Luke about 12 yearsIf you type
pwd
and press Enter, what is the output? (Star out username if you want) -
HikeMike about 12 yearsWhat's the output of
ls
? -
Karolos about 12 yearsDoes
cd ~/Documents
work ? -
superuser about 12 yearsAfter doing
pwd
I realized I was in another user's home folder. That's why I couldn't access the home folder. But I am the administrator, why can't I access the other standard user's folder, even withsudo
? It looks like their Public folder is the only one I could access. -
Karolos about 12 years@David: Using
sudo
doesn't mean you own the files from other users. Permissions still apply. -
superuser about 12 years@Karolos: But if I am the administrator of a machine, I should be able to access other user's file when I wanted. Is there anyway to add a rule on Macs that will let all administrators have access to other people's files?
-
Karolos about 12 years@David: No, the role of an administrator is to manage the machine and its applications. It's a breach of privacy to use administrative power to access other people's files. But in case your reasons are legitimate, you can impersonate the other user using
sudo bash
and thensu username
.
-