Linux Private Cuisine Part 2nd

Source: Internet
Author: User

I. Linux file permissions and directory configuration
  1. Users and Groups
    • File owner-can set file permissions
  2. Linux File Permissions Concepts
    • LS-AL:LS displays file name and related properties,-al indicates detailed permissions and permissions for all files listed

      The first character indicates that the file is "directory, file, or linked file, etc.":
      When [d] is the directory, for example, the row with the table file named ". GConf";
      When [-] is the file, for example, the previous table is named "Install.log" the line;
      If [l] is indicated as a link file (link file);
      If [b] is indicated as the device file inside the storage interface device (can be random access device);
      If [C] is indicated as a serial port device inside the appliance file, such as a keyboard, mouse (one-time reading device).
    • In the following characters, a group of three, each of which is a combination of three parameters, is "rwx". where [R] stands for readable (read), [W] stands for writable (write), [x] stands for executable (execute). Note that the location of the three permissions does not change, and if there is no permission, a minus sign [-] is present.
      The first group is "permissions of the file owner", the file "Install.log" as an example, the owner of the file can read and write, but not executable;
      The second group is "permission of the same group";
      The third group is "permissions for other non-native groups".

    • One more before the file name. ", the file is a" hidden document ", such as the. GConf line in the previous table, the file is a hidden document.
    • CHGRP: Change the group to which the file belongs
    • Chown: Changing the file owner
    • chmod: Features that change file permissions, SUID, SGID, Sbit, and so on
    • You can use numbers to represent individual permissions, and the score table for each permission is as follows: R:4, W:2, x:1
      Each identity (Owner/group/others) 's respective three permission (R/W/X) scores are cumulative, such as when the permission is: [-rwxrwx---] score:
      Owner = rwx = 4+2+1 = 7
      Group = RWX = 4+2+1 = 7
      others=---= 0+0+0 = 0
    • When setting the file name under Linux, it's best to avoid some special characters! For example the bottom: *? > <; &!  [ ] | ' "' () {}
  3. Linux directory Configuration
    FHS only defines what data should be placed under the three-level directory for the directory tree schema, which is the definition of the three directories below:
    • /(Root, root directory): related to boot system;
    • /usr (Unix software Resource): Related to Software installation/execution;
    • /var (variable): related to the system operation process.
    • /etc: Configuration file
    • /bin: Important Execution file
    • /dev: Required device files
    • /lib: Function libraries required for execution of files and modules required by the core
    • /sbin: Important System Execution files
      Note: These five directories must not be separated from the root directory in different partition slots
    • Two Special directories:
      . : Represents the current directory, or it can be used.
      .. : Represents the previous level of the directory, or you can ... /to represent.
    • There are five directories that cannot be placed with the root directory in different partition, such as/etc,/bin,/lib,/dev,/sbin five.
