Find Files Created On A Specific Date

We sure do have a lot of file management articles and this is another one that will help you find files created on a specific date. This is a relatively easy task and you won’t even have to install anything new. If you want to find files created on a specific date, you might as well use this method!

Here’s a similar article.

Find Files Modified On A Specific Day

So, what is file management? To me, it’s manipulating files on your file system. It’s gathering information about the files on your file system. That’s what I mean when I say ‘file management’. I’ve covered a lot of articles with this as a subject.

Seriously… I tag articles with various terms. There are pages and pages of articles that have been tagged with file management.

Articles Tagged With File Management

Yup, that’s a lot of articles. Managing your files is something you do on a daily basis. You’re creating, editing, and moving your files around your file system. That’s file management and that’s okay!

Because this is something you do on a daily basis, even if you don’t pay attention to it, it’s something covered often. Even if you’re just browsing the internet, you’re adding files such as cached files. If you’re emailing with an email client, you have added and deleted files – if not more. File management is a pretty big thing.

Today, we’ll be using two basic commands – ls and grep. Let’s learn more!

The ls Command:

The ls command is an application that lets you list files. There are flags you can use, but it’s a basic application that, at its core, just lists files. You don’t need to install anything. You can verify that ls is available with this command:

The output should look like this:

Check the ls man page with this command:

If you do that, you’ll see that we’re on the right path if we want to find files created on a specific date. The ls command is briefly described as this:

ls – list directory contents

We’ll be using the ls command to output a list of files and we’ll then use the pipe operator to process that output with grep.

The grep Command:

The grep command is one of those commands that’s used in conjunction with another command. By itself, it’s not that useful. It is when you use grep with other commands that you realize how powerful it is.

The grep command is usually used with the | “pipe” operator. The pipe operator takes the output from one command and processes it with another application. I’ve not yet covered this in an article, nor have  I done an article about the grep command. I should do both.

Again, you won’t need to install anything. You can verify this with this command:

The output should match this:

Next, you can check the man page with this command:

grep, egrep, fgrep, rgrep – print lines that match patterns

You can see that there are options. We’ll be using just plain grep. And, as you can deduce, this is yet another process that will help us find files created on a specific date. We’ll take the output from one command and use it with the grep command. This should appear obvious shortly if you have not yet realized how we’ll be proceeding in this article.

Find Files Created On A Specific Date:

Both ls and grep are tools used in the terminal. As such, you can be sure that you’ll need an open terminal. Either open a terminal from your application menu or open a terminal by pressing CTRL + ALT + T on your keyboard. This article assumes that you don’t have year numbers in your file names, as you’ll see…

With your terminal open, we can begin to find files created on a specific date. Further, let’s stay right there in the ~/home/user directory. We’ll keep it simple.

Let’s start with this command:

That will list all your files. Now, let’s add hidden files – with the -a (all) flag with the following command:

Next up, let’s get more information from the ls command with the -l (long listing format) flag. That looks like this:

You should now see that there’s a time listed. We’re going through this just so that the example commands work. This isn’t strictly necessary, it’s just how it is being explained in this article.

If you want, you can sort that output by time. The following example command will show you the time the files were created, starting with the most recent example.

Again, that’s not strictly necessary.

Pay attention to the date section, because that’s what we’ll be using. 

More specifically, we’ll be piping the output from the ls command to the grep command. That’s done like this:

NOTE: You’ll be grepping a pattern. So, if you look carefully, the dates from 1 to 9 have two spaces! You’ll need to grep accordingly!

So, if you wanted to list articles created on the day this will be published, the command would look like this:

Notice that there are two spaces.

If you wanted to find files created on the 10th of February, your command would be different. You don’t add a 2nd space, as there is no second space in the pattern you’re looking for:

That will show you all the files (including the hidden files) that were created on the 10th of February. It does not care about the year and doesn’t show the year field. You’re simply finding files created on a specific date (ignoring the year, of course).

This is still useful.

This is also only true for files created within the past year. The ls command will happily show the date on files older than a year.

Here’s an example where the files are older than a year:

So, to find files including the year, your command now has more spaces to contend with. For this command, you would now add two spaces between the day and the year. Like so:

See the two spaces? That’s essential.

Again, don’t forget that you need two spaces when you’re working with days that are a single digit. If I wanted to find files from the 4th of November in 2022, that command would be this:

REMEMBER: The grep command is used to find patterns and will only find the specified patterns. It’s very specific! It is also very powerful when used properly.

You can do even more with this. If you want to find files older than a year and by the specific year of their creation, you could simply run a command that looks like this:

Of course, you can substitute ‘2020’ with any year you’d like and get results – so long as you have files that were created in that year.

Also, of course, that command is ONLY useful if you do not have year numbers or numbers similar to years in file names. After all, 2022 is 2022 and grep is going to find them all. That’s what grep does – it finds patterns. As such, it’s up to you to pick the patterns you’ve used and this does have a limited functionality if you’ve gone ahead and added dates to your file names.

If you do have numbers in your file names and you don’t have spaces, you can still grep for a pattern. For example, this might work assuming no space in your file name is in front of the year field – which there generally shouldn’t be:

I can’t be too specific because I don’t know if you’ve put numbers/years in your file names. If you have, grep will equally find those. This whole article assumes that you’ve done nothing of the sort.

This can be even handier and here’s a little bit of some bonus information.

Let’s say you have a directory where you’ve stored files for years. Further, you want to know how many files you created in the year 2022. This directory contains files containing many years and you don’t want to just count them.

Well, you can do something about that!

That command lists the files. The grep command then finds files created in 2022. You then pipe that output to the ‘wc’ command to count the lines.

Here’s an example output:

That means I added 8 files to that directory in the year 2023.

It’s pretty complicated. If you have years and spaces in your file names, this isn’t going to work that well for you. If you use patterns that match the output from the ls command, grep will find them. That’s what grep does.

While this does have a bit of a limited use case, it’s more of an exploration of what you can do with two simple commands. Unless you use matching patterns in your file names, this should work just famously for you. Otherwise, not so much – but you can have both fun trying AND you can look for other patterns that you can pass to grep.

Closure:

Well, that was kind of fun. We used the ls and grep commands to find files created on a specific date. There are always so many fun things to do with Linux. Many of these fun things can be done in the terminal. I like to think we both learn and have fun here on this site.

This can also be a handy tool. Let’s say you made some changes and then had some trouble later. You know you added files, but you can’t remember which files those were. Before restoring from a backup, you decide you want to troubleshoot. To do so, you start by finding files you created on the same day that you last changed your system.

Of course, this can be useful in a business setting. If you need to account for a problem, you can find the files created that day. Should there be something amiss, you can find files created on a specific date. If, for example, files were created on a date when no files should have been created… Well, you get the idea.

Perhaps more importantly, this shows what you can do with just two basic Linux commands. You’ll find ls and grep on every single desktop Linux (or server Linux) you touch. There’s no need for you to install something. You don’t have to worry about which package manager you use or building software from scratch because the developers didn’t release a package for your distro. You just use the commands that are already available.

Anyhow, this article is already too long. Sorry about that…

I kid. If I was sorry, I wouldn’t have done it in the first place! Ha! Take that!

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.

Short: Show File Creation, Modification, and Access Times

Today’s article is short because there’s no reason to make it longer and we’ll just show file creation, modification, and access times. This is just a simple process and won’t take all that much to learn. It shouldn’t take too long to explain.

Files contain metadata. This can be everything from the GPS location of an image file to the kind of camera used. You can even add your metadata fields with audio files, for example.

For example, we’ve previously covered metadata in these articles:

How To: Sanitize Exif Data From Your Digital Images For Privacy Sake
Review: MetaClean (Clean Exif/meta Data From Email Attachments Automatically)

Well, your files contain other metadata. This information includes things like file creation, modification, and access times. You can easily find out when a file was created. It’s easy to show when the file was modified and just as easy to see when the file was last accessed.

Nice and simple, right?

Well, we’ll be using the stat command.

The stat Command:

You won’t need to install anything. You’ll find that the stat application is already available. You can verify this with:

The outcome should match:

You can check the man page with this command:

Doing so will show you that stat is described like:

Which is exactly what we need to show creation, modification, and access times. This will be the correct tool for the job.

Show File Creation, Modification, and Access Times:

This is a terminal-based process and you can usually access your default terminal by pressing CTRL + ALT + T. If that doesn’t work, find the terminal in your application menu.

With your terminal open, list the files:

Now, pick a file…

When you’ve picked a file, use the stat command. The syntax is easy:

