Playing With Your Bash History

Your Linux computer, assuming it’s ‘normal’ will retain the commands you typed in the terminal and this is your Bash history. Like all things Linux, this is something you can control. The ability to customize these things is one of the things that makes Linux great!

More specifically, this article will cover how to change the Bash history size. That’s one of the things you can control. It’s one of the settings you can customize. You don’t have to accept the default Bash history size. It’s easy enough to change those settings to whatever you want.

I’m going to assume ‘normal’. That is, normal to me. I’m going to avoid the word ‘standard’ because I don’t know if these things that are normal to me are standards. For example, even the Bash shell isn’t a standard. However, it’s normal for a Linux distro to provide Bash – typically as the default shell. It’s not a standard, it’s just normal. That is, normal to me.

Got it?

Well, your Linux computer usually uses Bash shell. It also normally keeps a history of commands you type. This file is normally a hidden file, called .bash_history and is a plain text file. 

Bash has a control file. That is, Bash has various settings that can be configured. This file is also normally hidden. It’s usually called .bashrc. As this is about the shell and Bash, you will need an open terminal to follow along with this article. You can normally just press CTRL + ALT + T to open a terminal.

What is the Bash shell?

Bash is a Unix shell. It stands for Bourne Again Shell. It has long since been ported to Linux and is what you’ll normally find when you look into the more popular Linux distros.

A shell is a command line interpreter. It’s a user interface that lets you interact with your computer in a text-based manner. There are other shells besides Bash, but this article isn’t going to cover any of them.

This article presumes you’re using the default Bash shell. If you’re curious, here’s a big comparison of shells. Some people like to use different shells with csh and and zsh being popular choices. 

Bash is just one of many possible shells, but it’s normal to see Bash as the default. If you’re not using Bash, this article may not apply. You won’t see me writing much about other shells, as I’ve mostly just used the default shell rather than spending time exploring other options.

Bash History:

As mentioned above, you usually have a .bash_history and Bash usually stores the commands you’ve entered in that file. That file is plain text, meaning you can search it, edit it, or even modify it. I’ve written some about Bash’s history before.

Search For Command History By Date
Dealing With Duplicates In Your Bash History
Let’s Delete An Entry In Your Bash History
How To: Not Save A Command To Bash History

This shouldn’t be a foreign concept to my regular readers, though I’ve not written much about Bash recently. This seems like a fine time to cover this subject.

Today, we’re going to change the Bash History Size. There are three variables you’ll need to know. Well, you can get away with just knowing two of them, but we’ll learn all three.

Bash History Variables:

As I said, there are three variables we’ll be using to control the size of your Bash history. They’re all pretty simple and they all control one aspect of the Bash history.

HISTFILE:

The first variable is ‘HISTFILE’ and you can echo this to get the information. The file is normally located at ~/.bash_history but you could change that value and have the history file anywhere you want. You can find the Bash history location with this command:

The output would look similar to this:

HISTFILESIZE:

The next variable we’ll concern ourselves with is ‘HISTFILESIZE’. This is how long, specifically how many lines, will be saved in the .bash_history file. You can your current configuration with this command:

Again, the output from that command might look similar to this:

That means the .bash_history file can be up to 2000 lines. That’s quite a bit, but not far from normal. I think I’ve messed about with it before, so I’m not sure if that’s the default. Just echo the variable to find your current settings.

HISTSIZE:

The next variable is going to be  HISTSIZE which is how many lines your shell should retain in memory. If the HISTSIZE is set to 20, you’ll have 20 lines of history to scroll back to visit. You can get the HISTSIZE settings with this command:

An example output might look like this:

NOTE: This can sort of be overridden by your terminal client. If you have a $HISTSIZE of 1000 and your terminal preferences (some terminal emulator clients have this setting) are set to 500, you’ll only have 500 lines kept in the cache at any one time. However, the number of cached commands is still 1000 – but your terminal will not show them.

We can change these variables!

Change Your Bash History Size:

Now that you know the default size settings for your Bash history, you can go ahead and learn how to change the settings for your Bash history. While it’s possible to change the location of your .bash_history file, there’s no need to.

