Show A Random Fortune When You Open Your Terminal

In today’s article, which should be a short one, we’re going to learn how to show a random fortune when you open your terminal. This should be pretty quick and easy, easy enough for anyone to follow. Read on, my delightful readers!

NOTE: You gotta be using bash for this, as evidenced by the use of ~/.bashrc.

Why this article? Well, I am having some connectivity issues and I want to ensure I get you a nice article while I have the connection to do so. I don’t want to count on enough time to write a longer article.

Besides, it’s another good day for a fun article. I am 99% confident that this article will teach you nothing of value! And that’s okay. It’s just you having fun – and having fun is always a good idea. So, this article will just be a bit more of that, some more fun…

First, you should read the previous article and follow the directions. That’s gonna be necessary for the next part. After all, you can’t get a random fortune when you open your terminal unless you’ve installed some software to do that. So, read this article:

How To: Display Your Fortune In The Terminal

Did you read that? Did you install ‘fortune’? Good… Now we can get into this article!

How To: Show A Random Fortune When You Open The Terminal:

Sorry about the ugly headline. Gotta optimize for Google, I guess.

This article requires an open terminal, like oh so many other articles on this site. Just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, we’re going to edit the ~/.bashrc file to make it show a fortune when you open the terminal. We’ll be using nano to do so, and that’s an easy enough process.

NOTE: You don’t need sudo for this, as you already own this file.

With nano opening your ~/.bashrc file for editing, you just need to scroll to the very bottom. When you get to the bottom of the file, just add the following line:

Next, you need to save the file. To save the file with nano, press CTRL + X, then Y, and then ENTER.

Now, you need to reload your bash profile. That looks like:

Now, that should reload the terminal and profile, showing you a ‘fortune’ quote. If you want to be really sure, or if doesn’t show you a fortune, just close your terminal and open it back up again. When you open your terminal again, it should definitely show you a fortune. See? Pretty easy! It’s darned near magical!

Closure:

And there you have it. You now know how to show a random fortune when you open your terminal. ‘Snot all that hard, now is it? If I’ve gotta bang out an article with intermittent connectivity, we might as well have fun with it! Thanks for reading and we’ll get some more serious content coming up – or will we?!? I should have decent connectivity soon. It can’t stay down forever, can 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.

How To: Display Your Fortune In The Terminal

Today’s article is just a silly article, one where you learn how to display your fortune in the terminal. It’ll be fun! It’ll also be quick and easy, probably. If you’re expecting anything serious, this is not the article for you. No… No, it is not!

Once in a while, we remember that all work and no play makes Jack a dull boy. Well, we don’t want to be a dull boy, so let’s do something that serves absolutely no benefit. Let’s just have unadulterated fun. It’s my site, I’ll do what I want!

To be fair, I’ve already cover this same topic. I shared how to use ‘cowsay’ with ‘fortune’. I suppose it’s cheating, but this time we’re just going to use the ‘fortune‘ aspect. Trust me, it’s a very different article.

Yes, it’s an excuse to have a quick and easy article. I had an easy article the last time and I still want an easy article. I don’t want to burnout and we’ve had more than 300 articles. So, an easy spell is nice. It’ll help prevent burnout. I’ll be over it in a day or two, I assume. (Note that I didn’t promise.)

Remember, a goal of the site is to be found by search. So, having a ‘fortune’ specific article isn’t a bad thing. Not everyone will want the silliness of ‘cowsay‘. (They not very fun people, but they’re people and they exist!)

So then, let’s just get going with the silliness…

Display Your Fortune In The Terminal:

Obviously, you need an open terminal! It’s right there in the title! 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, you need to install ‘fortune’. It’s probably available for those using apt and those using rpm based package managers. It may be available for others, but I have not checked. So, to install it:

On apt-based distros:

On rpm-based distros:

With ‘fortune’ happily installed, and feel free to try in other package managers – but leave a comment if they work, you can start with the basic ‘fortune’ command:

Now, as this is just a fun article, I’m actually going to cheat. I’m going to suggest you just use the man page to learn more:

See, this is why I wanted to cover ‘fortune’ by itself. There are a whole lot of options available for such a silly program. Of all of them, my favorite one is the -l flag. That one throws out longer fortunes, like this one:

See?!? The ‘fortune’ command is pure awesomeness! If you’re anything like a cat, or myself, you can bat at the fortune command (as though it was a balled up piece of paper) for way longer than what seems reasonable.

So, check that man page and have fun with ‘fortune’. For example, you can (with the default configuration – and you can do way more with ‘fortune’ than one might ever possibly wish) run one of the following commands:

So, have fun with it. I do! I revisit the command far more often than one might think a grown adult would. Even then, and my memory kinda sucks, I don’t think I’ve read them all. It’s a gift that keeps on giving.

