How To: Check Disk Usage With ‘df’

In today’s article, we’re going to do exactly what the title suggests; we’re going to check disk usage with ‘df’. This means we’ll be checking disk usage in the terminal. Seeing as ‘df’ is included with every distro on the planet (I’m pretty sure) it means this won’t be all that complicated.

I am still a bit under the weather, but the show must go on! I’ve gone this long without missing a publication date, so I might just as well keep the  streak up. 

As the title suggests, we’ll be using ‘df’ to check disk usage. This will already be installed as one of the default tools, so you won’t need to install it. That’ll save some time! If you’re curious, the ‘df’ tool describes itself as:

df – report file system disk space usage

If you want to get a head start, you can check the help page. To do that, you’ll want to run:

If you’re like to check the version, the command is:

So, with that in mind, let’s just jump into the article.

Check Disk Usage With ‘df’:

Obviously, this is yet another article where we’re learning about doing things in the terminal. That means you’ll 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.

With your terminal now open, you can just run the command by itself:

In some cases, it will throw an error and not be able to read everything. That’s usually easily resolved. Just run the command as a privileged user. So that would look like:

Now, you can use that output to do a bunch of math, or just pay attention to the percentages. Or, if you’re wanting, you can use the -h flag and get the output in human-readable format. That looks like:

The output of which might look a little something like this:

the output of sudo df -h
See? No errors and it is nice and readable! You can’t go wrong with that!

As you can see in the picture, I’m only using less than half of my available disk space. I don’t need to worry about running out of space any time soon, but if it gets low I can always check disk usage with ‘df’. Also, it doesn’t matter what directory you’re in when you run the command. As you can see, it runs just fine while in the Downloads directory.

I also wrote an article about using GUI methods to visualize disk space usage. You might prefer one of those methods, but you can always just use the terminal to check disk space.

Closure:

It seemed like a good idea to do a quick article tonight. I’m watching IMSA’s last race of the season and feeling poorly, so hopefully I get some sleep at a reasonable hour. Still, as I mentioned, the show must go on. The site has had a new article every other day for quite a while. I might as well keep up the schedule.

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: Go To A Specific Line In Nano

In today’s article, we’re going to learn how you can go to a specific line in Nano. It’ll be an easy article, perhaps even a fairly brief article. There are a just a couple of ways to cover, so it won’t take all that much time or space.

Often, when things like scripts throw an error, they’ll tell you on which line number the error happened. There are often hundreds or thousands of lines in complicated files and navigating to the correct line number is tedious, prone to error.

You can be pressing the down arrow for quite a while! So, why not note the line number where the error occurred and open the file at that specific line? It’s perfectly good sense! It’s such good sense that I figured I’d write an article about it.

You all know that I’m a Nano fan. You can read the ‘big’ Nano article here. If that’s not enough, this link is to a search for Nano across the entire site. There are nearly 30 articles that use Nano in them. I really am quite a fan.

Why am I a fan? Well, the first link will probably tell you that, but I like it because it’s simple. Nano’s starting to be fairly universal. It’s light and that’s why I like it – it’s only meant for quick text file edits.

Nano’s not really the right tool for writing a book, nor would I want to use it to write large scripts or for programming. For what it is, it’s great. If it’s not great, odds are good that you’re not using it as the tool it is. Sure, it’ll work for other things, but it excels at being what it is – a quick text editor in the terminal.

Go To A Specific Line In Nano:

Nano is a terminal-based tool. So, you obviously need to have 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. Tada! (That’s mostly copy/paste from previous articles, but I do sometimes mix it up a little!)

With  your terminal open, let’s show you how to go to a specific line in Nano. It’s pretty easy, and we’re going to use a file most users will have. If you don’t have a ~/.bash_history file, you can use any plain text file you want.

I suppose we should first make sure that you have Nano installed. To check, you can just look for the version. That’s done with:

Your output should look something like:

checking the nano version
As you can see, Nano is happily installed and ready for use.

If Nano isn’t installed, and you’re using any mainstream distro, it’s certainly in your default repositories. You can install it like you would any other piece of software in the repositories. 

Now, there are two ways to open and go to a specific line in Nano. The first is probably the easiest. Using our ~/.bash_history as an example, the command looks like this:

Where you see the +25 flag, that’s the place where you specify the line number to start with when  you open Nano. You can use any number you want, provided there are that many lines in the file you’re intending to edit.

The next way is also easy. Using your keyboard, press CTRL + Shift + . Nano will then present you with the chance to enter in a specific line. It looks like a lot like this:

open a specific line in nano
See? Follow the arrow and that’s where it prompts you to enter a line number. ‘Snot hard at all!

So, now you have two ways to go to a specific line in Nano. I told you that it was going to be easy! Nano is awesome.

Closure:

There’s another article! It’s on one of my favorite subjects – Nano. Now you’ve learned how to go to a specific line in Nano, which is a pretty handy trick to have in your toolbox. It can save you all sorts of time, and not just time scrolling. It means you aren’t paying attention to the rest of the fluff and you can concentrate better, or so it seems to me. For what it is, Nano is my favorite plain text editor and it’s remarkably useful at times.

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.

Compress A File With WinRAR

Today’s article is going to teach you how to compress a file with WinRAR. This isn’t exactly something you’re going to do often, unless you share files with Windows users. If you do share files with Windows users, this isn’t such a terrible idea. There are worse ideas, some of which are on this site.

Before you get to excited, there are countless ways to compress a file in Linux. The odds of  you technically needing WinRAR are about zero. Still, that doesn’t mean we can’t have fun and learn new things!

Right?

Right!

It’s great to learn new things, even if you’re never gonna use them. Until about 5 minutes ago, I can’t remember the last time I felt the urge to compress a file with WinRAR. I’ve previously written about WinRAR, actually. 

