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.
Dear all,
i would like to put a script to check permissions,
if the file permission is only rw i want to receive an e-mail.
rw means 600,
i did something like that but it only checks folders, not the files under the folder.
#!/bin/sh
PERM=600
PARENT=/.../folder
folders=$(find $PARENT -type d ! -perm $PERM)
if [ -n "$folders" ]
then
echo "$folders" | mailx -s "smt wrong in permission" abc@xzy.com
fi
That's because it is using -type d to select only the directories. You can check the files separately using -type f
Thank you very much.
i have files under a folder and under this folder for example only 1.txt permissions are 600. it means only rw. and i want to receive this notification. i want to see notification only that " there is something wrong with permission for file 1.txt"
-rw------- 1 122 Mar 21 08:49 1.txt
-rw-rw-r-- 1 82 Mar 21 08:54 2.txt
drwxrwxr-x 11 4096 Mar 25 09:01 3.txt
-rw-r--r-- 1 134406 Mar 25 10:32 4.txt
i have files under a folder and under this folder for example only 1.txt permissions are 600. it means only rw. and i want to receive this notification. i want to see notification only that " there is something wrong with permission for file 1.txt"
-rw------- 1 122 Mar 21 08:49 1.txt
-rw-rw-r-- 1 82 Mar 21 08:54 2.txt
drwxrwxr-x 11 4096 Mar 25 09:01 3.txt
-rw-r--r-- 1 134406 Mar 25 10:32 4.txt
how can i able to do this?
thank you.
As mentioned by Turbocapitalist, you have "-type d" which only checks directories.
Another issue I see is the "!" which is logical NOT.
For troubleshooting, breakup your tasks in 2. First just focus on the find... Once you have find working then add the notification piece...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.