Linux Learning Note II ———— files and directories for Linux systems

Source: Internet
Author: User
Tags file permissions

One, Windows and Linux file system differences

1, under the Windows platform, open "computer", we see a drive letter:

Each drive has its own root structure, which creates multiple tree-parallel scenarios:

2, under Linux, we do not see these drive letter, we see the folder (directory):

Ii. Unix-like system directory structure

1, Ubuntu does not have the concept of a drive, there is only one root directory/, all files are under it:

2. Linux Directory

  • /: root directory, only directory under the general root directory, under Linux there is only one root directory. Everything starts here. When you enter "/home" in the terminal, you are actually telling the computer to start with the/(root directory) and then go to the House directory.
  • /bin: or/usr/bin: A directory of executable binaries, such as common commands ls, tar, MV, Cat, and so on.
  • /boot: Place some files used by Linux system startup, such as kernel files of Linux:/boot/vmlinuz, System Boot Manager:/boot/grub.
  • /dev: Store the device files under the Linux system and access a file in that directory, equivalent to accessing a device, which is commonly used to mount the optical drive mount/dev/cdrom/mnt.
  • /etc: the directory where the system configuration file is stored, the executable file is not recommended in this directory, the important configuration files are/etc/inittab,/etc/fstab,/ETC/INIT.D,/etc/x11,/etc/sysconfig,/etc/ Xinetd.d.
  • /home: The Default User house directory, add user account, the user's home directory is stored in this directory, ~ represents the current user's home directory, ~edu represents the user Edu home directory.
  • /lib:/usr/lib:/usr/local/lib: A directory of libraries used by the system, which requires the assistance of a function library to invoke some additional arguments during execution.
  • /lost+fount: When an error occurs with the system exception, some missing fragments are placed in this directory.
  • /MNT:/media: CD-ROM default mount point, usually the disc is mounted under/mnt/cdrom, or not necessarily, you can choose any location to mount.
  • /OPT: A directory for the host to install additional software.
  • /proc: This directory data are in memory, such as system core, external device, network status, because the data are stored in memory, so do not occupy disk space, the more important directory has/proc/cpuinfo,/proc/interrupts,/PROC/DMA,/proc /ioports,/proc/net/* and so on.
  • /root: Home directory for system administrator root.
  • /sbin:/usr/sbin:/usr/local/sbin: Place executable commands that the system administrator uses, such as Fdisk, Shutdown, Mount, and so on. Unlike/bin, these directories are commands for the root of the system administrator, and the average user can only "view" and not be set up and used.
  • /tmp: The directory where files are temporarily stored by the general user or the program being executed, accessible to anyone, and important data cannot be placed in this directory.
  • /SRV: The data directory that needs to be accessed after the service starts, such as the Web page data that the WWW service needs to store within/SRV/WWW.
  • /usr: The application holds the directory,/usr/bin stores the application,/usr/share stores the shared data,/usr/lib storage cannot run directly, but is necessary for many programs to run some library files. /usr/local: Store the software upgrade package. /usr/share/doc: System description file storage directory. /usr/share/man: Program description file storage directory.
  • /var: Place files that change frequently during the execution of the system, such as log files that change at any time/var/log,/var/log/message: All login Files directory,/var/spool/mail: Mail storage directory,/var/run: After the program or service starts, its PID is stored in the directory.

3. User Directory

Located in/home/user, called the user working directory or home directory, means:

/home/user~

4. Relative path and absolute path

    • Absolute path

The path described at the beginning of the/directory is an absolute path, such as:

cd /homels /usr
    • Relative path

The path described at the beginning of the current position is a relative path, such as:

cd ../../ls abc/def

5、 . and..

Each directory has a. and.

. Represents the current directory

.. Represents the previous level of the directory, which is the parent directory

In the root directory. All represent the current directory

III. permissions-related issues

1. File permissions

File permissions are the access control permissions for a file, that is, which users and groups can access the file and what actions can be performed.

Unix/linux system is a typical multi-user system, different users in different positions, the files and directories have different access rights. In order to protect the security of the system, the Unix/linux system, in addition to the user's rights have been strictly defined, but also in the user identity authentication, access control, transmission security, file read and write permissions, etc. have been carefully controlled.

Each file or directory in Unix/linux contains access rights that determine who can access and how to access these files and directories.

2. Access users

You can restrict access by setting permissions from the following three types of access methods:

    • Only the user is allowed to access (owner) The owner is the user who created the file, the user is the owner of the file created by all users, and the user can allow the user group to access the user's files.

    • Allow user access (user groups) users in a pre-specified user group to be grouped into groups of users, for example, all users in a category or project can be categorized as a user group by a system administrator, and a user can grant file access to other members of the user group in which they are located.

    • Allow any user in the system to access (other users) users will also open their own files to all users within the system, in which case all users within the system have access to the user's directory or file. In this sense, all other users within the system are other user classes

This is somewhat similar to the access rights for QQ space:

    • This QQ space is mine, I am the equivalent of the manager (that is, "owner"), I want to access how to access.
    • At the same time, I can set to allow QQ friends to access, and these QQ friends are similar to the "user group."
    • Of course, I can allow everyone to access, and everyone here is similar to "other users".

3. Access rights

1) The user can control the degree of access to a given file or directory, and a file or directory may have read, write, and Execute permissions:

    • Read permission (r) has permission to read the contents of the file for the file, and for the directory to have the Browse directory permission.
    • Write permission (w) for the file, with the new, modify the contents of the file permissions, for the directory, to delete, move files within the directory permissions.
    • The executable permission (x) has permission to execute the file for the file, and for the directory, the user has permission to enter the directory.

Note: Typically, the Unix/linux system allows only the owner or superuser of the file to change the file's read and write permissions.

2) Example Description

The 1th letter represents the type of the file: "D" for the folder, "-" on behalf of the normal file, "C" for the hardware character device, "B" for the hardware block device, "s" for the pipe file, "L" for the soft link file. The latter 9 letters represent three groups of permissions: The file owner, the user, and other users.

Each user has its own read, write, and execute permissions.

    • The first set of permissions Controls access to their own file permissions, that is, owner permissions.
    • The second set of permissions controls the permissions of the user group to access the files of one of the users.
    • The third set of permissions controls the permissions of all other users to access a user's files.

These three sets of permissions give the user the ability to read, write, and execute different types of users (that is, owners, user groups, and other users) to form a 9-type permission group.

--------------------------------------------

Source: Organize from Network

Linux Learning Note II ———— files and directories for Linux systems

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.