Basic introduction to Linux and file systems

Source: Internet
Author: User

Linux and File system introduction 1 Internet Industry Status

In the server-side market:

    • Super computer
      • The November 2014 data shows that 485 systems in the top 500 systems are running Linux publishing systems, with only one running Windows system
      • Up to now, there are 22,851,693 processors running Linux systems, while Windows systems are only 30,720
    • Cloud computing

      The 2014 Linux Foundation wrote a report that found that 75% of large companies use Linux as their primary platform, compared with only 23% of Windows systems.

Mobile-Market:

Linux-based Android, the market share of andriod devices rose from 81.4% last year to 83.6% in the third quarter of 2014 with smartphone shipments
.

Embedded system:

research figures from 2013 show that about half of embedded systems are planned to be Linux-based. More and more Linux-based smart hardware devices, such as smart routers, are also being created.

As this series of articles is mainly about the Internet software development and testing, according to the current industry trends, Linux system has become the Internet industry's most important productivity platform, the relevant practitioners fully need to learn and understand the Linux system.

2 Typical computer systems

A typical computer system is composed of two parts: software and hardware.

The hardware system is composed of the following parts:

    • Cpu
    • Memory
    • External input/output (IO) devices

The components of the sections are as follows:


The software of the computer is the running program on the hardware and the corresponding document.

The operating system is the most basic software system running on the computer hardware, and the common system is as follows:

    • PC-Side
      • Windows
      • Linux
      • Mac OS
      • Other
    • Mobile side
      • Ios
      • Android
      • Windows Phone
      • Other

In today's mobile devices have become so popular in the era, I believe you have been able to realize that the operating system is not just windows, but based on a certain principle to be able to blossom the basic software system.

3 Basic Linux Introduction

As mentioned earlier, a basic computer system consists of "hardware" and "Software", a Linux device, the main composition as shown:


In general, we refer to the Linux system, specifically the intermediate kernel level of the section, we see the desktop of Linux desktops, for example: Kde,gnome are just ordinary applications. The core of Linux is its kernel, which is the link between applications and hardware programs.

There are two types of human-computer interaction in Linux:

    • Graphical Interactive interface
    • command-line interaction Interface (CLI)

Graphical interface, the user from under Windows should not be unfamiliar, but the graphical interface is not the essence of Linux, as a senior computer workers, should be able to see through the phenomenon of nature, all the essence of computing software is actually data processing and circulation. Desktop is not Linux, so it's going to move away from desktop and turn to Linux for learning and research.

4 Linux two ways of interacting

To look at the files under the root file system of Linux as an example, compare the differences between the two modes of interaction.

Under Desktop, open the file Management graphics application:


Enter the LS command below the CLI:

?  /  lsbin      deepinhost  etc         initrd.img.old  lost+found  opt   run   sys  varboot     Dev         home        lib             media       proc  sbin  tmp  VMLINUZCXASSOC  disk        initrd.img  lib64           mnt         root  srv   usr  vmlinuz.old

In the graphical interface through different views or properties can see more files directory and information, also in the CLI interface can enter a different command parameters, to obtain the corresponding file directory text description information.

Similarly, Linux's other common system management tools, such as:

    • Disk Management
    • Network management
    • Process Management
    • Software Management

Have a corresponding desktop program and CLI program to provide management, follow-up will be detailed, not mentioned here. In summary, the two interactions are essentially equivalent in terms of bearer information, and even the CLI can provide even more operations than a graphical user interface. Because the graphical user interface can be said to be a higher-level application, it is a graphical representation of the further encapsulation of the CLI functionality.

If you are a normal desktop-level consumer, master graphical interaction and graphical interface applications, but for Linux developers, you must be familiar with CLI commands to complete the various operations and calls to the system.

5 File directory and system

Unlike Windows, all directories under Linux are from the "/" directory and do not partition the hard disk into C, D, E drives. All file systems under Linux are derived from the same root node, and all disks must be mounted under the corresponding directory in the file system.


Both Windows and Linux have the following processes:

    • The newly purchased physical hard disk must be partitioned, regardless of whether it is in one or more zones. This partition is actually data-entry for the partition table of the disk, which is related to the boot location

    • The partition's hard disk must be formatted with the appropriate file system
      • Windows systems are generally NTFS file systems
      • Linux systems are generally EXT4 file systems
    • The formatted disk must be mounted to the appropriate file directory of the operating system
      • Windows is the equivalent of a root directory on top of the c/d/e disk, but apparently it does not actually follow this idea to popularize the system. The Windows system automatically helps the user to mount the partition to the directory, which automatically mounts the disk partition to the "directory" of the c/d/e disk
      • Linux, in addition to automatically mount the root partition startup items, the other needs to be configured by the user.

In a Linux system, the basic organizational unit of information is called a file. For physical devices, Linux also provides a simplified way of accessing the file system, which allows users to use the same commands to handle common files and physical devices.

6 standard file structure

Under the root directory, list the main directories for Linux:

? /ll Total dosage 104Kdrwxr-xr-x2Root root4.0K September - Ten: -BINDRWXR-xr-x3Root root4.0K September7  the: toBOOTDRWXR-xr-x -Root root4.3K September -  +: -DEVDRWXR-xr-x3Root root4.0K September7  -: GenevaDISKDRWXR-xr-x141Root root 12K September -  +: -ETCDRWXR-xr-x4Root root4.0K August to  A: onHOMEDRWXR-xr-x ARoot root4.0K September7  -: onLib Drwxr-xr-x4Root root4.0K September One  +: onMEDIADRWXR-xr-x5Root root4.0K August to  -: -MNTDRWXR-xr-x8Root root4.0K August to  the: *OPTDR-xr-xr-x211Root root0September +   -procdrwx------ -Root root4.0K September -  -: -ROOTDRWXR-xr-x ARoot root720September -  +: -RUNDRWXR-xr-x2Root root 12K September7  -: onSBINDRWXR-xr-x2Root root4.0K April - xx: toSRVDR-xr-xr-x -Root root0September +   -SYSDRWXRWXRWT8Root root4.0K September -  A: toTMPDRWXR-xr-xTenRoot root4.0K April - xx: +USRDRWXR-xr-x -Root root4.0K August to  -: thevar ...

With regard to the file description under the root directory, Linux is a set of criteria for reference: FHS (Filesystem Hierarchy Standard).

This article describes only the features of the main catalog.

Boot directory
includes system boot program, Linux kernel program file Vmlinuz, disk memory image file INITRD, and grub initialization bootstrapper and configuration file

In addition to the boot directory, the system must have 5 directories to boot:

    • Dev

      System device directory. Under the Linux system, any device corresponds to one or more device files, for example, the disk corresponds to the/dev/sd* file

    • etc

      Configuration text file for Linux system operation

    • Lib

      This directory contains the system boot process, and the need to run system commands to coerce kernel modules and a variety of dynamic link shared library files

    • Sbin

      System commands used by the Super users group

    • Bin

      Various common command programs shared by system administrators and ordinary users

Memory methods

Directory abbreviation splicing: DELSB, delete sb, who deleted this directory, who is that what what ^_^

Other directories that are most often encountered:

  • Home

    The root directory of the user home directory, each add a new user, the system will add a directory under this directory with the same user name, store user-related configuration and data

  • Media

    mount point for Removable Storage media

  • Mnt

    Temporary mount points for file systems

  • Opt

    installation directory for additional software such as applications

  • Var

    Store various variable-length data files, such as log files, etc.

  • Usr

    Unix Soft Resource Storage System provides a variety of shared data (user commands, library functions, header files, documents, etc.)

  • Root

    Super Administrator's home directory

  • Tmp

    Temp file directory, automatically emptied after system restart

  • Proc

    The root directory of the process file system is a virtual file system that can obtain a lot of information about the system's running state by reading the file in this directory: CPU, memory, uptime, etc.

For a detailed description of the other directories and their subdirectories under the root directory and the differences between the directories, please refer to the latest update on the Linux website for FHS (which is basically updated every year).

7 File description and Permissions

In Linux under the face of the operation of the file has a very important concept, that is: file permissions. Many beginners think that Linux is not good to use, basically a big reason is to stop at this place is not in-depth study down. Because for any system, the various operations of file data is certainly very high-frequency interaction, under the Linux system, if you do not understand the concept of file system permissions, then in the operation of the file data, will inevitably encounter various obstacles, and then forced to abandon the continuation of the Linux research.

In the graphical interface, the file's permissions are visualized by the file icon (or x number, etc.), and in the CLI interface, it is displayed by a special text tag:

?  /  ll | grep bindrwxr-xr-x   24. 0K  :  bindrwxr -xr-x   2 root root  12K  : sbin

For a total of 7 paragraphs, the description of the table of contents and documents:

    1. Permissions: File details, mainly permissions information/type information
    2. Link: Number of hard links or directory subdirectories of a file
    3. User: File Owner
    4. Group: Groups to which the file belongs
    5. Size: File size
    6. Time: File creation times
    7. File: Name

Memory methods

The English abbreviation for paragraph seven is ligatures:

Plugstf

Reference memory: Insert TF Card

    • Plugs: Plug
    • TF: The small SD expansion card currently used on the phone

PLUG Part is an important part of the authority, operating under Linux, the most important basic concept is the concept of file permissions, if this is not clear, you will often encounter various obstacles.

7.1 File Types and permissions

Typical text file permission descriptor characters are as follows:

Drwxr-xr-x

A total of 10 bits, grouped by function, can be divided into 4 functional segments, as shown in the following table:

File permissions and type information
type User Rights Group Permissions Additional Permissions
1 3 3 3
D Rwx R-x R-x

The first paragraph represents the type of file:

    • D:directory, indicating the directory

    • -: Dash "empty" means ordinary files, for example: text file, binary file

    • L:link, which represents a linked file, for example: shortcut

    • B:block, which represents a block device, for example: disk

    • C:character, which represents special files for characters, such as console terminal/printer, etc.

    • P:pipe, managing Files

    • Other types

      Generally for the application layer developers, the most contact is the directory and ordinary documents two kinds, other interested can go to specific access to the corresponding information.

There are three types of pure file manipulation permissions:

    • R readable
    • W Writable
    • X executable

The user identity for file operations is divided into three categories:

    • U User Direct dependent users
    • G group files belong to groups
    • O other users who do not belong to the above two

The three paragraphs of the file permissions, which correspond to different user identities for this file, do not allow any of the users to do anything more than their permissions on the file.

Pay special attention to the Linux system:

    • The type of the program is not determined by the extension.
    • Rather than using the. exe to determine whether the program is executable, the X property indicates that the file can be executed
    • Unlike files, the x attribute of the directory indicates that the work path can be switched to the directory

Permissions related to the 9-bit, respectively by 1 or zero to indicate that it does not have the appropriate permissions, it will produce some of the following common numeric values to represent the permissions of the file (using an integer less than 8 to represent the state value of 3 bit):

    • 777

      111 111 111 for U,g,o all read/write/execute Full development permissions

    • 666

      110 110 110 Indicates that the u,g,o is read-write but not executable

    • 644

      110 100 100 means that for U is read-write, for u and O is read-only

So if you want to modify a file to be read-write and execute for all users/groups/others, you can execute the following command:

chmod 777 Xxx_file

Or use a way to add permissions:

chmod a+rwx xxx_file

With regard to file permissions and operator qualification, the CLI provides a rich command-line tool that basically allows the user to complete all the operations required for the file system. Specific commands and operations, you can consult the corresponding books and documents, more practice, skilled operation can be.

7.2 Other descriptive information
    • File size
    • Creation time
    • File name

The use of this information is as intuitive and unambiguous as its name, and is not discussed here.

8 basic operations for files and directories

Basic operations on files and directories include, but are not limited to:

    • Directory Creation and deletion
    • File creation/modification/deletion
    • The movement of a file or directory
    • File or directory name modification
    • File Lookup

And so on, the use of these tools and proficiency, belong to the relatively low level of knowledge, understanding the theoretical framework of the previous, only need to constantly repeat the operation of the exercise can be, so that the brain can quickly operate the basic skills.

These command lines, which are everywhere in the corresponding Linux introductory books, or Web technical articles, are also omitted from the table.

9 Summary

The goal of this article is to the minimum space, as soon as possible to Linux beginners to build the overall understanding of Linux, the specific parts of the extension of details and tools, this article is limited in length, do not do a detailed introduction. The fragmentation of the information, there is a low threshold of access (through the web search engine), and the low threshold of the strengthening of learning methods (continuous exercise, practice makes perfect), is not the focus of this article, and the following series of articles, mainly in the assumption that practitioners have a certain basis of the Linux operation of the case, and expand the Linux application domain skills.

Finally, a word: The tool is important, but not the purpose, for the tool, the best estimate is the "free time to continue to strengthen practice, skilled operation," so that it becomes the habit of the brain, and then have more time and more efficient way to solve high-level problems.

Author: Harmo ha mo
Author Introduction: Https://zhengwh.github.io
Technical Blog: Http://www.cnblogs.com/beer
Email: [Email protected]
Qq: 1295351490
Time: 2015-09-18
Copyright Notice: Unlawful transmission for commercial purposes is prohibited without permission
To contact or reward: Http://zhengwh.github.io/contact-donate.html

Basic introduction to Linux and file systems

Related Article

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.