Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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
For folders, you could try something as simple as:
Code:
for i in `find ~/ -type d`
do
chmod 755 $i
done
Which could of course be written in one line:
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.
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".
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?)
Hm..., it doesn't run. If I try to run it as non-root it aborts: Permission denied or failed to get attributes, or No such file or directory; if I run it as root it aborts telling:
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
I don't know why. Worked for me.
instead of a script, try it from command line:
Code:
cd ~
mkdir temp; cd temp
touch file1; touch file2
mkdir ~/temp/new
#^testing purposes
cd ~/temp
chmod -R 777 .
for i in `find ~/ -type d`; do chmod 755 $i; done
ls -l
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.