Bulk Permission
I incidentally changed permissions on all folders in home directory to 644. This has lead to severla problems.
How can I change it back to 755 without having to click every and each folder and click permissions back to 755 using the mouse? Is it possible to change permissions to 644 or 755 depending on the file type from a shell using just one or two commands? Thanks in advance for your advise, Lu |
How to change every file/directory:
chmod -R 755 /path/to/home/directory Change based on filetype, that's probably going to require a bit (see that as A LOT) more work. However, look into possibly man file and then man chmod. Good Luck Cool |
What exactly do you mean by 'file type'? As in a specific extension, or binary, etc?
|
Thanks, guys, for your tips. I will try to chmod as you wrote. By file types I mean folders (which I want to be chmoded to 755), html files or office files chmoded to 644, and shell scripts chmoded to 751 or something, so that it is executable.
Of course, there are many folders in my home folder, and each folder within the home folder contain other folders. These folders contain different files, such as html's, swx's, png's, sh etc, shell scripts without file name extensions.... You see the problem? If I do each file by hand it will take me days, and in any way I will overlook something. For example, at this moment I can't run tar because there are wrong permissions. So the backup script (which run tar command) aborts with errors. Lu |
Well, let's see.
For folders, you could try something as simple as: Code:
for i in `find ~/ -type d` for i in `find ~/ -type d`; do chmod 755 $i; done The same idea goes for everything else - to find some kind of patterns. I'm assuming all the html files end in an extension. How about the scripts? Maybe they all have a particular line of text, such as "#!/bin/sh"? Maybe a way to check if you didn't miss a file is to find all files with the permission 644 and then removing the files you want to have that permission. |
btw, you said you messed up your home dir. Why is tar in your home dir?
|
Hey guys, can I ask similar question in this thread?
1. It might sound naive but how do I change the ownership of the directory? By mistake on my system /home/user1 has ownership of "root" but I want to make it "user1". 2. Why user1 is not able to create a directory in his/her home directory on my system? i.e. if user1 tries to create a directory "xyz" in /home/user1 then it gives an error saying "permission denied". Thank you all. |
nchauhan, I'm not a mod, but you shouldn't hijack ppl's threads.
1. man chown chown user:group /path/to/dir #see the manpage for more info 2. check permissions/ownership of directory. The user does not have rights to create files, if one cannot write to the directory. |
Sorry i did not intend to do that.
Thank you for help, though. |
All right. Tar is of course not in my home dir, but tar doesn't like to backup directories which do not have read and execute permissions, and it doesn't backup files which have no read permissions. You see the problem? shell script files start with #!/bin/bash
Well, just a moment, I will try your scripts (they are sh scripts, right?) |
[QUOTE]Originally posted by cuckoopint
[B] Code:
for i in `find ~/ -type d` bash: /root/: is a directory |
[QUOTE]Originally posted by MasterC
How to change every file/directory: chmod -R 755 /path/to/home/directory Good. This indeed seem to have changed all the files to 755. That permits me at least to run daily backups of the daily work. I will study further on how to change permissions on the files inside the folders depending on whether it is pl, shtml, or scripts. Certainly I don't need to give global exec permissions on the scripts Thanks :) |
Quote:
instead of a script, try it from command line: Code:
cd ~ |
Thanks for your help. Basically, the problem of schedulled backups is solved by chmoding everything to 755.
I chmoded scripts residing in my home dir in a similar way to rwx-r-r. I don't see how could I possibly chmod contents of other folders to rw-r-r leaving the folders rwx-rx-rx. Any other tip? |
Quote:
[code] for i in `find -type d /path/to/dir`; do chmod 733 $i; done for i in `find -not -type d /path/to/dir`; do chmod 644 $i; done [/code} ? |
All times are GMT -5. The time now is 02:55 AM. |