Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Yusuf Isah
Yusuf Isah

Posted on • Originally published atyuscode.hashnode.dev

Chapter 3 - Linux File System

Image description

Introduction

The Linux file system is a crucial component of the operating system, organizing files and directories in a hierarchical structure. Understanding the file system hierarchy and how to navigate through it is essential for effective system management. This chapter will cover the file system hierarchy, path navigation, and file types.

Table of Contents

File System Hierarchy

The Linux file system hierarchy follows a tree-like structure with the root directory at the top. Here are some important directories and their purposes:

/ (Root)

The root directory is the topmost directory in the Linux file system hierarchy. All other directories and files are located under this directory.

/bin

Contains essential binary executables required for system booting and single-user mode operation. Common commands likels,cp, andmv are located here.

/etc

Holds system configuration files and scripts. For example,passwd (user account information) andfstab (file system mount information) are found here.

/home

Contains the home directories for all users. Each user has a subdirectory under/home where their personal files and settings are stored.

/var

Stores variable data files such as logs, databases, and email. For example, system logs are located in/var/log.

/tmp

A temporary directory where programs can store temporary files. These files are typically cleared upon system reboot.

/usr

Holds user applications and utilities. It includes subdirectories like/usr/bin for user binaries and/usr/lib for libraries.

Path Navigation

Navigating the Linux file system efficiently is key to managing files and directories. Here are the basics of path navigation:

Absolute Paths

Absolute paths start from the root directory and specify the complete path to a file or directory. An example is shown below:

cd /home/user/documents
Enter fullscreen modeExit fullscreen mode

Relative Paths

Relative paths start from the current directory and do not begin with/\. Examples are shown below:

cddocuments/reports
Enter fullscreen modeExit fullscreen mode
  • mv ./file.txt ../../dir/: This command moves the filefile.txt from the current directory to thedir directory located two levels up. The dot. before/ in./file.txt means the current directory.

    mv ./file.txt ../../dir/
  • cp ../../dir/file.txt ./: This command will copy the filefile.txt from thedir directory located two levels up to the current directory../ refers to the current directory.

    cp ../../dir/file.txt ./

Special Directories

  • . Represents the current directory.

  • .. Represents the parent directory.

  • ~ Represents the home directory of the current user.

File Types

Understanding different file types in Linux is essential for managing the file system effectively.

  • Regular Files: Regular files contain data, text, or program instructions. They can be created using commands liketouch or text editors likenano andvim. We'll cover text editors in another chapter of this series.

  • Directories: Directories are special types of files that contain other files and directories. They are created using themkdir command.

  • Symbolic Links: Symbolic links are special files that point to other files or directories. They are created using theln -s command.

    ln-s /path/to/original /path/to/link

Another example is shown below:

```shln -s /home/user/documents/file.txt /home/user/Desktop/file_link```
Enter fullscreen modeExit fullscreen mode

The Linux command above creates a symbolic link calledfile_link on theDesktop, which points to the original filefile.txt in thedocuments directory. When you access the symbolic linkfile_link, you'll actually be accessing the original filefile.txt in thedocuments directory. If you edit the symbolic link, you'll be editing the original file!

Conclusion

Understanding the Linux file system hierarchy, path navigation, and file types is fundamental to effectively managing a Linux system. These concepts form the basis of file management and system organization, enabling you to perform various administrative tasks efficiently.

Feel free to leave comments and share this article. Follow my blog for more insights on Linux!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Hello. My name is Yusuf Isah, and I am a DevOps enthusiast from Nigeria. I am also passionate about Technical Writing.
  • Joined

More fromYusuf Isah

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp