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.

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.

hardinfo Has Been Rebooted As hardinfo2

If you’ve used hardinfo in the past, it may interest you to know that hardinfo has been rebooted as hardinfo2. This is just a quick ‘news’ article and won’t take up much of your time. It’s worth reading, however!

So, I wrote this some time ago:

Graphically Examine Hardware Info With HardInfo

I assume that’s how user ‘hwspeedy’ found this site and they sent me an email letting me know that hardinfo (no caps, I guess) has been rebooted as hardinfo2. That piqued my interest.

hardinfo2:

I looked and the project appears to have a dozen or so people behind it. That many people is a good start, which made me optimistic You can view the hardinfo2 project page here at the following link:

hardinfo Home Page

The original, hardinfo, hadn’t had any recent updates. These folks rebooted it. Their goal is to get hardinfo2 into all the distros and they’re 60% of the way there. I’m impressed enough to go ahead and write about it here.

The two major changes are the theme aspect, which I found silly and it made the text impossible to read on this system. Fortunately, you can turn it off. The second major change is the ability to upload your benchmarks. You can see how your system compares to others.

They have releases for pretty much every major version of Linux. See here:

Get hardinfo For Your System

I had hardinfo installed and hardinfo2 didn’t want to install. So, I purged hardinfo from my system with the following command:

I was then able to install hardinfo2. I did so with gdebi.

With the new version installed, I was quickly able to click on View > Themes > Disable Theme. That made it so that I could make out what was going on. Otherwise, it looked like this on a Linux Mint system:

Themes don't work well here...
None of the other themes fared better than this one did. You can disable them entirely.

This is just my refurbished PC that runs Linux Mint, so it’s nothing special. Even if it was, you wouldn’t know until you disabled themes.

Here it is with the themes disabled:

It's easy to disable themes in hardinfo2.
That’s much easier for these old eyes to make out. I’m pretty sure the themes don’t work well.

I went through the list and even did the benchmark thing. Things mostly seem to work. Some of the benchmarks didn’t show my level in the results, but that’s possibly just a teething issue.

This is useful if you need support – just click on Generate Report. You can generate a report to share with the forums when asking for support.

This is also useful for bragging rights – just click on Synchronize. You can see how you rank, and share it, against other users. As they’re now modern results, you probably won’t be dominating all the benchmarks as you did with the older hardinfo.

I have high hopes for these new developers. After I saw their email, I figured I’d share that information with you. I ignore most of that stuff but this is an application that I’ve used time and time again. It’s also an application that I’ve recommended. Seeing some people pick up and run with the task makes me happy. I wish them the best of luck.

I will point out that the sync button uploads a bunch of information. You can pick and choose what you upload; nothing nefarious is going on there. It’s simply a system-gathering (and benchmarking) tool and nothing more.

Closure:

Well, there’s not much more to cover. It still does the basic tasks as listed in the first article, it’s just now got some new features and is now being actively developed. It’s good to see some of the old tools being used and it’s good to see people acting when they see a lapse in the system. Without them, we’d not have much of an operating system.

So, thanks!

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 Number Of Running Processes Per User

This won’t be as complicated as it seems because we’re just going to cover how to count the number of running processes per user. This is a fairly basic task that requires fairly basic tools. If you want to count the number of running processes per user, read on! It’s quite simple…

Your Linux system requires many running processes. A running process is an application, though some applications can have multiple running processes. The Linux kernel manages processes and a full desktop system will require hundreds of processes to be complete.

Processes are on a per-user basis. As explained before, Linux is a true multi-user operating system. Each user will have their processes and all processes will be owned by a user. It’s a pretty basic concept once you get your head around it.

You won’t need to install anything for this article. We will use some basic tools to show you how to count the number of running processes per user. This isn’t an advanced operation and you’ll almost certainly have the correct tools installed.

What tools will you need for this article?

ps:

The first tool you’re going to use is the ‘ps’ application. Don’t worry, the application is installed by default. You can confirm this with this command:

Additionally, you can check the man page with this command:

If you do that, you’ll see that this is the correct tool for listing the running processes in your Linux system. It’s described like so:

ps – report a snapshot of the current processes.

See? That’d be the correct tool for listing the currently running processes.

We’ll also use…

wc:

This too will not require any additional software. It’s a near-certainty that the wc command is included in your Linux operating system by default. You can confirm that wc exists with this command:

When it comes to counting things, the wc command is the go-to command. You can tell this by checking the man page with this command:

As you’ll see, the wc command is described like so:

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

So, wc is the correct tool. We’ll use the -l flag (count lines) to go along with the wc command, meaning this should be something you can figure out already without me needing to write the rest of the article! Linux isn’t all that difficult to work with and the terminal doesn’t have to be a complicated affair.

Count The Number Of Running Processes Per User:

Both the ps and wc commands are terminal-based commands. That means you’ll need an open terminal to count the number of running processes per user. You can usually open a terminal by pressing CTRL + ALT + T. If that doesn’t work, open one from the application menu.

With your terminal open, you can show the number of running processes with the following command:

That’s the first part of this exercise. 

Next, we’ll use a pipe. We’ll pipe the output from that command to the wc command and tell the wc command to count the lines. That’s done like this:

That will give you a count of all the running processes which is nice but not the goal of this article. This article is meant to show you how to count the number of running processes per user.

So then, let’s show you how to show the processes owned by a user…

For example, I’d find processes owned by me with this command:

Now, to count the number of running processes per user you just go ahead and pipe it to the wc command used above, like so:

Again, an example:

That command should show you all the running processes that are owned by root. It’s a pretty easy set of commands to figure out and I’m sure you can figure it out from here…

Closure:

Well, we set out to learn how to count the number of running processes per user. I’d like to think we accomplished that goal. You never know when you’ll want to see the processes owned by a user, but it could be useful when debugging things – like finding out what’s eating up your resources.

This is one of those commands that are pretty obvious once you know about it. They’re two simple commands that combine to create a pretty good result. Linux is like that. You don’t always need to know some esoteric commands. You can often combine some basic commands to get the output you’re after. You can achieve much with just a few basic commands and it’s good to get more comfortable doing so.

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.