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.

Mastering Efficiency: Unleashing the Power of Bash Aliases

In the realm of command-line prowess, efficiency is king, such as Bash aliases. Every keystroke saved is a victory, and every shortcut mastered is a step toward domination over the terminal.

Among the arsenal of tools at your disposal, one weapon stands out as a champion of efficiency: Bash aliases. These humble shortcuts can transform your command-line experience from mundane to magnificent, allowing you to wield the power of complex commands with the simplicity of a single word.

Join us on a journey as we delve into the world of Bash aliases and unlock their full potential.

What are Bash Aliases?

Bash aliases are custom shortcuts or abbreviations that you can create to simplify and speed up your command-line tasks. They allow you to define your own commands or override existing ones with your preferred options or parameters.

Think of them as your personal command-line assistant, ready to execute your commands at a moment’s notice.

Why Use Bash Aliases?

The benefits of Bash aliases are manifold:

  1. Speed: With aliases, you can execute complex commands with just a few keystrokes, saving valuable time and effort.

  2. Simplicity: Long and convoluted commands can be distilled into concise aliases, making your command-line interactions more intuitive and less error-prone.

  3. Customization: Aliases are highly customizable, allowing you to tailor your command-line environment to suit your specific needs and preferences.

  4. Productivity: By automating repetitive tasks, aliases can significantly boost your productivity and streamline your workflow.

How to Create Bash Aliases

Creating Bash aliases is a breeze. Open your .bashrc  file, located in your home directory, using your favorite text editor (such as Nano). Then, add your alias definitions to the file using the following syntax:

Replace shortcut with the alias you want to create and command with the command you want to associate with the alias. For example:

This alias allows you to list all files in the current directory in a long listing format with file details.

Once you’ve added your aliases, save the .bashrc file and either restart your terminal or run source ~/.bashrc to apply the changes.

Examples of Useful Bash Aliases

Here are some examples of useful Bash aliases to get you started:

Best Practices for Bash Aliases

To make the most of Bash aliases, keep the following best practices in mind:

  1. Choose meaningful names: Use descriptive names for your aliases to make them easy to remember and understand.

  2. Avoid overriding existing commands: Be cautious when overriding existing commands with aliases to prevent confusion and unintended consequences.

  3. Document your aliases: Consider adding comments to your .bashrc  file to document your aliases and their purposes for future reference.

  4. Stay organized: Group related aliases together and organize them logically within your .bashrc  file for easier management.

Conclusion

In the fast-paced world of the command line, efficiency reigns supreme. Bash aliases empower you to wield the full power of the terminal with unparalleled speed and simplicity.

By mastering the art of aliases, you can elevate your command-line prowess to new heights and easily conquer even the most daunting tasks. So go forth, fellow command-line warriors, and unleash the power of Bash aliases upon the digital realm!

Can you tell that this was written by AI? The prompt I used for this was:

Write an article about Bash Aliases in the style of linux-tips.us.

It didn’t do very well at nailing my style and it used a lot of headers. It also rambled on quite a bit, but I do that too. I’m not sure how much time this saved. I still had to do quite a bit of formatting. A simple cut-and-paste would not match the mostly consistent formatting I have used as of late. That meant quite a bit of formatting.

I also ran the article through Grammarly. It’s too bad that they won’t accept me into the affiliate program. I quite like what they do for my writing. They make me look almost literate!

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.

Learn About Your Wireless Connection

Many of us rely on a wireless connection for our connectivity and this is for those who want to learn about your wireless connection. It should be a relatively simple article. Though, if you do not use wireless internet this won’t be very interesting.

Today’s article about your wireless connection will show you how to learn things like the quality of your connection, the transmission power, the frequency you’re using, and other sundry wireless bits. It’s a bit technical, and we will learn about your wireless connection in the terminal, but it’s all good information and not very complicated.

The tools we’ll be using should be installed in all current major distros. For example, we won’t use ifconfig because it is deprecated. We’ll be using the ip command instead. We’ll also be using iwconfig in this article. You shouldn’t need to install anything for this article. All the tools you need should be installed by default.

