Find Files Owned By A Specific User

In today’s article, we’re going to explore one way to find files owned by a specific user. We’ll be using the ‘find’ command for this exercise, which means it’s probably an article more for an intermediate user than a Linux beginner.

NOTE: This article is mostly a duplicate of an earlier article. I didn’t realize that until after I was done and hit the preview button. So, I saved it as an unpublished article, with the goal of just hitting the publish button (scheduling it, really) when I had a day where I was just otherwise occupied. Today is that day. After all, the “Big Game” starts in about 30 minutes.

But… I’ll do my best to make it one small bite that’s useful for beginners, but there’s no guarantee. I’ll see what I can do! So, if you want to play around with the ‘find’ command, read on!

The ‘find’ command does pretty much what you’d expect it to do, given the name. It’s used to find things – so you don’t have to stretch your imagination any to figure this command out based on the name.

You’ll find that ‘find’ describes itself succinctly, as this:

find – search for files in a directory hierarchy

See? Pretty much exactly as you’d expect. As you can also see, you’re probably gonna be asked to specify a directory. We can do that! Even you new Linux users can do that. I have faith in you!

So then, with that information freshly reviewed, there’s no reason to make the intro any longer. Let’s just jump into the article…

Find Files Owned By A Specific User:

If you’re a regular reader, you know what’s coming…

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Let’s start by finding files owned by you in the ‘Downloads’ directory. With the open terminal, enter the following:

Now, the ‘.’ is telling the ‘find’ command to search the current directory. You have to specify the username. For example, with me, it’d be:

You can also specify another user. Want to see if ‘root’ owns any of the files in your ‘Downloads’ directory? You can do that. Just change the username, like so:

Want to find all the files owned by root on the whole system? Well, you can do that – but it’s gonna be a whole lot of files and is going to take a while to run. You just specify the root directory (not to be confused with the root user). You do that like so:

In that command, you’ll notice we switched the path. We changed it to ‘/’ which is the root of the file system. You can be even find out if root owns any files in your user directory. Try this:

In my case, I’ve done things like compile and install software from my ~/Downloads directory, so I actually have files in there that are owned by root. If you’re a new user, you quite likely won’t have anything like that going on.

Play around with the ‘find’ command a bit, and it’ll become a bit more clear. Don’t forget to run man find to learn more about the command. There’s a lot more to it and it can be a pretty useful command.

Closure:

Anyhow, that’s a small bite of the ‘find’ command – but it’s a useful bite. The goal is to take a small bite and do what I can to make it approachable by even a new Linux user. Hopefully, I’ve done just that. Give me a yell if you think it worked – or if you think it didn’t work. 

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe to Newsletter!
Get notified when new articles are published!
We promise to never share your email!
icon

Author: KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.