Some Fun With Sorting The Output Of ‘ls’

Today’s article will be relatively short and easy, as we have some fun with sorting the output of ‘ls’. It’ll be a pretty short and simple article, but that doesn’t mean it’s not useful. Read on and learn about sorting the output of ‘ls’!

The last article I wrote was:

Some Fun With Formatting The Output From ‘ls’

This article will be remarkably similar, but isn’t about formatting the output of ‘ls’, it’s about sorting the output of ‘ls’. Yes, there is a difference! This is useful for a variety of reasons, but it’s mostly useful for viewing your files categorically. There are just a handful of sorting options, but we’ll cover them all.

Like always, it’s important to know that you should not to parse the output of ‘ls’. Parsing the output of ‘ls’ if full of risks, so you shouldn’t do it! The link explains it better than I can, and it tells you what to do instead of parsing the output of ‘ls’.

Obviously, and again, we’ll be using the ‘ls’ command. The ‘ls’ command defines itself fairly accurately as:

ls – list directory contents

So, just like the last article, there’s no real reason to make the intro longer than it needs to be. Let’s just jump right into the article.

Sorting The Output Of ‘ls’:

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, you can stay right there in your /home directory, or you can ‘cd‘ into a directory of your choice – preferably one with a variety of files in it.

When you’re done picking a directory, you have the following choices:

See? I even alphabetized them for you! The list of what they do should be fairly obvious, with ls --sort=version being the most unusual and only applying to versioned files.  Also, while included, there’s not a whole lot of reason to use ls --sort=none, as that’s just the default output.

I find sorting by time to be pretty handy, as well as sorting by size. I don’t have much of a reason to use the rest, but they’re there if you need them. I figured I’d include ’em all, rather than just those that I find useful.

Closure:

There you have it, another short article! It’s also another article about the ‘ls’ command, but this time we’re sorting the output of ‘ls’. I figured I’d do this article right after the other one, mostly so that I’d remember to actually cover it. 

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.

Some Fun With Formatting The Output From ‘ls’

Today’s article will be a nice and simple one, in which we’ll have some fun with formatting the output from ‘ls’. It’s just a quick article today, as there’s no real reason to make this all that difficult. Read on, my dear readers!

While it’s true that you shouldn’t parse the output from the ‘ls’ command, you can format it to get an output that more suits your needs. You might want to do this to more easily understand the output from ‘ls’. There are a half dozen or so formatting options and we’ll show them all to you in this article. One (or more) of them might tickle your fancy.

Obviously, we’ll be using the ‘ls’ command. The ‘ls’ command describes itself like this:

ls – list directory contents

Which is exactly what it does. It’s not a very complicated command, as far as some commands go, but there are a lot of options. Like always, I highly suggest that you read the man page (man ls) to get more information than will be contained in this article.

Anyhow, I said this will be a short article, so I will just get right into the meat of the article instead of typing a bunch of additional fluff. You’re welcome!

Formatting The Output From ‘ls’:

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, you can choose to view the output of ‘ls’ with a variety of formats. They’re more or less self-explanatory, so I’m just going to show them all to you. If you’re confused by any of them, try them in your terminal, which will should make it more clear.

I even made you an alphabetized list! See? I am helpful today!

So, for ls --format=across you’ll get the output spread across your screen (as much as possible). If you use ls --format=comma, the files will be separated by a comma.

Out of all of them, I tend to use ls --format=verbose more often than I use any of the other ways of formatting the output from ‘ls’. It gives me just enough information, from file modification date and time to the file’s permissions. So, out of all of them, that’s the one I’ll use most often. 

Feel free to flip through and try them all. You’re bound to find something interesting in there. The ‘ls’ command is surprisingly useful, and it’s harmless enough for you to explore it at length.

Closure:

See? I told you that it’d be a pretty short article today. I just showed you some ways of formatting the output from ‘ls’ and that’s all I’ve done. There’s no reason to make this longer than necessary. I think my readers are smart enough to take it from here, and figure out what they like most, or find the most useful.

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.

Find Files Modified On A Specific Day

In today’s article, we’re going to do exactly what the title says, we’re going to find files modified on a specific day. Imagine that! We’re doing what it says in the title! I dunno why I write the things I do. But, I do have quite a few people reading, and hardly any of ’em complain!

So, why would you want to do this? Well, let’s say Big Bad John logged into your system on Friday. He was fired for drinking at lunch, but still had access to the system for another hour before security got around to hauling his butt out of the building.

Wouldn’t you like to know what files were changed on his computer that day, just to see if he’d done anything malicious? You might also have some weird system errors and want to know what files have changed today so that you can narrow down your search for the culprit. There are all sorts of reasons why you might want to know how to find files modified on a specific day.

We’re going to be using a simple command, and just one command. We’ll be using the ‘find’ function. There are surely other ways to do this, but we’ll use the find command. It works and it means you have a relatively short article.

