Cannot create file permission denied linux

Getting «unable to create file ‘/run/user/1000/dconf/user’: Permission denied»

I use GNU/Linux Mint 18.2 (based on Ubuntu 16.04). Very recently, I’ve started seeing the following error message, repeated many times, when I start some GUI apps (e.g. meld):

unable to create file '/run/user/1000/dconf/user': Permission denied. dconf will not work properly. 

Now, I’m able to work around this by manually changing the ownership of /run/user/1000/dconf/user , but that’s kind of a lame hack and certainly not robust. Why have I been seeing this error and what’s the «right way» to avoid it (if any)?

I think it’s caused by running certain GUI programs as superser: I get this same problem when running ktsu to open a terminal app (called terminator) as a root window. Apparently terminator is using my UID instead of root’s in /run/user/UID/user, and that can change the owner of the file to root causing «permission denied» when I run terminator as myself.

3 Answers 3

The issue can be caused by running a GUI after changing user using su command. Certain environmental variables are not changed causing the error. See

Try running the program by logging in as that user directly.

chown 1000:1000 /run/user/1000/dconf/user

#!/bin/bash # rmdconfuser - remove dconf user if [ -e "/run/user/1000/dconf/user" ] then rm -f /run/user/1000/dconf/user fi # Uncomment the next line if mate-settings-daemon is eating up too much memory # killall -9 mate-settings-daemon 

then execute chmod +x rmdconfuser and place rmdconfuser into your ~/bin/ or /usr/local/bin as root and sudo rmdconfuser to stop the problem. You can also make rmdconfuser set its own uid to root, so you can run it without being root yourself.

Unfortunatelly this is only a work around. The problem may appear again & again.

Источник

cp: cannot create regular file: Permission denied

I am running a PHP script on my Apache server and from the script I need to copy some files (to run a Bash script that copies files). I can copy to a directory /tmp with no problems, but when I want to copy to /tmp/foo then I get this error:

cp: cannot create regular file '/tmp/foo/file.txt': Permission denied 

even though the permissions for the directory /tmp and /tmp/foo are set to the same value. Do you know what is the problem?

@SivaPrasath /tmp is always for root by default! the two commands results is not related in this case, becase /tmp has all the permissions for all users

@HamidYousefi yes, tmp is for root, but not for /tmp/foo OP might be running the script as a different user with /tmp/foo belongs to.

Читайте также:  Dcp 1602r драйвер linux

Hello welcome. To make things easier in the future, when asked for clarification, please clarify by amending the question (not by adding a comment), show commands, and output in full. This will help us with answering you question more quickly. Thanks, and happy questioning.

1 Answer 1

/tmp Directory has all the permissions (read/write) for all users. but if you made /tmp/foo by your own account, it has its permissions just for you! if you want to make it writable for other users (or programs) change its permission with this command:

If you have any other files inside this directory from before, add -R flag to above command.

Update: Use this command to change /tmp/foo owner from your own to apache default user:

sudo chown www-data:www-data /tmp/foo -R

also please check your apache2 configuration to see which user it has for running the php scripts.

Источник

Create file in folder: permission denied

I have a problem copying files to a directory on Ubuntu 12.04. I create a directory in the home directory so that the path where I want to copy to is:

francisco-vergara@Francisco-Vergara:/home/sixven/camp_sms/inputs$ touch test_file.txt touch: can not make `touch' on «test_file.txt»: permission denied 

I can not copy files directly in that directory. How can I assign permissions with the chown & chmod commands to copy the files? I do not know which user and group to use.

From what you have copy-pasted, you are running touch as user francisco-vergara , but your directory is in /home/sixven is that really the home of user francisco-vergera or does it belong to a sixven user ? You should clarify what you want to do exactly. Write in another user’s home ? Share that directory among a group ?

3 Answers 3

First of all you have to know that the default permission of directories in Ubuntu is 644 which means you can’t create a file in a directory you are not the owner.

you are trying as user:francisco-vergara to create a file in a directory /home/sixven/camp_sms/inputs which is owned by user:sixven .

So how to solve this:

    You can either change the permission of the directory and enable others to create files inside.

sudo chmod -R 777 /home/sixven/camp_sms/inputs 
sudo chown -R francisco-vergara:francisco-vergara /home/sixven/camp_sms/inputs 

So i advise you to use Option 1.

Or if this directory will be accessed by both users you can do the following trick:

change ownership of the directory to user:francisco-vergara and keep the group owner group:sixven .

sudo chown -R francisco-vergara /home/sixven/camp_sms/inputs 

Like that both users can still use the directory.

But as I said you before It’s easiest and more efficient to use option 1.

Источник

Permission denied to create files in particular directory under home directory

I copied a folder recursively from the /www/ directory to one of my directories under my home directory. Now, every time I want to create a file or a folder in this copied directory, it says permission denied . So, I have to use sudo every time. The problem is that I can create files/folders in other directories under the home directory, except this one. I tried changing the permission of this directory recursively to 755 but still the same problem. Can anyone point out what the exact problem I am facing is? And how do I get around this?

Читайте также:  Проверить работает ли postgresql linux

3 Answers 3

The folder, quite obviously, is property of the root user, which is why you have to use sudo in order to interact with the folder. I don’t think chown is able to apply permission changes to a folder, so you would have to go for the graphical route, as explained below.

[EDIT] A folders location typically doesn’t affect it’s permissions level or owner. For example, I could be the owner of a folder sitting in /usr/share/, but root could be the owner of a folder on my desktop. If you’re wondering why it is this way, I’d say ask Bell Labs. They started it. 🙂

(I used Nemo, but the steps are the same for Nautilus)

First, open a terminal and type sudo nautilus (again, I used Nemo, but it’s the same procedure), and enter your sudoer’s password.

sudo nautilus (in this case, nemo)

When Nautilus opens, navigate to the folder you wish to change permissions on. Depending on what program you use, you may see and «Elevated Privileges» notice. This is to remind the user to be careful with what they do, as root permissions could damage the computer if used the wrong way.

Navigate to the folder desired

Now right click the folder you want to change and choose «Properties» go to the «Permissions» tab, and it should look something like this:

Root permissions on folder

Select the dropdown menu for Owner and Group, and change them from «root» to your username (in my case, ben). It should look like this now:

How it should look

If desired, click «Apply Permissions to Enclosed Files». Then close Nautilus and exit the terminal.

Источник

Fix: cannot create directory permission denied

Linux displays the file or directory permissions held by the user via the “ls -l” command. These permissions are of three types: “read”, “write”, and “execute”. The “read” permissions are represented by “r”, and “write” permissions are identified by “w”, and the “execute” is denoted by “x” in Linux.

This guide describes the causes and possible solutions for the issue “cannot create directory permission denied”. The outline of this article is as follows:

Let’s get into the reasons and the solutions of the error.

Читайте также:  Средства контроля целостности astra linux

Reason: Permissions Not Granted

The error “cannot create directory permission denied” occurs because the currently logged-in user does not have the “write” permissions to create the directory. Suppose the user runs the “mkdir” command to create the directory “test” and “subtest1” as a subdirectory. It will not create as it shows the below error shown in the screenshot:

Check the “test” directory permissions by running the below-mentioned command:

The owner “itslinuxfoss” does not have the write permissions to create the “subtest1” directory as it only reads the “test” directory.

To resolve this type of error, the user needs to access the write permissions of the “test” directory

Solution: Allow the Directory Permissions

Change the “test” directory permissions to create the “subtest1” directory inside it. For this purpose, use the “chmod(Change Directory)” command with the combination of “a+w” and the target directory name in the terminal (Ctrl+Alt+T):

The “test” directory now has the “write” permissions.

Execute the “ls” command again to verify the new changes:

The output confirms that now the “test” directory has the “write” permissions to create a directory inside it.

Now run the “mkdir” command with the “subtest1” directory in the terminal. Now the below command will definitely create the “subtest1” directory without any error:

The output verifies that the error “cannot create directory permission denied” has been fixed now, and the “subtest1” is created successfully inside the “test” directory.

Alternative Solution: Change the Directory Ownership

Here is another solution to create the directory. To perform this task, change the ownership of the specified directory using the “chown” Linux command. Run the below command in the terminal to make the current user an “owner” of the directory:

$ sudo chown -R "$USER:" /path/to/the/directory

The above command contains the following components:

  • chown: Linux command that is useful to change the ownership of file/directory.
  • -R: This flag represents “recursive” as it changes the ownership of files and subdirectories located in a directory.
  • $USER: The current user replaces the global variable.
  • path/to/directory: Shows the specified directory path.

That’s all about the reasons and the solutions to the error “cannot create directory permission denied”.

Conclusion

The “cannot create directory permission denied” can be resolved by “Allowing the Directory Permissions”.The permissions of the desired directory can be changed by utilizing the “chmod(Change Directory)” command. This article has explained all the possible solutions to resolve the error “cannot create permission denied” in Linux.

Источник

Оцените статью
Adblock
detector