- Forums
- Linux Systems
- How To Locate Or Find Files By Owner In Linux Shell Command Finding Files By Owner
this tutorial will show you how to locate or find files by owner in linux shell command ... locating files by owner, the find utitiy is used to locate files based on a linux user [2906], Last Updated: Sat May 18, 2024
linux
Thu May 03, 2007
0 Comments
15423 Visits
locating files by owner, the find utitiy is used to locate files based on a variety of criteri. determine whether you have a directory in /tmp anmed the same as your user login name for example, run this command:
Commandls -ld /tmp/$USER
if a long listing for your direcotyr in /tmp is displayed, make sure the permissions allow you to rwx the direcotyr. if you do not have a directory in /tmp of your login anme, create one with this command:
Commandmkdir /tmp/$USER
and copy three more of your files ot he directory you created in /tmp with this command:
Commandcp any_file another_file 3rd_file /tmp/$USER
now lets looks for some files, this is the command you could use to find files by the owner since in this example, i will be looking for my own files ($USER)
Commandfind /tmp -user $USER -print
EXPLANATION OF COMMANDS
COMMAND | DESCRIPTION |
find | instructs the shell to execute the find utility, which searches a target directory and all of its sbudirectories. |
/tmp | this first argument to find instrucs find to start its search in the /tmp direcoty and search all directories below that. |
-user | an option to find, instructin it to search for files by owner, not by name or any other criteria. |
$USER | this argument directly follows the user agrument and is interpreted by find to be the user whose files should be located. the shell replaces $USER with your login anme. all files belonging to this user in the directory tree starting at /tmp are located |
-print | specifies that the full pathname of each occurence of the files matching the selection criterion should be oupt. in addition to pringint, find can be instructed to remove located files, change file permisions, or emply essentially any shell file-manipulation command |