Side note: The site sure does load fast without ads! I’ll be finding a new ad provider soon enough, I just haven’t done so yet. I may appeal to Google. We shall see, but the site sure is fast! Alas, it generates no income to offset my expenses. So, we will have ads again. It’s going to happen.

As for the tools we’ll be using…

The IP Command:

The first tool we’ll use will be the ip command. As I mentioned above, the ifconfig tool has been deprecated. It is no longer supported and we’ve moved on to bigger and better things. Most major distros will have made this change. For a bit of completeness sake, I’ll include details for the old way.

You can verify that the ip command is available with this command:

If you check the man page, with man ip command, you’ll see that this is the correct tool for the job. The job is what was indicated in the article’s title. Anyhow, the ip command is described like this:

ip – show / manipulate routing, network devices, interfaces and tunnels

We’ll be using the command to identify the name of your wireless connection. It’s easy enough and you can easily follow along.

The IWCONFIG Command:

The iwconfig command is how we’ll be gathering information about your wireless connection. You should find that you don’t have to install anything for this. If you’re using a major distro that’s modern, you’ll almost certainly have iwconfig available. You can confirm that iwconfig is available with this command:

Just like we did above, you can run the man iwconfig command to see that this is the tool for the job. The output should include the following:

In our case, we won’t be doing any configuration – but we will be using this command to learn about the wireless connection. It’s a handy tool, but we’ll just be using it to gather data.

So, let’s get into the actual article itself…

Learn About Your Wireless Connection:

I mentioned above that this is something you do in the terminal. You probably know how to open your terminal by now. If not, you can usually press CTRL + ALT + T to open up your default terminal.

With your terminal now open, you can check your network connections. The purpose of this command is to learn which of your connection names is the correct one for your wireless connection.

If you’re using an older system, and some modern systems still contain the command, you can use the deprecated ifconfig like so:

Scroll through that data to find your wireless connection. It’ll begin with a W. It used to have a nice simple name by default, but times have changed. In my case, it looks like this:

In this case, you can see that the name of my wireless device is wlxe4beed0e5f5c. Unless you’ve renamed them, your wireless connection should start with a W and should be the only connection that starts with a W.

With that information in hand, you’ll next want to learn about your wireless connection with the iwconfig command. The syntax is quite simple:

So, in my case, the command would look like this:

The output would look like this (in my case):

From there, you can see the access point you’re connected to. You can find out the bit rate, frequency, and power management status of the device, and much more. See? Pretty easy.

HINT: If you don’t want all that information, you can always pipe it through grep. That’s pretty simple:

An example output would be:

This is a quick and easy way to learn about your wireless connection. It’s something that’s not too difficult and something everyone can practice to get a little bit more comfortable working in the Linux terminal.

Closure:

Someone asked if I was running out of ideas for articles. I do not believe I am. There’s just so much to write about and so many things that are worth covering. Today we’re learning about your wireless connection. Tomorrow we’ll be on to something else. And that’s okay… 

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.

Get Your NVMe SSD Information

If you’re using a modern computer, you might be using an NVMe SSD and you might want to know your NVMe information. The standard and older tools may not be all that helpful, even though NVMe SSDs have been around for a while. This article will help you with that, should you want to get your NVMe SSD information.

Let me see if I can explain this…

You’ll often see “NVMe M.2 SSD”, which is a mouthful.

NVMe stands for Non-Volatile Memory Express which is just a specification.

M.2 is another specification for expansion cards.

The device that is used for NVMe is an SSD – Solid State Drive.

SSD, which has been around for quite a while now, differs from previous generations of storage in that it’s electronic and not magnetic. 

We humans have a long history of trying to record things. We’ve used everything from words to pictures, from dots on paper to grooves on wire, from symbols to magnetic, and more…

For computers, a long time was in the magnetic storage age. From spinning drums holding mere bytes of data to complicated spinning platters that hold terabytes of data… We’ve made good use of the magnetic storage mediums over the years.

