Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 119625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:40:57+00:00 2026-05-11T03:40:57+00:00

Example: find / * Gives me all files and directories, but I want only

  • 0

Example:

find / * 

Gives me all files and directories, but I want only those files I may read and those directories I may see the contents of. Otherwise I get problems as when I try to find file information for all files:

for i in ls $( find / * ); do file $i; done 

Which results in:

find: /lost+found: Permission denied find: /proc/tty/driver: Permission denied find: /proc/1/task/1/fd: Permission denied find: /proc/1/fd: Permission denied find: /proc/2/task/2/fd: Permission denied find: /proc/2/fd: Permission denied find: /proc/3/task/3/fd: Permission denied # and so on ... 

If it’s possible I would like it in a generic way, so that I may use the same command line regardless of which user I am logged in as, but still get those files and directories I may see as a result from find.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:40:58+00:00Added an answer on May 11, 2026 at 3:40 am

    Use the -readable option to find (assuming a modern system using GNU findutils):

    Matches files which are readable. This takes into account access control lists and other permissions artefacts which the -perm test ignores. This test makes use of the access(2) system call, and so can be fooled by NFS servers which do UID mapping (or root-squashing), since many systems implement access(2) in the client’s kernel and so cannot make use of the UID mapping information held on the server.

    Using -perm and variants doesn’t work because it only looks at the file’s flags, and not whether those flags give you access.

    If you don’t have -readable, you can pipe the output of find through this trivial Perl script which only outputs the file names of the supplied files that are readable:

    #!/usr/bin/perl -w  use POSIX qw[access]; use strict;  foreach (split(/\0/, <STDIN>)) {     print $_ . '\0' if (POSIX::access($_, &POSIX::R_OK)); } 

    e.g.

    % find / -print0 | access_test | xargs -0 -n 1 do_cmd 

    but note that this will still generate output errors on stderr as find attempts to recurse into directories that it doesn’t have permission for. The print0 option to find (and xargs -0) is there to make sure that the system works on file names with embedded spaces in them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find a date after a give weeks(months). For example, I want
Every example I can find is in C++, but I'm trying to keep my
How to find all files with a specific key word in a directory with
I am using Linux(Ubuntu), I am trying to find the files, but it is
I find that my C++ header files are quite hard to read (and really
I've tried every single example I could find, they all produce an internal server
How can I find the permutations of k in a given length? For example:
I found this command line search and replace example: find . -type f -print0
Every example I find of anyone implementing plugins in android seems to use aexp.intent.action.
I was able to find example code to get the current timestamp in Linux

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.