Keep getting "Permission Denied" when trying to write files
DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Keep getting "Permission Denied" when trying to write files
I just installed Debian and am brand new to this. When I go into vi editir and create a file, I cannot save it. I get "permissions denied". I understand that there are read-write privledges assigned for each directory, but:
1) I don't know how to assign them or check them
2) I thought that I would be able to at least write to my home directory, but I cannot write to any directory
ls -la will show you a list off all the files and there permissions.
It'll look like this:
-rw-r--r-- 1 root root 488 Jan 22 09:24 temp
Now I am going to break this down for you, first with permissions.
There are 10 bits to the permissions, first bit (- in my example) is the suid bit. If this is set (it'll say s instead of -) then when a user with permission to the file uses it they use it as if they are the owner. The next three bits (rw-) in the example are the rwx permissions for the files owner. The next three after that (r--) in the example are the rwx for members of the group the file belongs to. The last three (r--) in the example are the rwx for all other users. So in this case temp can be read and written by the owner, read by any member of the group, and read by all other users. We will ignore the 1 for now, the first label, root, is the owner of the file. The second, also root, is the group the file is in. The next number is the size in bytes. After that is the date it was last written to. And the last thing is the name of the file.
To change permissions you must be the owner of the file, or have privileges to it (root has privileges to all files). chmod is the command to change permissions, type man chmod to see how that works.
Oh ya, and about that first 1, that is the number of items that link to the file. Linux file systems (ext2, ext3, reiserfs, ect.) support linking at the file system level. See the man page on ln to understand more about linking.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.