We’ll worry about our Bash history size, that is how many lines the history file will hold. Anything else is superfluous so we’ll skip it.

The first variable you might want to change is the total number of lines that will be stored in your history file. That’s done like so:

If you want your Bash history to hold 5000 lines, the command would look like the following command:

That won’t take effect immediately. You’d have to reboot or close all the terminals before opening a new terminal for the new settings (reloading what is normally called .bashrc) to take effect. However, you can force the issue with the following command:

If you want to change the value for the maximum number of cached commands a shell can retain in any one setting, you can use the following command:

If you wanted to match the HISTSIZE with the new HISTFILESIZE, that’s easy enough to do. Just enter the following command to change the value for HISTSIZE:

Just like before, you’ll have to tell Bash to reload your settings because they’ve changed. Rather than close things, log out, or reboot, just enter the following command for the HISTSIZE change to take effect immediately:

Note that none of these commands require sudo. If you are having to use elevated permissions, you’re doing it wrong. Well,  you could be modifying the settings for another user but that’d take direct editing of the .bashrc file and you’re better off modifying that file when logged in as the user.

Closure:

Well, that was a pain in the butt to write and format. I hope that it’s not too confusing. I kept typing the variables wrong and this article about changing your Bash history settings required quite a bit of advanced formatting. That takes time, which means this article took time. Still, I wanted to cover the Bash history configuration choices and I wanted to do them all in a single article.

This article is much longer than my normal articles. I dare say that I’ve changed my writing style – again. I’ve been doing longer format articles. Previously, I’d have only covered the $HISTFILESIZE variable and left it at that, without adding many links or much additional information. I do welcome feedback and suggestions.

If you don’t like the longer format, say so. If you do like the longer format, say so. Hell, if you read the closure section say so! I don’t know if I’ll change much based on the feedback, but it’s good to know. Lately, I’ve been pulling down quite a bit more traffic, so something must be working. I’m no SEO expert, so I do what I can and follow directions from people who have had more success. But, the site is coming along nicely.

Amusingly, I’ve had almost no emails on the advertising subject since I added the Sponsorship link. I should mention that it’s possible to sponsor an article even if you’re not a business. I’d just put in a ‘thank you’ notice and link to pretty much anything you want if you did indeed want a link. This site has a solid reputation, but it’s still growing – and growing pretty quickly as of late.

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.

Monitor Progress With RSYNC

When you’re moving a lot of files around you might want to know the progress, so here’s how you monitor progress with rsync. This will likely be an intentionally short article, an easy article, as it’s another weekend article – this time about rsync and how you can monitor the progress.

The rsync application is a tool for transferring and synchronizing files between two places. It’s a very handy application and rsync has a whole lot of features. It’s possible to write a half-dozen rsync articles and not even scratch the surface. We’ve had rsync available since the mid-90s and you can visit the rsync project page.

You’ll almost certainly not need to install anything to use rsync. It’s pretty much available with every distro though I’ll mention ahead of time that this is a terminal-based application. By the way, if you’re not happy with your terminal, you can change to a new default terminal easily enough.

There are frontends for rsync, such as luckyBackup, but we’ll just be using a plain old terminal for this article. If you play with luckyBackup, you’ll discover that you can use it to spit out the actual rsync command you’ve configured and use it in the terminal without any additional overhead.

RSYNC:

If it’s not obvious, the tool we’ll be using is rsync. Specifically, we’re going to monitor the progress as rsync synchronizes your data from one place to another. It’s going to be a very easy article, I promise. Well, I think it’s easy. I suppose I could be wrong and you find it more difficult.

You shouldn’t need to install anything to follow along. You can first verify that you have rsync installed and available. Use this command:

If you don’t have rsync available immediately, I’m sure you can install it from one of your default repositories. If it’s not installed by default, let me know. I’m curious…

Anyhow, you can check the man page (with man rsync) to learn more about this application. It’s a rather long and complicated man page, but rsync is described as:

rsync – a fast, versatile, remote (and local) file-copying tool

And that’s what we want to do. We want to monitor the progress of file transfers. So, that’s what we’re going to do.

