Remove Unused Kernels From RHEL

Today’s article is only going to apply to some of you, specifically those who use RHEL and want to remove unused kernels from RHEL. That’s a pretty narrow subset of people, but it’s worth knowing this information if you’re a RHEL user.

Red Hat is one of the oldest Linux distributions out there. Along the way, they’ve turned into an ‘enterprise’ (business class) distro. They’ve made some strange strategic decisions lately, but I’m not going to get into that in this article.

As an enterprise distro, it is not entirely free (as in cost in dollars). They are a distro that has a great deal of support for long periods. They’re meant to be stable and ideal for business use. You’re expected to pay for RHEL – sort of.

RHEL has a free version if you sign up as a developer. You can learn about the RHEL developer program at this link. I thought it was free for a few devices, but it looks like I might be wrong and that it may be more than that. From the linked page:

An entitlement to register 16 physical or virtual nodes running Red Hat Enterprise Linux.

So, that’s more than three – but you’re not going to get support. If you want to go this route, you’re expected to support yourself. Fortunately, RHEL has extensive documentation and your dev subscription will get you access to any of that documentation that’s behind a paywall. Or, at least that’s my experience.

I don’t do enough with RHEL!

Linux Kernels:

I’ve explained what the kernel is before. Linux is just the kernel. We add stuff to the kernel to make an operating system. We then add more stuff to make it a specialized operating system – such as a desktop operating system, like the readers of this site use.

Along the way, as you update and upgrade, you’ll add new kernels. These are not necessarily removed by default. They can take up quite a bit of space and you might be paying for that space (especially if you’re using RHEL as a server somewhere). So, removing the oldest kernels is just good housekeeping.

That’s all we’re doing in this article. I suppose it’d probably also work for CentOS but I don’t pay any attention to that distro these days. It’s not that I’m angry or annoyed with RHEL’s decisions, it’s that I only care for things with long-term support. I’m old and changes scare me!

We’re just going to clean up any old kernels, probably while keeping the 2 most recent kernels, to keep things nice and orderly. This isn’t something you technically have to do. You can keep all the kernels you want. But, if you want to remove unused kernels from RHEL this might be the article for you!

Remove Unused Kernels From RHEL:

Now, if you’re using RHEL as a server then you’re already connected via SSH (probably) and already have a terminal open. If you’re using RHEL as a desktop OS, you will need to open a terminal. You can just press CTRL + ALT + T and your terminal will pop open.

With your terminal open, you first need to install yum-utils. That’s nice and easy, just use this command:

(You’ll need elevated permissions unless you’re logged in as root.)

Next, run the following command to see how many kernels you have installed:

If you have more than two kernels installed, you can run this command:

You can adjust that command if you’d like. That particular command will keep the kernel you are currently using and the previous kernel. (You can boot to older kernels via GRUB if you want. That article is actually about recovery mode on Ubuntu, but the pictures should clue you in until I write an article just for this purpose.)

If you use a --count= of 1 or 0, it will remove every kernel except the one in use, it will not remove the kernel that’s in use.

That’s all you have to do. There’s nothing more to it. The command will automatically remove older kernels at the level you decided. You can keep the most recent three kernels, four kernels, or however many kernels you want. It’s not terribly complex.

Closure:

I don’t do a whole lot of RHEL articles, but it’s nice to at least write one here and there. If you’ve got extra kernels, you now know how to remove unused kernels from RHEL. It’s a pretty easy task and something even a new user can handle. If you’re a new user, go for it! It won’t break anything – in and of itself. (I’d highly recommend keeping the current kernel and the most recent kernel, just in case.)

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.

Locate Your Home Directory

Today’s article will not be long, nor will it be a complicated article, as we learn how to locate your home directory. This is something you probably already know, but you may encounter a strange system where things are a little different. It can happen.

More importantly, this article is going to try something new. Rather than a very long article, it’s going to be a short article. Well, shorter than most – assuming I stop puffing it up with text such as this. Why? Well, I want to see the reception and the statistics.

So, basically, every user account you’re likely to use should have a home directory. This is where the user’s files, customizations, and settings reside. Not every user has a home directory, but the accounts you’d normally use (that is log into and operate) will likely have such a directory. However, you don’t have to have a home directory – though you can expect some weirdness without one.

