The Unix User and the Home Directory

You’ll always be logged in as a specific user when logged into a Unix system.

Typically, this is just your name. It is the name you entered when you first set up your account.
You’ll see your name before the symbol when you are on your command prompt. It is just telling you that you are logged in as that user.

This user (the one you’re logged in as) typically has a Home folder.

On Mac systems, this folder lives in a folder at the root of the hard drive: /Users

On my macOS, my Home folder looks like

/Users/jason

On many Unix systems, the home folder might be at:

/home/jason

Each user on the Unix system gets their own home folder. (/home/alice, /home/bob, etc)

However, note that different Unix systems will work differently, but all adhere to this basic concept.

This special folder that matches the logged-in user’s name is that user’s home folder.

When you open a Terminal window, your operating system automatically opens the terminal shell prompt with the user logged into your OS, but that doesn’t need to be true. If you weren’t logged in, you would pass the username to log in with before an @ while connecting:

joe@

(If your username is joe)

You’ll see this, for example, if you use SSH to connect to another Unix system running on another computer.

When trying to log in, Unix prompts you for your password:

On Mac OS and Windows with WSL, when you open the Terminal, you are automatically logged into your shell prompt with the user from your operating system. (Remember, Windows WSL users must open the Ubuntu terminal, not the DOS terminal.)

What’s in your User’s Home Folder?
Most people are familiar with the concept that your home folder contains subfolders like Documents, Photos, Music, etc. However, your user’s home folder is also a special place where many hidden files exist that configure nearly everything you will use in Unix. These hidden files begin with a . (period).

Normally, you won’t see hidden files. That is unless you explicitly ask to be shown them. In a future lesson, you’ll learn how to look at the hidden files.

For now, remember that hidden files exist in your home folder and they begin with a period (.).

They typically hold configuration settings that apply to your user. Specifically, configuration settings for the Unix commands you use.

The Special ~ Character

When you see ~ character in a filepath it means the current user’s home directory. It is a placeholder, and when Unix interprets it, it is as if you type the current user’s home directory.

For example ~/.gitconfig on my system is /Users/jasno/.gitconfig

This hidden file is where my Git configuration settings are stored. (You know it’s a hidden file because it begins with a .)

We’ll use this when constructing file path names— the ~ character is a shortcut that always refers to the home directory for the current user.