0

CODE:

root@crane-linux:/home/crane/Downloads# sudo chmod 400 ~/home/crane/Downloads/mykey.pem
chmod: cannot access '/root/home/crane/Downloads/mykey.pem': No such file or directory
root@crane-linux:/home/crane/Downloads# ls
discord-0.0.1.deb  mykey.pem  torguard-latest-amd64.deb
root@crane-linux:/home/crane/Downloads#

Someone please help. I am having trouble with chmod not recognizing my file. I am using the provided tutorial to launch an instance through aws, but I keep getting a "No such file or directory" error, but as you can see when I did ls, the file does exist. Am I missing something here? Ive tried googling for the answer and tried entering the command in a bunch of different formats, but I keep getting the same problem.

No one said this would be easy....

P.S. I dont know how to make the quote box show up without the word "quote" like I see people do when they share something from the console. Its probably something simple IM just looking over but....

1
  • 1
    Did you notice that the path that ~ expands to is different from the one you list?
    – Celada
    Commented Mar 12, 2017 at 19:07

1 Answer 1

3

Your tilde expansion is not pointing your current working directory, where the file is. Use either an explicit or the correct tilde-expanded path:

chmod 400 /home/crane/Downloads/mykey.pem

or

chmod 400 ~crane/Downloads/mykey.pem

To expound on the tilde expansion a bit:

~ means "my home directory". If you're the root user, this is typically /root.

~somebody means "the home directory of the somebody user. This is typically /home/somebody (or, on Macs, /Users/somebody).

When you, as root, use ~/home/somebody, that expands your home directory, and becomes /root/home/somebody.

2
  • Thanks so much. Im a complete noob to linux so I guess that just makes me a complete noob. That ~ explanation really broke it down for me though. Thanks a ton. Commented Mar 13, 2017 at 2:31
  • Happy to help! We all started somewhere. Welcome to Linux, and to U&L!
    – DopeGhoti
    Commented Mar 13, 2017 at 3:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .