How To: Check Your Hard Drive Temperature

Today’s article is going to teach you how to check your hard drive temperature (in Linux, of course). There are a number of ways to do this, so we’ll just cover one way in this article. It may seem complicated, but it’s not. This should be a pretty short article.

You should have a general idea of the temperature of components within your computer. The components have various operating temperatures and keeping them within spec means they’ll last longer and give you better performance.

Hard drives generally have temperature sensors and we’ll be using ‘hddtemp’ in the terminal to check your hard drive temperature. It won’t work with every hard drive, but it may work with yours. It’s a pretty easy application to install and use, so we’ll go over it as though you’re using Debian/Ubuntu/Mint or something that uses apt. A quick check says you have this available for other distros.

By the way, ‘hddtemp’ defines itself accurately enough, like so:

hddtemp – Utility to monitor hard drive temperature

Which is, as the article intends, exactly what we’re going to do…

Check Your Hard Drive Temperature:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, let’s install ‘hddtemp’:

Next, we want to start it as a service:

And we’ll want to have ‘hddtemp’ start with the boot process:

That’s about it for the installation. Now all you need to do is know which hard drive you want to check. You can get a list of hard drives by running:

Next, you’ll run ‘hddtemp’ as a privileged user and use the path to the drive you want to check. So, it’d look a lot like this:

If you’re in luck, it’ll spit out the drive temperature. If you prefer Fahrenheit, the command should look similar to this:

That’s really all there is to it. You can check the man page for other options, but this is how most folks are going to use ‘hddtemp’ on their own local computers.

Closure:

Well, this was a short article. I have a bit of a stomach ache, so picked one that’d be shorter than most. Ah well… At least now you know at least one way to check your hard drive temperature. That’s always a good thing.

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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Show Hidden Files And Folders

Today, you’ll read an article that tells you how to show hidden files and folders (in Linux, of course). This is something everyone should know. This is a basic skill that you’re almost certain to need if you make the decision to use Linux.

Fortunately, it’s pretty easy to show hidden files and folders. You’ll see…

First, I should probably explain what hidden files and folders are. They’re files and folders that start with a period. So .foo.txt is a hidden file and .bar could be a hidden directory. One should remember that Linux is, by design, a multi-user system. With that in mind, having hidden files makes sense – if you don’t want those files to be accidentally (or maliciously) edited.

Any files or folders that begins with a period will be a hidden file. If you’re new to Linux, you might want to leave them hidden until you’re a bit more comfortable working with system files. Or not… It’s your system, you do what you want with it.

In a GUI file manager, you can usually figure out how to show hidden files and folders pretty easily. Sadly, it’s not universal in a GUI. Look in the right click menu, under the “View” option, or in the application’s preferences. It’s also often ALT + H and I want to say I’ve even seen it be ALT + F4. Look around, you’ll find it.

This article is more about showing those hidden files and folders in the terminal. It’s a really easy command and won’t take too long to explain it to you. So, enough preamble, let’s begin.

Show Hidden Files And Folders:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

We’ll stay right in the default directory, your home directory. If you’re not currently in your home folder,  you can get there with:

Your home folder should have all sorts of hidden files and folders. First, let’s see your home directory without showing the hidden files and folders:

Unless you’re in the habit of storing files in your home directory, you should have a fairly tidy list of folders and files that you’re likely already familiar with. 

Now, let’s try again – this time showing hidden files and folders:

Or, you can get a more easy to read output with this command (and you get more information with it):

If you want to see it in action, you can try this command:

Now, if you use the ls command you won’t see that file. If you use the ls -a command you’ll see the hidden file that you created called .foo.txt. This of works with directories, as they too can be hidden.

Yup, that’s it. That’s today’s article. See? I told you it was easy.

Closure:

Indeed, it is an easy article – and one most of my readers will already know. This one is aimed squarely at the new user who has yet to learn how to show hidden files and folders. It’s a pretty important skill to learn, and it’s also important to know which ones you probably shouldn’t edit. So, judicious use is important.

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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Reduce The Size Of .png Files

