Once we are in a terminal in a Linux setting, it is no longer a point and click interface for making folders or moving files into folders. In a Windows setting, it has a graphical user interface (GUI) and it is easy to visualize where the folders are and is easy to move folders around. They use the term folder because it comes from putting files into folders.
In a Linux setting, we use the term directory which has exactly the same meaning as folder. In a Linux setting, there is a GUI but terminals are used more often. Furthermore, once we ssh into another machine, we only have a terminal. Therefore, it is useful to know how to make directories and how to move between directories in a terminal.
As mentioned in the previous post, making a directory is fairly simple which is mkdir name (ex. mkdir Project). However, we need to consider where we want to create before making one. A question arises how to get there.
For example, in your machine, you have the following directory structure.
There are two types of paths we can consider when moving around: absolute path and relative path. Absolute path always starts from the root to where you want to go and it doesn’t matter where you are currently located. For example, if you are inside the Jinny directory and you want to be in the Guest directory, you can use an absolute path and type cd /home/Guest. One advantage of the absolute paths is you don’t need to know where you are now. From anywhere, the absolute path of the destination is always the same. By the way, if you want to check where you are, you can use the command pwd which shows the path of the working directory.
Contrast to the absolute path, the concept of relative path is where the destination directory is relative to where I am right now. For example, if you are inside the Jinny directory and you want to go to the Guest directory, you can use relative path and type cd ../Guest. The first ../ makes you get out of the Jinny directory and the second Guest makes you go into the Guest directory. One advantage of relative paths is you can type less. However, you need to think about how the destination is related to where I am now.
In a Linux setting, we use the term directory which has exactly the same meaning as folder. In a Linux setting, there is a GUI but terminals are used more often. Furthermore, once we ssh into another machine, we only have a terminal. Therefore, it is useful to know how to make directories and how to move between directories in a terminal.
As mentioned in the previous post, making a directory is fairly simple which is mkdir name (ex. mkdir Project). However, we need to consider where we want to create before making one. A question arises how to get there.
For example, in your machine, you have the following directory structure.
- /
- home
- Jinny
- /
- home
- Jinny
- Guest
There are two types of paths we can consider when moving around: absolute path and relative path. Absolute path always starts from the root to where you want to go and it doesn’t matter where you are currently located. For example, if you are inside the Jinny directory and you want to be in the Guest directory, you can use an absolute path and type cd /home/Guest. One advantage of the absolute paths is you don’t need to know where you are now. From anywhere, the absolute path of the destination is always the same. By the way, if you want to check where you are, you can use the command pwd which shows the path of the working directory.
Contrast to the absolute path, the concept of relative path is where the destination directory is relative to where I am right now. For example, if you are inside the Jinny directory and you want to go to the Guest directory, you can use relative path and type cd ../Guest. The first ../ makes you get out of the Jinny directory and the second Guest makes you go into the Guest directory. One advantage of relative paths is you can type less. However, you need to think about how the destination is related to where I am now.