Linux Documentation and directory structure

Source: Internet
Author: User

Linux File System architecture

The organization of the Linux directory structure differs greatly from Windows. First Linux does not have the concept of "disk (C-disk, D-disk, e-disk)". The hard disk partition that has already established the file system is mounted to a directory, and the user implements the disk read and write by manipulating the directory.

Linux is not a system directory like Windows, and Linux uses a forward slash "/" instead of a backslash "\" to identify the directory.

Windows directory:

Linux directory:

Linux is the first to create a root "/" file system, all directories are also derived from the root directory.

After logging into the system, enter the command in the current command window:

LS/

View results such as:

Under Linux, all files and directories start with the root directory, the source of the directory and the file, and then branch down as if it were a tree, so this directory is configured as: directory trees.

What are the characteristics of the directory tree?

    • The starting point of the directory tree is the root directory (/,root);
    • Each directory can not only use the local file system, but also can use the file system on the network, you can use the NFS server to mount a specific directory.
    • Each file name in this directory tree, including the full path, is unique.

Directory tree Schema

The following is an explanation of these directories:

  • /bin:
    The bin is the abbreviation for binary, which holds the most frequently used commands.

  • /boot:
    Here are some of the core files used when starting Linux, including some connection files and image files.

  • /dev:
    Dev is the abbreviation for device, which stores external Linux devices, and accesses the device in Linux in the same way that it accesses files.

  • /etc:
    This directory is used to store all the configuration files and subdirectories required for system administration.

  • /home:
    The user's home directory, in Linux, each user has a directory of their own, generally the directory name is named after the user's account.

  • /lib:
    This directory contains the system's most basic dynamic connection shared library, which acts like a DLL file in Windows. These shared libraries are required for almost all applications.

  • /lost+found:
    This directory is generally empty, and when the system shuts down illegally, some files are stored here.

  • /media:
    The Linux system automatically identifies some devices, such as a USB flash drive, an optical drive, and so on, and when identified, Linux will attach the identified device to this directory.

  • /mnt:
    The directory is provided to allow users to temporarily mount other file systems, we can mount the CD-ROM drive on the/mnt/, and then enter the directory to view the contents of the CD-ROM.

  • /opt:
    This is the directory for the host to install additional software. For example, if you install an Oracle database, you can put it in this directory. The default is empty.

  • /proc:
    This directory is a virtual directory, it is the mapping of system memory, we can access this directory directly to obtain system information.
    The contents of this directory are not on the hard disk but in memory, we can also directly modify some of the files inside, such as can be used to block the host ping command, so that others cannot ping your machine:

    1>/proc/sys/net/IPv4/icmp_echo_ignore_all   
  • /root:
    This directory is a user home directory for system administrators, also known as super-permissions.

  • /sbin:
    S is the Super user's meaning, which is stored in the system administrator's use of the System Management program.

  • /selinux:
    This directory is a unique directory of Redhat/centos, SELinux is a security mechanism, similar to Windows Firewall, but this set of mechanisms is more complex, this directory is to store selinux related files.

  • /srv:
    This directory holds data that needs to be extracted after some services are started.

  • /sys:
    This is a big change in the linux2.6 kernel. This directory installs a new file system Sysfs that appears in the 2.6 kernel.

    The Sysfs file system integrates information from the following 3 file systems: The proc file system for process information, the Devfs file system for the device, and the Devpts file system for the pseudo-terminal.

    The file system is a visual reflection of the kernel device tree.

    When a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem.

  • / tmp:
    This directory is used to store some temporary files.

  • / usr:
    This is a very important directory, the user's many applications and files are placed in this directory, similar to the Program Files directory under Windows.

  • /usr/bin:
    The application that the system user uses.

  • /usr/sbin:
    Super users use the more advanced hypervisor and System daemon.

  • /usr/src: The default drop directory for the kernel source code.

  • / var:
    This directory is stocked with things that are constantly expanding, and we are accustomed to placing directories that are often modified in this directory. Includes various log files.

