Find Recently Modified Files

Over the past couple of years, I’ve done a lot of articles about file management; this one will help you find recently modified files. There’s nothing too complicated about this, so most of my readers should be able to follow along.

There are a number of reasons to find recently modified files. Perhaps you need to assess a file system that shouldn’t have been altered. You may need to do so for some accountability process. Then again, you could want to check a system to see what’s changing and eating up your disk space.

You might want to find recently modified files for all sorts of reasons. Heck, you might have forgotten where you placed a file but recall that you did so within the past 48 hours. This can help you narrow down your search, helping you find the file more quickly.

Of course, this will be in the terminal. That’s how we do things around here. This will also be portable. You need only the find command and you’ll certainly have that available by default.

The find Command:

As I said, you’ll need the find command. This will be installed by default. You can verify that find is available with this command:

The output should match this:

Next, you’ll want to check the man page (with man find) which will show you that this is the correct tool for the job. Notably, it says this:

find – search for files in a directory hierarchy

Yup. That’s what we want to do. 

The find command is very capable and will seem complicated to the newer Linux users. It may even push some more advanced users away. I aim to make Linux approachable, so we’ll only be worried about a couple of flags.

The type Flag:

The first flag we’ll be using is the type flag. If you check the man page, you’ll see that there are many types. We’ll specify f which signifies we wish to find regular files.

The newermt Flag:

While you’re on the man page you will see references to newer but nothing specific about newermt. It’s a reference to time. Specifically, it means less than or equal to. For example, a file that’s one day old will be listed in the results if you ask for files one day old or newer. That’s what we’ll be doing in this article.

Find Recently Modified Files:

While you will find that you have the find command available in any distro I can think of, you’ll also need to know that this is an exercise that requires the terminal. There are GUI options out there, but we’ll be using the terminal. So, press CTRL + ALT + T and let’s get started!

The syntax of the command would be this:

In our case, we’re going to use the ~/Downloads directory in our examples.

The "time frame" is where things get interesting. For the find command, you can almost use plain English. The command understands seconds, minutes, hours, days, weeks, months, and years.

Let’s say you want to scan your Downloads directory for files that you have added within the past four weeks. Well, simply use this command:

If you want to search for files within the past three months, use this command:

In the case of that command, it will find any files newer than (or equal to) three months of age. It’s a very simple command to use once you understand the syntax.

You do have to use numbers. 

If you want to quickly test this, try the following:

You could have even specified that in seconds:

You can also put dates in there.

Let’s say you want to find files newer than February 1st, 2024. You can do that. If you live in the US, you might have to use a date format that you’re not used to. So, the basic syntax would be:

Or, for today’s exercise:

I’m not sure if it’s possible to tell it to use the US date formatting. I was unable to make that work in the two attempts I made at it. Let’s just say that I didn’t invest a whole lot of energy.

There’s a lot more to the find command, but this is one way to use it. The goal is small bites that help make Linux more acceptable. Even I can be overwhelmed and I’ve been doing this for years.

Closure:

Well, if you’ve ever wanted to find recently modified files, you now have the tools to do so. While there’s a lot to this command, it’s possible to use the command without being fully versed in the matter. You don’t have to know everything to take advantage of the tools. Just like you don’t have to be a carpenter to know how to swing a hammer well enough to seat a nail.

Hmm… This article isn’t even all that long!

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Find A File While Ignoring Case Sensitivity

Today we’ll have a fairly short article as we’re simply discussing a way to find a file while ignoring case sensitivity. This can be a pretty handy command to have in your toolbox, so I’ll do what I can to turn this into an article. If you’re into finding files, especially with the terminal, you might just want to read this article!

I might even give you a bonus method! Maybe… It depends on how well you behave yourself! Don’t make me pull this car over!

Alright… Back on topic…

So, what is case sensitivity? We usually have lowercase files and commands. Linux is case-sensitive. If you type sudo APT update nothing is going to happen. Why? Because apt is lowercase. Similarly, a file named  FOO.bar is not the same as foo.bar.

If you try to perform an operation on a file with the wrong case, the operation will not take place. The file isn’t found, because you’ve used the wrong case. In the above command, not even SUDO apt update will work. You have to use lowercase.

Much of Linux is in lowercase. You can’t even use capital letters in your username, by default. Sure, you can force Linux to accept a bad username, but that’s not what the system is expecting.

So too are filenames. Well, mostly… Sometimes you will come across files that use mixed case or maybe all capital letters. You might even have created a file yourself with mixed case letters. When performing an operation on those files, you need to use the correct case.

Now, you can find files while ignoring the case. That’s what this article is all about accomplishing. It shouldn’t be too long.

The Find Command:

The find command is used in the terminal, so we will have to open the terminal to follow along with today’s article. However, on the plus side, you absolutely shouldn’t need to install anything. This find command should be available by default – unless you’re on an extremely stripped-down version of Linux.

If you check the man page, you’ll see that find is the right application for this.

find – search for files in a directory hierarchy

As we’re trying to find files (while ignoring case sensitivity) that seems like one of the good tools for the job – and it is.

Find A File While Ignoring Case Sensitivity:

As mentioned above, we do this in the terminal. More often than not, you can just press CTRL + ALT + T and your default terminal should open. Otherwise, you can open your terminal via your application menu.

With your terminal now open, let’s change directories and create a file.

You can confirm that the file exists by running the ls command.

Next, try this command:

Unless you have another file with that name, you will not get any results from that command. That’s why you need the -iname flag. Simply add that to your command and you can find the file while ignoring case sensitivity.

So, in our case, it’d be:

Sure enough, that finds HeLLo.txt.

If you don’t feel like changing the directory, you can change the command up a bit. The syntax would look like this:

So, in our example:

And, sure enough, that finds the file while ignoring case sensitivity! 

Pretty neat and pretty easy, right?

How about that bonus?

Find A File While Ignoring Case Sensitivity (with locate):

You probably don’t have locate installed by default. You’ll need to install it.

To that end, read this previous article:

And Still Another Way To Find Files By Extension

Specifically this part is of interest (saving you a click):

With your terminal open, we can get mlocate installed with one of the following commands:

Debian/Ubuntu:

Arch/Manjaro/etc:

RHEL/CentOS/etc:

OpenSUSE/GeckoLinux/etc:

There are other package managers. If your package manager isn’t covered, just go ahead and search for “mlocate” and you’ll likely find that it’s available by default.

So, with locate now installed, the syntax is also very simple. You simply need the -i flag to find files while ignoring case sensitivity.

First, we should update the locate database:

Next, try this command:

That will not find the file in your ~/Documents directory. Add the flag and run the command again, like so:

If you want to run that locate command in a specific directory, you can do that. The syntax is a little different than many other commands, but it’s easy enough.

Or, in our case, it’d look like this:

Sure enough, that outputs the information exactly as planned. It will happily ignore the case sensitivity and find your file named HeLLo.txt.

And now you’ve learned two ways to find a file while ignoring case sensitivity. One of the ways is even a nice bonus way to do accomplish this goal.

Closure:

As the headline and opening paragraph suggested, you can find a file while ignoring case sensitivity. It’s not particularly taxing and there are multiple ways to accomplish this goal. I figured I’d give some ‘bonus’ information with this one and share how to find a file while ignoring case sensitivity with the locate command used in the previous article. Why not?

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Another Way To Locate Files By Extension

I figure that today is a good day for a shorter article, so we’ll look at another way to locate files by extension. This is something that you can do in so many different ways. We’ll just cover another one, simply because we can.

You might want to locate files by extension when you’re doing file management tasks. When you have a directory containing many files, the output from the ls command can be pretty cluttered. For example, you might want only to list the files with a .txt extension. This article will help with that.

It should be noted that Linux doesn’t much care about file extensions. If you create a plain text file without any extension at all and add some text to the file, Linux will know that it’s a text file. See this article on Wikipedia about magic bytes:

List of file signatures

See also this article:

Magic Number on Wikipedia

About a year ago, I wrote a couple of articles on this same subject – that is finding files by extension. Of course, those articles are different than this article. This is a different way to locate files by extension. Those previous articles were:

Find Multiple Filenames By Extension – With Locate
How To: Find Multiple Filenames By Extension

