How To: Disable CPU Cores

This is not something everyone is interested in doing but you might as well learn how to disable CPU cores. This is something that’s easily done and easily reversed, so you might as well have an article on the subject.

Why would you do this? Well, maybe you have a low-power project and want to save energy. You may have more CPU horsepower than you need and you prioritize energy use. This might even be something you do to increase the battery life in your mobile devices. Maybe you want to lower the heat output from your CPUs.

There are valid reasons why you might want to disable CPU cores.

It’s just that this isn’t going to apply to most of you. I’d say that 99% of you aren’t going to want to disable your CPU cores.

What are cores? Well, you probably have one single CPU chip in your computer. That computer is then probably broken down into multiple cores. Each core looks like a single CPU to the hardware and operating system.

Of course, each core may also have multiple threads. Threads would also represent themselves as individual cores. If you disable a CPU core, you’ll also disable the threads on that core, if you use a multi-threaded CPU.

NOTE: Moden CPUs may have high-power and low-power CPUs. I have no clue which will be disabled if you follow this article. I don’t have a fancy CPU to test with. You can test and let us know the results! It’s easily reversed. You can add your cores back with no problems.

GRUB:

GRUB is the application we’ll be playing with. I should also mention that GRUB stands for Grand Unified Bootloader and is the default bootloader for most Linux distributions.

GRUB controls how your system boots and GRUB can also give you the option of which operating system to boot if you use a multi-boot system. It’s one of those things that you can modify pretty heavily. You can even modify your boot screen’s appearance when you’re using GRUB.

Trying to access the GRUB man page is interesting. It isn’t your traditional man page and isn’t accessed in the same way. If you want to check the man page, you use this command:

If you run that command you’ll see what looks like an index page. That’s because it is an index page. Use your arrow keys to navigate and use the enter button to open a category page. It’s pretty simple to navigate but there’s a whole lot of information there.

If you’re a newbie, you might just want to look and see that info page. Trying any of that out may result in a system you can’t boot. You have been warned. Tinkering blindly with GRUB will eventually break your system unless you know what you’re doing. Not even I understand everything – but that’s true about a lot of things.

This article assumes that you have GRUB and Nano installed.

So, now that you know what we’ll be using, let’s get into the article!

Disable CPU Cores:

If you didn’t figure it out from the ‘Nano’ mentioned above, this is one of those things you do in the terminal. More often than not, you can open a terminal by pressing CTRL + ALT + T on your keyboard. If that doesn’t work, look in your application menu to find your terminal and open it.

Next, you need to know how many CPUs you have. You should probably already have that information. If you don’t have that information, you can use something like ScreenFetch to find that information. (I used lscpu to find my information, but I’m trying to keep it simple for you.)

Just run this command (once you’ve installed ScreenFetch):

The output should tell you how many cores you have available. Like so:

screenfetch showing CPU cores
This should be easy enough for anyone to figure out! You can find this information easily.
The Exercise Itself:

Now that you know how many cores you have, you can modify GRUB.

Find the following line:

Change that line to something like this:

As you saw above, this system has 8 CPUs listed. Let’s say I wanted to cut that in half, perhaps to save battery life while I’m on a trip and not doing any computationally heavy tasks. I’d change that line to match this:

Now that you’ve made the edit, you need to save the file. As you’re using Nano for this, you save files by pressing CTRL + X, then Y, and then ENTER.

The next step is to update GRUB, telling GRUB to reconfigure itself because you’ve changed some of the information. This step is essential but simple.

Next, you reboot the system for the changes to take effect:

When you next open your system, run screenfetch again to confirm that you’re using fewer cores and that you’re using the number of cores you specified.

I did this in a virtual machine with 2 CPUs. This was done to confirm that it works and to provide you with some screenshots. When I did so, I did so with lscpu and not ScreenFetch. I hadn’t thought of ScreenFetch and I’d already taken the screenshots. So, that’s what you get.

The Results:

The original configuration:

using lsusb to show the number of CPU cores
As you can see, there are two cores in this instance. Core 0 and Core 1.

After the change:

using lscpu to show that there are now fewer cores loaded
Sure enough, there are now fewer cores in use than there were before. It’s just core 0.

