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.

Count The Files In A Directory

I think I’ve covered this before with the ls command but this time we’ll count the files in a directory with the find command. This being Linux, you can usually count on there being multiple ways to accomplish something.

There are lots of tools out there that let you visualize disk usage. I’ve covered a bunch of them over the years. You can also count the files in a directory to see if there’s something abnormal going on. You may also have some sort of file limitations that mean you’re limited to a certain number of inodes and thus you need to react accordingly.

This is just one way to count the files in a directory. There are surely a variety of ways and we’re only going to cover counting the files with the ‘find’ command. 

In this case, you won’t need to install anything. The find command is a part of the GNU ‘findutils’ and will be included by default in any desktop (or server) you’ll interact with. You’ll also be using the wc command, again something we’ve used in the past, and that too will be installed by default because it is a part of the coreutils.

The find Command:

As I said, you won’t need to install anything to use the find command. You won’t need to install anything at all for this article. You can verify that you have the find command available with this command:

We’ll search for files (with the -type f flag) and then count them with the wc command. If you check the man page for find (with man find) you’ll see that find is a good tool for the job.

find – search for files in a directory hierarchy

We will pipe the output from the find command to the wc command to count files in a directory. You’ll see…

The wc Command:

The output from the find command would be a long list of files. Rather than view that list or anything like that, we’ll simply pipe that command to the wc command. You won’t need to install anything and you can verify that the wc command exists with this command:

You can tell right away that this is a fine tool for counting things. Just check the man page (with man wc) and you’ll see this:

wc – print newline, word, and byte counts for each file

So, you can tell right away that this is a great tool for counting things. In our case, we’ll be counting new lines because the output from the find command would be one file per line. See? It just makes sense!

Let’s get to it!

Count The Files In A Directory:

If the above information wasn’t much of a clue, this is something done in the terminal. Regular readers should be expecting this because we do a lot in the terminal. Open up a terminal (you can usually just CTRL + ALT + T) and we’ll get started.

The syntax is pretty simple…

You’re using the “-type f” flag. That outputs a new file on a new line. Try it with this command, if you’d like to see:

Then, pipe that to the wc command and use the -l flag. The -l flag counts lines, of course. So, each file is on a new line and the wc command counts those new lines instead of displaying them in the terminal.

I do have this in my notes…

If you were to run this against the root “ /” drive, you’d get permission errors. Try this command for example:

Well, you can redirect the output to /dev/null using 2>, like so:

I am not sure why that’s in my notes but it is. It strips out the permission-denied responses and that’s about it. You might want to see those so that you know what wasn’t necessarily counted. Of course, you can also run this command with elevated permission via sudo. So, don’t forget that.

Closure:

There you have it… If you want to count the files in a directory you can do that with the find and wc commands. That makes it relatively simple because you won’t need to install anything. This should just work for any Linux system you’re using. That makes it pretty universal and worth remembering.

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.

Get System Information With The ‘uname’ Command In Linux

Today we’ll be learning about a basic Linux command that’s known as ‘uname’ and it will be available in every Linux you are likely to touch. The uname command is one way to show some important system information in the Linux terminal.

You won’t even need to install anything. That’ll keep things easy and short!

The uname command stands for ‘Unix Name’ and is a part of ‘coreutils’, meaning it’s a default application included with Linux. If you’re using Linux, you almost certainly have the uname command available to you. I suppose someone might have stripped it out of an embedded system somewhere, but even that’s unlikely.

The uname command is used for displaying system information. It’s a bit limited in scope, but it still has useful information and the command is one you’ll see referenced often enough.

As I said, it’s a core utility in Linux. That means that uname is included with a bunch of other core utilities. If you want, you can easily check the man page with this command:

If you do that, you’ll see this:

uname – print system information

So, this command can and will show system information. That’d be what I told you it did in the first paragraph. I do my best to not steer you wrong and that’s exactly what we’ll do with this article.

So, let’s learn how to use the uname command in Linux:

Use The uname Command:

As mentioned above, you use the uname command in the terminal. That means you’ll need an open terminal. You can usually press CTRL + ALT + T to open your terminal. So, do that…

With your terminal open, you can just run uname in the terminal and it will tell you what sort of system you’re running. Try it…

It’ll happily spit out that you’re using Linux – if you are indeed using Linux.

It’ll also happily tell you the kernel name with the -s flag.

It should again spit out “Linux”, as that’s the kernel’s name.

If you want to know the kernel release information, use the -r flag.

Do you want to know if it’s 32 or 64-bit (or if it’s ARM? Try this command:

If you want to know the specific kernel version:

Then, you can learn the machine’s name with the -m flag.

You may just remember ‘mrs’ as that’s commonly  asked for in some support circles (and worth remembering):

There’s more to it but all you need to know is how to get all the information at once. That’s all you need to know. That’s just using the -a flag, like so:

You’ll get an output similar to this:

Which is quite a bit of system information and makes the uname command a useful command in and of itself. It’s an easy-to-remember command and one available in any Linux you’re likely to touch.

Closure:

I was a bit surprised that I’d never covered the uname command before. It’s a pretty basic command and so I’m surprised that I overlooked it. No worries. I’ve covered it now. There’s more to it but you’ll be fine with just the flags I mentioned.

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.

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.