Score:0

What are permissions to create a folder or file?

cn flag

I've seen lots of stuff on the internet about HOW to set permissions.

Please tell me WHAT permissions are required for a user to be able to create a folder or a file. I would have thought just w but I'm not sure.

Nmath avatar
ng flag
The only permissions are read, write, and execute. What is the actual problem that you are trying to solve? It's better to ask about the actual problem and provide details and context than ask a coded/vague question that won't actually help you solve the problem.
cn flag
small addition: the directory -above- where you want to make a dir or file needs to be rwx for your user and/or your group and/or others depending on the user used to create it.
Score:1
sa flag

To change file and directory permissions change directories with cd to the directory that contains the file/directory whose permissions you want to change, and use the command chmod (change mode).

Add write permissions to a file or a directory:

chmod +w filename
chmod +w directoryname

If you want to read the file and also want write permissions, you need read permissions too. Add read/write permissions to a file or a directory:

chmod +rw filename
chmod +rw directoryname
Score:0
cn flag

In Linux (and all Unix-like operating systems), there's the principle that "everything is a file". That includes, among other things, directories. A directory is basically a file that contains information about the contents of the directory.

So if you have, for example, the directory /home/kristy/some_files/ and want to create a new file (or a new subfolder) in this directory, you need to write to the file representing this directory. And in order to do that, you need write permissions on this directory.

kristy1024 avatar
cn flag
Thanks for your responses. Apparently I was right: the user needs w. The permissions on my folder are: drw-rw-rw- 2 www-data www-data 4096 Dec 20 20:05 tmp Yet when I try to write a file to it from a php called shell_exec command I get this: [Errno 13] Permission denied: '/var/www/tmp/TestTopics.txt' How can I make the www-data user able to write a file to /var/www/tmp ?
kristy1024 avatar
cn flag
Sorry, this forum is very restrictive. The permissions on the folder: /var/www/tmp are drw-rw-rw- 2 www-data www-data 4096 Dec 20 20:05 tmp I'm trying to create/write a file to the tmp folder in Python from a php shell_exec command. I'm getting this error in Python: [Errno 13] Permission denied: '/var/www/tmp/TestTopics.txt' How can I make the www-data user able to create a file in /var/www/tmp ?
cn flag
@kristy1024 This isn't a forum, I'm afraid. You may want to look at the [tour](https://askubuntu.com/tour) to find out how this site is intended to be used. Regarding your (new) question, write permission on the directory should allow any user that has this permission to create a new file in the directory. If the file already exists, you need to look at the file's permissions. Also check that your programs or scripts actually are running as `www-data` , that's not necessarily the case. The details may depend on how exactly you have set up your system.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.