In the Linux system, there are several directories are more important, usually need to be careful not to accidentally delete or arbitrarily change the internal files.

/etc: Also mentioned above, this is the configuration file in the system, if you change a file in this directory may cause the system will not start.

/bin,/sbin,/usr/bin,/usr/sbin: This is the placement directory of the system preset execution files, such as LS is in the/bin/ls directory.

It is worth noting that,/bin,/usr/bin is the instruction for the system user (except for root), and/sbin,/usr/sbin is the command to use for root.

/var: this is a very important directory, the system ran a lot of programs, then each program will have a corresponding log generated, and these logs are recorded in this directory, specifically in the/var/log directory, the other mail preset placement is also here.

Related Operations for Directories

We know that the command to switch directories is a CD, then first we need to know how to switch directories, this must be carefully remember!

.    Current directory:    Previous level Directory-    previous working directory-    home directory where the current "user" resides

It is important to note that there are two directories under all directories, namely "." and "." ", representing the current directory, the upper directory, respectively! So how do you prove its existence?

Command: Ls-la/
View command explanation: Man ls (help command under Linux)
Conclusion: Ls-list directory Contens (List contents)
Ls-la/ Display all contents of list/directory in vertical format

Next, look at the commonly used directory processing directives:

CD: (change directory, changing Directories) PWD: (show current directory) MkDir: (Create a new directory) RmDir: (Delete an empty directory)
cd command, transform directory

CD is the abbreviation for Change directory, which is a command to transform the working directory, note that there is a space between the command and the directory.

mkdir, create a new directory

MKDIR is the abbreviation for Make directory, which is used to create a new directory, which, by default, is created at the first level.

For example I want to build/home/oldboy/python directory, I must have home/home, then/home/oldboy, finally/home/oldboy/python, if there is no/home/oldboy, you can not build a python directory!

Visible efficient creation of the directory with the-p parameter, you can directly execute the command "Mkdir-p/home/oldboy/python", the system will automatically add the/home,/home/oldboy,/home/oldboy/python in turn to establish the directory, is not very convenient, ^ ^

rmdir, delete empty directory

When I want to delete an empty directory, I use RmDir, for example, I want to delete the Oldboy directory I just created, and/tmp/oldboy/python, you can use "RmDir Oldboy", but note that rmdir can only delete empty directories.

Delete command to use "RM-RF" correctly
Path to Linux

Students should configure the environment variable (path) under Windows, knowing that the system will search for executable files in the directory defined by path, according to the path setting.

So how do you see the PATH environment variable under Linux?

Execute command: Echo $PATHecho command is printed meaning $ sign followed by path, indicating output path variable

PATH (must be uppercase) This variable is made up of a bunch of directories, the delimiter is ":", and unlike Windows ";" No.

Absolute path vs. relative path

Under Linux, pay special attention to the filename/path notation, which defines the so-called path as an absolute path (absolute) and a relative path (relative). The two filenames/paths are written according to this:

    • Absolute path: A filename or directory name, such as/home/oldboy/test.py, that is written by the root directory (/).
    • Relative path: The name of the file in relation to the current path. For example./home/oldboy/exam.py or. /.. /home/oldboy/exam.py, simply speaking, as long as the beginning is not/, is the relative path

So you have to understand that the relative path is represented by the relative path to your current path.

For example, you are now in the/home directory, such as to enter the/var/log path, how to write it?

    1. Cd/var/log (absolute path)
    2. Cd.. /var/log (relative path)

Results

Because you are under/home, so you have to go back to the previous level. /) in order to continue to/Var, pay special attention to:

    • . : Represents the current directory, or it can be used./to represent
    • .. : Represents the previous level of the directory, you can also use the. /to indicate

Split Line----

This is a. With. The catalog concept is very important and usually you will see the CD. or Python. /home/oldboy/exam.py is the Python code that represents the previous level and executes the relative path!

Linux Documentation and directory structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.