0

I used root user to change a something in my directory and I typed in
sudo -i
followed by /etc/hostname
and it says -bash: /etc/hostname: Permission denied

closed as off-topic by Ghanima, lenik, Jivings Jan 15 '15 at 8:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Ghanima, lenik, Jivings
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    /etc/hostname is not a batch file or a command... are you trying to edit it? if so, try nano /etc/hostname – Kryten Jan 13 '15 at 17:39
3

While I'm not quite certain why Linux decides to say permission is denied rather than giving a more helpful error the problem here is that you're not telling it what you want to do, you're just giving it the path of a file.

I'm assuming you want to edit the file to change your hostname? In that case you'll want to open it in an editor like nano for example.

nano /etc/hostname

Remember to add sudo if you aren't already running with sudo -i.

  • 1
    You're correct in so far as it's because /etc/hostname is not a command (+1). More specifically, though, commands are just executable files, and the problem here is that /etc/hostname is not set executable (if it were, you'd get a different sort of error, since it's just a line of text). So the "Permission denied" error is actually correct. There are three basic permissions: Read, Write, and Execute. User root will have the first two on /etc/hostname but no one has the last one because there would be no point in doing so. en.wikipedia.org/wiki/File_system_permissions#Permissions – goldilocks Jan 13 '15 at 17:51
  • Ah, good point. I spend to much time in the Windows world. Forgot that whether or not a file is executable is dictated by the permission system in Linux. – Leonick Jan 13 '15 at 17:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.