I used root user to change a something in my directory and
I typed in
followed by /etc/hostname
and it says -bash: /etc/hostname: Permission denied
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.
Remember to add sudo if you aren't already running with sudo -i.