how to list all directories for group has access to in unix/linux - linux

Is there a way to list all directories for group has access to in unix/linux. Or a way to list all groups along with directories for which the group has access.

find all directories with execute permission (yes, execute as you need execute permission to a directory to be able to access files in it) that belong to group group.
find ${dir} -type d -group ${group} -perm -g=x -print
see man page of find(1) for details and examples of -perm option.

I believe that ls -lahp | grep '/' would do the job for you

Related

How to get all files and directories by user in Linux

I am trying to find all the directories and files owned by user with the following command.
find / -type d -user greg | grep -v proc
it is working fine sometimes and hanging up sometimes. Is there any performance issues associated with it or is there any better way to executing this.
To keep it from descending into /proc, use -prune. It's better than filtering out entries with grep -v as it'll avoid descending into /proc at all.
find / -path /proc -prune -o -type d -user greg -print
Read -o as "or". If the path is /proc, prune it, i.e. don't go in there. Otherwise, match directories owned by greg. (If you want files too then get rid of the -type d test.)
When you use -prune, you also have to use -print to print matches. -print's normally implied, but using -prune changes that.

Granting my access permissions to everyone?

If folder folder is read/write/execute accessible to me, then it should become read/write/execute to everyone.
Calling chmod -R 777 ./folder does not suit, because it makes all files executable, even those that were not executable before.
Is there an easy way?
You could do it with UNIX find combined with the exec flag to run a chmod command on every file that matches a filter, and filter on the executable bit.
e.g.
first find the non executable files recursively and change them to all RW
find ./folder -not -executable -exec chmod a=rw {} \;
then find all the executable ones recursively and change them to all RWX
find ./folder -executable -exec chmod a=rwx {} \;
You might want to add add the files in the folder to a user group like everyone or users depending on your distro.
chown -R <youruser>:everyone ./folder
You can check what available user groups you have with groups command.

Linux command to create the empty file called 'test1'

Enter a Linux command to create the empty file called 'test1' in the directory 'systems' (you are still in your home directory).
Assuming 'systems' is a subdirectory of the current directory:
touch systems/test1
Assuming that you only know that the directory 'systems' is some subdirectory in the directory tree of the current directory then: find . -name systems -type d -exec touch "{}/test1" \; Will create such a file. Alternately, so will find . -name systems -type d -execdir touch systems/test1 \; However, both will do so in every subdirectory named 'systems' in the current directory tree. We could limit that action to only the first, the last, or some other criteria, but the list of possible permutations is just too long.
You really have not provided enough information for us to provide a complete answer.

How to find directories to which the owner and group has defined rights?

I would like search in a given tree directory directories to which the owner of the directory
(not necessarily the user executing the script) has the right to read, but do not have write or execute permission, and the owner group has the right to read.
what i have done so far:
find $1 -perm u+r -perm /u+wx ! -perm g+x
$1=provided argument to the script
This should work for you:
find $1 -type d ! -perm /u+wx -perm /u+r -perm /g+r
I think the reason your command wasn't working was because of the lack of a / in the last part - -perm g+x is telling find to match entries with exactly permissions 010. (Also, you said you wanted the group to be able to read, not execute).

Find all directories without r/x permissions for world/other

I want to find all the directories that that are not both readable and executable by the 'others'. Or put another way, anything where the permissions for 'other' users is anything except r-x or rwx.
I thought this woud work, but I'm off somehow:
find . -type d ! -perm -o+rw
This syntax will work:
find . -type d ! -perm /o+x,o+r
Check the examples section of the man page for more info.

Resources