When you opened your default terminal, you probably opened it in your home directory. Most of you will have a ~/.bashrc  file, so we’ll use that. An example of this stat command would be:

Here’s an example output:

As you can see, there’s the ‘birth’ (file creation time), an access time, and a changed time. There’s a lot of other information, but that’s outside the scope of this article.

Be sure to read the man page:

You can use several flags to extract just the information you want. If you wanted to, this would be useful for scripting or other programming. You don’t have to have the full output. For this simple and short article, the information isn’t that overwhelming. I see no reason to cover any particular flags unless I intended to cover a half dozen of them. You can find those just fine on your own.

Closure:

This has just been a short article. I wanted to cover the stat command and there’s not much to it – for the average user. File management is a pretty advanced topic and we cover that often. This time around, it’s just file creation, modification, and access times. Nothing too advanced.

I don’t do many of these short articles. I probably should, as they’re quick and get straight to the point. They’re quick articles that should be plenty easy to process and you don’t have to wade through a lot of text to get to the point of the article. If you like them, let me know.

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: Crack A PDF Password

I don’t know how handy today’s article is going to be in reality but it’s sort of possible to crack a PDF password. Once you read the article, you’ll see why I said “sort of possible”. The odds of success will vary greatly.

Everybody knows what a PDF file is. It’s a Portable Document Format. This is actually a standard (ISO 32000). You don’t need Adobe products to create, edit, or read PDF-formatted documents. Odds are good that your distro comes with tools for manipulating PDF documents.

It’s possible to password-protect a PDF document. You can have an owner’s password (allowing editing) or you can have a user’s password (allowing you to read the document). This may be something you’ve encountered in the past.

Well, like all things password-protected, it’s possible to crack the password.

What do I mean by crack? I mean it will reveal the password to you in plain text. This will allow you to access the document in one form or another, depending on which password you crack.

This is gonna take some time…

Also, I’ll assume you’re using something based on Debian because I’ve not tested this with other distros. I’ve only tested this on my systems.

The tool we’ll be using is a ‘brute-force’ password cracker. That means it starts from the letter a and works its way up, adding new letters after the rest of the letters have been tried. So, you’ll see aa, ab, ac, ad, and progression along those lines. You can immediately see why this is going to take a while.

The tool we’ll be using is helpfully called ‘pdfcrack’.

pdfcrack:

This pdfcrack is a terminal-based PDF password-cracking tool. You can use brute force or lists of words such as common passwords. You can also specify the character list, though the default is to just use the regular alphabet in both uppercase and lowercase formats.

The pdfcrack application is helpfully described as such:

pdfcrack – Password recovery tool for PDF-files

I’ll assume that you’re only trying to recover passwords on documents you should legally have access to. I assume that you won’t use this to access content that does not belong to you. That seems like a safe assumption!

As you can see, this is the correct tool if you want to crack a PDF password.

Crack A PDF Password:

As mentioned above, you’ll crack passwords in the terminal. That requires an open terminal, so we might as well install pdfcrack in the terminal. Just press CTRL + ALT + T and that will usually open up a terminal for you.

With your terminal now open, install pdfcrack:

With that installed, check the man page:

Download:

Example PDF File

Now, crack it…

As it’s a download, it’s probably in your ~/Downloads directory, but mine is stored in my ~/Documents directory because it’s a document. So, my example:

That uses a very simple password that should be cracked in a few seconds. On my older and slower computer, I was able to do more than 20,000 words per second. This short password should crack almost instantly.

Leave a comment telling me what the password is!

By default, pdfcrack will crack the user password. You can specify which password you wish to crack. Though the syntax is a little wonky. In this case, the syntax is as follows:

Which translates into the following…

For the owner:

For the user:

If you want to pause this, you can! 

To pause a running pdfcrack instance just press CTRL + C. This will save the progress as savedstate.sav. The program will automatically resume when you run the command again. Pretty neat!

There’s a lot you can do with this command. Let’s say you recall the password was between 8 and 12 characters and want to just search in that area.

You can also specify the character set. If you want to use uppercase, lowercase, and numbers you can do that. You just add them to the command with the -c flag, making sure to put them in quotes. That’d look like this:

You can specify a wordlist like so:

The format for that file appears to require one word per line and there are collections of common passwords you can download to help you crack a PDF password.

