CentOS Linux Directories
Directories are folders created under
file system.
The easiest way to compare both structure
is to run "tree" command at both MS Windows and CentOS Linux,
you will notice that MS Windows start it
root(top) directory is C:\ while for Linux is \ (the following shows .
means current directory). Example below, I am do a level tree listing
"tree -L 1".
tree -L 1
.
|-- bin
|-- boot
|-- dev
|-- etc
|-- home
|-- lib
|-- lost+found
|-- media
|-- misc
|-- mnt
|-- net
|-- opt
|-- proc
|-- root
|-- sbin
|-- selinux
|-- srv
|-- sys
|-- tmp
|-- usr
`-- var
|
Going to explain each File and Directory
is very tedious and boring job, I will only explain a few important
directories
|
Directory |
Description |
| boot |
It
contains all the information and configuration that Linux use for
boot up |
| dev |
Linux
consider hardware as files, it will stored here |
| lib |
the
library files, like MS Windows's system32's dll |
| sbin |
root's
command is stored here |
| tmp |
temporary files storage |
| media |
all
cdrom, dvd, usb is connected here |
| home |
user
home directory |
| root |
root's
home directory |
| var |
store
various information such as logs, mail spool. A very busy and
dynamic directory |
|
lost+found |
stores
recovered files from after scandisk check if the system was crashed
|
How do we do we identify the system
listing a file or directory?
Look for the first character of the first
column of it start with "d". In our example, we have "." , ".." and "myDir"
are the directory. However, please take note that "." and ".." is not a
folder. This special symbol "." represent the current folder and ".."
represent the parent folder.
|
ls -la
total 56
drwxr-xr-x 3 root root 4096 Nov 28 11:49 .
drwxr-xr-x 25 root root 4096 Nov 28 11:14 ..
-rw-r--r-- 1 root root 0 Nov 28 10:01 A.txt
-rw-r--r-- 1 root root 0 Nov 28 10:55 .hiddenfile
drwxr-xr-x 2 root root 4096 Nov 28 11:49 myDir
-rw-r--r-- 1 root root 16 Nov 28 11:17 My Work
-rw-r--r-- 1 root root 13 Nov 28 11:19 My Work Linux
-rw-r--r-- 1 root root 14 Nov 28 11:21 My Work of Centos
|
How we only list for directories?
In this example we are listing ("ls") the
any folder (using wildcard *). Now we have correct answer : myDir,
which have no files in side (total 0)
|
ls -l * d/
ls: d/: No such file or directory
-rw-r--r-- 1 root root 0 Nov 28 10:01 A.txt
-rw-r--r-- 1 root root 16 Nov 28 11:17 My Work
-rw-r--r-- 1 root root 13 Nov 28 11:19 My Work Linux
-rw-r--r-- 1 root root 14 Nov 28 11:21 My Work of Centos
myDir:
total 0
|
Special directory symbols
|
Symbols |
Descriptions |
| / |
root directory |
| . |
current directory |
| .. |
parent directory |
| ~ |
user home directory |
Working with directories
Based on above table we perform some test
here. The below example shows the path that we manipulated using above
special directory symbols tables.
[root@srv1 demo]#
ls
.
A.txt myDir My Work My Work Linux My Work of Centos
[root@srv1 demo]#
ls ..
bin boot demo dev dvd etc home lib lost+found media misc mnt net
opt proc root sbin selinux srv sys tmp usr var
[root@srv1 demo]#
cd ~
[root@srv1 ~]# pwd
/root
[root@srv1 ~]#
cd /
[root@srv1 /]# pwd
/
[root@srv1 /]#
|
|