-
File addressing in Linuxlinux 2023. 2. 20. 16:59
In Linux, the file addressing system is a way of specifying the location of a file on the file system. The file system in Linux is structured like a tree, with the root directory at the top of the tree and subdirectories branching out from it. Here is an example of the file system hierarchy:
/ ├── bin ├── boot ├── dev ├── etc ├── home ├── lib ├── media ├── mnt ├── opt ├── proc ├── root ├── run ├── sbin ├── snap ├── srv ├── sys ├── tmp ├── usr └── varTo address a file on the file system, you need to specify its path, which is the sequence of directories that leads to the file. There are two types of paths in Linux: absolute paths and relative paths.
An absolute path specifies the full path to a file starting from the root directory. Here is an example of an absolute path:
/home/user/file.txtThis path specifies a file named file.txt in the user directory, which is inside the home directory, which is at the root of the file system.
A relative path specifies the path to a file relative to the current working directory. Here are some examples of relative paths:
./file.txt ../folder/file.txtThe first path specifies a file named file.txt in the current working directory, while the second path specifies a file named file.txt in a directory named folder, which is one level up from the current working directory.
Here is a table of common file addressing options in Linux:
OptionDescription
/ Root directory . Current directory .. Parent directory ~ Home directory And here are some simple examples of how to use these file addressing options:
- To navigate to the root directory, use the following command:
cd /- To navigate to the current directory, use the following command:
cd .- To navigate to the parent directory, use the following command:
cd ..- To navigate to the home directory, use the following command:
cd ~- To navigate to a directory using an absolute path, use the following command:
cd /path/to/directory- To navigate to a directory using a relative path, use the following command:
cd path/to/directoryNote that the file addressing system in Linux is a fundamental concept that is used in many commands and utilities. Understanding how to navigate the file system and address files is essential for working with Linux.
'linux' 카테고리의 다른 글
Set default permissions for files and directories in Linux (0) 2023.02.21 What is inode (0) 2023.02.20 How to display file contents in linux (cat) (0) 2023.02.20 How to remove directory in linux (rmdir) (0) 2023.02.20 How to create a file in linux (touch) (0) 2023.02.20