[Linux] What do “~”, “$”, and “#” mean on the command line? [For beginners]

Hello, I'm inusuki from the System Solutions Department, a jack-of-all-trades otaku who loves games and anime

This time, for beginners, I will write down here the symbols that you will often see on Linux CLI (command line interface)

Related terms and commands

term explanation
directory It is a container for storing files, similar to a folder in Windows

You can create new files and directories within a directory

Hierarchical structure It refers to a structure in which there is a directory within a directory, within that directory, and so on

Also, because it branches out like a tree, it is also called a tree structure

Root Directory This is the topmost directory in a hierarchical directory structure

The root is represented as (/)

Home Directory The directory that serves as the base for the logged-in user

Users can essentially create files and directories freely within that directory

For example, when you create a user named dog, the home directory will be /home/dog by default

Current directory It is also called the current directory or working directory

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

Absolute path (full path) It refers to the path from the root directory to the destination
Relative paths This refers to the path from the current directory to the destination

 

command explanation
CD change directory is an abbreviation for

As the name suggests, it is used to move between directories

pwd print working directory is an abbreviation for

Displays the absolute path from the root directory to the current directory

What do the symbols on the Linux command line mean?

This is the kind of guy it is

I will explain each one

[dog@hostname ~]$

[root@hostname ~]#

「~」

The home directory of the logged-in user is displayed as "~"

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

Let's check using the pwd command

[dog@hostname ~]$

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

Go to /var/log for comparison

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

The hostname is now followed by "log" instead of "~" (yay!)

This is because the current directory changed to /var/log when you changed directories with the cd command

So the pwd command results in the following output:

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

「$」

"$" in Linux has various meanings and uses,

The "$" at the end of the CLI indicates that you are operating the command line as a normal user

[dog@hostname ~]$

「#」

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

There was a time when I called this a hashtag. #BeginningEngineer

[root@hostname ~]#

Differences between administrator users and general users

The main difference is the level of authority they can handle

The administrator user has all the privileges by default, but the initial general user has only limited privileges

Although administrators can grant permissions to general users, we recommend granting the minimum level of permissions appropriate for the purpose

This is one of the principles of privilege management, and is called the Principle of Least Privilege (PoLP) .

 

In addition to user-level permissions, Linux also allows you to set operation permissions on a file or directory basis

I won't go into detail here, but if you're interested, try searching for Linux permissions

 

Thank you for viewing.

If you found this article helpful , please give it a like!
26
Loading...
26 votes, average: 1.00 / 126
21,510
X facebook Hatena Bookmark pocket

The person who wrote this article

About the author

inusuki

Joined Beyond as a new graduate in April 2021.
Maybe it's because I have a problem with my output, but sometimes I say strange things.