How To: Find Files Modified On A Specific Day:

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, let’s say you want to find files edited on the day this article is published. To do that, you’d run this command:

For the sake of simplicity, the format is YYYY-MM-DD. You could use other date formats that are recognized by the system, but we’ll just stick to this date format as it’s nice and easy.

Now, you can also adjust your ‘maxdepth‘ value. If it’s a 1, it will dig down one directory deep. So, if you’re in your home directory, it’ll dig into ~/Downloads, ~/Pictures, ~/Documents, etc… If you change it to 2, it’ll dig into the sub-directories, like ~/Downloads/foo and ~/Documents/bar.

If you want to find files modified on a specific day, simply change the date in the command and start searching. It’s handy if you edited a file and can’t recall which file it was you edited. The command can be used for all sorts of things like that. Good luck!

Closure:

There you go… You have another article and this one teaches you how to find files modified on a specific day. It’s a short article with just one command. There’s no reason to pad the article further. It’s just the one command. Thanks for reading!

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.

Today’s Article Is Just A Lubuntu (And Ubuntu) Membership Update

Today’s article is just going to be a short article about my Lubuntu (and by extension Ubuntu) membership status. It’s only a news/meta article and you can safely skip it. Or you can read on… I don’t mind… It’s just some news.

For starters, you can see when I first joined the Lubuntu team originally:

Meta: I’m Now An Official Lubuntu (And Ubuntu) Member!

What I do, more often than not, is do the live testing for the daily .iso. It’s tedious work, but I enjoy the challenge and have the time. You might want to read:

What it’s Like To Beta-test Linux, Specifically Lubuntu

Now, I do my testing with Lubuntu. I’m also an Ubuntu Member. This is because I have to be an Ubuntu Member to be a Lubuntu Member. If you’re an official member of some of the more recent flavors, that’s no longer true. You can be an official member without official Ubuntu membership.

Membership lasts a a year. My year was up and I submitted a renewal application. I was once again accepted as an official member. 

So, I’m an official Lubuntu (and Ubuntu) Member for another year. Yay!

I’d like to take a moment to invite others to join in helping out their favorite distro. You don’t have to dedicate all your time to it. You don’t  have to be a programmer. If you want, you can get involved – and make an appreciable difference.

So, thus ends this article. I need an easy day once in a while, and now you know my membership status has been renewed. Enjoy the easy day!

Add A Message Of the Day (MOTD) To SSH

In today’s article, we’re going to learn how to add a message of the day (MOTD)  to SSH. It won’t be a very long article, ’cause I can refer to some earlier articles. But, I’m sure someone will find it handy.

So, yeah… There have been a lot of SSH articles. I love SSH and it has a ton of features, so they get written about. Here’s a link to a list of previous SSH articles. If you have any SSH questions, you’re free to read those articles. They answer all sorts of SSH questions.

SSH stands for ‘secure shell’ and is a way to remotely manage computers. It’s a handy tool, one I think most users should learn. You can sometimes SSH into a broken computer and repair it. It’s pretty handy that way.

The astute among you might notice that this article is a little late. So, I lost internet connectivity and wrote and scheduled an article – or thought I did…

Normally, WordPress would hold that article in cache – but I wasn’t connected. I seem to recall noticing an error when I did hit the scheduling buttons, but it looked normal so I assumed it’d work. That means I’m writing this article right now, ’cause I don’t really want to break my streak of an article every other day. 

Which also explains why this one is just a short article.

Recently, I covered how to show an SSH banner. Well, this is pretty much the same thing. When someone logs into SSH, they’ll see the banner. When someone logs into SSH, they can also see the MOTD. I figure I’ll give you the option to pick which ever one you want.

Add A Message Of The Day (MOTD) To SSH:

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, we’re going to use nano to do some file editing. It’s really simple. First:

Add whatever text you want. You can generate a fancy ASCII logo and some text about who’s allowed to access the server and remind hackers (’cause they’ll surely listen) that unauthorized access is illegal. To save your MOTD with nano, just press CTRL + X, then Y, and then ENTER.

That’s actually mostly it. You shouldn’t have to edit the SSH configuration for this, it should just work when you restart the SSH service with:

SSH should pick it up automatically and now display your brand new SSH MOTD. It’s a ‘message of the day’ so you can change it regularly and SSH should pick up those changes automatically.

Depending, you might not even have to restart the SSH service. I’ve had it use the MOTD automatically, and I’ve had to restart the service to get it to show. You can have some fun and use things like this to generate some ASCII text. It’s your MOTD, do whatever you want with it!

Closure:

See? This was a nice and easy article. If you want to add an MOTD to SSH, you now know how to do so. Also, for the record, I’m getting pretty darned fast at writing articles. Well, some of them are pretty speedy to write. It helps if I don’t have to consult my notes that often. If I do, I often just put them on a different screen and that makes it easier to read them.

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.