Solid-state drives don’t use magnets. Data is stored on memory chips that retain their memory (non-volatile) even if the power is disconnected. An SSD is quite common today.

Less common, but growing in popularity, is the NVMe M.2 SSD. This is a much smaller format than the early SSDs (which even came in the 3.5″ format, and surely some obscure formats that I’m overlooking). This is also on a faster bus lane, meaning the read and write speeds far exceed the storage medium before it – including the aforementioned larger SSDs that connect via IDE or (preferably) SATA.

The current consumer options are pretty great and an NVMe SSD is much faster than a regular SSD. The standard SATA SSD is quite common still, while the NVMe M.2 SSD is the latest and greatest.

With me so far?

Well, an NVMe M.2 SSD is a very different architecture and, as such, there are special tools to use. If you want to find the temperature of your NVMe SSD, the normal tools (like hdparm) may not yet work. Instead, there are other tools that you’d want to use.

In this article, we’ll be talking about a tool known as ‘nvme-cli’…

About nvme-cli:

You almost certainly don’t have nvme-cli installed by default. If you did, you’d be able to check the man page. Doing so would show that nvme-cli is described like this:

nvme – the NVMe storage command line interface utility (nvme-cli)

It should be important to know (and we’ll get to the installation step in just a minute) that you’ll be installing the package with one name but referring to, that is using, the application with another name.

For example, it’s man nvme to access the man page. 

NOTE: You will want to read the man page. There’s a whole lot of options and we’re just going to cover one basic command. We’ll learn stuff like the operating temperature of your NVMe. We won’t be worried about the various other options, of which there are many.

Find Your NVMe Information:

If you want to find your NVMe information in the terminal, you can do that. You’ll first need to install a tool known as nvme-cli. To do this, you’ll want an open terminal. You can usually open a terminal by just pressing CTRL + ALT + T

With your terminal now open, you must first install nvme-cli. You’ll find that packages are available for many distros, as they should be as the format is becoming more and more popular. 

Follow one of the basic installation methods below, specifically the one suitable for your distro’s package management system.

Debian/Ubuntu/etc:

SUSE/OpenSUSE/etc:

Fedora/Asahi/etc:

RHEL/CentOS/etc (those with yum available still):

Arch/Manjaro/etc:

I’m pretty sure there’s an nvme-cli package available for all the major Linux distros. If not, I linked to the project page above and you can check there for a package or to compile nvme-cli from source.

Find Your NVMe’s Absolute Path:

You’re going to need the absolute path to where your drive is mounted. That’s a part of the command, so you’ll need that. Just to mix things up a little bit, we’ll use the ‘df’ command. You should have df installed automatically on any major distro. The man page will helpfully describe the df application like so:

df – report file system disk space usage

We don’t care about all that. We just care about the absolute path. This usually starts with /dev/ and ends with the device ID. In an NVMe’s case, it will usually include nvme in the title, which is quite helpful.

So, let’s get that information…

You’ll get an output similar to this one:

It should be obvious that the absolute path for this would be /dev/nvme0n1p1 and that’s the data we’re going to need.

Now, to find your NVMe information, the syntax would be like so:

Using the output from above, an example of that would be:

This will then give you an output like so:

nvme status in the terminanl
There you go, you now have your NVMe Information. It’s not too difficult to do.

Of course, you can pipe this output to other commands. Let’s say you wanted to know the current temperature of your NVMe SSD. You’d do that with the grep command. An example would be:

If you want to know the number of times you’ve powered the device on, you can do that by piping the output to grep again. For example:

So, you can use the nvme-cli application (the nvme command) for quite a bit. You can do a whole lot more with it, so be sure to check the man page if you’re interested in doing more than checking the temperature or how many times you’ve cycled the power on that device.

As NVMe SSDs get more common, you’ll likely start seeing this package installed by default. From what I can see right now, no major distro is including this by default. If you’re using an NVMe M.2 SSD, you might just want to install it. If nothing else, it’s yet another tool that might come in handy.

Closure:

Today’s article is a bit longer than some but I think it’s worth reading. If I didn’t think it was worth reading, I wouldn’t have written as much! There’s so much that I could have covered but I didn’t. Articles have to have only so many words before people lose interest.

