Chmod 777 to a folder and all contents [duplicate] - linux

This question already has answers here:
How do I change permissions for a folder and its subfolders/files? [closed]
(19 answers)
Closed 4 years ago.
I have a web directory /www and a folder in that directory called store.
Within store are several files and folders. I want to give the folder store and all files and folders within the store folder all permissions.
How do I do this? I am guessing via .htaccess.

If you are going for a console command it would be:
chmod -R 777 /www/store. The -R (or --recursive) options make it recursive.
Or if you want to make all the files in the current directory have all permissions type:
chmod -R 777 ./
If you need more info about chmod command see: File permission

If by all permissions you mean 777
Navigate to folder and
chmod -R 777 .

You can give permission to folder and all its contents using option -R i.e Recursive permissions.
But I would suggest not to give 777 permission to all folder and it's all contents. You should give specific permission to each sub-folder in www directory folders.
Ideally, give 755 permission for security reasons to the web folder.
sudo chmod -R 755 /www/store
Each number has meaning in permission. Do not give full permission.
N Description ls binary
0 No permissions at all --- 000
1 Only execute --x 001
2 Only write -w- 010
3 Write and execute -wx 011
4 Only read r-- 100
5 Read and execute r-x 101
6 Read and write rw- 110
7 Read, write, and execute rwx 111
First Number 7 - Read, write, and execute for the user.
Second Number 5 - Read and execute for the group.
Third Number 5 - Read and execute for others.
If your production web folder has multiple users, then you can set permissions and user groups accordingly.
More info :
Understanding File Permissions: What Does “Chmod 777″ Mean?
What file permissions should I set on web root?
Why shouldn't /var/www have chmod 777

You can also use chmod 777 *
This will give permissions to all files currently in the folder and files added in the future without giving permissions to the directory itself.
NOTE: This should be done in the folder where the files are located. For me it was an images that had an issue so I went to my images folder and did this.

Yes, very right that the -R option in chmod command makes the files/sub-directories under the given directory will get 777 permission. But generally, it's not a good practice to give 777 to all files and dirs as it can lead to data insecurity. Try to be very specific on giving all rights to all files and directories. And to answer your question:
chmod -R 777 your_directory_name
... will work

for mac, should be a ‘superuser do’;
so first :
sudo -s
password:
and then
chmod -R 777 directory_path

This didn't work for me.
sudo chmod -R 777 /path/to/your/file/or/directory
I used -f also.
sudo chmod -R -f 777 /path/to/your/file/or/directory

Related

Grant acces to dictionary only via my script

I have few directories with files on debian 9 system. I want to disable privilege to read these directories for everyone than owner, but I want to let some users list files in this directories only by my own script in bash.
I change privileges to directories and to my script but i get "permission denied" when i try using it. I understand why, but cant fix it.
OKAY after we had a small chat I understand the following:
that you (your user is called user0) have a directory with some files in it, and you have a special category of users (user1,user2...usern) on your machine that you want to give access to this folder. First you must create a group called for example "cowboys" witch the users who will be privileged to read, and execute the folder will add.
# create the group cowboys
groupadd cowboys
# add user1, user2, etc to the group
usermod -a -G cowboys user1 user2 .... usern
Lets admit your folder that you want to give access to is called "/somehow/there/dictionary"
So after you created the folder and joined it, you chown it to you and the group cowboys
chown user0:cowboys /somehow/there/dictionary
in the next step you must chmod the folder it in a way that you can read(400) write(200) and execute(100), cowboys can read(40) and execute(10) and rest of the word can nothing(0).
chmod 750 /somehow/there/dictionary
the last step is that you now must chmod the files in the derectory
1) The executable files you must chmod very similar to the way you chmod the folders, because folders need to have "executable" rights for one to "cd" in the folder
chmod 750 /somehow/there/dictionary/*
2) the non executable files you will chmod like this :
chmod 640 /somehow/there/dictionary/*
and this should do the trick.

In Linux - How to set permission for folder, which save files for client app call and download file

In Linux, How to set permission for folder, which save files for client app call and download file?
I set : chown -R www-data:www-data ./folder
And: chmod - R 777 ./folder
It's not security, anyone show me how to do this?
Thanks!
From what I read, you would need ro perms for www-data on that whole directory, so I'd suggest:
chmod -R 400 ./folder
For future times:
4 - READ
2 - WRITE
1 - EXECUTE

Add permission to two users (my apache server and myself)

I want my php script to be able to create file, edit, and delete it, so I need to give it permissions to do so in Linux.
I've done this with one of the stackoverflow answers with this code:
sudo chown -R www-data:www-data .
But when I do so, I lose my user access to files - so I can't open them with gedit for example until I change permissions back like so:
sudo chown -R igor /var/www/html/demo/myDir
I think I need to give permission to Apache, but leave my access as well. I feel there is some easy answer to make it work, but I can't find one. Any suggestions?
You are changing the owner of the files, if you want to change the permission of the files without changing the owner you need to use : chmod.
For example if you want to read write and execute on the current folder you can use: chmod 777 .
If what you want is the two users have the same permissions over the folder you could add your user to the group www-data (assuming that you are in the files folder):
sudo usermod -a -G www-data youruser
sudo chgrp -R www-data .
sudo chmod -R 770 .

Enable write permission for directory in Linux

I keep trying to move files from a directory on Linux- but I keep getting permission errors.
Initially I was told
sudo chmod -R r+w /directory/*
But this only applies it to the directory folder (and not the files inside)
Trick is- you need to "select all" to apply the file permissions to:
sudo chmod -R a+rwx,go-w /directory/
And that's it
Or you could do sudo chmod 777 /dir/
and that's just a simple way to do the answer stated above.

Setting Drupal root directory to 777

A company mine is working with is having permissions issues for uploading files (via FTP). We found a workaround of putting everything to 777 (not my first choice, but ease of use trumps security here).
The problem with this is that Drupal breaks upon putting the root directory as 777.
Why is this? How can I change that?
Typically your files directory should be:
chmod -R 775 files
But also make sure your owner and group are correct. The owner in this case should be your ftp user. And your group should be the apache user.
chgrp -R apache_user files
chown -R ftp_user files
Having problem to upload files with ftp or with drupal? Drupal need write permission in sites/default/files to save images and css etc.
Maybe its problem with owner too?
Check this page: http://drupal.org/node/244924
The problem with this is that Drupal breaks upon putting the root
directory as 777.
Actually you need to change not root of Drupal directory but the directory sites/default/files.
If you want to do that in easiest way change this directory permissions to 777:
cd <your Drupal root>/sites/default
chmod -R 777 files
The secure way is to set your WWW user (e.g. www-data) as an owner of this directory:
cd <your Drupal root>/sites/default
chown -R www-data files
chmod -R 775 files
Also you can add your group (e.g. my_group):
chgrp -R my_group files

Resources