Closure:

And there you have it… You can now display your fortune in the terminal. I mean, it’s probably not really your fortune – but that doesn’t mean you can’t have some fun with it. Life is short, but not too short to have some fun in the Linux terminal.

By the way, like the last article, this article was prompted by an recent article on a forum I frequent. Nobody mentioned the ‘fortune’ command, so I figured I’d return to it and try to give it some justice. It’s a fun application with way more  options than it needs – and that’s awesome.

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 Learn A Little About The ‘dir’ Command

In today’s article, we’re going to learn about the ‘dir’ command. The ‘dir’ and ‘ls’ command are quite similar, but ‘ls’ seems to get all the press. So, today we’ll be looking at the ‘dir’ command. It will be a relatively short article (I suppose) and easy enough for new people to follow.

You’re possibly already familiar with the ‘ls’ command. I’ve written a variety of articles about ‘ls’. We’ve used ‘ls’ in numerous articles along the way. Here are a couple of ‘ls’ articles:

Some Fun With Sorting The Output Of ‘ls’
Let’s Use ‘ls’ To Sort Files By Time

Those are just a couple. WordPress, the backbone of this site, isn’t very good at searching for just two characters like ‘ls’. That’s for good reason and I’m not sure if that behavior can be changed.

Ah well… Root around and I’m sure you’ll find more. I’ve written about 300 articles and can’t possibly remember them all!

Anyhow, we’ll be using the ‘dir’ command in this article. It describes itself pretty well in the man pages, and is similar to the ‘ls’ command. It describes itself as:

dir – list directory contents

So, if you’re familiar with the ‘ls’ command, you’ll find ‘dir’ to be quite similar. I’m sure there’s a reason that both exist – I’m just not sure what that reason is, nor am I sure why both are included by default. Feel free to let me know your thoughts or theories!

Edit: See this link to see why Linux contains both.

Well then, let’s get on with it…

The ‘dir’ Command:

Well, you shouldn’t need to install anything for this article, but you will need to have an open terminal. By now, you know how to open the terminal if you’re a regular reader, but others need only press CTRL + ALT + T and their default terminal should open.

With your terminal now open, let’s just start with the basics. If you just enter the ‘dir’ command it will output a list of all the visible files in that directory. It looks like:

You can also specify a directory, like:

If you want to show hidden files, you can try this:

If you want to list things in a single column, in a list format, you can just add the -l flag. This also shows the file’s permissions and modification time. So, you could try:

If you want to list files with the ‘dir’ command and to do so recursively (digging into the folders within folders), you can do that too. All you need is the -R flag. So, for example:

That’s just scratching the surface of the ‘dir’ command. There’s a whole lot more that you can do, so just try the man page for more nifty tricks  you can do with ‘dir’.

If you have any questions or nifty ‘dir’ information, please feel free to leave a comment. It’s a pretty handy command to have on hand, much like ‘ls’.

Closure:

And there you have it. You have yet another new article, this one about the ‘dir’ command. It’s not terribly complicated and it’s another tool to toss into your toolbox. You never know when you might want to use it instead of the ‘ls’ command, though they’re awfully similar.

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 The Boot Processes That Slow You Down

In today’s article, we’re going to show you how to find the boot processes that slow you down. What you do with this information is up to you. You can opt to tweak and try to speed up the boot process, or you can just learn to live with it. It shouldn’t be too long – or too hard.

Note: This article assumes you’re using systemd. If you’re not, get with the program!

With modern computers, even those a decade old, I don’t really understand the fascination with speeding up your boot process. This is especially true with Linux. After all, how often are you booting? People spend 3 hours improving the boot time by 3 seconds!

using uptime to show how long the system has been running
As you can see, I do not reboot all that often, pretty much only as needed.

Even if you reboot every day, unless your boot time is so slow that it’s indicative of a problem, you can always just press the power button as you walk by the computer to get your morning coffee.

This article is aimed towards those who have a slow boot problem. It’s aimed at you people who have slow boot times, boot processes that slow you down without good reason. People interested in optimizing their boot time can also benefit from this article, but that’s not the point.

Also, this article isn’t going to show you what to do next. This article will just be showing you how to find the boot processes that slow you down. The steps you take from there will vary based on your problems or your objectives.

Find The Boot Processes That Slow You Down:

Like oh so often, this is a trip down Terminal Lane. We do a lot in the terminal on Linux-Tips! It’s great to get new users to get comfortable with using the terminal. 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 can take a look at the boot process. To do so, let’s start with a basic command:

Picking one of the slower devices in my stable, you end up with an output similar to this picture:

output from systemd-analyze
That’s rather middle of the road, I would assume. You can get much faster and slower.

