Make wget Use IPv4 or IPv6

Today’s article is a fun one, an article where you learn how to make wget use IPv4 or IPv6. Not only is this useful, it’s easy! In fact, it’s easy enough for most anyone to figure out. Plus, this will be a fairly short article – I think. I mean, I haven’t written it yet, but it seems like a short one.

I’ve done a couple wget articles, with the most recent showing you how to make wget ignore certificate errors. In fact, in that article I showed you how to enable that permanently. I’ll have to add that to this article. That’ll come in handy for like 0.01% of you.

If you don’t know, wget is a tool for downloading content from servers. These days, we use it to grab stuff from web servers without having to go through a browser – more often than not. Sometimes we use it to scrape entire sites without actually visiting them in a browser! (Sometimes, doing that makes you a dick.) It’s a handy tool for that sort of stuff.

Once in a while, while using wget, you’ll come across a finicky download that will throw an error about wanting IPv6 (or IPv4 if you’re using IPv6). That’s when this article is going to come in handy. Sometimes, a server isn’t configured for, or will refuse connections from, one or the other. That’s when you’ll see errors and that’s what we’ll resolve in this article.

Hmm… Do I need to explain wget more? Nah, y’all know what it is. IPv4 vs IPv6? Well, how about you check out this link to learn the difference and why it matters. That’s a good link. Alright, moving on…

Make wget use IPv4 or IPv6:

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. The wget command will throw an error, letting you know if you must use one or the other.

If you need to force IPv4, it’s nice and easy:

If you need to force IPv6, it’s also nice and easy:

If you find yourself doing this often, one way or the other, you can actually tell wget to do this on a permanent basis. Like in the previous wget article you can edit your .wgetrc file (create it if it doesn’t exist) to include either --prefer-family=IPv4 or --prefer-family=IPv6 and it’ll try one before trying the other if it’s available.

Closure:

See? Nice, neat, and simple. You’ve learned how to make wget use IPv4 or IPv6 – should you find yourself needing to do so. It’s a handy trick to have up your sleeve, ’cause you will eventually find a server that requires one or the other. Given enough use, it’s gonna happen.

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.

Disallow SSH Login For A Specific User

In today’s article, we’re going to learn how to disallow SSH login for a specific user. The reasons you might want to do this should be obvious, so that’ll save some time! Read on to learn how!

I’ve covered SSH in many articles. If you search for “SSH”, you’ll find a bunch of articles covering the subject. I’m not sure why there are so many, but there are. I seem to have a lot of notes on the subject. 

Here, this link will help you search for SSH articles.

SSH is “Secure Shell”, a method to login to remote computers so that you can manage them without being their physically. It’s used by systems administrators regularly, without ever needing a GUI to manage their Linux systems.

It’s also used by people like me, too lazy to walk to the other side of the room. I’m literally using SSH to manage stuff on my laptop from here on this desktop as I write this. On top of that, while not logged in right now, I was using SSH to manage a VPS earlier today.

So, SSH isn’t just for professional system administrators and, if you use SSH at home, you might as well know how to secure it. This article will help you secure your system – by learning how to disallow SSH login for a specific user.

Disallow SSH Login For A Specific User:

This article requires an open terminal on (and connection to) the computer you wish to change. That may require you to login to that computer remotely. If you’re on a local device and 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. Otherwise, SSH into it like a boss.

With your terminal/connection now open, enter the following command:

Find a place to make a new line and enter the following with some care:

Now, this one is a bit picky. Obviously, you substitute <username> with the real name – but in between “DenyUsers” and the username you absolutely MUST press the TAB key. If you try to just use spaces, it will not work! You MUST use the TAB key which will appear to insert spaces for you!

Assuming you’ve done everything correctly, you’ll need to restart SSH for the changes to take effect. You can do that with this command:

If you were logged into a remote system to make the changes on that system, the above command is gonna log you out and you’ll need to login again. You knew that, but I figure I’ll mention it.

Hmm… If you’re a barbarian that doesn’t use systemd, try this:

When SSH restarts, the prohibited user will get a “Permission Denied” message when they try to login. Ha! That’ll teach Jerry in accounting from thinking he’s a system admin!

Closure:

Whelp… You have another article. This one has shown you how to disable SSH login for a specific user (Jerry in accounting, who had no business accessing the server anyhow). You’re welcome!

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.

Use ‘apt’ To Download A Program And Its Dependencies

In this article, we’ll discuss a way to use ‘apt’ to download a program and its dependencies. The usual reason to do this is to install said program on an offline computer. We’ll be doing it all nice and neatly, just using the ‘apt’ application along the way. It won’t be all that difficult, but will be easy to link to and reference.

As I said, the usual reason to do this is because you have a computer that’s not online and you want to install some software on that computer. This could be a remedy for when you need wireless drivers in order to connect the device, or other sorts of situations. It’s a handy way to get those drivers up and running, so we might as well learn how to do so today.

We’ll be using ‘apt’ for this. We’ve used ‘apt’ for all sorts of software management tasks in the past. In fact, in the past this required a bit more effort. You’d use the ‘–download-only’ flag and get some files in your apt archives directory. Today, it’s just a quick task that outputs a handy file that is extremely portable.

In fact, this article really only needs one command, making ‘apt’ do its thing. It’s not all that difficult, either. By the way, if you don’t already know, ‘apt’ stands for Advanced Package Tool. Anyhow, I’ll still make it an article – as it’s a useful one to know and reference.

Download A Program And Its Dependencies:

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 emulator now open, you need to know the name of the program you want to download. For example, I tested this with ‘openjdk-17-jre’ and it worked as expected. (For the commands you’ll use, I’ll just use my traditional brackets.) Before I tested with openjdk, I made sure it had dependencies, and it did. To see if it had dependencies, I used this command:

Once you see that it has dependencies, you can go straight to downloading the program and its dependencies. You no longer need any long commands, it’s just (even if it doesn’t have dependencies):

All you have to do at that point is wait for the files to download. When they’re done downloading you can find the file in your ~/Downloads directory combined into a single compressed file. In my case, the filename was openjdk-17-jre.tar.gq and the download completed without error.

The process is the same if you have dependencies or not. The reason we pay attention to dependencies in this article is so that you know to check and make sure those dependencies are included, so that you’re able to install the software on your offline computer.

And, with all that said, now is a good time to verify that it contains all the files it should contain. Assuming the files are what you expected, with dependencies as needed, now is the time to sneakernet them to the offline computer, where you can install the program by first installing the dependencies before installing the program.

NOTES: It does build an ‘install.sh’ which should let you install the program and dependencies in one fell swoop, but it accessed the ‘net in my testing. So, just do ’em manually if you want to be sure, otherwise make it executable and give it a shot. This will only work if the versions are all compatible with the offline computer. If that’s not the case, you could end up in dependency hell or perhaps not able to install the program at all.

Closure:

And there you have it… You have yet another article! This one is handy if you want to install a program and its dependencies on an offline computer. It may also be handy if you want to establish a base-line and standardize on that specific version of the software. In that case, you’ll have a copy of what it once was. It’s something you can reference and restore as needed. But, yeah, it’s most likely to be used by people who want to install software on offline computer.

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.

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.