As you can see from the screenshots (again, taken in a virtual machine), it’s easy enough to disable CPU cores in Linux. Well, assuming you’re using GRUB… I’m sure it’s possible with other bootloaders but I don’t have any real experience with them in the memorable past. I’ve used GRUB, more or less exclusively, for quite some time.

If you want to undo this change, or if you want to change the CPU cores to some other number, just remove or edit the added text. If you do that, be sure to run sudo update-grub again to ensure that your changes take effect. If you don’t remember to do that, any changes made will be lost. So, it’s important to update GRUB when you’ve changed any of the information – not just this information.

Closure:

Well, I’m not sure how many Linux users are going to want to change their CPU cores to a lower value. It was in my notes and seemed like a fine article to share with you. I can see doing this in a few instances, such as when you want to save power. Of course, modern operating systems are pretty good at saving power on their own, but it’s still something one might consider.

If you have any other reasons as to why one might want to disable CPU cores, leave a comment. I’m a bit curious. I’d probably do it if I needed longer battery life while on the road or something. I don’t do too many computationally heavy tasks these days. So, I could get away with it on some systems.

Also, this is from my notes. My notes predate the modern CPUs. Quite literally, I have no idea how this will work on systems that have cores that are different, such as high-power and low-power cores. Feel free to test and let me know what you learn. Again, leave a comment. I promise I won’t share your information with anyone and I’ll never send you an email you didn’t ask for.

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.

Seeing as you’re here, why not visit our friends at Blunix?

“Blunix GmbH offers Debian and Ubuntu focussed Linux Emergency Support 24/7, Project-based Linux Consulting, FOSS-based Managed Hosting on your company IaaS provider account as well as custom Training and Workshops. We prioritize fair business partnerships and employee quality of life over profit. We focus on reasonable security by default and encourage your employees and developers to keep things secure enough to avoid 99% of security issues with automated attack vectors. We focus exclusively on this and do partner with other companies to refer customers that do not fit exactly what we do, or where we require additional help (for example we have a security-focused company that we partner with for higher risk factor hosting setups).”

Click to visit Blunix GmbH

Another Way To Show Mounted Filesystems

We’ve covered this topic before, but I want to show you another way that you can show mounted filesystems. As previously covered, you have multiple filesystems mounted at any one time. So, let’s examine them, shall we?

If you use Linux, you use multiple filesystems. There are real and virtual filesystems created and used by the operating system. A real filesystem would be something like a partition on your storage device (one filesystem per partition, of course). A virtual filesystem would be things like your temporary files or cached files, among other filesystems used by the system.

We’ve covered this before and this is just another way to show your mounted filesystems. This is good information to have, as it’s handy to know the path for those things so that you don’t do something silly like misfire a dd command and hosing your OS partition. (Ask me how easy that is.)

Show Your Filesystem In The Linux Terminal
Another Way To View Attached Storage Devices
Another Way To View Attached Storage Devices

(And there are more! This is an oft-covered subject on Linux-Tips!)

So, what will we be using?

findmnt:

You shouldn’t need to install anything for this article. The findmnt tool should be installed by default. You can verify that findmnt is installed by running the following command:

The output of that command should probably match this one:

You check the man page with this command:

There’s additional information available in this application. Run this command:

But, if you check the man page, you’ll see that this is indeed one of the correct tools for the job. This being a basic task, there are many ways to show mounted filesystems. It’s up to you to pick a favorite – or find the most useful of commands for your particular situation.

Anyhow, the man page describes it as:

findmnt – find a filesystem

That’s what we want to do. That means that this is the correct tool for the job.

Show Mounted Filesystems:

You’ve been here long enough to know that we’re likely to use the terminal. If your hunch was that we would be using the terminal, your hunch was correct. You’ll find that findmnt is a terminal-based application so open your default terminal emulator by finding it in your application menu or pressing CTRL + ALT + T on your keyboard.

With your terminal open, you can show mounted filesystems with this command:

You’ll see that it even has a nice tree output. You’ll find things like Snaps have their own filesystem if you’re using a system that uses Snaps. Other jailed applications may also use their own filesystem as a way to keep things separate from the system as a whole. 

Here’s an example truncated output from Lubuntu:

That’s not nearly as complicated as it looks, once you get used to it.

Now, you can trim all that down. You can opt to show only the ‘real’ filesystems. That’s done with the --real flag.

This is an example of that command on that same Lubuntu system used above (Snap applications are seen as ‘real’ filesystems as a part of their separation from the system):

Here’s an example output from a Linux Mint system that does not use Snaps:

You can do more with the findmnt command, such as select the columns you want in your output, so be sure to check the man page. This is just a quick overview because the vast majority of you will never need more than just the basic command.

As I said, it’s a useful command for when you want to verify the path to a filesystem. Beyond that, the usage is up to you. That’s what I use it for when I don’t bother with any one of several other commands.

Closure:

You might see no reason to add this to your list of commands, but it is useful when you want to see all the mounted filesystems on your system. If you need the path for a filesystem, this is a good command. It’s also useful for finding out some attributes of your mounted filesystems.

This is one of those commands you really could keep in your back pocket. You might first lean on a command like lsblk but that only lists block devices – that is, storage devices, and doesn’t include the many other mounted filesystems. If you don’t need this command today, that’s fine. You might need this command in the future, and now you know it exists.

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.

Another Way To View Attached Storage Devices

Linux offers myriad ways to accomplish the same task, which is a good thing, and this is another way to view attached storage devices. This is a useful way to learn more about your storage devices and is a bit more advanced than others.

There are many ways to view attached storage devices. While not the same, you can learn which storage devices are attached to your system with any of the following articles:

Show Your Filesystem In The Linux Terminal
Show Mounted Partitions
How To: List Mounted Partitions
Yet Another Way To Check Filesystem Space Use

Stuff like that…

Well, you can also just plain old view attached storage devices in the Linux terminal. The application I’ll be showing you will do more than this, but we’ll concentrate on just showing attached storage devices.

The tool we’ll be using is known as:

lsscsi:

Yes, we’ll be making use of the lsscsi application for this article. This won’t take very long and you should find that lsscsi is available for pretty much every operating system out there. It does what you’d think, list SCSI devices.

Once installed, you could check the man page to see that this is the correct tool if your goal is to view attached storage devices. The man page describes the lsscsi application like this:

lsscsi – list SCSI devices (or hosts), list NVMe devices

It’s a simple application, at least for our needs. You’ll find that you can get some of the same information with the following command:

However, that command won’t give you things like the path. Mounted storage devices tend to have a path of something like /dev/<path>, and that information isn’t available with the cat command listed above. As we often want to know the path information, and there are many tools to do this, you might as well learn about lsscsi. 

By the way, your GUI disk manager (such as gnome-disks) will happily give you some of this information. It’s also a graphical environment, which may be easier for some folks. This is for those needing that information while using the terminal, or for those who are just interested in doing more in the terminal.

But, when it comes to disk and data management, you may need to know this information – especially the paths. So, this is a good command to have in your pocket. You never know when it will come in handy.

View Attached Storage Devices:

If you’re unfamiliar with the lsscsi application, it’s a terminal-based application. If you’re already familiar with the lsscsi application, I’m not sure why you’re still reading the article! Either way now is the time when you open a terminal. Oftentimes, you can open a terminal by just using your keyboard. Try pressing CTRL + ALT + T and your default terminal should open.

With your terminal now open, it’s time to install lsscsi. The directions to do so will depend on your package manager, but I’m going to cover most of them because this application is widely available and packaged for almost anything you can think of.

Installing lsscsi:

With your terminal open, use the correct command for your package manager:

Debian/Ubuntu/etc:

RHEL/CentOS/etc:

Gentoo:

OpenSUSE/SUSE/etc:

Arch/Manjaro/etc:

One of those should work for most of you. If not, let me know in the comments and I’ll amend the application. If they’re wrong, please do let me know in the comments. I did not test all of these. I’m going with a combination of my notes and what I’m able to scrape from the internet.

Using lsscsi:

With that open terminal, just enter the name of the command and you have about all the use you’ll really need from the application. The command is simply:

If you want, there’s more to the application – which you might need for some advanced operations. You can just check the man page with this command:

Here’s an example output:

Here’s another example output:

If you look at the bottom one, there’s a bit of an Easter Egg. You’ll see that it starts with an N and that means it’s an NVMe device. You don’t need any special tools beyond lsscsi to view NVMe devices, which is nice. The program happily recognizes it and other attached storage devices.

Closure:

You never know when you’re going to want to view attached storage devices. However, the odds are good that you’ll eventually want to know this information. It’s always good to verify the path of a dd command, for example. A malformed command can really cause you some problems.

So, now you know how to view attached storage devices – a task that has many solutions in Linux. There’s nothing wrong with variety and each of the various tools will have different strengths. Knowing what to use and when to use it is something you’ll learn as you make progress.

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.

Show USB Devices In A GUI In Lubuntu

Today’s article will be easy to follow and is for those who’d like to show USB devices in a GUI in Lubuntu. Though truth be told, this is applicable for other distros. I’ve just tested it on Lubuntu and Linux Mint.

I want to assume that all my readers are familiar with USB. There are all sorts of things that can use USB, which stands for Universal Serial Bus. You can plug in USB storage, fans, power devices, and (with USB C) even connect external monitors or graphics cards. The standard has existed since 1998 and the most recent version is USB4. It has come a long way.

Linux is pretty good at enumerating USB devices and can use many of the various USB-powered tools. It’s possible to show the USB devices in the terminal, of course. I just figured I’d cover a way to do so graphically. You never know who wants to show USB devices in a GUI, so why not cover it in an article?

I’ve covered ways to show USB devices before. I’ve done so multiple times, so it seems. Click one of the links below to view another article.

Show Your USB Devices In The Linux Terminal
A Little About The ‘lsusb’ Command.
How To: List USB Devices

As this article is for Lubuntu, I’ll give directions as though you’re using Lubuntu. This is going to work on any Debian/Ubuntu-based operating system. The tool we’ll be using is also available for Arch and, I assume, other package managers.

So, what will we be using?

usbview:

We’ll be using a small application known as usbview. This is available in your default repositories and is easy to install. I’ll cover the installation methods below.

If one were to check the man page, you’d see it’s the right tool for the job.

usbview – display information on USB devices

Further, you can see this on the man page:

No command line options are accepted by usbview.

So, usbview a graphical (GUI) tool. There are no options for the terminal – but you’ll need to start it from a terminal. For reasons beyond my knowledge, there’s no application menu added when you install usbview. That’s something to keep in mind. It’s a GUI tool – but you start it from the terminal. Got it? Good!

Show USB Devices In A GUI In Lubuntu:

As mentioned above, you’re going to need an open terminal. As you’re using Lubuntu, you can just press CTRL + ALT + T and your default terminal should open.

With your terminal open, you first install usbview…

That’s nice and simple.

Now, you can run usbview with this command:

Yes, you need elevated permissions. It throws an error otherwise.

You’ll get a new window that looks something like this:

using usbview to show usb devices
This is pretty self-explanatory, though I don’t have much plugged in.

You can not only view USB devices, you can learn more about them. There’s not much to configure and you can ignore all the buttons except the Quit button. You’ll want that to quit the application.

But, there you go… That’s how you show USB devices in a GUI in Lubuntu!

Closure:

Anyhow, now you’ve learned how to show USB devices in a GUI in Lubuntu. This is a good thing and something you can trivially apply to other distros. I’m sure there’s a way to build usbview if you don’t already have usbview in your repositories. If graphically viewing USB devices is your goal, usbview is a possible 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.

Seeing as you’re here, why not visit our friends at Blunix?

Here’s why you might just want to visit Blunix:

“Blunix GmbH offers Debian and Ubuntu focussed Linux Emergency Support 24/7, Project-based Linux Consulting, FOSS-based Managed Hosting on your company IaaS provider account as well as custom Training and Workshops. We prioritize fair business partnerships and employee quality of life over profit. We focus on reasonable security by default and encourage your employees and developers to keep things secure enough to avoid 99% of security issues with automated attack vectors. We focus exclusively on this and do partner with other companies to refer customers that do not fit exactly what we do, or where we require additional help (for example we have a security-focused company that we partner with for higher risk factor hosting setups).”

Click to visit Blunix GmbH