In today’s article, we’re going to learn how to reduce the size of .png files. PNG stands for Portable Network Graphics and they can be pretty large. They are raster image format files using lossless image compression. So, today we’ll be doing just that, compressing .png files, in the terminal.

As stated, PNG stands for Portable Network Graphics. Some folks will say that it stands for “PNG’s Not GIF” but they’re incorrect – but are correct about the motive. The .png format was developed to be a free-of-patent alternative to .gif files – some 25 years ago, as of the time this article is published. You can read more about the file format at the PNG Wikipedia Page.

The tool we’ll be using is known as ‘pngquant‘, which should be available in most default repositories. You can check the man page, but it defines itself as:

pngquant — PNG converter and lossy image compressor

You’ll note that it says ‘lossy’ and that means you can lose some image quality with this compression – but from my testing it spits out a perfectly usable image, even while compressing it a great deal. It’s pretty handy. I haven’t tested it as a batch process on a bunch of files, but I have tested it on some files. In each case, I got a perfectly usable image that spit out the other side.

So, with that, let’s move on into the meat of the article, where we’ll learn to …

Reduce The Size Of .png Files:

As pngquant is a terminal-based application, it stands to reason that you’re gonna need an open terminal. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

I’ll give you the installation instructions for Debian/Ubuntu/Mint, but you should be able to find the package in most default repositories. To install in those particular distros:

Once ‘pngquant’ has been installed, navigate to a directory where you have some .png files waiting to be compressed. Once you’re there, run this command:

That’ll tell you the size of the .png in question. Now, you’re going to compress it with the following command:

By default, ‘pngquant’ will retain the original file and create a new file that has appended – fs8 to the file name. So, foo.png becomes foo-fs8.png. You can change that behavior with the --ext flag. 

Here’s an example where an already small .png file was reduced even further by way of pngquant:

pngquant in action - reducing the size of .png files
As you can see, it reduced the file size by about half. The resulting quality was fine.

You can find GUI software that will do this for you, but this is a quick and easy way to reduce the size of .png files in the terminal. While not opensource, there’s XnViewMP and I’m pretty sure XnConvert works with Linux as well. If not, XnViewMP does and has batch conversion as an option – while the latter is specifically for batch conversion.

Closure:

And there you have it… You have a way to reduce the size of .png files in your terminal. Just what you always wanted! I don’t see my average reader doing a whole lot of this, but it’s an option if you want. I use a service that switches my images to WebP as it’s faster and lighter. It’s done by my CDN for me, which is nice and one of the reasons the site loads quickly.

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 own site. The first person to read this sentence should contact me and I’ll donate five dollars to their favorite charity that accepts PayPal. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

How To: Free Some Disk Space By Deleting Old Logs

In today’s article, we’re going to free up some of your disk space by deleting old logs. It’s a relatively safe and easy thing to do, and can free some space up if you’re running low. Unless there’s a problem, you really don’t need a bunch of old logs kicking around and taking up space.

There are other reasons for deleting old logs, such as keeping things tidy or even ensuring old activities aren’t easily discovered by browsing old log files. You may have done some debugging and now want to start with a new slate, so there’s another reason to delete logs. 

Who knows what motivations you’ll have, but today we’ll be covering how to do it. The tool we’ll be using for log cleaning is ‘journalctl’, which is used for (according to the man page):

journalctl – Query the systemd journal

While ‘journalctl’ is a pretty nifty tool, we’re only going to scratch the surface. This article is only about deleting old logs and ‘journalctl’ is just the tool we’ll be using. If you want an article about all the features of ‘journalctl’, this is not that article. See? I’m saving at least a few people some time!

Anyhow, this article obviously requires a distro that uses ‘systemd’. If you don’t have ‘systemd’, you probably don’t have ‘journalctl’ and you’ll have to find another way to delete your logs. As most mainstream distros are using ‘systemd’, there’s a pretty good chance that you have ‘journalctl’ available.

So, with all that preamble gibberish out of the way, let’s go about …

Deleting Old Logs:

Like oh so many articles here, this one requires an open terminal. Why? Because of course it does. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Now, with your terminal open, let’s have a look and see how much space your logs are taking up. You can do that with this command:

Now that you’ve seen how much space your logs are taking up, there are a couple of commands you can use for deleting old logs. If you want to go by space, you can use this command:

You can edit the ‘100m’ to whatever suits your needs. You can also use ‘g’ for gigabytes if you’d like to keep using that much log space.

If you want, you can also delete your old logs by the day. Let’s say you want to retain the last 3 days of logs. Well, that command would be:

I suspect you can figure out that the ‘d’ stands for ‘day’ and the 3 is how many days. You can, of course, change that to any number of days you wish. If you want, you can even use ‘w’ for weeks. Though, if you’re deleting log files to clear up disk space, you’re probably going to want to trim the logs even more than that.

Anyhow, when you’re done running one of the cleaning commands from above, you can verify that the space has been cleaned by running the very first command listed. That will do exactly what it did the first time you ran it – it’ll tell you how much space your logs are taking up. If they’re still not small enough for your liking, feel free to edit and run one of the above commands a second time.

Closure:

Well, there you have it… You have another article! This time I tell you how to go about cleaning old logs from your system. It’s a handy skill to have, though most folks probably have ample disk space – except those running on stuff like Chromebooks or the likes. If you’ve gotta live within 16 GB, you’re going to want to keep your logging to a minimum. Also, I still haven’t skipped a day from writing articles. It seems likely that I’ll do so eventually!

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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Let’s Use ‘netstat’ To Find Out What Process Is Listening On A Specific Port

Today’s article is going to teach you how to use ‘netstat’ to find out what process is listening on a specific port. If you have open ports and don’t know why – and what’s listening on that port, you’re not making good security choices.

Let’s say you followed an article about how to monitor TCP/UDP in real time. If you’re new, or even just not all that advanced with Linux and networking, you might not know why there are all those ports and all that activity. Well, one of the things you should know is how to identify what process is listening on a specific port.

There are a number of ways to do this, but we’ll be using ‘netstat’. The ‘netstat’ application can be pretty advanced, but what we’ll be doing is pretty straightforward. If you’re curious, ‘netstat’ defines itself thus:

Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

As you can see, it’s a pretty advanced application. It has a rather expansive man page, and we’ll largely ignore that as we really only need some limited functionality. All we really need to do, for this exercise, is find out what process is listening on a specific port.

With that in mind, let’s leap into the meat of the article…

What Process Is Listening On A Specific Port:

This article requires an open terminal. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

Once you have that open, you’ll need to find out if you have ‘netstat’ already installed. There are many ways to do this, I prefer:

If you do not have ‘netstat’ installed, it’s certainly available for all mainstream distros and easily installed from your default repositories. Here’s how to install on a few distros:

Debian/Ubuntu/Mint/etc:

RHEL/CentOS/Fedora/Rocky Linux/etc:

SUSE/OpenSUSE/etc:

If you’re using a different distro, root through the default repositories. It’s a pretty common tool and I’d like to imagine it’s easily available to anyone.

Once you have ‘netstat’ installed, the command we’re going to use is really, really, simple. In fact, I wrote this whole darned article mostly for just one command. I probably could have made it shorter. Still, it might as well be long enough to give some extra information along the way.

Anyhow, the command you run is this:

For example, you might have an open port 22 and want to know what process is listening on that specific port. So, you’re command would look like this:

The end result will look something like this:

netstat being used to find out which process is listening at a specific port
While not completely clear, you can deduce that it’s just the SSH daemon listening on port 22.

It may not be completely clear, but you can use this to deduce what process is listening on a specific port. If it’s not completely clear, you can get actually dig a little deeper. See the “1100” in there? Well, that’s the PID (Process ID) and you can use the following command to get more informtion. It looks like this:

The output from that in this case is:

Which, as we know, is the daemon for SSH and thus nothing unexpected is running on port 22. See? Security!

Closure:

And there you have it, another article. This one is a pretty handy one, especially for when you want to know what process is listening on a specific port. If you have things running that you can’t identify, you can always stop by Linux.org and ask for help. Someone there will try to find out what’s going on for you.

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 own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.