top of page

Posts

[Linux] What do “~”, “$” and “#” Mean at the End of the Command Line?




Related terms and commands

Terms

Description

​Directory

It’s a container for files and is called a folder in Windows.

You can create new files and directories in the current directory.


Layered structure

It refers to the structure of a directory within a directory and a directory within the directory….

It is also called a tree structure because it branches out like a tree.


Root directory

It is the top-level directory among the directories organized in a hierarchical structure.

Home directory

The home directory is the base directory for a logged-in user.

Within that directory, basically the user has the freedom to create files and directories.

For example, when creating a user named "dog", the default home directory would be /home/dog.


Current directory

The current directory or working directory is also referred to as the present working directory.

It refers to the directory in which the logged-in user is currently located.


Absolute path (full path)

Refers to the route (path) from the root directory to the destination.

Relative path

Refers to the path from the current directory to the destination


Command

Description

cd

It stands for change directory.

It is used for changing the directory.


pwd

It stands for print working directory.

It displays the absolute path from the root directory to the current directory.



What do the symbols on the Linux command line mean?


I’m going to explain each of the symbols' meanings.

[dog@hostname ~]$
[root@hostname ~]#

「~」

The home directory of the logged-in user is displayed as "~" to represent its abbreviation.


If the current directory of the "dog" user is their own home directory (/home/dog), it will be displayed as "~" instead of "/home/dog".


You can use the "pwd" command to confirm it

[dog@hostname ~]$
[dog@hostname ~]$ pwd
/home/dog

Let's move to "/var/log" as a point of comparison

[dog@hostname ~]$ cd /var/log
[dog@hostname log]$


As you can see after the hostname, it became “log” instead of “~”.


This is because the current directory was changed to /var/log by moving the directory with the cd command.


Therefore, the output of the pwd command looks like the following

[dog@hostname log]$ pwd
/var/log

「$」

The “$” in Linux has many meanings and uses, though, the “$” at the end of CLI indicates that you are an ordinary user operating on the command line.

[dog@hostname ~]$

「#」

The “#” at the end of the CLI indicates that you are operating the command line as an administrator user (root).

[root@hostname ~]#

Difference between administrator user and general user

The main difference is the level of authority that can be handled.

The administrator users have all privileges as standard, but general users have limited privileges.

Although administrator privileges can be granted to general users, it is recommended to give the minimum necessary privileges for the intended purpose.


This is one of the operational principles of authority and is called the Principle of Least Privilege (PoLP).


Also, Linux allows setting operating permissions to user-level on each file and each directory basis.


I’m not going to explain here, but you can look up “Linux permissions” if you are interested.


Thank you.



This blog post is translated from a blog post written by Sota Ichiki on our Japanese website Beyond Co..


bottom of page