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

View Some Logs In The Terminal

Today we’ll have a relatively simple set of commands that will show you how to view some system logs in the terminal. We’re only going to cover a few of them that are similar in operation. There are far more things that get logged.

You generate logs as you use your computer. These will vary and there are quite a few logs kept. Logs aren’t just kept by the system. Some third-party applications create logs. We’ll only be covering a few system logs. I just want to keep things simple.

The tool we’re using for this exercise is the cat command. The cat application is one tool that lets you read text files in the terminal. It’s a frequently used tool at my house. Hopefully, you too will get comfortable using this command at your house.

It seems like that should be enough of an intro. If you have any questions, you can always leave a comment. Those get seen and addressed more quickly than when you try to contact me elsewhere. (Comments almost instantly send a notification to whatever computer I’m using. They’ll even ping my phone if I turn the notification sound on.)

Anyhow… Ask away, should you have any questions…

View Some System Logs In The Terminal:

We’ll be viewing a few different types of logs. As mentioned above and in the heading, this is something we do in the terminal. You can usually open a terminal by pressing CTRL + ALT + T. If that doesn’t work, you’ll almost certainly find a terminal in your application menu.

First, we’ll view the kernel log.

The kernel is the actual “Linux” in your Linux. The kernel deals with task scheduling, and running processes as needed. It’s an abstraction between you and the hardware.

If you want to view the current kernel log, use this command:

If you want to view the previous session’s kernel logs, use this command:

Both of those commands will flood your terminal. That’s okay, you can use the pipe operator and the less command like so:

Next, we’ll view the boot log.

When you boot your computer, the computer keeps track of what happens during that process. This is known as the boot log. It can be exceptionally handy when you have a problem booting. 

If you want to check the current boot log, use this command:

If you want to check the previous boot log, check it with this command:

Again, you can use a pipe and the less command to manage the flow of data.

Next, we’ll view the system log.

The system logs all sorts of additional information. If you’re not finding the information you want in the previous two logs, checking the system log is prudent. The system logs all sorts of things that are useful for resolving problems.

If you want to check the current system log, use this command:

If you want to check the previous system log, run this command:

Don’t forget that you can use a pipe and less in this command. This will give you a slower output you can manage with your arrow keys.

And that will show you your system log.

That’s all it takes to view the major system logs. There are other logs and we’ll have to cover them at some point.

Closure:

Well, this didn’t take too many words or too much time… That’s nice. If you want to start troubleshooting your own problems, learn to read the system logs. If you don’t want to ask for help, learn to read the system logs. Well, that and learn to read the man pages, but that last bit is outside the scope of this article.

I do hope you enjoyed this article. They’re fun to write but it does sometimes feel like work. I never wanted this to feel like it was work, but here we are. It probably would have been wiser to not set such a schedule and to allow some vacation time in there. This whole project started when I had far more time due to the pandemic.

We do have a special day coming up… You’ll see!

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.

Short: Move A File To Multiple Directories

Today’s article should be a fairly short article, where I take the chance to show you how to move a file to multiple directories – at the same time. It’s a pretty simple process, albeit a bit weird. If you want to move files to multiple directories, this is the article for you!

I’ve done a lot of articles about file management. This is another one. We usually manage files in the terminal here on Linux Tips. We’ll be doing that again this time around. We’ll be managing files in the terminal!

The tool we’ll be using is the tee command. I covered that recently.

The task we’ll be doing is showing you how to move a file to multiple directories – at the same time and in the Linux terminal. It’s a pretty handy skill to have, though there’s some tee weirdness along the way.

Move A File To Multiple Directories:

You’ll need an open terminal for this, as the intro suggested. You can find a terminal application in your GUI file manager. You can often open your default terminal by pressing CTRL + ALT + T on your keyboard.

With your terminal open, let’s just run through some exercises to ensure we’re all on the same page and ready to move a file. 

First, let’s make a directory:

Next, let’s move to that directory:

Next, let’s make that file that we’ll copy to multiple directories:

I suppose we’ll need a few folders next, so let’s create them:

Now, let’s move the file foo to multiple directories:

The syntax is:

We throw the & in so that the tee command doesn’t hang, awaiting further input. You’ll get an extra message or two, but that’s fine and can be ignored.

Now, we can verify them:

The following command will show you that the file exists:

That should show the file, like so:

Now, you can check the other folders. 

And, of course:

Each of those should show you that the foo file exists in each directory.

Now, we can clean up after ourselves with this command:

Tada! Now there shouldn’t be any remains left behind and we’ve covered how to move a file to multiple directories at the same time and in the Linux terminal.

Pretty easy and pretty short!

Closure:

You never know when you’ll want to move a file to multiple directories but now you know how to do so. It isn’t a very difficult exercise, warranting only a short article. This seemed like good fodder for a short article and a handy tip to share with my readers.

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 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.

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.