How To: Find Out When A File Was Created

Today, we’re going to learn how to find out when a file was created. Odds are good that you could use the right click menu in a GUI file manager and figure it out, or you can sort by time and show details, that sort of stuff. Those being ‘easy’ we’ll learn how to find out when a file was created in the terminal.

Yeah, a lot of these articles explain how to do things in a terminal – even when there’s a nice graphical way to accomplish those same things. While it’s true that we may have different shells, we’re far more universal in the terminal than we are in a graphical desktop environment.

It’s good to learn how to do things in the terminal. If you can accomplish your goal in the terminal – you can accomplish it quickly and easily everywhere. That’s a pretty great benefit. (It’s not even unique to Linux – as you can do a whole lot via command line in Windows and MacOS.)

Also, today’s article feels a bit like work. I was hoping that it’d take longer to really start feeling that way. It’s okay. I picked a brief subject, what should be a short article, and that’ll be almost like a day off.

Find Out When A File Was Created:

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 open, change to the directory that contains the file you want to find out when it was created. Let’s say it’s in your Documents directory:

Now, you can just use the -l flag with the ls command. That’d look like this –  showing the creation date (and maybe time, if the file is recent enough) for all the files in that directory:

That’s pretty messy, especially if you have a lot of files in the directory. So, you can specify the file for which you want to find the creation date by specifying the filename in the command itself, like so:

That’ll do it for you. Well, it should do it for you! If not, something’s broken and don’t ask me to fix it!

Closure:

There you have it… You can now tell when a file was created. It’s not a very difficult process and it’s one you can easily commit to memory. I find myself using it when I’ve created a file and then can’t find it among other files with similar names – I’ll check to wee when a file was created and figure it out that way.

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.

[Fixed] A Rambling Post About Switching To Linux

Today, we’re going to talk about switching to Linux – in what I believe will be a brief article. This article is just based on some observations, and I think we can have some fun with it. (Ed. Note: It’s not very brief.)

Note: I hit the publish button instead of the Schedule button, so the article was briefly published and notifications went out about this. Sorry ’bout that. I’m an idiot. In my defense, I get it correct the vast majority of the time!

Moving on…

First, for this article, if you want to ‘help’ and ‘contribute’ then please do so as  a comment – you’ll see why before the article ends. Adding your comments as a comment here makes more sense.

When people take piano lessons, and history/experience tell me that this is similar for other instruments, 90% of them will quit within the first year. That is, they will have paid for equipment and formal lessons (as that’s where this data was drawn from) and they still quit taking lessons within a year.

Sure, you can learn a lot in a year – including how to give yourself further instructions. But, are they really quitting taking lessons for that reason – or are they quitting taking lessons for other reasons, like not making progress fast enough, not enough reward for the effort put in, or simply not having enough time to continue with a hobby when life has more pressing problems? Have they truly quit playing Piano?

And, well, I suspect the number is similar for people who try to switch to Linux. I strongly suspect, but have no data – simply observations – that approximately 90% of the people who try Linux will give up and return to using their previous operating system – be it Windows or MacOS, or what have you – within a year.

Let’s talk about …

Switching To Linux:

I get it. It’s hard. If you’ve been using Windows since Windows 95, you’ve got some serious muscle memory going on – and you have some legit knowledge built up. You’re pretty much an expert with Windows by then – or you’ve spent a whole lot of money to get other people to repair your computer for you. I suppose the latter is possible, but let’s just ignore that subset. You’ve still invested a ton of hours into learning how to use Windows itself – never mind the hours invested in learning to use the applications you are used to using.

Right now – and this is what prompted it – I am on my 4th day without smoking. (I am taking the drug Chantix. It’s awesome, at least for me.) 

I’ve tried quitting before – and I’ve even gone extended periods without smoking. I dare say that I’ve quit smoking so many times, I’m an expert at it! However, your odds of success get better every time you try to quit. I’m being optimistic, even though I’d kick a nun for a cigarette. (That’s a figure of speech… Well, it’s my figure of speech. Please don’t send ninja nuns to my house to beat me up.)

I can hear  you now… “Alright, David… What are you on about?”

Well, I’ve written about switching before – but this is a different aspect. See, when you make the switch, you’re not just starting to learn how to use Linux, you’re quitting using Windows. That’s a lot of habits and oh so many countless hours invested in learning to use Windows – and you’re giving up on all of that and all the benefits (and limitations) that entailed. You have things you know and those things you know are now things you knew – ’cause those things you knew ain’t true with Linux.

I don’t want to talk about formalities. This isn’t a technical article. Instead, I just want to show you one of the motivators I keep using to not smoke out of habit. (My cravings are kinda gone, I think. It’s just now the times I’d smoke out of habit.)

