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.

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.

Let’s Learn About The htop System Monitor

There are any number of tools out there to monitor your system and today we’ll cover the ‘htop’ system monitor. This htop application is a pretty solid application and one that you might want to be familiar with. So, let’s learn about htop…

First, your Linux desktop comes with a system monitor called ‘top‘. This is true for so many distros that we might as well accept it as fact. The top application has been around 40 years at the time of this writing and it stands for ‘Table Of Processes’.

The top application is a task manager and system monitor, allowing you to manage processes while also monitoring system resources. You can learn a lot from top, such as uptime, RAM use, CPU use, the number of running processes, and so much more…

top:

If you want,  you can open top with the following command:

(You can just press Q to exit top.)

The output should look a little like this:

An example of top running in the terminal.
This is the top application, which you may already be familiar with…

The man page describes the top application as:

top – display Linux processes

The man page for the top command will also explain that you can do the following with it, which you may find interesting.

As you can see, top is pretty versatile. 

So then, what is htop?

htop:

The name is htop simply because the author’s name is Hisham. It is otherwise similar to the top application but comes with some great benefits. Another great benefit is that htop is going to almost certainly be available for your distro. Some distros have started installing htop by default.

Why htop instead of top?

Well, for starters the layout is much nicer. You can also use your mouse to control htop. This includes scrolling, making it easy to navigate. You can kill processes like this, change their nice value, and more. Additionally, you can even kill multiple processes at the same time.

You can filter and search easily with htop, meaning you can narrow down the results and keep it easier to read. On top of that, htop has a cascading tree layout for the processes. 

I’m told that htop is quicker due in part to how it gathers the information but I have no way to verify this. Both applications seem reasonably quick to me, but that’s what they tell me. I believe this has something to do with being ncurses-based. 

You’ll also click the setup option and configure htop to your needs. It has a nice colorful layout that is quite intuitive. Filtering is also easy, as is searching. Those both come in handy when you want to kill some processes all at once.

If you’re curious, htop looks like this:

running htop in the Linux terminal
It’s more colorful and easier to navigate with a mouse – but you don’t need a mouse to control it.

There are times when you can’t access your GUI system monitor to clear out frozen processes or things like that. So, you should get used to either top or htop. I think you’ll find htop is more featureful and useful in modern times. Even if you can’t use a mouse at the time (say you’re in a TTY), htop is still easy to operate, which is nice.

Install htop:

As I mentioned above, some distros (like Ubuntu) now include htop by default. There are older versions of Ubuntu out there that are still supported, so I’ll include htop installation instructions for them. Then again, they’d be the same instructions used by Debian, so it wouldn’t be that hard to figure out.

For simplicity’s sake, let’s install htop with the terminal. That’s a fairly universal thing. Most of the time, you can open your terminal by pressing CTRL + ALT + T. Otherwise, you’ll find a terminal option in your application menu.

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

Debian/Ubuntu/etc:

SUSE/OpenSUSE/etc:

Fedora/etc:

Rocky/Alma/etc:

Arch/Manjaro/etc:

One of those should work for you.

The syntax to use htop is just this:

There aren’t a bunch of flags to worry about, but it’s worth checking the man page:

If you’re going to learn anything from the man page, you might want to learn the keyboard shortcuts for when you do need to use htop without a mouse. There are many, but learning the basics will take you ten minutes. I’d call that ten minutes that were properly invested because htop is a great application.

There you have it.

You should now have htop installed and know how to run the application. I think you’ll like it more than you liked top. I know I do. It’s definitely what I prefer of the two – but it’s not the only option.

Closure:

I’ve wanted to write this article for a while but just didn’t want the hassle of writing it. I finally had both time and motivation, so I wrote the article. There’s some chance that a major storm is going to take out my internet, so I might as well leave you with a good article to keep you going. Now you know about htop, a top replacement. That’s a good thing.

Seriously, I prefer htop over top. It’s just much nicer and easier to work with. Be sure to check the setup options because you can configure htop to your liking. That’s a handy feature to have.

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.

Mastering The Power Of Linux Tee Command

I want to write an article that includes the Tee Command but it was one of those commands that I didn’t seem to be able to write properly. I wrote this article manually before I realized how much I was not too fond of the outcome.

So, I decided to lean on AI again. This seems like a fine article for AI to write, so let’s see how it did. (Hint: It did much better than I did…) I think I’m learning how to use AI as a tool to help me. That’s a good role for AI and is one of the reasons I’m not too worried about our future.

Mastering The Power Of Linux Tee:

In the vast landscape of Linux commands, few hold the versatility and power quite like tee. Often underestimated, the tee command is a true powerhouse for those who dare to delve deeper into its capabilities. If you’re ready to elevate your Linux command line skills, then it’s time to master the art of tee.

Understanding the Basics:

At its core, tee is a simple yet elegant command designed to read from standard input and write to both standard output and files simultaneously. Its syntax is straightforward:

This means you can use tee to capture command output and redirect it to multiple destinations, whether it be a file, a pipeline, or even another command.

The Power of Redirection:

One of the key strengths of tee lies in its ability to redirect output to multiple files. This comes in handy when you need to save the output of a command for later analysis while still seeing it in real time. For example:

This command will display the output of ls -l on the terminal and simultaneously save it to both file1.txt and file2.txt.

Piping Output for Further Processing:

Tee can also be combined with other commands using pipes to create powerful data processing pipelines. For instance:

In this example, the output of cat file.txt is simultaneously filtered by grep to find lines matching a certain pattern and those that don’t. The results are then written to different files.

Appending to Files:

While tee typically overwrites the content of files, it also supports the -a option to append to existing files. This can be useful when you want to continuously add data to a log file without losing previous entries. For instance:

This command will append “New entry” to logfile.txt without deleting its existing content.

Real-World Applications:

The versatility of tee makes it indispensable in various real-world scenarios. Here are a few examples:

Monitoring System Logs:

This command continuously monitors the system log (syslog), saves a backup copy to syslog_backup.txt, and filters out lines containing the word “error” to create a separate error log.

Debugging Scripts:

When debugging a script (script.sh), redirecting both standard output and standard error to a file using tee allows you to analyze any errors or unexpected output more effectively.

Capturing Command Output:

In the realm of Linux command-line utilities, tee stands out as a versatile and powerful tool. Whether you’re redirecting output to multiple files, creating complex data processing pipelines, or simply monitoring system logs, tee proves to be an invaluable ally. By mastering the art of, you unlock new possibilities for efficient data manipulation and analysis on the Linux command line. So, next time you need to capture command output or create intricate data workflows, remember the power of tee and wield it with confidence.

Closure:

Yeah, that sums up the tee command. AI really can do a better job than I can do with certain subjects. I wish I’d had this tool available for some of my more basic articles. AI would do a better job than I, as it certainly did with the tee command. I did have to edit this one quite a bit, but it’s an acceptable article. I might do more with AI but I did want to cover the tee command.

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.