Enable/Disable Your Network Interface

Today we’ll cover one way to enable or disable your network interface in the Linux terminal. We will cover enabling and disabling your network interface, so you might want to keep this in mind.

If you have multiple network interfaces, you might want to disable one of them. You might want to disable networking to keep a computer offline. There are many reasons why you’d want to enable or disable your networking.

This isn’t a very complicated process, so it won’t take too long.

The command we’ll be using, and we’ll be using it twice, is the ‘ip’ command.

The ‘ip’ Command:

If you’ve got a modern Linux desktop (or server), you’ve got access to the ‘ip’ command. It’s a relative newcomer in the space but it’s pretty universal at this point. 

That’s it. That’s the only tool (other than ‘sudo’) we’ll need for the job. You can verify that ‘ip’ is installed with this command:

The output should match:

If you check the man page, you’ll see why this is the correct tool for the job:

ip – show / manipulate routing, network devices, interfaces and tunnels

We’ll use the command with a couple of different ways to enable and disable your network interface. It’s not terribly complicated.

Enable/Disable Your Network Interface:

Yes, the ‘ip’ command is used in the terminal. That means you’ll need an open terminal. Just press CTRL + ALT + T and your default terminal should open.

With your terminal open, your first step is to identify the network interface:

That should look something like this:

show your network interface names
It should look something like that. That’s both a wired and wireless network interface.

With that information, the syntax to disable a network connection is simple.

For example:

If you’ve disabled the device, it’s just as easy to enable it. The syntax is:

An example would be:

See?  It’s pretty easy to enable or disable your network interface.

Closure:

If you need to enable or disable your network interface you now know how. That’s a handy thing to know as folks have inadvertently disabled their network interface. This enables it if you did. This also disables your network interface if you’d rather.

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.

Check Your NIC Speed In The Terminal

Today’s exercise is a nice and simple exercise where we check your NIC speed in the terminal. Anyone can do this, but it’s less useful for you if you don’t use a NIC and rely on wireless. If you’re using a wireless controller, this isn’t the article for you.

I’ll make this article short.

What is a NIC?

computer NIC
An example of what a NIC might look like.

NIC stands for Network Interface Card and is how you connect to a wired internet connection. They come in various speeds with gigabit being a fairly common speed these days. There are a number of reasons to use a wired connection, including security and maximum speeds.

The tool we’ll be using is ‘ethtool’. We will also use the ‘ip’ command. If you don’t have ethtool available immediately, you must install it. The ‘ip’ command works by default (unless your system is rather old).

ethtool:

As I said, if you don’t have ethtool you’ll need to install it. I just checked a couple of distros and it appears to be a fairly common application, installed by default. If you check the man page, you’ll see this:

ethtool – query or control network driver and hardware settings

So, if we want to check your NIC speed in the terminal this is a good tool for the job. We will use another command along the way…

ip:

There’s another command we’ll be using. This will be available by default in a modern system. This is, of course, the ‘ip’ command. We’ll just use the ip command to identify our NIC. If you check the man page, you’ll see this:

ip – show / manipulate routing, network devices, interfaces and tunnels

That’s exactly what we need to do! So, this is the correct tool for identifying your NIC. You used to be able to just assume that it was eth0 but those days are no more. Now it’s a longer string of characters.

Check Your NIC Speed:

As mentioned above, this is a terminal-based article. You’ll need an open terminal, of course. You can usually press CTRL + ALT + T and your default terminal will open. Try that before checking in your application menu. It’s not quite a standard but it’s pretty common.

With your terminal open, we first identify our NIC. In this case, we’ll use the following command to show our network devices:

From there, find your NIC’s name. It’s probably going to start with enp and then be followed by some letters and numbers. Mine is enp0s31f6 for example. 

You then take that information and use it with the ethtool command. This command requires elevated permissions, so we’ll be using sudo. The syntax is as follows:

Then, you’re looking for ‘Speed:’, which will tell you the currently connected speed. There’s additional information that will tell you things like supported speeds, but this section tells you the current speed. 

I suppose you could use grep for this…

Or, using my case as an example:

Which looks like this:

That’s it. That’s all you need to know for this article…

Closure:

Well, if you ever need to know your NIC’s speed you can refer back to this article. I don’t expect you’ll need to check your NIC speed often enough to commit this one to memory, though it is relatively short and easy. If you don’t remember it, you’ll know where to find it. There’s that…

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.

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn how to do that while using tools you have already installed. This won’t even be all that complicated.

If you use a wireless connection to connect to the internet, you may notice that it changes over time. It can fluctuate quite a bit, depending on the quality of your hardware. The reasons to monitor your wireless connection are thus pretty obvious.

The good news is that you won’t have to install any new software for this. If you’re using a desktop Linux, you’ll already have the tools available. You won’t even need to know the name of your wireless connection. All you’ll need to do is run a couple of simple commands.

The commands we will use are the cat command and the watch command. I’ve covered the cat command before, so regular readers will be familiar with the cat command already. Those of you who are not familiar should click the link.

The watch command is a bit different, but you won’t need to install anything to use it…

The watch command will run a command (like a cat command) periodically. Are you seeing where we’re going with this? It’s a pretty simple concept.

Monitor Your Wireless Connection:

Using the cat command means using the terminal. Just press CTRL + ALT + T and your default terminal should open. Otherwise, you should know how to do that already. (I have faith in you!)

With your terminal open, you can simply check on the state of your wireless connection with a trivial command. That command is just:

Next, you can use the watch command to run that command over and over again. That’s simple enough. The syntax is as follows:

If you want to run the command every five seconds, it looks like this:

That will run the command as expected, refreshing every five seconds. 

When you’re done monitoring your wireless connection, you can close the watch process by pressing CTRL + C. That closes all sorts of stuff in the terminal, so it’s a good idea to memorize it no matter what.

Closure:

It doesn’t take much to monitor your wireless connection. You have the tools already installed and you’re simply checking the text in a file every so often. There’s nothing to install. The tools are already there, you just need to know how to use them. 

Which is, I suppose, why I wrote this article… It’s a nice and easy article, fit for the weekend, and one where you don’t have to work all that hard to learn something interesting.

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.

How To: Clear the DNS Cache

Today’s article will be a nice and easy article where we learn how to clear the DNS cache as a simple exercise. This isn’t very difficult and won’t take too much time, so this article should be relatively short.

If you don’t know what DNS cache is, that’s fine. I’ll do my best to explain.

Chances are good that you do not need to clear your DNS cache. This isn’t something you’ll need to do all that often, maybe not ever. I only clear the DNS cache when I need to.

What is DNS?

DNS stands for Domain Name Service. When you type a domain name into your browser’s address bar, it relies on an IP address behind the scenes. DNS is the interface between those two.

You can think of DNS like a phone book, translating names to numbers.

While not important, a single IP address can host many websites. So, think of DNS as the phone book and nameservers are like the names of people who live in the same apartment complex.

As you browse, your computer tries to save you some time. It saves a cache of DNS hits. It saves a cache of domain names and their IP addresses. With a speedy connection, you won’t notice this as much today. However, it’s meant to speed up browsing when you revisit a site you’ve already visited.

Make sense? 

Let’s say you’re like me and have a website. For reasons, you decide to change your hosting company. You do so and update the nameservers. You now have a new IP address for your domain name, at least you will when the changes propagate.

Suddenly, you have an old IP address cached for that domain name. Because it is in the cache, your system won’t look that address up again. What do you do to get access to the site again?

Clear DNS Cache:

We’ll learn to clear the DNS cache in the terminal. In fact, I don’t know of a GUI way to do this for the system. (It’s possible to clear the DNS cache in Chrome via a GUI.) So, open a terminal. Many of you can just press CTRL + ALT + T and your default terminal will pop open.

With your terminal now open, enter one of the following commands to see the state of affairs regarding your DNS cache:

Or:

One of those two commands should work for you.

Here’s an example output:

Now, let’s clear that cache.

One of the following commands should work for you:

Or:

There won’t be any output from that command to confirm that the cache has been cleared. If you run the first command all over again, you should see something like this after you’ve run the command:

See? It’s pretty easy to clear the DNS cache!

Closure:

This is only something a few people will need to do. If you’re having issues visiting a site you recently were able to access without issue then this might be something you try. You can try to clear the DNS cache to see if it helps but there are a million and ten reasons why a site may suddenly be down and DNS is unlikely to be the issue unless you have a specific reason to expect this particular problem and solution.

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.

Hide The Output From wget

This won’t be a very complicated article and will only apply to those who want to hide the output from wget. It’s just a matter of a simple flag so that it won’t be a very long article.

You can download from the terminal. You can transfer files from the terminal. One of the tools for this is wget. There’s also curl, but this article won’t be complicated and will only apply to those who want to hide the output from wget.

This could probably be called a short, but it’s something I wanted to cover.

wget:

You probably won’t need to install wget. It’s one of those tools that you’ll find installed by default. It’s a pretty handy tool. You can verify that wget is an available application with this command:

The output should match this:

If you want to see why I’d cover such a small piece of wget, check the man page with the following command:

First, you’ll see the description of wget, which is this:

Wget – The non-interactive network downloader.

Now scroll down…

Keep scrolling…

And keep going…

There’s a whole lot to the wget command. It’s a very complicated command. If you’re a new Linux user, you will be overwhelmed by this man page. 

This is the sort of command that you can learn to use bit by bit. You don’t need to learn everything. You almost certainly don’t need everything. That doesn’t mean you can’t use it for useful tasks.

I often use the wget command. I use it not only with my Lubuntu testing but also with my regular activities. I’ll often find the URL for a file and then use wget to download the file. When I do that, it’s because I want to monitor the output.

Other times, I don’t want to monitor the output. So, for that, I use wget in quiet mode. That’s what this article is about.

Hide The Output From wget:

The wget application is an application used in the terminal. I believe there are download managers that are GUIs that use wget in the background. We’ll ignore those and use the terminal. So, press CTRL + ALT + T and let’s learn how to hide the output from wget.

The command you’re after is just the wget command with the -q flag. It would look something like this:

The thing is, this now means that you no longer see the progress. You can tell wget to keep trying until it performs as expected. That’s the ‘complete’ flag ( -c) and looks like this:

You can try this on your own with this command:

That’s a pretty small file, so it won’t take a lot of time. 

You won’t see any messages in your terminal, it will just download the file.

You can test this by running ls in your terminal after the fact. You’ll happily see that you’ve downloaded a file called ‘sort.txt’ and that it kept trying until it was completed.

So, now you know how to hide the output from wget…

Closure:

So, yeah, this probably could have been labeled a ‘short’ article, but I didn’t do so. I try to use that title for things that aren’t as involved, just a simple command in other words. This is pretty simple, but it’s also something you might use regularly.

The wget command is this hulking command with a bunch of options. Not even I fully understand all of the options and I’ve been using the application for years. There’s just a lot to it and that’s far more than we’ll ever cover and far more than most of you will ever use. Still, it can be a pretty handy command and you’ll see more of it in the future.

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.