Except, I’m also going to show you how to make a simple backup of your data as a bit of bonus information. Let’s get on with it!

Monitor Progress With RSYNC:

Now, I did tell you that you’ll need an open terminal for this. That’s easily done. More often than not, you can open your default terminal by pressing CTRL + ALT + T. Otherwise, you can find it in your application menu.

With your terminal now open, your standard command would be something like this following rsync command:

To monitor progress with rsync, you’d add the --progress flag, like so:

That’s all well and good, but let’s pretend you want to make a backup of your home directory with rsync and that you want to monitor the progress. Well, you can happily use rsync with directories. This is going to be pretty easy!

The -r flag means ‘recursive’. That means it will include the files in the directory you specified, find the additional directories within that directory, and include those files. It will keep digging until there are no more directories unless you decide to specify a maximum depth.

Let’s further assume you have a USB device plugged in and you want to store your home directory on that USB. Let’s also assume that the USB’s called ‘backup’. The command for that would just be something very close to this command:

That might look something like this:

showing the progress of rsync
As you see, it’s easy to monitor the progress of rsync. Yes, that’s Windows ME. Don’t judge me!

That command will move all the files from your home directory (as we know that ~/ is a short way to say your /home/user directory) to your USB device. You’ll have then backed up your personal data. The second time you run it, it will sync those files – only replacing those files that have changed since the last time you ran the command.

You can easily use that command (modified for your needs, of course) to make a backup of your home directory. This is the most important data on your system. The rest is just system files and those are easily restored with a fresh installation.

While it would be possible to use rsync to backup the entire drive, it’d try to do stupid things like backup the /media directory. You’d need an advanced command for that and that’s beyond the scope of this article.

As it stands, the backup bit is extra. This article is just about how you can monitor the progress with rsync. It’s a pretty trivial thing, but something you can learn about quickly.

Closure:

Yeah, it’s a pretty short and easy article. At least I hope it’s easy. I did make a promise, after all! This one should be easy enough for anyone because it’s not all that hard to learn how to monitor progress with rsync. Also, with a reasonably large file, you can do things like check transfer rates, be it over a network or from one drive to another. There’s all sorts of fun!

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.

Restoring Google Search To Chromium When Installed In Linux Mint

Well, that’s a long headline, but it’s not easy to compress the idea of restoring Google Search to Chromium when installed in Linux Mint! However, this is another article that is just me scratching my own itch. You’ll understand what I mean soon enough, I hope. I mean, I think I can describe it well enough.

Also, I’m using a new keyboard. I wore the last one out. That always slows me down for a little while. Ah well… I digress, and needlessly so…

So, let’s say you’ve done a fresh install of Linux Mint. Let’s also say that you decided you want to use Chromium. Fortunately, Chromium is in the default Linux Mint repositories. Given the ease of this operation, you go ahead and install Chromium in Linux Mint with the following command:

Everything appears well and good – until such a time as you decide you want to search from the search bar. At that point, you’ll notice that Chromium in Linux Mint uses a different search engine. This should be easy to change (and it is) but when you look in the settings you’ll see that Google Search is nowhere to be found.

There’s a resolution for this! We won’t even need the terminal.

I’ll presuppose that you’ve already installed Chromium, so we’ll skip that part. You can figure that out if you haven’t already figured that out and are now curious about adding Google Search.

Restoring Google Search To Chromium:

First, you will want to open Chromium, click the three vertical dots in the upper right, and select ‘Settings’.

From there, you look to the left to find the ‘Search engine’ option and click on that. Chances are good that you already tried this, assuming you’ve wanted to restore Google Search to Chromium.

You next click on ‘Manage search engines and site search’, which is where we want to be to edit search engines in Chromium.

Scroll down to ‘Site Search’ and click on ‘Add’, like so:

adding google search to chromium in linux mint
See? It’s a pretty basic concept. The rest is also easy. We can restore Google Search!

That’s going to pop up a new window that looks like this:

adding a new search engine in chromium
There aren’t many fields to be filled out – and Google isn’t your only option.

