[RUBY] What is a terminal? -Absolute path & relative path-

What is a terminal

A terminal is one of the command lines and is a tool for giving commands to a PC. You will need it to execute the file of the code you wrote. Command line is an abbreviation for command line interface (CLI), which is a method of operating by typing the characters "command" from the keyboard to a PC. In contrast, the method of operating a PC using graphics is called a graphical user interface (GUI).


#### command

Here are some commands that are often used in the terminal.
cd command This is a command to move the directory.

ls command Shows files and folders directly </ strong> in your current directory.


##### What is a directory?

--A directory is like a container for files and is a folder. The directory has a hierarchical structure The directory at the top level is called the root directory </ strong>. The directory you are currently in is called the current directory </ strong>. Also, the directory that is displayed when you open the terminal is called the home directory </ strong>. The default home directory on Mac is / Users / username </ strong>.


Let's get back to the story. You can use the `cd` command to move between directories, but you can reach the desired directory by entering the path after the` cd` command.

There are two ways to write in that path. ・ Absolute pass ・ Relative path

Absolute path

--The absolute path is the path described from the root directory. It is a rule to write from /.

Terminal.


$ cd /

###Now you can go to the root directory

I think the default root directory for Mac is Macintosh HD, so use cd / to change to Macintosh HD. If you check the directory directly under it with the ls command, you can check and move even if you do not know the path.

Relative path

Relative paths do not start with /. You can move it by writing from the directory directly under the current directory.

Thank you for reading this article.

Recommended Posts