Create file in folder: permission denied
Solution 1
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
This command will change the permission of the directory recursively and enable all other users to create/modify and delete files and directories inside.
You can change the owner ship of this directory and make
user:francisco-vergara
as the ownersudo chown -R francisco-vergara:francisco-vergara /home/sixven/camp_sms/inputs
But like this the
user:sixven
can't write in this folder again and thus you may moving in a circular infinite loop.
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.
Solution 2
To change the file ownership, do this as root:
chown -R user:user /home/sixven
If you decide to go the chmod way:
If you know that the user is part of the group of the file
chmod -R g+rw /home/sixven
Otherwise:
chmod -R o+rw /home/sixven
But this way is not too secure.
Solution 3
The default UMASK 022 (in Ubuntu ), so the permissions for /home/username becomes 755. and you logged in as user francisco-vergara
and trying to creating files in user sixyen Home: i.e. /home/sixven
. it does not have write permission to Other users Only User/Group of sixven
has write access.
if you want write access in that directory, then you need to be part of Group sixven
using usermod -G sixyen francisco-vergara
OR chmod -R 777 /home/sixven
(don't use it's bad practice ).
Related videos on Youtube
![fran.sand66](https://i.stack.imgur.com/pY01W.jpg?s=256&g=1)
Comments
-
fran.sand66 almost 2 years
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:
/home/sixven/camp_sms/inputs
But when ini run the following command in the terminal to create a sample file as follows:
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.
-
terdon over 10 yearsHow did you create the directory? Why is it in
/home/sixven
? Why isn't it in your home directory? -
Leiaz over 10 yearsFrom 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 userfrancisco-vergera
or does it belong to asixven
user ? You should clarify what you want to do exactly. Write in another user's home ? Share that directory among a group ?
-
-
guntbert over 10 yearsAren't you rushing things a little? We still don't know the OP's situation.
-
Douglas Adams about 8 yearsResurrecting this to say: you should almost never 'chmod -R 777' anything. Setting ownership correctly is a far safer practice. digitalocean.com/community/tutorials/… askubuntu.com/questions/20105/…
-
Faris Rayhan over 7 yearsWorks like a charm
-
rici about 4 yearsThe default permissions of a directory are normally 0755. 0644 is the default for regular files. Also, what @douglasAdams said.
-
Syd Lambert over 3 yearsCopy-pasters beware,
usermod -G
will remove you from all other groups (including sudo). Useusermod -aG
to append a new group.