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.
Best Answer
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 byuser:sixven
.So how to solve this:
You can either change the permission of the directory and enable others to create files inside.
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 ownerBut 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 ownergroup:sixven
.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.