Please, click this link to see a timeline of benefits you get from quitting smoking:

What happens after you quit smoking?

Edit: Here’s a link from a .gov site, so maybe having more authority.

Ideally, that link will take you to the anchor – which is a timeline of benefits you get when you quit smoking. If not, scroll down until you get to said section. Those benefits are what’s keeping me motivated. Those are my rewards for putting up with the discomfort. (I dare say they’re pretty good rewards, but that’s a topic for an article on a different site.)

I have a point to this! It’s coming!

Timeline of Benefits:

If you have followed the link(s) above (and please do before commenting), you’ll see that there are benefits as soon as 20 minutes has passed. That’s right, just 20 minutes after quitting smoking you’ll have some benefits.

So, for this exercise, I want you to tell me what benefits you’d have (at those, or other) various timed intervals after quitting Windows and switching to Linux.

Like, so…

After 20 minutes of quitting Windows, you’ll see that you actually decide when your computer is updated and rebooted! So far so good!

After 12 hours of quitting Windows, you’ll see that you don’t have to hunt for software because everything you need to get started is available in the default repositories – and it’s free! These are benefits you get from switching to Linux!

After 24 hours of quitting Windows and switching to Linux…

(And carry on like that…)

You don’t have to do the full list unless you feel like it. You can even change the timeline hours/days/weeks/months, whatever – just have fun with it. It’s not some school exercise, it’s just for fun.

I do ask that you leave these replies as comments here, so that others can find and read them down the road. If you’re unwilling to do that, feel free to leave them on Reddit or on Linux.org, but here would be ideal. So far, in all my years hosting sites, I’ve never sold anybody’s data – and I’ve never had your personal information compromised. Commenting here is pretty painless and relatively low-risk.

Like I said… Don’t just have fun with it, be funny with it – if you want. The sky’s the limit. Do what you will with the idea!

Closure?

By the way, I think users HUGELY underestimate how many hours they’ve invested in learning to use Windows. It’s just like how they don’t recall how many hours they took to learn to walk, to talk, to spell in their native language, etc… They don’t seem to realize they’ll need to put in a similar number of hours to learn to use Linux. Ah well…

Have fun with it. “In 15 years, you’ll be a wizened old graybeard writing shell script like a wizard cast spells, with Windows being naught but a dim memory only recalled when drinking heavily or in the feverish nightmares of an old man.”

What was it like when you were switching to Linux? What was your timeline like? If you’re just switching, what do you want your timeline to look like?

What was the timeline like for you? Feel free to make it an accurate summation of events as you witnessed them. You do what you gotta do, but leaving them as a comment will mean they’re attached to the post ‘forever’ (or as long as I keep paying the bills). So, be funny, be real, be optimistic, or be you. 

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.

Let’s Install And Use ‘locate’

Today, we’re going to learn to install and use locate and we’ll even cover some basic usage. If you’re unfamiliar with locate, it does exactly what you’d expect – it helps you locate files on your computer. Read on for a basic understanding.

The locate command is a terminal-based command, a text way to find files on your computer. It can be a pretty useful command – with some advanced usage – but we’ll just cover some basics.

The locate command is actually installed by installing ‘mlocate‘. So, let’s just get that out of the way. Depending on the distro you use, it’ll likely be in your default repositories and you can install it much like you’d install any other software. For example, in a distro that uses apt you’d install it with:

You may have it installed by default. You can check that with:

If that spits out a version and some version information, you’ve already got it installed and there’s no need to install it.

Anyhow, with that accomplished, let’s learn a bit about how to …

Use Locate:

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.

Of course, you’d have had to open the terminal in the preamble, but I  might as well tell you again. With the terminal open, you can check the man page for locate. You’ll see it does exactly what you’d expect it to do:

locate – find files by name

To use the locate command, it’s quite simple. It’s ‘locate <flags> <file_name>‘ and really quite simple. It does what you tell it to do, nice and easy. 

For example, it may return a lot of results:

Or it can be quite targeted:

However, it needs a database to work from. If you’ve just installed the mlocate package, you’ll need to update the database. Hmm… I probably could have mentioned this sooner. Oh well… You’ll find it if you need it. It pays to read all the words, folks!

To update said database, it’s this command:

Now, there are a couple of useful flags. We’ll cover a few. You can just return a number of how many files match the description with the -c flag:

You can limit the number of responses with ‘-n <number>‘ easily enough:

The locate command defaults to being case-sensitive, but you can change that behavior with the -i flag:

Finally, you can check the database statistics with this command:

While there are other options for the locate command, including using it with other commands, those are the options I find myself using more often than not. I suspect those will be the most often used options when you too make use of the locate command. Be sure to check ‘man locate‘ for more information.

Closure:

See? It’s a quick and easy article about how to use locate to find files on your Linux computer. It’s not terribly difficult and it’s a handy command to have learned. As mentioned, the man page has even more options for you to use the locate command. Feel free to check ’em out.

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.

Let’s Delete An Entry In Your Bash History

In today’s article, we’re going to learn how to delete an entry in your ‘bash’ history. It’s a useful skill to have, for any number of reasons. It’s not all that difficult and this shouldn’t be a very long article. Read on, my dear readers! Even a long-term Linux user might learn something – but I make no promises!

I’ve previously covered how to remove duplicates from your bash history. It may be worth checking that article out, as most of you are going to be using bash. Sure, there are other shells, but bash is the most common on desktops and servers. So, we might as well learn with bash.

If you don’t know, bash is both a language and an application. Unless otherwise specified, you’re almost certainly using bash when you open a terminal or TTY. 

When you enter a command in the terminal or TTY, it’s saved to your bash history. In fact, it’s saved to the hidden file ~/.bash_history. If you so wanted, you could just open the .bash_history file with a text editor and remove lines as you wished. That works just fine.

However, in this article we’ll be using the ‘history’ command. It’s a handy command, useful for recalling previously entered commands and managing those stored commands. I guess this is really more an article about performing some very basic tasks with the history command. Like I said, it’s good for you to know this sort of stuff – especially as a Linux beginner.

Delete An Entry In Your Bash History:

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 right up and be ready for use!

So, with your handy-dandy freshly-cracked-open terminal, let’s just display your bash history. You’re going to do that with just the following command:

You’ll notice that every stored command from your bash history is assigned a number that’s shown on the left (or right, if you use a RTL language). Well, that’s how you delete it. You use that number in the following command:

You can use that command to delete an entry in your bash history, and you can do so as often as you’d like. While you’re there, you can also just plain clear your entire bash history with this command:

That will clear all of your bash history – more or less. Your current session may have not been written to the history at the time you issued that command. It might not be saved until you close the terminal instance. This makes it slightly more complicated to make sure the history is truly empty. However, it’s definitely close enough.

Anyhow, you might want to delete your bash history to remove commands that you’ve memorized. You might want to remove commands that didn’t work. If there are sensitive commands in your bash history, this is a way to remove them, surgically or en masse. There are all sorts of reasons why you might want to go through your bash history to delete past commands – and now you can!

Closure:

Yay! It’s another back-to-basics kind of article. In this one, we learn how to delete an entry in your bash history file. In some cases, it may be easier for you to just do so with a GUI and a GUI text editor. You don’t even need ‘sudo’ to make the changes and removing a lot of entries might be faster with a graphical application. Just remove the lines you don’t want showing up in the history any longer.

Also, I should mention somewhere that you can see the history by just pressing the up arrow, but I suspect folks will already know that. ‘Snot the best way to go about managing them, but you can see and select them, running them again as you wish.

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.

Sort Files By Size (In The Terminal)

In today’s article, we’re going to cover something nice and simple; how to sort files by size in the terminal. This is something everyone should know, because sorting files is often a prerequisite to understanding and managing said files.

Besides, not all the articles have to be something complicated. The tagline for Linux-Tips is “Getting you up to speed!” It’s supposed to be aimed squarely at new Linux users. The problem is, many of those articles are boring to write and the 2nd largest group of readers aren’t really beginners. 

So, yeah…

Today, we’ll have a nice, basic article that tells you how to sort files by size – in the terminal. In fact, some of the more regular users may not have these commands memorized. Now’s a good time to learn ’em.

We’ll be using the ‘ls’ command for this. It is said that you shouldn’t parse the output of ‘ls’ for anything important. It’s bad practice for reasons I think I’ve touched on before. However, you can safely use ‘ls’ for this process as it’s just sorting the files by size and doing so by itself.

For those that don’t know, ‘ls’ has a ton of options. It’s a tool used to show the contents of a directory. You can use man ls to get more information about the command. We’ve previously covered:

Let’s Use ‘ls’ To Sort Files By Time

Well, today we’ll use ‘ls’ to …

Sort Files By Size:

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.

You might just as well stay right there in your default location – which should be your home directory. Feel free to switch to a new directory, but you really won’t need to. It’s an easy command. 

First, we’ll show the output sorted to show the largest files first:

Of course, you can reverse that sort order and show the smallest files first. To do that, you just add -r (reverse) to your flags, like so:

That command should show you files listed with the smallest ones first and that’s really all there is to this article. Well, there’s the closure section – but nobody reads those.

Closure:

And, well, this particular closure section won’t have anything truly interesting or different in it. After all, this is just a simple article that shows you how to sort files by size. ‘Snot that much more to it. ‘Snot that much more that I can add.

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.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.