Monday, May 6, 2024
133
rated 0 times [  133] [ 0]  / answers: 1 / hits: 173577  / 2 Years ago, thu, july 28, 2022, 2:15:07

I tried to use sudo cd name_of_dir but am getting the error message:



sudo: cd: command not found


Is there any other way to enter a directory owned by another user which has 700 permission?


More From » command-line

 Answers
7

sudo cd won't work because the cd command is built into the shell. So you are saying become root and then run this command. You become root and then the command after sudo is searched for but there is no cd command to find.



The method to use is to switch to the user that owns the directory. Permission 700 is meant as "owner can read, write and execute".



So if root owns the directory sudo -i, password and then cd {dir} is the only correct method. If someone else owns the directory you can still use the 1st method but can also change to that user with su {username} and then use cd as that user.


[#43801] Friday, July 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tatoethin

Total Points: 377
Total Questions: 110
Total Answers: 98

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;