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 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.