So, finding files by their extension type has been covered before. We’re just going about it another way. The previous examples were a bit convoluted and this is just going to be an “easier” way. (I suspect that it’ll be easier. I guess that depends on what you consider to be easy!)

Locate Files By Extension:

Yes, we’ll be doing this in the terminal. I’m sure there’s a GUI way to do so, but that’s going to be a matter of the file manager you use. They will not all have the same features and not all of them will access those features in the same way. So, let’s get started by opening your terminal – just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, we’ll use the find command again. You almost certainly won’t need to install anything but you can confirm that you have find installed with this command:

See? You have the find application installed already. 

If you check the man page (with man find), you’ll see find is described as:

find – search for files in a directory hierarchy

We’ll also be using grep and a pipe “ |” in this article. You should know that grep helps you sort stuff and that the pipe lets you take the output from one command and use it in another. The pipe is a very underrated tool by people who don’t know much about the terminal.

The command we’ll be using is a find command. The syntax is quite simple and would look something like this:

For example:

The -type f is telling the find command to only look for regular files. Then, the output from that command is then piped to the grep command. After that, the grep command looks for file names that contain a . and the specific extension you’re looking for. The output might look like this:

using find and grep to locate files by extension
This is a fairly new installation and most of my .iso files are stored on the network.

Now, this isn’t going to work if you just use wonky file names. This isn’t going to find files without that extension name. Remember, we’re trying to locate files by extension. We are not determining if the extension is correct and we are not determining what the file really is.

See? Pretty simple!

Closure:

Well, I said today’s article would be shorter. It’s also fairly simple. If you need to locate files by extension, there are many ways to do it. Some methods are easier than others. Perhaps some are more robust than other methods. Either way, you can now locate files by extension type. 

You might also be interested in this article:

Find Out What A File Is

Otherwise…

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Search For Files By Name

Today’s article isn’t going to be all that complicated, as we’re just going to cover one way to search for files by name. It is a pretty useful skill to have, and a skill that one should probably learn early on. If you want to learn how to search for files by name, read on!

So many of us will parse the output of the ‘ls’ command, but you really shouldn’t parse the output from ‘ls’. Sure, it’s nice and easy to use something like ls -la | grep <filename>, but that’s a bad idea for reasons better explained by clicking the above link.

One of the options you can use instead of ‘ls’ would be the ‘find’ command. We’ve used it a few times before, but this time we’ll be using it to search for files by name. It’s relatively easy and I’m sure you can figure it out. The find command’s man page defines itself as:

search for files in a directory hierarchy

Which is a good description, because that’s what it does. Which is also good, because that’s what we want it to do! So, let’s get this article started rather than wasting time in the intro…

Search For Files By Name:

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.

With your terminal now open, the command you’re looking for would look a little like this example:

As you can see, you must declare a directory and a file name. If you want some level of leeway, you use ‘-iname‘ which indicates that it isn’t case-sensitive. As a matter of habit, I use ‘-iname‘ instead of ‘-name‘. This works for me and we’ll use ‘-iname‘ from here on out.

Let me give you an example…

Say you wanted to find the ‘firefox.desktop’ file and ensure it’s there. You could use this command:

Of course, if you aren’t sure it’s a desktop file, you can use:

The asterisk means anything, so you’ll get results for firefox.desktop as well as anything else.

If for some reason, you wanted to search your entire system for anything containing firefox, it’d look like this:

That’ll likely throw a whole lot of errors, as you don’t have permission to look in those areas, so you just add sudo to the command:

Which should show you every instance of a file starting with firefox on the entire computer. The ‘find’ command can seem pretty difficult to tackle for a new person, but if you take it in small bites you’ll start to learn that it’s not all that complicated. Be sure to check man find for more details.

Closure:

There you go… It’s yet another article. This time, we’ve covered how to search for files by name, a task that you may do with some frequency. If you know what you’re doing, it’s possibly faster than rooting around in a GUI hoping you find the right directory.

You don’t even need to know the entire file name to at least narrow it down a great deal. So, it’s a great tool to add to your toolbox and is more reliable than parsing the output of the ‘ls’ command.

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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

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 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.