The du Command In Linux

There’s always time for a basic article or two and today we’ll do that as we just play around with the du command in Linux. This is a functional tool and one you can learn to use in just a few minutes. Because of that, I’ll try to keep the article reasonably short.

Storage…

On Linux, everything is a file. These files are stored with a system – such as a particular formatting method like Ext4. Collectively, this is your file system.

Because of this, you may have done similar things, you’ll find that file sizes are all divisible by four. That’s because of the way things are stored. They’re stored in blocks and 4KB is (generally speaking) the smallest block you can have. So, it only makes sense that things can be divided by four.

Running out of storage space is A BAD THING®. It can even prevent you from booting! You do not want to run out of space on your drives. You don’t want to run out of space on any of your partitions.

When you installed Linux, you should have taken care to ensure that the partitions will be large enough for you to grow into. It’s possible to add storage. You can even modify your system to move your ~/home directory onto a partition all its own.

It’s easier to ensure you have enough room when you start. Storage space is relatively inexpensive these days. You can get really fast storage (such as an NVMe M.2 SSD) for little money. If your motherboard doesn’t support NVMe, you can get a cheap PCIe riser card to add that feature.

We’ll be using the du command to see how much space you’ve used.

The du Command:

The du command is a terminal-based application. You shouldn’t need to install anything for this article, it should be installed by default. We’ve previously used this command to sort files by size if you’re curious.

Anyhow, you can ensure du is available with the following terminal command:

Which should give you an output like this:

If you get an output similar to that, you’re good to go and won’t need to install anything to finish this article. The man page can be accessed with the following terminal command:

The output from that command should be a good indicator that we’re using one of the correct tools for the job. This being Linux, there are many choices. In this case, the du command is described as:

As you can tell by the introductory paragraphs, that’s a good tool for the task we’ve set for ourselves today. We want to see how much file space we’re using.

Using The du Command In Linux:

If you read the above paragraphs you’d know that this is another one of those things you do in the Linux terminal. Yes, there are graphical tools that will let you do this – but this way is universal. You’re going to find the du command on any Linux system you’re likely to touch. So, press CTRL + ALT + T and we can get going.

With your terminal open, you can just start with the basics:

That will show you the bytes used by the directories. We want to see the storage space consumed by directories and files, so we’ll add the -a flag to the following command:

That should show file and directory sizes in bytes. That’s not very readable by a human unless you want to do some math in your head. So instead we’re going to add the -h flag. Like so:

That’s all well and good. You can use cd to navigate around your computer or you can specify the path. How do you do that? Well, the syntax follows:

So, if we want to view the storage consumption of the ~/Downloads directory we’d simply use the following command:

Now, if you just want to see the total value of the directory you can use the following command with the -s flag:

If you want to find out how much storage space is consumed by your entire ~/home/<user> directory, that’s a very simple command:

I’d not suggest using the du command to check the entire drive of a running system. It will want to also calculate anything plugged into the computer and take forever. There are other ways to view drive usage information.

If you want to use a GUI, here’s a few tools for you:

A Few Ways To Visualize Disk Usage In Linux

There are innumerable ways to do this in the terminal and I’ve covered many of them. Most recently, I showed you a way to use Python to view disk usage. I admit my bias, but that’s a neat way to give you some basic information in a handy format that’s easily understood.

This is one of those things you can do with a multitude of tools. It is also a fairly basic task and something we should all be aware of. Know how much free storage you have and act accordingly.

Don’t wait for the drives to fill up before acting because that just makes it harder on you. You know the adage about how an ounce of prevention is better than a pound of cure? Well, keep that in mind when you think about your storage solutions.

Closure:

Oh, I’m sure I’ve mentioned the du command before. It sounds like something I’ve written about. I do know that I used it so that you could sort files by size, which is nice. At least I’m pretty sure I did…

At this point, who knows? I could do a lot of searching just to check, but the search doesn’t always do a good job and it’s too late now because I’ve written the article!

As of today, you should be fairly fluent in the du command. You might want to read the man page. There’s quite a bit that I didn’t cover. I only covered the basics. More specifically, I only covered the ways I use the du command. You may have very different needs. You may have a very different process. With that in mind, read the man page.

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.