file permissions problem?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Angel25
Level 1
Level 1
Posts: 19
Joined: Sat Sep 05, 2020 4:37 pm

file permissions problem?

Post by Angel25 »

I was trying to fix file permissions for files copied from ntfs drives and I ran this command

find /home/user -type f -exec chmod -c 644 {} ";"

That changed the permissions for many files in hidden .folders in my home folder from 664 to 644, and some from 600 to 664. Is that a problem? How can I fix?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
dave0808
Level 5
Level 5
Posts: 987
Joined: Sat May 16, 2015 1:02 pm

Re: file permissions problem?

Post by dave0808 »

You may or may not know, but 664 to 644 has simply turned off write-permission for group access. Most, if not all, files that you changed will be in your group anyway, so not a problem.
and some from 600 to 664.
I'm assuming this is a typo and you mean "600 to 644". Here, you have given read permission to group and to "others", aka 'any account' on the system. Whether this is a problem or not, only you can decide.

Potentially more annoying is if you had any files that were marked as "executable" as these files will no longer be so - as in you won't be able to run them until you make them executable again. These may include files like local shell scripts or any AppImages.

The "bad" news is that there's no undo for this kind of operation. But it is not all bad news.

If you are the only user on this system, and if you're concerned about system processes accessing your files, then you could run the command again and use 640 (or o-r) instead, which will remove read access for "other". Next, if you had any executable files, they will simply fail the next time you try to run them, at that point you can add the executable bit once more, use u+x instead of absolute octal numbers.

Alternatively, if you have a VERY recent and COMPLETE backup of your home directory, you could use it as a template to see what the permissions were and change them back on your live home directory. This would be quite tedious though.
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: file permissions problem?

Post by Termy »

If any of the files needed the execute bit set, then you will have to sort that out yourself, but since they're from NTFS, I'm guessing that's not a problem here.

The command you ran will only change the permissions (mode) of all (including those hidden) files in '/home/user' to 644 (rw-r--r--), not 664 (rw-rw-r--). For most people, 700 (rwx------) for directories and executable files, and 600 (rw-------) for all other files is sufficient.
dave0808 wrote: Fri Jul 23, 2021 11:37 am Alternatively, if you have a VERY recent and COMPLETE backup of your home directory, you could use it as a template to see what the permissions were and change them back on your live home directory. This would be quite tedious though.
This can be fairly easily automated with a script, so if the OP does have such a backup, I imagine someone would be up for that task. It'd be a case of a few loops and using chmod(1) with stat(1) to determine and correct the modes.
I'm also Terminalforlife on GitHub.
Angel25
Level 1
Level 1
Posts: 19
Joined: Sat Sep 05, 2020 4:37 pm

Re: file permissions problem?

Post by Angel25 »

Thanks for your help

Ultimately, I spent a lot of time changing them back manually :evil:
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: file permissions problem?

Post by Termy »

Angel25 wrote: Mon Jul 26, 2021 5:08 pm Thanks for your help

Ultimately, I spent a lot of time changing them back manually :evil:
I'm sorry for your loss (of time). :P At least it's sorted, now.
I'm also Terminalforlife on GitHub.
Aztaroth
Level 5
Level 5
Posts: 764
Joined: Mon Jan 11, 2021 1:48 am

Re: file permissions problem?

Post by Aztaroth »

To change the permissions of all files of a special permission type :

Code: Select all

find <mypath> -type f -perm 644 -exec chmod 664 {} \;
will set the permissions of all files that have a 644 perm to 664 in <mypath>.
Of course, you should know the meaning of the permission octals you put in.
If it's easier, you can also use symbolic permission labels : find . -perm -220 can be 'translated' into find . -perm -g+w,u+w. This example comes from the man find manual.

PS : Next time, use -not -name '.*' in your original command if you don't want to hit hidden files beginning with a dot.
dual boot LMDE4 (mostly) + LM19.3 Cinnamon (sometimes)
Locked

Return to “Beginner Questions”