As you can imagine, and as you were warned near the start, this process can take a while. Assuming you have the right characters loaded and enough time, it’s certain to work eventually.

Go ahead and crack my example file above. That one won’t take you very long, even on a slow computer. It won’t be instantaneous, but it’ll be pretty quick.

If you want, you can also run a benchmark to see how fast your computer is. The command to do that is quite simply this:

I ran this on the slowest computer I use. I didn’t run it on anything faster because I don’t care that much. I’m sure you’ll do better on your computers, though you can share the results as a way to compare your rig with others.

Anyhow, my output was this:

Be sure to check out the man page. It’s a simple application but there are many options available for pdfcrack and you might as well learn about them now. You never know when you’ll find an old PDF document with a forgotten password. It can (and does) happen!

Also, be sure to check the pdfcrack project page.

Closure:

So, you might wonder why I’d include an article like this. After all, isn’t cracking passwords a potential legal mess? Isn’t it immoral to crack passwords? Is it even legal to crack passwords?

The answer is simple enough. It’s a tool you can use to recover your lost passwords. You can use this tool to access things that you shouldn’t be accessing, just like you can use a screwdriver to poke things you shouldn’t be poking. I’m just giving information.

I am also not a lawyer. I permit you to crack the password of the included file. For other files, don’t do anything illegal in your jurisdiction. If it’s a crime, don’t do it. I’m decidedly not your lawyer. If you think this requires asking a lawyer, go ahead and do so.

That and it’s not a great secret. If you’re relying on a password to protect PDF files from anyone serious, you’re probably doing your security wrong. It’s well known that this is possible and that the tools are easily installed. PDF passwords aren’t very good for security, though you can make complicated passwords.

The distro you’re using may very well have pdfcrack available, even if it isn’t one of the Debian-based distros. Just search and you can find it. With some work, you can even mostly install it with PIP. Just click the link above to the project page for more information about that.

As always…

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.

The du Command In Linux

There’s always time for a basic article or two and today we’ll do that as we just play around with the du command in Linux. This is a functional tool and one you can learn to use in just a few minutes. Because of that, I’ll try to keep the article reasonably short.

Storage…

On Linux, everything is a file. These files are stored with a system – such as a particular formatting method like Ext4. Collectively, this is your file system.

Because of this, you may have done similar things, you’ll find that file sizes are all divisible by four. That’s because of the way things are stored. They’re stored in blocks and 4KB is (generally speaking) the smallest block you can have. So, it only makes sense that things can be divided by four.

Running out of storage space is A BAD THING®. It can even prevent you from booting! You do not want to run out of space on your drives. You don’t want to run out of space on any of your partitions.

When you installed Linux, you should have taken care to ensure that the partitions will be large enough for you to grow into. It’s possible to add storage. You can even modify your system to move your ~/home directory onto a partition all its own.

It’s easier to ensure you have enough room when you start. Storage space is relatively inexpensive these days. You can get really fast storage (such as an NVMe M.2 SSD) for little money. If your motherboard doesn’t support NVMe, you can get a cheap PCIe riser card to add that feature.

We’ll be using the du command to see how much space you’ve used.

The du Command:

The du command is a terminal-based application. You shouldn’t need to install anything for this article, it should be installed by default. We’ve previously used this command to sort files by size if you’re curious.

Anyhow, you can ensure du is available with the following terminal command:

Which should give you an output like this:

If you get an output similar to that, you’re good to go and won’t need to install anything to finish this article. The man page can be accessed with the following terminal command:

The output from that command should be a good indicator that we’re using one of the correct tools for the job. This being Linux, there are many choices. In this case, the du command is described as:

As you can tell by the introductory paragraphs, that’s a good tool for the task we’ve set for ourselves today. We want to see how much file space we’re using.

Using The du Command In Linux:

If you read the above paragraphs you’d know that this is another one of those things you do in the Linux terminal. Yes, there are graphical tools that will let you do this – but this way is universal. You’re going to find the du command on any Linux system you’re likely to touch. So, press CTRL + ALT + T and we can get going.

With your terminal open, you can just start with the basics:

That will show you the bytes used by the directories. We want to see the storage space consumed by directories and files, so we’ll add the -a flag to the following command:

That should show file and directory sizes in bytes. That’s not very readable by a human unless you want to do some math in your head. So instead we’re going to add the -h flag. Like so:

That’s all well and good. You can use cd to navigate around your computer or you can specify the path. How do you do that? Well, the syntax follows:

So, if we want to view the storage consumption of the ~/Downloads directory we’d simply use the following command:

Now, if you just want to see the total value of the directory you can use the following command with the -s flag:

If you want to find out how much storage space is consumed by your entire ~/home/<user> directory, that’s a very simple command:

I’d not suggest using the du command to check the entire drive of a running system. It will want to also calculate anything plugged into the computer and take forever. There are other ways to view drive usage information.

If you want to use a GUI, here’s a few tools for you:

A Few Ways To Visualize Disk Usage In Linux

There are innumerable ways to do this in the terminal and I’ve covered many of them. Most recently, I showed you a way to use Python to view disk usage. I admit my bias, but that’s a neat way to give you some basic information in a handy format that’s easily understood.

This is one of those things you can do with a multitude of tools. It is also a fairly basic task and something we should all be aware of. Know how much free storage you have and act accordingly.

Don’t wait for the drives to fill up before acting because that just makes it harder on you. You know the adage about how an ounce of prevention is better than a pound of cure? Well, keep that in mind when you think about your storage solutions.

Closure:

Oh, I’m sure I’ve mentioned the du command before. It sounds like something I’ve written about. I do know that I used it so that you could sort files by size, which is nice. At least I’m pretty sure I did…

At this point, who knows? I could do a lot of searching just to check, but the search doesn’t always do a good job and it’s too late now because I’ve written the article!

As of today, you should be fairly fluent in the du command. You might want to read the man page. There’s quite a bit that I didn’t cover. I only covered the basics. More specifically, I only covered the ways I use the du command. You may have very different needs. You may have a very different process. With that in mind, read the man page.

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.

Show Your USB Devices In The Linux Terminal

Today’s article won’t be all that long or complicated because we’re just going to show your USB devices in the Linux terminal. This is something easily done and not something too unusual. You never know when you’ll want to show your USB devices, but this is your chance to do so.

We have covered the lsusb command in the past, but we’ll include that and go beyond that. Why? Because we can. It’s okay to revisit earlier material if we’re going to add to it.

USB stands for Universal Serial Bus and there are many versions. I’d like to think that my readers don’t need to be told what USB is. You’ve probably used USB devices in the past, including using a USB storage device to install Linux or use as an input device like your keyboard and mouse. 

Not having to explain that will save a lot of time!

Show Your USB Devices:

You can learn quite a bit about your USB devices in the terminal. You can learn what the devices are, maybe the product name, where it’s plugged in, and more. So, we’ll cover that in this article.

The two tools we’re going to use shouldn’t require any new software. Sweet!

lsusb:

The first tool we’ll cover is the lsusb application. You won’t need to install this. It will be installed by default. You can confirm that you have lsusb installed with the following command:

Sure enough, you can check the man page to see that this is a good tool for this task. That command is:

With that information, you can see that it’s described like this:

lsusb – list USB devices

See? It’s exactly the tool for the job!

To run this command, you simply run it in your terminal – like so:

That will output a bunch of USB information.

usb-devices:

Now this is a command that I’ve not previously covered. It’s a simple command to operate but the output is different from the above. This command gives a great deal more information than the above lsusb command does. 

You can ensure that usb-devices is installed with this command:

If you want to check the man page, run this command:

You’ll see that this is a useful tool if you want to show USB devices. In fact, you’ll see that it’s possibly better than the plain lsusb command. It’s described like:

usb-devices – print USB device details

The important part is ‘details’. This command will show you a great deal of the details regarding the USB devices.

NOTE: This will only show the details for things that are active. If you have inactive USB devices it will not show them. That explains the difference between the lsusb command and the usb-devices command. Well, that and this command spits out a lot more information.

If you want to run this command in your terminal, it’s simply done like so:

That’s not very complicated at all and will reveal quite a bit more information than you’d get with the previous lsusb command. It’s worth running both in some situations, but run this usb-devices command if you need detailed information.

Closure:

See? I told you that this one wouldn’t take all that long. I probably could have labeled this one as a short article, but I didn’t. It’s also written in a different format – not even telling you how to open your terminal. If you need to know that, you can figure it out – or you already know. I did mention the terminal in the headline.

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.

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.