Under ‘Search engine’, add: Google 
Under ‘Shortcut’, add: google 
Under ‘URL’ add: https://www.google.com/search?q=%s 

Note, that the %s is where your search terms would go in the website’s URL. If you wanted to add Ecosia, for example, you’d use this in the last section:

Be sure to click the ‘Add’ button when you’re done.

By the way, the ‘Shortcut’ is the text you’d type to manually pick that search engine. You start your address bar query with the shortcut text, add a space, and then add your search terms. That will let you pick among the various search engines manually. In the above example, you’d first type ‘google’ and that’d give you results from Google Search.

Of course, you can just make Google Search the default…

Make The New Search The Default Search:

If you want, you can make the newly added search engine the default search engine. That’s what I did, but it’s entirely up to you. You could always just preface the search with the word/letter you put in the 2nd second and manually select your search engine.

To make the newly added search the default search, simply click the three verticle dots next to the new entry and set it as the default. Like so:

Make the newly added search engine the default search engine.
  Tada! It’s default!

That’s all there is to it. You’ve now made the newly added search the default search. When you search from the address bar, it will use your default search engine. If you highlight and right-click to search, it will now use your new default search engine.

Notes:

I mentioned Ecosia and gave an example. It’s pretty easy to find the right URL. Go to the search engine (or site search engine) and enter ‘example’ into the search bar.

If you did that here on Linux-Tips, you’d get this:

To add this site as a search engine, you’d replace ‘example’ with %s. Like so:

If you wanted to add Bing, you’d do the same thing:

Verify that you can remove the gibberish:

(And you can…)

So, the result needed to add Bing as a search engine would be:

 You can generally do this with any sites you want – so long as they’re reasonably accessed and have the search term included in the address bar. If you wanted to search Linux.org from the search bar, you’d use:

Yes, that will work and it will still properly filter the results according to date. It’s pretty easy. As I mentioned, I’m mostly scratching my own itch with this article. This was a change I needed to make and I thought it’d make a good article. I’ve decided to make it more thorough, showing you that you can do more than just restore Google Search to Chromium.

This will also work with browsers based on Chromium. If you are using Brave, Vivaldi, Edge, Chrome, etc., then you can almost certainly manage your search engines just like this. I tend to have a few search engines configured but I mostly rely on Google Search as it seems to consistently work best for me. You do you, however.

Closure:

Well, there you go. It’s pretty easy to learn about restoring Google Search to Chromium when installed in Linux Mint! (That’s such a long headline…) The concept is easier than trying to make a concise headline out of it. I dare say this is the longest headline I’ve ever had. Search engines are not going to like it. Hopefully, the content makes up for that!

If you’re still reading this far, you might as well know that Google uses a different address in their search settings. It’s a convoluted thing and I hope I get this right…

However, you don’t need all that. You’re fine (as far as I can tell) with the basic option I gave above. But, I figured I’d include this just for the sake of completeness. Good luck restoring Google Search in Chromium when installed in Linux Mint! It’s not that challenging and I’m sure you can figure it 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 site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Meta: The State Of Linux-Tips #21

It seems like now is a good time to write another article about the site itself, because I’ve not done a meta article in over two months. Yeah, it has been that long since I last did a check-in to let folks know how things are going. Every time I’ve thought about writing a meta article, I’ve decided to write something else.

The thing is, there’s not much to write about. Things are going very, very well. At least I think things are going well. It’s quite amazing how far this site has come and I have you, the regular readers, to thank for that. I have you, those who have contributed, to thank for that.

When you point out a problem in an article, you make the site better. If you choose to comment, it provides motivation. Those who voice their appreciation give me the confidence to continue. Without you, I’d have long since run out of any shred of desire to write.

Thank you! Really, thank you!

So, what do I mean when I say that things are going well?

Some Numbers:

In November, more than 17,500 unique visitors visited the site and did so more than 26,000 times.

I remember when I was stoked to see 20 visits in a day.

Once upon a time, I didn’t have to pay extra for bandwidth. In November, this site went through nearly 70 GB of traffic. LOL If you want to donate, that’s where your donations go – into paying the CDN. Fortunately, the bills aren’t that high.

Advanced Web Statistics claimed that I showed about 1,300,000 pages – but that seems unrealistic. I’m pretty sure that’s counting bots. Bots account for a bunch of my bandwidth, but the stats I share with you do their best to only include real human visitors.

This will be article #482.

I’ve not missed a day yet, though I remain convinced that I will – and I’m okay with that. So far, I’ve just been lucky. Eventually, Mother Nature and my infrastructure will cause me to miss an article. So far, there has been at least one article every other day. That was the schedule I decided upon when I started the site. That is the schedule I’ve followed.

Sponsorship:

I get so many requests to link to this or that. People constantly request that I allow them to write a ‘guest’ article. They do this because they want a link on my site and that helps with their SEO (Search Engine Optimization) goals.

If you look at the top of the page, you’ll see a new link up there. Those are the rules and fees for me sharing an article or a link. I have intentionally priced them high. I mostly formalized this so that I can just respond to those emails with a link.

Man… So many SEO link requests… Most of them don’t even seem to know what the site is about. It’s like they just shotgun requests and hope for desperate blog authors. I am not desperate.

If you want to legitimately write an article that’s not to promote your site, feel free to do so. I’ll happily accept those. If you’re not doing it for SEO reasons, that’s fine by me.

Speaking of SEO, I’ve paid some attention to it lately. I’ve been learning more about SEO and trying new things. The site ranks pretty well for some keywords and phrases.

Search Engines:

I’m finally listed in Bing.

Bing sends me maybe 1% of my traffic…

I get traffic from all the major search engines – and some of the not-so-major search engines. Like, I get a few people from Ecosia. Weirdly, Duck Duck Go sends me the second-most amount of search engine traffic. The first is Google, of course. Bing and Yandex are respectively next, after “Unknown Search Engine”. That’s followed mostly by the regional Google instances, such as google.uk or google.de.

As mentioned above, I’ve done some on-site SEO work. They care about things like links, readability, load time, and stuff like that. This site ranks well in all those categories, as a general rule.

If you search for “ask a good support question”, you’ll likely find this site at the top of the list. Sadly, the people who most need that information will never search for that information. I’d call it irony, but it really isn’t ironic. It’s just a statement of the human condition, I suppose.

The site also ranks well for terms like ‘screenfetch vs neofetch‘, ‘Prevent SSH Root Login‘, ‘ls -l format‘, ‘restart teamviewer‘, and ‘sudo apt purge‘.

It’s a weird assortment. I have a hard time knowing what articles will be the most appreciated by Google. They tell me that I should know that before I even start writing an article, but I don’t worry about it.

Also, writing these meta articles takes more time and effort than writing regular articles. Search engines don’t even like these articles!

What Can You Do?

You can keep reading and keep commenting – even if nobody ever comments here. 99% of the comments here have got to be spam. I’m not kidding. I’ll get a dozen spam attempts a day – and that’s AFTER automatic filtering.

Bots can’t easily spam the site, so these are real humans wasting their time. I can’t imagine being so poor that I’d undergo a task with so little chance of success. I sort of feel sorry for these people, but not enough to let them spam the site.

You can donate of course. As I said, all the donations go straight to paying for bandwidth. You don’t have to. I’ve long since concluded that I’ll pay the bills regardless of how high they go. The site is not currently at risk of going under. Still, it’s an option.

You can unblock ads. I appreciate it if you do, but I understand if you do not. If you do unblock the ads, please only click on ads that you’re legitimately interested in. Clicking a bunch of ads is a nice gesture, but that makes Google angry. I do not like it when Google is angry! Google has been angry before. 

Closure:

Like I said, these meta articles take me longer to write than it takes me to write the average article. They’re kind of a pain in the butt and I almost regret doing the first few as that now makes me feel obligated to keep doing them. They may disappear entirely, but I’ll keep going for now.

The first few were easy, as I didn’t have much to say. Now, I have hundreds of facts and figures that I could share, but I’m not going to invest the time and effort to do so. If you have any questions about this sort of stuff, feel free to ask me. I just don’t want to invest that much time and effort into some article that’s going to be read by maybe 50 interested parties.

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.

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