Okay, I intend to calibrate the permissions in my home folder by building more to this script that I have named 'permicali':
Code: Select all
#!/bin/bash
# This script is being developed to calibrate permissions for some user files and folders in Linux MX 21.3
# Link to general script template: https://forum.mxlinux.org/viewtopic.php?p=725990#p725990
# Link to code and discussion: https://forum.mxlinux.org/viewtopic.php?p=745301#p745301
# Hovedsekvens begynd
case $1 in
# Sekvens begynd
'Music'|'music'|'Musik'|'musik')
if [ -d "$HOME/Musik" ] ; then
find ~/Musik -type d | while read DIR ; do chmod 755 "${DIR}" ; done
fi
if [ -d "$HOME/Musik" ] ; then
find ~/Musik -type f | while read DIR ; do chmod 644 "${DIR}" ; done
fi
;;
# Sekvens slut
# Sekvens begynd
'Billeder'|'billeder'|'Pictures'|'pictures')
if [ -d "$HOME/Billeder" ] ; then
find ~/Billeder -type d | while read DIR ; do chmod 755 "${DIR}" ; done
fi
if [ -d "$HOME/Billeder" ] ; then
find ~/Billeder -type f | while read DIR ; do chmod 644 "${DIR}" ; done
fi
;;
# Sekvens slut
# Sekvens begynd
'Videoklip'|'videoklip'|'Videoclip'|'videoclip')
if [ -d "$HOME/Videoklip" ] ; then
find ~/Billeder -type d | while read DIR ; do chmod 755 "${DIR}" ; done
fi
if [ -d "$HOME/Videoklip" ] ; then
find ~/Billeder -type f | while read DIR ; do chmod 644 "${DIR}" ; done
fi
;;
# Sekvens slut
# Sekvens begynd
'all')
echo ''
echo 'Option "all" is not ready yet'
echo ''
;;
# Sekvens slut
# Sekvens begynd
'-h'|'--h'|'help'|'-help'|'--help'|'/h')
echo 'WARNING: Repair script under development, not tested'
echo "Use: '${0##*/}' [Argument] - Calibrate permissions for files and folders."
echo ''
echo ''
echo ''
echo 'Arguments:'
echo ' none Shows way to help'
echo ' help Shows this help'
echo ' musik Calibrate sub folders and fils in ~/Musik'
echo ' billeder Calibrate sub folders and fils in ~/Billeder'
echo ' videoklip Calibrate sub folders and fils in ~/Videoklip'
echo ''
echo ''
echo ' all Calibrate all user folders mentioned above'
echo ''
echo 'Examples of use:'
echo '"'${0##*/}' musik" Calibrate sub folders and fils in ~/Music'
echo '"'${0##*/}' all" Calibrate permissions in ~/Musik, ~/Videoklip and ~/Billeder'
;;
# Sekvens slut
# Herunder kommandoen, som benyttes, når intet argument forinden er blevet genkendt.
*)
echo ''
echo 'Help syntax: "'${0##*/}' -h"'
echo ''
;;
# Herover kommandoen, som benyttes, når intet argument forinden er blevet genkendt.
esac
# Hovedsekvens slut.
As you can see the folder names in the script are hard coded in Danish so it will need some edit before it can be used for another language. I might make an English version also if there is a demand for it but I still don't know if it ends up being worth sharing.
My plan is now, guided by the task, to go from folder to folder and make a specific script sequence for each one.
I don't know how far I will get, that also depends on the demand and the skills others wants to put in it.
However, I think I at least have to fix these user folders if I can:
~/Music
~/Pictures
~/Videoclip
~/bin
~/.thunderbird
~/.restore
~/.icons
~/Documents
~/Desktop
Do you know any files in them folders that are not supposed to be chmod 0644 ?
Or folders that are not supposed to be chmod 0755 ?
I know some files in ~/bin but I believe they are easy to calibrate.
Maybe launchers in Desktop are also not that difficult to handle.
I don't know about ~/.icons
~/.thunderbird and its files are important but I am almost blank.
Where can I find information about the correct state for permissions.?