I’d have loved to cover the history of computer memory (or perhaps even more about how we humans have recorded stuff) but that didn’t seem prudent. I figured I’d limit the number of words to 1,200, but I still managed to exceed that – though not by too many. Seriously, it’s a pretty fascinating bit of history. You should use Google (and/or YouTube) to see learn about all the different ways we’ve stored data, and that’s just scratching the surface!

Fascinating stuff, I tell you! Fascinating!

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.

Monitor Your Wi-Fi In Linux

If you use a wireless connection on your computer, or wi-fi for short, you might want to monitor your wi-fi. This is a simple task in the terminal and won’t take too long to learn. So, if you’ve ever wanted to monitor your wi-fi, this is the article for you!

There’s more to your wireless connection than just the throughput. There are things like link quality and signal strength that might interest you. It doesn’t stop there, there are all sorts of other bits of information you can learn if you decide to monitor your wi-fi in Linux.

I’ve written a few similar articles, each using a different technology. If you’re interested in those articles, click one of the following links:

Visualize Your Network Traffic With ‘darkstat’
‘vnStat’ A Tool For Monitoring Your Bandwidth Usage
Monitor Bandwidth In Real Time
Monitor Bandwidth With nload

Those are all about monitoring bandwidth and your network connection speed. They’re all fit for purpose, but this article covers wavemon, which is quite different and more specifically about monitoring your wi-fi connection as a whole. This isn’t very complicated or anything. You’ve got this!

This will be done in the terminal, so you might as well prepare yourself for that. So many of my articles do indeed require an open terminal.

wavemon:

The tool we’ll be using is known as wavemon. Like most of these articles, it’s another tool that’s fit for purpose. We want to monitor the waves, radio waves that is. This is one of the tools for the job. In fact, you’ll find the man page describes wavemon like so:

wavemon – a wireless network monitor

To install wavemon, we’ll need an open terminal. You can frequently just press CTRL + ALT + T to open your default terminal emulator. Give that a go. If it doesn’t work you can find the shortcut in your application menu.

With your terminal now open, we need to install wavemon.

Debian/Ubuntu/etc:

RHEL/CentOS:

Arch/Manjaro/etc:

Fedora:

I think I have all of those correct. If not, please leave a comment down below so that I can fix it. If you’d like to add the code to install wavemon on other distros, please leave a comment below. I’m pretty good at getting back to commentators and tend to be quick at fixing articles.

Anyhow, wavemon is the tool you’ll want to use to monitor your wi-fi!

Monitor Your Wi-Fi In Linux:

Leave your terminal open from the installation phase.

This section of the article will be nice and quick. You don’t need to do anything else besides run the command. You don’t even need elevated permissions (such as sudo) for this.

With your terminal open, just enter the following command:

You’ll get a handy output (it may help to resize your terminal for this one) that’s full of information. An example of that output would be this:

using wavemon to monitor wi-fi in the Linux terminal.
It’s fairly easy to understand the output from the wavemon command.

I can’t get F1 to do anything, but F2shows a histograph.

If you do start wavemon with sudo, you can scan for wireless networks with the F3 button.

You can change some settings with F7 if you want.

The F10 button should quit the program. 

If that doesn’t work, CTRL + C will exit wavemon.

But, you can see how much data you’ve received (during this session) and how much data you’ve sent (during this session). It’s all pretty basic stuff and wavemon is a nice and easy way to monitor your wi-fi in Linux.

Closure:

Well, that’s one way to monitor your wi-fi in Linux. If you use a wireless connection and want more information about that connection, wavemon is an acceptable tool for the job. There are certainly other tools out there and this is just one of them. It’s an easy tool to use and I find it’s familiar enough for anyone to understand with relative ease.

I did say that this would be a fairly easy article. It is indeed a fairly easy article! This is one of those things you can learn in just a few minutes. You never know when this information will come in handy. Then again, you might just be curious and want to know this information. You can customize it a bit but I didn’t need to do so.

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.