With that information, you can see how long it takes to reach ‘userspace’. For most folks, that’s going to be the number you’re interested in – as it’s when you can graphically interact with the system, usually to login to the system.

I should also mention that that’s not the total boot time. The computer has its own boot process. This time only includes what happens after POST, as the Linux operating system takes over. It doesn’t include how long you saw the original computer’s OEM logo/boot screens or anything like that. Your real-world boot time will be slightly longer.

So, let’s have some more details and see how that startup is actually working. Let’s see how long it takes for each step of the boot process. To do that, you’d want to look at the following command:

Yup, it’s a bit of clever naming. It’s systemd letting you know what process(es) to blame for a slow boot time. Pretty handy, huh?

If you want, you can even make a nifty picture of the boot process – a picture that includes showing  you the dependencies needed to complete the boot process. 

That’ll output an image that’s quite large, to large to bother including, but it’s easy enough to understand. If you’re having serious issues booting, that image might be something you can share with a forum when you’re asking for assistance.

What steps you take next will depend on your individual situation. If you’re looking to speed up your boot process, you can mask services that you don’t need. If you’re having problematic services and/or dependencies, your situation will be different and require different fixes.

Closure:

And there you have it! You have another article. This article tells you how to find boot processes that slow you down, so it’s an article that could be helpful to all sorts of people. Once you have this information, you can start looking to make changes. It’s a handy way to get boot process information with systemd.

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 And Remove Duplicate Files With rdfind

In today’s article, we’re going to find and remove duplicate files with rdfind. We’ll try to make this as safe as possible. I’d suggest newer  users not actually worry about duplicate files. Allocate enough space to your OS and don’t worry about it. Disk space is cheap these days.

Warning: Blindly removing duplicate files can be a risky operation. It can break things. You have been warned. Exercise caution!

If you’re interested in removing duplicate files, then the rdfind application is one solution you can try. There are others, but we’ll be using rdfind. We may cover other choices in the future.

You don’t have to run rdfind with it automatically deleting the duplicate files and that’s what I’m going to suggest you do – at least at first. It’s good to see what’ll be deleted before it is actually deleted.

If you check the rdfind man page, you’ll see it’s described as:

rdfind – finds duplicate files

It does what it says on the tin. It finds duplicate files. You can run the command in a manner that automatically removes the found duplicates, but that’s not something to take lightly.

Again, and I can’t stress this enough, some duplicates are there for a reason – they belong there. So, don’t run this on the root directory and expect a good outcome. Running this on the root directory and automatically removing duplicates is going to break stuff. Feel free to do so, ’cause it’s your computer. Just don’t blame me when it breaks.

There… I feel you’re safely and properly informed! Let’s get this article started…

Install rdfind:

We’ll just use the terminal to install rdfind. To open your default terminal emulator, press CTRL + ALT + T and your default terminal should open. You might as well leave it open, as rdfind also runs in the terminal and you’ll need an open terminal in the next step.

Debian/Ubuntu:
Arch/Derivatives:
RHEL/CentOS:
Fedora/Derivatives:

Now that you have installed rdfind, you should probably consult the man page. That’s an easy command:

With that knowledge fresh in your memory and rdfind installed, we can just jump into the article!

Find And Remove Duplicate Files With rdfind:

Your terminal should still be open from the previous step. If not, go ahead and open it now. You’ll need a terminal open to find and remove duplicate files with rdfind. It is not a graphical application.

So, I suppose you can start with this command:

That may look dangerous, but it’s not. If you run that command, it simply finds the duplicate files and then creates a text file for you. You then review the text file and manually remove the duplicate files. This is probably for the best. It’s also the same thing if you do a dry run, like so:

You can actually delete the files and replace the first one found with hard links. While not recommended by me, it’s at least safer.

Finally, you can just go right ahead and just find and remove duplicate files! This is safer if you have both a recent backup and you’ve gone ahead and run one of the first two commands. Then, if you have run one of those two rdfind commands, you’ll know what’s going to be deleted.

Just don’t run rdfind on your root directory, and probably don’t run it directly on your home directory, and you should be more or less okay. Feel free to run it on your Downloads folder, on your Documents folder, or even your Pictures folder.

Running rdfind that way, on those types of directories, will be fine and at least should not break things. Rdfind pretty good at finding just duplicates, or I’d not recommend it. Be sure to backup first and make sure you give it a dry run before you start automatically removing stuff! Seriously, do not run this on your root directory.

Closure:

And there you have it… You have yet another article! This time, we’ve learned how to find and remove duplicate files with rdfind. You were given a clear warning, but you’re gonna do what you’re gonna do. Man, I really need to write that article about backing up properly!

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.