July 29, Marco Linux study on the fifth day, the main content of study:
First, the index node
Second, hard links and soft links
Iii. Redirection and piping
Iv. Users and user groups
First, index node
A node (an index node) is a table item that contains information about the file (metadata), including:
File type, permissions, Uid,gid
Number of links (pointing to the number of path names for this file name)
The size of the file and the different timestamps
Data block pointer to file on disk
Additional data about the file
A directory is a mapping between a file name and an inode number in a directory
CP Command and Inode:
Allocate a free inode number, generate a new entry in the Inode table create a directory entry in the directory, associate the name with the inode number copy data to generate a new file
Cp-f/etc/issue/f1/etc/issue/Delete and create F1 file
RM Command and Inode:
The number of links is decremented so that the inode number released can be reused
Put data blocks in the free list
Delete a catalog item (the data is not actually deleted immediately, but will be overwritten when another file uses the data block)
MV Command and Inode:
Target and source on the same file system: Create a new directory entry with a newer file name delete the old directory entry corresponding to the old file name does not affect the Inode table (except the timestamp) or the data location on the disk: No data is moved!
Target and source in a different file system: MV equivalent to CP and RM
Second, hard links and soft links
Hard Links
Syntax: ln filename [linkname]
Creating a hard link adds an additional record entry to reference the file, corresponds to a physical file on the same file system, each directory references the same inode number, the number of links is incremented when the file is deleted, and the RM command decrements the count of links; file to exist, at least one link number when the number of links is zero, the file is deleted ; Cannot cross drive or partition, cannot create hard link to directory.
Soft links
Syntax: ln-s filename [linkname]
A symbolic link points to another file, the name of the Ls-l display link, and the referenced file; the content of a symbolic link is the name of the file it refers to, can be made to a directory, can span a partition, and a path to another file, with the size of the length of the path string pointed to ; does not increase or decrease the reference count of the target file inode.
Third, redirect
Standard input and output:
Linux provides three types of I/O devices to the program:
Standard input (STDIN)-0 accepts input from the keyboard by default
Standard output (STDOUT)-1 Default output to terminal window
Standard error (STDERR)-2 default output to terminal window
I/O redirection: Changing the default location
StdOut and stderr can be redirected to a file: command action Symbol file name
Supported operational symbols include:
> redirect stdout to file (set-c: Suppresses overwriting of existing files but can append mandatory overrides: >| Set +c: de-disable)
2> redirect stderr to file
&> Redirect all output to file
(> file content will be overwritten >> original content, append content)
The standard output and error outputs are directed to different locations:
COMMAND >/path/to/file.out 2>/path/to/error.out
Merge standard output and error output redirect for the same data stream:
(1) &>: Overwrite redirect &>>: Append redirect
(2) COMMAND > /path/to/file.out 2> &1 (&1 indicates the correct output directory with standard)
COMMAND >> /path/to/file.out 2> &1
Multi-line redirection: Cat <<eof cat > File <<eof
(): Consolidation of multiple programs (Cal stdout; cal) > All.txt
TR command: Convert and delete characters
TR [OPTION] ... SET1 [SET2]
-C or--complerment: a complement to the character set
-D or--delete: Deletes all characters belonging to the first character set
-S or-squeeze-repeats: the consecutive repeating character is represented by a single character
-T or--truncate-set1: Converts the corresponding character of the first character set to the corresponding character of the second character set
tr [A-z] [a-z] converts lowercase to uppercase (cannot be deleted directly when input, can be deleted using Ctrl+backspace)
Pipeline
Command 1 | Command 2 | Command 3 | ...
A connection program that implements the output of the previous command directly after a program as an input data stream
ls | Tr ' A-Z ' A-Z
StdErr cannot be piped forward by default and can be implemented with 2>&1 or |&
Less: one page, one page view input: $ ls-l/etc | Less
Mail: Send input by e-mail: $ echo "Test Email" | Mail \ S "Test" [email protected] LPR: Send input to Printer $ echo "Test print" | Lpr-p Printer_name
Tee command: One input, two output (standard output + file)
$ Command 1 | Tee File name | Command 2
Save the stdout of command 1 in the file name, and then pipe the input to the command 2
cat/etc/issue/| Tee/tmp/issue.tee | Tr ' A-Z ' A-Z
Use: Save different stages of output, troubleshoot complex pipelines, and view and record output at the same time
Special Equipment:
/dev/null
To use the status result without executing the result, the execution results are put into/dev/null
Iv. Users and user groups
Users user
Linux Users: Username/uid
admin: Root, 0
Normal Users: 1-65535
System User: 1-499 (CENTOS6), 1-999 (CENTOS7) Assign permissions to the daemon to get resources
Login User: (CENTOS6) +, + (CENTOS7) +
Interactive Login
Group
Linux Group: Groupname/gid
Administrators group: root, 0
Normal Group:
System groups: 1-499, 1-999
General Group: 1000+,
Primary group of users (primary group):
The user must belong to one and only one primary group group name with the user name and only one user: private group
Additional groups for users (secondary groups):
A user can belong to 0 or more secondary groups
Linux security context
The permissions that a process (a running program) can access to a resource depends on the identity of the process's runner
The complexity strategy for passwords
Use at least 3 of the numbers, uppercase letters, lowercase and special characters
Long enough (at least 8 digits) to use a random password
change regularly; Do not use passwords that have been used recently
Encryption algorithm
Symmetric encryption: Encryption and decryption using a
Asymmetric encryption: Encryption and decryption using a pair of keys (public key, private key)
One-way encryption:: Hash algorithm, can only encrypt, not decrypt, extract the data signature (fixed-length output, avalanche effect)
Algorithm type: MD5 SHA1 sha224 sha256 sha384 sha512
Primary profiles for users and groups
/ETC/PASSWD: User and its attribute information (name, UID, primary group ID, etc.)
/etc/group: Group and its attribute information
/etc/shadow: User passwords and their associated properties
/etc/gshadow: group password and its related properties
passwd file format
①login Name: Login name (WANG)
②PASSWD: Password (x)
③uid: User identification Number (1000)
④gid: Login Default group number (1000)
⑤gecos: User's full name or comment
⑥home Directory: Household directory (/home/wang)
⑦shell: The user uses the shell by default (/bin/bash)
Shadow file format
Login with Name
User password: Generally with sha512 encryption ($n $salt$ password where n is the encryption type salt is the random number added each time)
From January 1, 1970 to the time the password was last changed
The password can be changed in a few days (0 means it can be changed at any time)
The password must be changed in a few days (99999 means never expire)
The system reminds the user a few days before the password expires (default is one week)
Password expires days payback will be locked
From January 1, 1970 onwards, the number of days after the account expires.
Group file format
Group name: is the group name
Group password: usually does not need to be set, the password is recorded in/etc/gshadow
GID: Is the ID of the group
List of users with the current group as additional groups (comma delimiter)
Gshdow file format
Group name: is the group name
Group Password:
Group Admins list: List of group admins, change groups passwords and members
List of users with the current group as additional groups: (comma delimiter)
This article is from the "Laugh Monkey" blog, please be sure to keep this source http://xiaomonky.blog.51cto.com/11869371/1833394
Day5:linux File System (3) + Redirect and pipe + user group Hull Rights Management (1)