One. > And >> instructions
> Execution result is written back to the file:
the file, if the file does not exist will be created automatically
> : Redirect the output will overwrite the original file contents
>>: Append redirect appended to the end of the file
Query results can be written to a file, you can create an empty file with the echo:
echo “” > a.txt
two. echo command
The contents of the input to the console
You can enter the file path:
as follows: echo " I am Yang three little " echo $ the PATH
three. head instruction
head to the beginning of the content file, display the number of rows may be provided:
10 lines of the file path to view the file before head
head before -n 5 file path to view the file line 5
four. tail command
tail end of the display for a file, by default tail command displays the contents of the file of 10 lines, with less difference is that it can block and tracking changes to the file.
10 lines tail file before viewing the file path tail -n 5 before the file path to view the file line 5 tail -f file path to real-time tracking of all the update files often use -----
Fives. ln command
Soft links, also known as symbolic links, windows in the shortcut similar to the main storage of the path links to other files.
Soft link is to copy the original directory links, when the original link has been removed and the connection will disappear, hard links are operating side by side with the original file links.
ln source file or source file folder name soft link hard link
LN -s source file or source file folder name soft flexible connection link
When you delete a soft connection when not plus / and best not to add -r *
rm -f linktoroot
six. history instruction
View history command has been executed, can also command execution history
history to see all the history commands History 10 View 10 most recently executed instructions ! 100 instruction execution numbered 100
Seven. The date and time classes
Displays the current time to the console
date displays the current date DATE +% the Y display the current year DATE +% m current month DATE +% D shows the current day date +%Y-%m-%d %H:%M:%S
Supports date "+% Y-% m-% d% H:% M:% S"
Eight. cal command
You can view the current calendar:
cal displays the current calendar CAL 2020 show calendar 2020 CAL 10 2018 show in October 2018 calendar
nine. find instructions
find [range] [options] Range: refers to the path, do not write down from the current default look, look like windows Options: - name filename lookup by file name - the User username find all the files belonging to the user - size Find by file size + 20M - 20M 20M 20K
find can use wildcards to match:
1. According to a.txt name lookup file in the / home directory of
the Find / home -name a.txt
the Find / home -name "* .txt"
2. Find / opt directory under the user name lxx file
find / opt - LXX the User
3. Find files larger than 20M under linux system throughout
the Find / -size + 20M
4. query / directory, all .txt files
find / -name "* .txt"
ten. grep command and the pipe symbol |
Pipe character: "|", indicates the result of processing the previous command output to the command processing later.
grep filter to find representatives.
grep [options] content filtering Options: - the n-match display line and the line number -i ignore the case of letters
example:
Find a ' yes ' in the row, and displays the line number a.txt CAT | grep -n " yes " ignore case, look for ' yes ' row cat a.txt | grep -ni "yes"
eleven. Compression and decompression:
1.gzip / gunzip instructions (for file compression only):
For compressing and decompressing files
gzip file path
gunzip gz file path
After using gzip compressed files, it will not retain the original file.
2. zip / unzip instruction
for compressed zip file, unzip a decompression, in this project package will be released in very useful.
zip [Options] xxx.zip compressed content compressed file or directory - r archive directory unzip [Options] xxx.zip extracting file After the specified compression storage directory -d directory
example:
The / all files in the home were compressed into mypackage.zip zip -r mypackage.zip /home ZIP -R & lt mypackage.zip / Home / * the mypackge.zip extract to / opt / tmp The unzip -d /opt/tmp mypackge.zip
twelve. tar command
tar command is packed instruction, after the last file is packaged
compression: tar - zcvf xx.tar.gz compressed content (files, folders, also multiple lines) compression tar -zxvf xx.tar.gz - C target path in extraction z: Use gzip compression format, otherwise it is simply packed c: Compression x: unzip f: displaying the compression decompression process v: display a message
example:
Compressing a plurality of files, / /home/a1.txt and / Home a2.txt compressed into a.tar.gz
takes -zcvf a.tar.gz /home/a1.txt /home/a2.txt
thirteen. Group basic introduction
Linux each user must belong to a group, outside the group do not operate independently. In linux each file has, where the group concept of an owner other groups.
File / directory owner:
General file creator, who created the file, it is poised to become the owner of the file.
Check the file owner:
ls -ahl
Modify the file owner:
chown username filename
Create a group:
chown username filename
File / directory's group
When a user creates a group when a user creates a file, the default file where the group is the user is located.
Check the file / directory where the group
ls -ahl
Modify the file's group
chgrp group file name
Change the user's group:
usermod -g group name Username
Permissions Introduction
ls -l -rwxrw-r-- 1 root root 1213 Feb 2 09:39 abc 0 -9 Bit Description Bit 0 of determining the file type (D, - , L) The first 1-3 position to determine the owner (owner of the file) have access to the file The first 4-6 bits determine the owning group (the same group of users) have access to the file The first 7-9 bits identify other users who have access to the file
rwx are represented by:
r: read
w: write [write does not mean you can delete, delete a file premise is to have write access to the directory where the file]
x: executable
rwx role to catalog:
r: read (ls view contents of available) w: writable [can be created in the directory + + Delete to rename a file or directory] x: executable [can enter the directory]
Actual case file and directory permissions
-rwxrw-r-- 1 root root 1213 Feb 2 09:39 abc - indicates the type of file A first set of rwx: indicates the owner read-write executables A second set of RW - : indicates the same group of users but can not perform read and write Third group R & lt - : indicates other users read only Available figures indicate: R & lt =. 4 W = 2 X =. 1 thus rwx =. 4. 7 = + 2 +. 1
edit permission:
chmod permission to change the format of the file or directory path Permission to change the format a: u: owner g: All groups o: other users a: Everyone U = rwx 1., RX = G, O = X 2. O + w w increases permissions to other users 3. ax subtracting all execute permissions
example:
1 . Abc file owner read and write permissions to the execution, to read where the group permission to execute, execute permissions to read other groups U chmod = rwx, G = rx, O = rx abc 2 . abc files to the owner to remove execute permissions, group write permissions to increase U the chmod the -X-, G + W abc . 3 . abc files to all users add the read permission chmod a+r abc
Modify the permissions you can also write:
Permission to change the format of two: R & lt = 2. 4 = W = X = RX. 1. 5. 7 = rwx the chmod U = rwx, RX = G, X = O can be written as chmod 751
example:
Examples: 1. The permission / home / abc modified file-XR- rwxr X, used to digitally implemented chmod 755 /home/abc
Modify the file owner:
chown newowner file to change the file owner
chown -R newowner folder so that all sub-files or subdirectories into force
Modify the file's group:
chgrp newgroup file change file all groups
chgrp -R newgroup folder so that all sub-files or subdirectories into force