Monday, May 13, 2024
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 3179  / 2 Years ago, wed, january 19, 2022, 8:21:28

I want to get the list of all the files in my home folder, having rwx (read-write-execute) or 777 permissions for everyone.



Also, what is the command to know the permissions of a file?


More From » command-line

 Answers
2

From the terminal:




  • The terminal opens up in your home directory by default. From anywhere else, type cd ~ to return to the home directory.


  • ls -l will show you the file permissions at the beginning, e.g.



    -rwxr-xr-x 1 izx izx 11217428 Oct 2 2011 wkhtmltoimage-amd64




First Method: The watch-and-learn way




  • You can then filter with grep to get your desired result:



    ls -l | grep -P ".{7}rwx.*"



    • the regular expression here tells grep to only select lines where characters 8-10 are rwx


  • which in my home directory shows:




    -rwxrwxrwx 1 izx izx 0 Jun 15 23:42 sd.png
    -rwxrwxrwx 1 izx izx 0 Jun 15 23:42 slashdot.png
    drwxrwxrwx 3 izx izx 4096 Jun 15 21:31 src



Second Method: The proper, recursive way




  • In your home directory, type find . -perm -a+rwx




    • You're telling find to look through the current (home) directory and all subdirectories, for files that are rwx by all; the results will be displayed with full relative paths, e.g.




    ./.mozilla/firefox/lr5z24b3.default/lock
    ./src
    ./src/accountsservice-0.6.15/src/libaccountsservice/.libs/libaccountsservice.so
    ./src/accountsservice-0.6.15/src/libaccountsservice/.libs/libaccountsservice.la
    ./src/accountsservice-0.6.15/src/libaccountsservice/.libs/libaccountsservice.so.0
    ./src/accountsservice-0.6.15/debian/libaccountsservice-dev/usr/lib/libaccountsservice.so
    ./src/accountsservice-0.6.15/debian/libaccountsservice0/usr/lib/libaccountsservice.so.0
    ./src/accountsservice-0.6.15/debian/tmp/usr/lib/libaccountsservice.so
    ./src/accountsservice-0.6.15/debian/tmp/usr/lib/libaccountsservice.so.0
    ./.pulse/676238f89edd1f57138b3da400000004-runtime
    ./sd.png
    ./slashdot.png
    ./XnView/lib/libQtGui.so.4
    ./XnView/lib/libQtWebKit.so.4
    ./XnView/lib/libQtXml.so.4
    ./XnView/lib/libQtDBus.so.4
    ./XnView/lib/libQtNetwork.so.4
    ./XnView/lib/libQtCore.so.4
    ./XnView/lib/libQtSvg.so.4

  • The bold entries in the home directory also showed up in the first method.







For more ways on using find to accomplish what you want, please refer to Eliah Kagan's answer just above or below this one.


[#37552] Thursday, January 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sator

Total Points: 258
Total Questions: 119
Total Answers: 101

Location: Sweden
Member since Fri, Apr 16, 2021
3 Years ago
sator questions
Mon, May 29, 23, 08:06, 1 Year ago
Mon, May 1, 23, 18:09, 1 Year ago
Tue, Mar 1, 22, 10:57, 2 Years ago
Fri, Sep 10, 21, 02:40, 3 Years ago
;