How To: Create a New User Without a /home Directory

The usual home directory will be in /home/<user> and that’s pretty much the standard we’ve come to know and love. You really shouldn’t need to locate your home directory, but there comes a time when you just might want to.

So, that’s what this article covers. It covers how to…

Locate Your Home Directory:

So, we’ll be doing this in the terminal. That’s a nice place to do things. Press CTRL + ALT + T and your default terminal should open. If it doesn’t open, pick a better distro!

Nah, just open it from your application menu and love the distro you’ve chosen.

We’ll just be covering a couple of quick ways to locate your home directory. That’s all this article is and there’s no reason to turn it into a longer article. We’ll do them both with the echo command. See man echo for more details.

First, you can try this command:

As you should know by now, the tilde (~) is a shortcut for your home directory and it works just fine in this use case.

There’s another echo command you can memorize, but slightly longer:

That command uses both the echo command and an environment variable, specifically $HOME (obviously). This will happily echo the results, sending them to your standard output. This can be quite useful if you’re into scripting or the like.

See also:

How To: Show All Environment Variables

I told you that this wouldn’t be long or complicated. You can now locate your home directory from the Linux terminal.

Closure:

As I said, I figured I’d try the opposite of what I’ve been trying lately. My most recent articles have been quite long and quite detailed. I like them. I enjoy writing them. This time around, it seemed like a good idea to try something different with a subject that benefits from brevity.

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.

Change Your Timezone In Linux

Today’s article is an easy one about how you can change your timezone which isn’t something you’ll likely need to do all that often. It’s not all that complicated, though it can look like it is. It can be a bit tedious, but that’s just at first blush. I’ll show you how to make it a bit easier.

NOTE: This is actually a duplicate. I wrote it some time ago and realized it was a duplicate, or reasonably close to another article. I decided to save it and publish a duplicate article when an ’emergency’ came up. Well, we have an ’emergency’. I had too many adult beverages before it was time to write a new article. So, you get this one.

Now, the title is obviously not correct. You’re not going to change your timezone, you’re going to change the timezone settings your computer is using. Alas, headlines aren’t to be all that long and are allowed to make some assumptions. If you want to change your timezone, you’ll have to move.

This article is only useful to you if you use systemd.

My regular readers may have noticed a giant outage. Linux-Tips.us was unreachable for a good part of the 6th. My initial assumptions were that we’d been hacked, that is that WordPress had become compromised. That’s a reasonable assumption.

It turns out that we’d been moved to a new data center. We’re now located in New York. I use a CDN that relies on an IP address. There are a bunch of DNS records behind the scenes. Those records had to be updated. That wasn’t a major task, but troubleshooting the problem was the challenge.

Everything turned out okay and I won’t even miss a scheduled publication. Of course, I’m writing this at 04:45, but you will have your article today. So far, I haven’t missed a publication date. I’m quite amazed by this.

Speaking of today’s article, we’re going to be learning how to change your timezone. We’ll be doing this in the terminal and the tool we’ll be using is known as timedatectl. If your distro uses systemd, you have this installed. When you check the man page (with man timedatectl) you’ll see that timedatectl defines itself as:

timedatectl – Control the system time and date

As you can see, this is probably the right tool for the job – assuming the job is changing your timezone. Seeing as that’s what the title says we’ll be doing, we might as well do that.

Change Your Timezone:

As mentioned in the introduction portion of this article, you’ll be doing the work in the terminal. It’s often easy to open a terminal with a keyboard shortcut. Frequently, you can open your default terminal by just pressing CTRL + ALT + T. Otherwise, look in your application menu. That’d be a good spot to look for a way to open your terminal.

With your terminal open,  you can enter the following command to see what you have for your current timezone settings:

Before you can change your timezone you have to know what time zones are available. There are a whole lot of them, meaning you can be scrolling for quite a while. Go ahead and enter this command:

(You can press CTRL + C to get out of that.)

So, what we’re going to do is narrow down the results shown to you. You’ll need to know the region you’re in, such as Europe, Africa, America, etc for this next part and we’re going to use a pipe and grep (which we’ve used in the past). For me, I’d want to set my timezone to New York in America and my command would look like:

You’ll note that this is case-sensitive. Listed in the output would be the text I’m after, the text needed for the command that lets you change your timezone. It looks like this:

With that information available, I can now complete the command to change my timezone to that of New York. That command is easy enough. It just looks like:

Or, when using my location as the example, the command looks like this:

It’s not too daunting a task to change your timezone. If you entered the wrong timezone during installation, you can trivially change it to the correct timezone.

I should mention that your computer will use NTP to keep your system’s clock set. This is also stored in your system’s hardware. The CMOS battery keeps that and other settings stored while the power is disconnected. This battery can go bad.

If that battery does go bad, you may find yourself setting the date and time of your system every time you start your computer. NTP should then kick in and keep your system’s time updated. For reasons deeper than this blog will go, your system depends on time (specifically Unix Time) in all sorts of applications.

Closure:

Well, there was some drama. The site was down for an extended period and this article wasn’t written until the wee hours of the morning. However… However, I didn’t miss a publication date. Also, I just realized I haven’t done a meta article in a while.

With some great help from the hosting company upstream, everything was resolved and you got an article about how to change your timezone in Linux. All’s well that ends well.

While there are backups, my heart sank when I thought that the site had been hacked. Cleaning that mess would have been tedious. Fortunately, that wasn’t required. No data was lost and we can move on knowing that it’s just a footnote in the site’s history.

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.

Access Recovery Mode On Ubuntu

Today’s article shouldn’t be too long, but covers something important, which is how to access recovery mode on Ubuntu. If your Linux system has problems, you may need to access the recovery mode in order to fix it. This shouldn’t be a very long article, and I don’t think it’s all that complicated. Others may view this as complicated, but it seems pretty basic to me.

It isn’t all that complicated a process, but it’s something you should memorize, just in case you have no other way to access a search engine to learn this information. This is one of those skills you really ought to know by rote. It is one of those things about Linux that you probably should have memorized. 

What is Recovery Mode?

When you boot to recovery mode, you’ll be given a choice of booting to any of your currently installed kernels. The system then boots with the minimal amount of resources and mounts the root partition as read only.

You might be interested in a recent article on the subject of multiple kernels:

Show Installed Kernels In Ubuntu

Recovery mode lets you access the system to troubleshoot problems. It probably isn’t a necessary step for most issues, but it’s a necessary step that you will want to take if your desktop isn’t otherwise loading. If you’re unable to get to the GUI desktop, you should try recovery mode.

You can also try previous kernels by doing this. Recovery mode is just one option you’ll have from the GRUB menu. You get to pick your other kernels and even enter a text mode to work on your system via the CLI. For most folks that have had the kind of difficulties that stop the GUI from loading, trying recovery mode is a good step to take.

This may very well work in other operating systems. I’m being specific to Ubuntu because that’s what I have pictures for. Well, technically I’m using Lubuntu in a VM to get the pictures, but this should work for all sorts of distros. Do me a favor and leave a comment if you know this works in other distros. It’s way too late in the day and I don’t have time to check.

Access Recovery Mode On Ubuntu:

Well, you don’t need a terminal for this exercise, but you do need to reboot your computer. I suppose we can do this from a terminal, if you really want. You can just as easily use the GUI, or you can close things down gracefully and then run the following command in the terminal:

BEFORE YOU DO THAT…

We need to know if you are using EUFI/EFI boot or if you’re using the legacy BIOS mode to boot your computer. Fortunately, I’ve already covered this!

How To: Tell If You Are You Using UEFI or BIOS

Now, when your computer reboots, it’s going to perform a quick POST (Power On Self Test). That’s the point when you can decide to just let it boot or decide to enter a temporary boot menu. These shouldn’t be confused. If you’re interested in accessing your temporary boot menu, read this article:

How do I ‘Boot to USB’? (Or CD/DVD, if Such is Available)

As soon as POST ends and the OS starts to load, there’s a very brief window of time when you can press a key and access the GRUB menu. Trust me, this works. You may have to try multiple times before you get the hang of it, but this 100% works.

If you have a working keyboard, this works. You just need to time it right. You can try pressing and holding the right key as soon as you reboot, or you can try tapping the key over and over again. Should you have issues getting it right, check your settings for “Fast Boot” and temporarily disable that to give you more time.

If you’re using UEFI, the key you’ll press is the ESC key.
If you’re using BIOS, the key you’ll press is the SHIFT key.

Assuming you’ve done this right, you’re now at the GRUB menu…

The GRUB Menu:

GRUB stands for “Grand Unified Bootloader” and is what you’ll be seeing (and using) on a stock Ubuntu configuration. There are other bootloaders out there, but we’re assuming you’ve not changed from the default.

If you’ve done the above steps properly, you’ll see a GRUB screen. If you haven’t done this correctly, you’ll see the splash screen as the operating system starts to load. When you see the splash screen, you might as well just reboot so that you can try this all over again.

The first screen you’ll see will look like this:

the grub boot screen
I’ve highlighted the choice you want to select with your arrow keys and enter button.

As indicated, you want to select the advanced options for Ubuntu. Of course, that won’t be the case if you’re using a different distro. You’ll want to pick the advanced options for that distro.

Finally, you need to select the correct option to access the recovery mode on Ubuntu. It’s really obvious, but here’s a handy picture:

grub option to pick the recovery mode for ubuntu
You can see that you can also select the recovery mode from an older kernel.

Once you’ve done that, and with any luck, your computer will boot to the recovery mode, and you’ll have learned how to access recovery mode on Ubuntu. You can see the option to boot to an older kernel is there as well. That’s another useful tool to have in your Linux toolbox.

Closure:

Well, if everything goes perfect (and it seldom does), you won’t need to access recovery mode on Ubuntu. It’s just not something you’ll need to do. But, if things don’t go perfect – and we tend to tweak, modify, and break things as Linux users, you do have a recovery mode, and it’s not too hard to access it. Of course, what you do once you’ve entered recovery mode is up to you and will depend on your problems, but you now know how to access it.

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.

How To: List Mounted Partitions

Today we’ll have a nice and simple article, simply because we can, about how to list mounted partitions in Linux. Like so many of these articles, we’re going to need an open terminal. On the other hand, we’ll just be exploring a couple of tools to help us along the way.

Your disk drives, be they solid state or hard disk drives, will be separated into partitions. It can get confusing until you realize that the outputs from these commands won’t always just represent what I’ll call physical partitions. Sometimes, there are virtual partitions – sometimes with their fun file systems.

You may have everything from mounted temporary partitions to software designed to run in its own mounted partition space. When you run these bellow commands, you’ll learn that there are all sorts of mounted partitions. This is completely normal. It’s also pretty easy to weed out the physical partitions.

Why would you want to do this? Well, I’m having a goofy error when I boot one of my computers and I need to narrow it down to which disk it is that’s giving me the error. Once I take the time to do that, I can move on to troubleshooting the problem and finding a solution for the problem.

The tools we’ll be using are ‘findmnt’ and ‘df’. They’re described as the following:

finding:

findmnt – find a filesystem

df:

df – report file system disk space usage

As you can see from the description, both of those have something to do with getting information about a file system. That makes them good tools for the job.

NOTE: There are multiple ways to list mounted partitions. You have GUI and CLI-based tools available to you. One of the goals surrounding this whole project is not just to make people more familiar with Linux but also to help them get comfortable working within the terminal. You’ll be just fine!

List Mounted Partitions:

As I mentioned above, we’ll be using a terminal for this. I do not mind which terminal you’re using but you can usually open the default terminal by pressing CTRL + ALT + T. That works most of the time.

With your terminal now open, you can try the following command:

The output from that command will list your mounted partitions. It’s a lot of text, but most folks are probably only interested in the start of the line. The output of the findmnt command may look a little something like this:

The next command you’re going to want to try will be the ‘df’ command. We’ll be using a few flags. It’s not very complicated, though it may look like it. The command is a simple ‘df’ command and looks like this:

We use the -a flag for ‘all’. Then we use the -T flag because that means type. Finally, we use the -h flag because that means the output will be “human readable” (or more easily read by us mortals.) The output of which looks something like this:

No matter which of those commands you use, it will make your terminal list mounted partitions. If you need to know which partitions are mounted, these are the tools you can start with. They’re easy enough to work with.

Closure:

Well, it’s a bit late in the evening. I almost forgot that there was an article due tomorrow. This happens when I get a lot of responses (elsewhere) on the wrong day. My brain just doesn’t click. I should probably set an automated notification to let me know which days require articles, but I haven’t failed yet. In fact, you get an interesting article about how you can list mounted partitions.

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.