- Learn Linux Quickly
- Ahmed AlKabary
- 588字
- 2021-06-11 18:43:43
The Linux filesystem
Alright, you are at the root of the tree and ready to climb up. In Linux, just like an actual tree, the beginning of the filesystem starts at the root directory. You can use the cd command followed by a forward slash to get to the root:
elliot@ubuntu-linux:~$ cd /
The cd command is short for Change Directory and is one of the most used commands in Linux. You can't move around in Linux without it. It's like your limbs (arms and legs), can you climb a tree without your limbs?
The forward slash character represents the root directory. Now to make sure you're at the root directory, you can run pwd:
elliot@ubuntu-linux:~$ pwd
/
And sure enough, we are at the root of the Linux filesystem. Whenever you are lost and you don't know where you are, pwd is here to rescue you.
Alright, while we are still at the root directory, let's see what's in there! Run the ls command to view the contents of the current directory:
elliot@ubuntu-linux:/$ ls
bin etc lib proc tmp var boot
dev home opt root sbin usr
To have a better view of the contents, you can use the long listing -l option with the ls command:
elliot@ubuntu-linux:/$ ls -l
drwxr-xr-x 2 root root 4096 Dec 28 15:36 bin
drwxr-xr-x 125 root root 12288 Jan 1 11:01 etc
drwxr-xr-x 21 root root 4096 Dec 26 23:52 lib
dr-xr-xr-x 227 root root 0 Jan 3 02:33 proc
drwxrwxrwt 15 root root 4096 Jan 3 02:35 tmp
drwxr-xr-x 14 root root 4096 Jul 24 21:14 var
drwxr-xr-x 3 root root 4096 Dec 29 07:17 boot
drwxr-xr-x 18 root root 4000 Jan 3 02:33 dev
drwxr-xr-x 3 root root 4096 Dec 26 23:47 home
drwxr-xr-x 3 root root 4096 Dec 27 15:07 opt
drwx------ 4 root root 4096 Dec 29 09:39 root
drwxr-xr-x 2 root root 12288 Dec 28 15:36 sbin
drwxr-xr-x 10 root root 4096 Jul 24 21:03 usr
This output gives you a lot of valuable information that we will discuss in detail in the upcoming chapters. But for now, we focus on the first letter in the first column of the output. Take a look at the first column of the output:
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
.
.
.
.
You will see that the first letter is d, which means that the file is a directory. The first letter reveals the file type. The last column of the output displays the filename.
OTHER FILES!
You will have more files under your root (/) directory. I have only chosen the most important and common ones that should exist on every Linux distribution. So don't freak out when you see way more files than those listed in this book.
Now each one of these directories has a special purpose, as you can see in the following table:

Table 2: Linux Directories Explained
You can also run the man hier command to read more about the Linux filesystem hierarchy:
elliot@ubuntu-linux:/$ man hier
Alright, now let's do further climbing on the Linux directory tree. Take a look at figure 1, and you will understand why we choose a tree to describe the structure of the Linux filesystem.

Figure 1: The Linux directory tree
The preceding figure only features very few files and by no means is a representation for the whole directory tree, as the Linux filesystem literally contains thousands of files. So you can think of the preceding figure as a subtree of the actual Linux directory tree.
- Mastering OpenLayers 3
- 實(shí)戰(zhàn)Java程序設(shè)計(jì)
- C語言課程設(shè)計(jì)
- 軟件品質(zhì)之完美管理:實(shí)戰(zhàn)經(jīng)典
- MongoDB,Express,Angular,and Node.js Fundamentals
- Yii Project Blueprints
- IBM Cognos Business Intelligence 10.1 Dashboarding cookbook
- Learning Unreal Engine Android Game Development
- 大話Java:程序設(shè)計(jì)從入門到精通
- Go語言底層原理剖析
- Visual C++從入門到精通(第2版)
- Responsive Web Design with jQuery
- Android初級(jí)應(yīng)用開發(fā)
- Python面向?qū)ο缶幊蹋ǖ?版)
- Android項(xiàng)目實(shí)戰(zhàn):博學(xué)谷