Two. linux File and directory management
  1. Directories and Paths
    Here are a few common commands for working with directories:
    • CD: Transform Catalog
    • PWD: Displays the current directory
    • mkdir: Create a new directory
    • RmDir: Delete an empty directory
      Different identity users default path, the default can run arbitrary commands are also different (such as Root and Vbird);
      Path can be modified, so the general user can still use to modify the path to run some commands under/sbin or/usr/sbin to query;
      Using absolute or relative paths to directly specify the file name of a command is more appropriate than searching for path;
      command should be placed in the correct directory, the operation will be more convenient;
      This directory (.) It is best not to put it in path.
  2. File and Directory Management
    • Copy, delete and move: CP, RM, MV
  3. File Content Lookup
    • Cat starts displaying file contents from the first line
    • The TAC begins with the last line, and you can see that the TAC is backwards written by cat!
    • NL display, the output line number!
    • More page-by-page display file contents
    • Less is similar to more, but better than more, he can page forward!
    • Head's just a few lines.
    • Tail only look at the tail a few lines
    • OD reads the contents of the file in binary way!
    • Non-plain text file: OD
    • Modify file time or build a new document: Touch
    • Revise a file date to current (Mtime and Atime)
      4. Default permissions and hidden permissions for files and directories
    • File default permissions: Umask
    • FILE-Hidden properties: chattr (Profile-hidden property) lsattr (show file-hidden properties)
    • File Special permissions: SUID, SGID, Sbit
    • Set UID
      /etc/shadow can not let Vbird this general account to access, why Vbird can also modify the password in this file? This is SUID's function.
    • Vbird for/USR/BIN/PASSWD This program is the X-permission, indicating Vbird can run passwd;
    • The owner of the passwd is the root account;
    • Vbird Run the passwd process, will "temporarily" Get root permissions;
    • Set GID
      Users can enter this directory if they have r and X permissions on this directory;
      The user's active group (effective group) in this directory will become a group of that directory;
      Purpose: If the user has permission to W in this directory (can create a new file), the new file created by the consumer will be the same as the group for this directory.
      /etc/shadow can be modified by the passwd run by Vbird.
    • Sticky Bit
      When the user has W, x permission, that is, the Write permission for this directory;
      When a user creates a file or directory under that directory, only himself and Root have the right to delete the file
    • Observation file type: Files
  4. command-and-file search
    • Command name search: which (find "Run File")
    • File name search: Whereis (looking for specific files), locate
    • UpdateDB: According to the/etc/updatedb.conf configuration to search the system hard disk file name, and upgrade the database files within the/var/lib/mlocate;
    • Locate: According to the database record in the/var/lib/mlocate, find out the key file name entered by the user.
Three. Linux disk and file system management
    1. Disk-to-directory capacity
      • DF: Lists the overall disk usage of the file system;
      • Du: Evaluating the disk usage of the file system (commonly used in the estimated capacity of the catalog)
    2. partitioning, formatting, checking and mounting of disks
      • Disk partition: Fdisk
      • Disk inspection: fsck, badblocks
      • Disk parameter revision: Mknod,e2label,tune2fs,hdparm
        4. Configure the Boot mount:
      • Start Mount/etc/fstab and/etc/mtab
      • Some limitations of the system mount:
        The root directory/must be mounted, and will have to be mounted before the other mount point.
        Other mount point must be a directory that has been created and can be arbitrarily specified, but must adhere to the required system directory schema principles
        All mount point can be mounted only once at the same time.
        All partition can only be mounted once within the same time.
        In the removal process, you must first move the working directory outside of Mount point (and its subdirectories).
    3. The Memory replacement space (Swap) is built:
      • Using a solid split slot to build swap
Four. File compression and Packaging
    1. Common compression commands for Linux systems
      • *. Z Compress Program Compressed files, the original files compressed by compress will disappear, and the compressed files will be created, and the extension will be *. Z
      • *.gz gzip program compressed files;
      • *.BZ2 bzip2 program compressed files;
      • *.tar the TAR program to package the data, and has not been compressed;
      • *.tar.gz tar program packaged files, which are also compressed by gzip
      • *.TAR.BZ2 tar program packaged files, which are bzip2 compressed
    2. Package Command: Tar
      • Compression: Tar-jcv-f filename.tar.bz2 The name of the file or directory to be compressed
      • Enquiry: Tar-jtv-f filename.tar.bz2
      • Unzip: tar-jxv-f filename.tar.bz2-c the directory to unzip
        Take out the root directory, assuming you have the backup data in/tmp, then the extracted file name will become "/tmp/etc/xxx". However, if the root directory is not removed, the extracted file name will be the absolute path, that is, the extracted data will be placed in the/etc/xxx! "In this way, the data under your original/etc/will be covered by the backup data.
    3. Full Backup tool
      • Dump
      • Restore
    4. Disc Write Tool
      • Mkisofs: Creating an image File
      • Cdrecord: CD Burning tool
    5. Other common compression and backup tools
      • Dd
      • Cpio

Linux Private Cuisine Part 2nd

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.