How To: Extract An .rar File

So, if you follow that link you’ll learn how to perform the other end of this operation! I’d like to pretend I planned it that way, but I did not. No, there’s no rhyme or reason to the publication schedule – except you get a new article every other day.

Compress A File With WinRAR:

Yup. You’re gonna need an open terminal for this one. 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.

First, you’re going to need rar. It’s probably in your default repositories. It’s there for Debian, Ubuntu, and Mint. So, it’s probably available for you. You can get the proprietary version of WinRAR here. (Or not… I don’t see a whole lot of folks wanting that, but it’s there if you do! Also, I think it’s just a trial version.) Or, install it from your repositories. With those operating systems, it’s just:

Now, it’s really easy to compress a file with WinRAR. The command is:

The ‘a’ flag is telling the command to archive the file/folder you named. If you wanted to compress a file (or even a directory) named foo, it’d look like this:

See? That’s all you really needed to know if you want to compress a file with WinRAR. It’s not exactly complicated, but it’s helpful to know how if you come across a situation where you actually need to know. Again, there’s a zillion ways to compress files in Linux, so you’re not going to need this one all that often unless you really need it. If you do use WinRAR with Linux often, please leave a comment explaining why.

Closure:

Yup. It’s another article! This one teaches you how to compress a file with WinRAR. In my defense, this is information that’s from my notes. I have a whole lot of notes, but this one stood out today and so you get this for your article. You’re welcome!

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: Hide The Output From wget

In today’s article you’re going to learn that you actually can hide the output from wget. I am not one of folks want to do this, but some do. Or at least the option is there, so I assume they do. Either way, read on and you’ll know how to hide the output from wget! 

Goodwood Revival is this weekend, but you’ll still get an article. I am thinking about going in person next year, so I’ll have to write articles ahead of time. I probably should have done that even though I’m just streaming it.

Anyhow, there’s an option that will let you hide the output from wget and it’s in my notes. I might as well turn it into an article because I’m sure someone wants to do this. 

What this does, to be clear, is shows no wget output in the terminal once you enter the command. You’re not running blind, however. I’ll show you how to at least ensure the command gets completed. So, it does have uses – when  you just don’t need to see the clutter.

Lots of people do loads of useful work in the terminal and don’t really need to see clutter, so this is one way to avoid that terminal clutter. I actually prefer to see what’s going on, but I’m weird like that. If you do not prefer to see what’s going on with wget, this article is for you!

Hide The Output From wget:

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.

It next requires that you use wget to get something. So, pick something and download it with wget. I don’t care what. You do you and download anything you want. To hide the output from wget, the command is:

That’s really it. However, you then have no idea if it it completed. Fortunately, you can make sure wget completes its task (within reason) with the -c flag. So then the command would look like:

See? Pretty simple. That command will not only hide the output from wget, it will ensure the download is completed. You’ll avoid cluttering up your terminal, or something…

Closure:

There you have it! You now know you can, and how you can, hide the output from wget. You can even be reasonably sure it completes behind the scenes. It’s not a very difficult article to follow today, so consider it an easy day. Now, back to my racing…

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.

Change Your Home Directory

In today’s article you’re going to learn that it’s possible to change your home directory. Why? Because Ol’ David is in a bit of a rush to get this out on time. I can’t miss my publication deadline! So far, there has been an article every other day. Gotta keep up the schedule.

Yesterday was an extremely frustrating day. People managed to waste my entire afternoon. The only consolation I got was that I drove home really quickly, in a very spirited manner. That was not enough consolation. So, I just drank a couple of delicious beers (Sierra Nevada Pale Ale) and went to sleep.

I expected to get up early and write the article. I did wake up early, but I fell back to sleep. My body wanted to catch up on some missed sleep and it did. Which means I’ve got like an hour to write this article.

(I don’t think there has ever been a more ‘bloggy’ post than this one! It’s horrible and I’ll hopefully never do it again.)

When I first planned this article, I planned on showing you how to change your home directory with a new user. It was going to be fairly long and needlessly complicated. So, instead, I’m just going to tell you how to do it. You can learn how to create a new user.

So then, let’s get onto the meat of this…

Change Your Home Directory:

There are all sorts of reasons why you might want to change your home directory. Maybe you don’t want people being able to easily spot it by traversing your directory tree? You might want to move it to a different partition that has more space? Who knows?

But, this isn’t something you want to do willy-nilly. See, a whole lot of things depend on your home directory and your home directory probably contains a lot of stuff. So, after you’ve changed your home directory you’re probably going to need to move a lot of stuff around. That’s why it’s best to do this with a new user. If you want to practice this, I’d say do it to a new user. There’s a link in the preamble to learn how to create a new user.

The command is remarkably simple. Just open up your terminal and run:

So, if I wanted to move my home to /foo/bar, the command would look like:

You don’t have to specify /home/kgiii – even though that’s the full directory path. The -d command knows that we’re generally talking about the home directory. If you’ve already moved your home directory, and it is outside of the /home directory, you’re probably gonna have to specify that. I don’t actually know, I’ve never tried that.

This isn’t something I’d undertake lightly. I’d really only recommend this on a new user OR if there are some very specific circumstances. You might do this if you’ve filled up your disk space, added a new disk, and want to move your home directory to the new disk so that you don’t have to muck about with changing partitions or anything. Even then, it’s a bad solution – but probably one of the best solutions you have available.

Closure:

Consider this an article that’s for a very special set of circumstances. It’s for when someone on a forum has run out of disk space and wants a way out without any changes to partitioning and doesn’t want to reinstall. This isn’t something you probably need to go playing around with, but you can. I ain’t stopping you. The potential to make a mess of this is pretty strong.

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.

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.