[Linux] What do “~”, “$”, and “#” mean on the command line? [For beginners]
table of contents
Hello, I'm inusuki from the System Solutions Department, and I'm an omnivorous otaku who loves games and anime.
This time, for beginners, I will write down the symbols that are often seen on the Linux CLI (command line interface).
Related terms & commands collection
term | explanation |
directory | In Windows, this is a container for storing files.
You can create new files and directories within a directory. |
Hierarchical structure | It refers to the structure of directories within directories, directories within those directories, etc.
Also, because it branches like a tree, it is also called a tree structure. |
root directory | This is the topmost directory in a hierarchical structure.
The root is written as (/). |
home directory | This is the base directory for logged in users.
Users are basically free to create files and directories within that directory. For example, when you create the dog user, the default home directory is /home/dog. |
current directory | Also called the current directory or working directory.
This refers to the directory where 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 route (path) from the current directory to the destination. |
command | explanation |
cd | change directory It is an abbreviation of
As the name suggests, it is used to move directories. |
pwd | print working directory It is an abbreviation of
Displays the absolute path from the root directory to the current directory. |
What do the symbols on the Linux command line mean?
It's this kind of guy.
I will explain each one.
[dog@hostname ~]$
[root@hostname ~]#
「~」
The home directory of the logged-in user is abbreviated as "~".
If the dog user's current directory is the user's own 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
Move to /var/log for comparison.
[dog@hostname ~]$ cd /var/log [dog@hostname log]$
The end of hostname is now “log” instead of “~” (Yutane!)
This is because the current directory has changed to /var/log by moving the directory using the cd command.
Therefore, 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 general 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 used to call this a hashtag. #Bedtime engineer
[root@hostname ~]#
Difference between administrator user and general user
The main difference is the level of authority that can be used.
The administrator user has all privileges by default, but the initial general user only has limited privileges.
Although you can grant privileges to general users with administrator privileges, we recommend granting the minimum privileges that suit your purpose.
This is one of the principles of privilege management and is called the principle of least privilege
In addition to user-level permissions, Linux also allows you to set operational permissions for individual files and directories.
I will not explain it here, but if you are interested, please search for Linux permissions
Thank you for viewing.