Linux Learning Notes

Source: Internet
Author: User
Tags bz2 create directory

1, the permissions of the directory: R indicates that the directory can be displayed. W indicates whether the file under the directory can be created, deleted, renamed and other operations. x indicates whether the directory can be entered and the directory becomes the current working directory.

2, the Linux file does not have the so-called extension, the Linux file extension only serves the hint function (uses to indicate the file content and so on information).

3, Linux under the file can be executed regardless of the extension of the file, as long as the permissions of the file has X, for example [-rwxr-xr-x] means that the file can be executed. (Can be executed with the ability to be executed successfully are two concepts).

4, Absolute path: must be the root directory/write path.
Relative path: The path compared to the current working directory.

5. · Represents this Layer directory
·· Represents a previous level directory
-Represents a previous working directory
~ Represents the home directory of the current user
~account represents the home directory of the account user

6. Pwd:print working Directory
Attention:
The option-p (uppercase) indicates that the exact path is displayed rather than the path of the link file.

7. mkdir: Create directory
Attention:
Option-m means configure profile permissions! Do not need to look at the default permissions (Umask) face
Example: Mkdir-m 766 Test (test has permission of drwxrw-rw-)
Option-P (lowercase) indicates a recursive build directory (including upper-level directories)
Example: Mkdir-p test/test1/test2

8. Rmdir:remove directory (empty)
Options:
-P: Also deleted along with upper [empty directory]
Note: The Delete object must be an empty directory

9. Echo $PATH
Echo: Display, print
PATH: The front plus $ means that the variable is followed, so the current path! is displayed

10. PATH: Environment variable
Path= "$PATH":/root: Add/root to PATH
Attention:
Different identity users have different path presets, and the default commands that are arbitrarily executed are different.
Path can be modified, so the general user can still modify path to perform certain/sbin or
/usr/sbin under the command to query.
Using absolute or relative paths to directly specify the file name of an instruction is more appropriate than searching for path.
Instructions should be placed in the correct directory, the implementation will be more convenient.
This directory (.) It is best not to place it in path.

11. CP:
Options:
-A: equivalent to the meaning of-PDR
-P: Copy the past with the properties of the [archive] instead of using the default properties
-R: Recursive continuous Replication for directory replication behavior
-I: If the target file (destination) already exists, the action will be asked before overwriting
CP hello.c HI.C copy hello.c to current directory and rename to Hi.c
CP hello.c HI.C test/Copy the hello.c and HI.C to the test directory 1221

12. RM:
Options:
-F: The meaning of force, ignoring the non-existent file, no warning message appears
-I: Interactive mode that asks the user whether or not to move before deleting
-R: Recursive deletion, commonly used in directory deletions.
Delete a file with-start (-test): RM./-test or RM---Test

13, Rm-i hello*, * (asterisk) represents 0 to infinity of any number of characters

14, MV:
MV [-fi] source destination
MV [options] Source1 source2 source3 .... directory
-f:force mandatory Meaning, if the file already exists, does not ask for direct coverage
-I: If the target file (destination) already exists, you will be asked to overwrite
Catalog renamed: MV Mvtest mvtest2 (renamed directory Mvtest to Mvtest2)

15, Umask:
umask:0002
Umask-s: U=rwx,g=rwx,o=rx
Umask is 002, so take off the permissions for--------WX, so:
Archive: (-rw-rw-rw-)-(--------W) = (-rw-rw-r--)
Contents: (drwxrwxrwx)-(--------W) = (drwxrwxr-x)

16. File:
Consult the file format, and have no use of the dynamic library (shared library) and so on information

17, which: Looking for [execution file]
-A: Lists all instructions that can be found in the path directory, not just the first one found.
This instruction is to search for the file name of [execution file] According to the path of the environment variable [path].
Which CD: The CD is not found as a common instruction, because the CD is [bash built-in instructions], and the which preset
is to find the directory within the path specification, so can not find.

18. Whereis Locate Find

19, Gzip, Zcat
gzip [-CDVK] File name
-V: Can show the original file/compressed file compression ratio and other information;
-D: decompressed parameters
-C: Output compressed data to the screen, can be processed by data flow redirection
-K: retains the source file without deleting the original archive Oh!
Attention:
When compressing using gzip, the original file will be compressed into a. GZ filename and the source files will no longer exist in the preset state.
Gzip-c hello.c > hello.c.gz: Compress the hello.c and keep the original file.
Zcat file name. GZ: Reads the compressed file after the plain text file is compressed.

20. bzip2 [-CDVK] File name
-V,-D,-c option as on gzip
-K: retains the source file without deleting the original archive Oh!
Bzcat file name. BZ2: Reads the compressed file after the plain text file is compressed.

21. 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
Options:
-J: Compression/Decompression via BZIP2 support: This file name is preferably *.tar.bz2.
-Z: Compression/decompression via GZIP support: The file name is preferably *.tar.gz at this time.
-C: Create a packaged file that matches the file name (filename) that was packaged during the-V view.
-T: See what file names are in the package file, and focus on [file name].
-X: The ability to unpack or decompress can be solved in a specific directory with-C (uppercase).
-V: During the compression/decompression process, the file name being processed is displayed!
-C (Uppercase): This option is used for decompression and can be used to decompress in a specific directory.
Attention:
-C,-T,-X cannot appear in a sequence of instruction columns at the same time.

22, Tar: Decompression, only the method of extracting a single file.
Tar-jxv-f Packing archives. tar.bz2 file name to be unpacked

23, Tar: Packaging a directory, but does not include some files in the directory
Tar-jcv-f packing file name. tar.bz2--exclude=file1--exclude=file2 ... Directory to compress

24, if you need two lines of input, the most followed by a backslash (\) and immediately press [ENTER], you can continue to enter the second line.

25. Vim:
General mode: Cursor movement, copy paste, search substitution, etc.
(1) Cursor movement:
H: The cursor moves one character to the left
J: Move the cursor down one character
K: The cursor moves up one character
L: The cursor moves one character to the right
0: Number 0, move to the front character of this line
$: Moves to the last face character of this line
G: Move to the last line of this file
NG: Jumps to nth row. n is the number, which is the line number you want to jump to.
GG: Move to the first line of this file
N<enter>:n is a number. Move the cursor down n rows
(2) Search and replace:
/world: Looking down at a string named word to the cursor
World: Looking for a string called word on top of the cursor
: n1,n2s/word1/word2/g: N1 and N2 are numbers. Look for the string word1 between the lines N1 through N2 and replace the string with Word2!
: 1, $s/word1/word2/g: look for the word1 string from the first line to the last line, and replace the string with Word2!
: 1, $s/word1/word2/gc: look for the word1 string from the first line to the last line, and replace the string with Word2! and display the prompt character before the substitution to confirm (confirm) If you need to replace!
(3) Delete copy and paste on
X,x:x Delete one character backwards, X to delete one character forward
DD: Delete the entire row where the cursor is located
NDD: Delete the downward n rows of the cursor
YY: The line where the cursor is copied
Nyy: The n row where the copy cursor is located
P/p:p the copied data is pasted on the next line of the cursor, P is a row attached to the cursor
U: Undo Previous Action
[Ctrl]+r: Redo a previous action
(4) Block selection
V: Character selection, where the cursor passes through the white selection
V: Row selection, the line that the cursor passes through is reversed white selection
[CTRL]+V: Block selection, you can select data in a rectangular way (often used in neatly arranged text files)
Y: Copy selected white block
D: Delete selected white blocks
(5) Multi-file editor: Vim file1 file2 file3-----
: N Edit Next file
: N Edit Previous file
: Files lists all the files that are currently open by this vim
(6) Multi-window editing function
: SP filename opens a new window and opens a new file in a new window filename
[Ctrl]+w+j or [ctrl]+w+↓ cursor moves to the lower window first press [Ctrl], then press W to release all the keys, then press J (or DOWN ARROW key)
[Ctrl]+w+k or [ctrl]+w+↑ cursor moves to the top window
[Ctrl]+w+q is actually: Q ends away

Other
Set Nu: Display line number
Set Nonu: Cancel line number

26.
~/.bash_history records the previous login and the previously executed commands, and the instructions executed by this login are temporarily in memory, and when you log off the system, the instruction memory is recorded in the. bash_history.
Alias command aliases, such as [alias Lm= ' Ls-al '].
The instruction is too long to wrap with a backslash \ Note: [\enter].

Wildcard characters
* 0 To infinity of any number of characters
? There must be an arbitrary character
[] There must be a character inside the parentheses.
Example: [ABCD] representative must have a character that may be a,b,c,d these four any one of
[-] All characters in the encoding order.
Example: [0-9] represents any one of the numbers from 0 to 9
[^] Reverse selection
Example: [^ABC] must have a character, as long as the non-a,b,c accept

Special symbols
# notation: This is most commonly used in script, which indicates that the data behind it is not executed
\ Skip Symbol: Restores [special characters or wildcards] to general characters
| Pipeline (pipe): Delimited two pipeline command definition (the latter two sections are introduced);
; Continuous instruction release delimiter: the definition of continuity command
~ User's Home directory
$ fetching Variable leader
& Job Control: Turn the directive into a background job
! Meaning of [non] not in the sense of logical operation
/directory Symbols: path-delimited symbols
>> Data Flow redirection: Output orientation, sub-deletion is [replace] and [accumulate]
<, << Data Flow redirection: Input guidance
' Single quotes, no function of variable substitution
"" With the function of volume permutation
' Two in the middle of an inverted quotation mark, as an instruction that can be executed first, or $ ()
() in the middle for the beginning and end of the child shell
{} In the middle is a combination of command chunks

27.
Shell variables: PATH MAIL self-setting variables, etc.
(1) variable to fetch: ECHO $ variable Name
(2) Setting of variables:
1 Variable name = variable Contents For example: Myname=suph
2 equals sign cannot be directly connected to a space character error: Myname= Suph or myname= suph SS
3 variable Contents If there are spaces, use double quotation marks or single quotes to combine the contents of the variables.
Special characters within double quotes such as $ etc., can retain the original characteristics
For example: var= "Lang is $LANG" then echo $var can get Lang is en_US
Special characters in single quotation marks are general characters only (plain text)
For example: var= ' lang is $LANG ' then echo $var get Lang is $LANG
4 the variable name can only be the English parent and the number, but the beginning character cannot be a numeric error: 2myname=suph
5 You can use the skip character \ To change a special symbol (such as ' "\ space to enter, etc.) to a general character
6 in a series of instructions, you also need to provide information by other instructions, you can use the anti-single quote ' instruction ' or $ (Directive).
In a sequence of instructions, the instructions in the ' instruction ' and the $ (Directive) take precedence
Example: Enter the core module directory
cd/lib/modules/' Uname-r '/kernel
or cd/lib/modules/$ (uname-r)/kernel
7 Expand variable contents, use "$ variable name" or ${variable name} to accumulate content, as follows:
Path= "$PATH":/home/bin path=${path}:/home/bin
8 to cancel a variable by using the Unset:unset variable name
Simple application: If you have a common directory ~/test/test1/test2, how to do that directory simplification
Work=~/test/test1/test2 CD $work
9 Export: Custom variable to environment variable (share your own variable set to the file or other program that was called later)
Export variable Name
Reading variable read variable name of keyboard input
-P: Prompt characters can be followed
-R: Number of seconds to wait after
Read-p "Please keyin your name:"-T-Name
Declare declaring variable type declare [options] Variable
-A: Defines the variable variable as an array type
-I: Define the variable variable as an integer numeric type
-X: Similar to export, turn variable into an environment variable
-r: Sets the variable to the readonly type, changes not to be changed, and cannot be unset
Example 1: #sum =100+300+50
#echo $sum
100+300+50
Example 2: #declare-I sum=100+300+50
#echo $sum
450
The variable type defaults to a string, so if you do not specify a variable type, 100+300+50 is a string instead of a formula
12 array Variable type
Declaration: Declare-a Var (that is, array name)
Assignment Value: var[1]=content1
Var[2]=content2
...
READ: Echo "${var[1]},${var[2]},${var[3]}"
Content1,content2,...
13. The question mark is also a special variable. It is the value returned by the last executed instruction
In general, if the command is executed successfully, a value of 0 is returned, and if an error occurs, the error code (typically a non-0 value) is returned.

28. Data Flow re-orientation
Is the data that should appear on the screen after a certain instruction is executed and transmitted to other places, such as a file or device (such as a printer)

Standard output (STDOUT): normal outputs (instructions to perform the correct message uploaded to the screen)
Standard error Output (STDERR): The error message that is not returned to the screen after the command execution failed
Data flow redirection allows stdout and stderr to be transferred to other files or devices, respectively.

Standard input (stdin): code 0, using < or <<
Standard output (STDOUT): Code 1, using > or >>
Standard error Output (STDERR): Code 2, using 2> or 2>>

If you export > to an existing file, that file will be overwritten.
If the output is in >> to an existing file, the data is added to the bottom of the file.
Create a new file with the same name if it doesn't exist.

After some commands are executed, both the correct information is output, the error message is output, and it can be output separately to different files: command >list_right 2>list_err

/dev/null Garbage bin black hole device. Discard the error message: Comand 2>/dev/null

Write the correct and wrong data to the same file, because two strands of data may be confusing in a cross-write file, so you have to use a special syntax:
Command >list 2>&1 or command &>list

Standard input: < and <<
Replacing data that would otherwise need to be entered by the keyboard, instead of the file content

29
Continuous instruction release without regard to directive relevance: CMD1;CMD2;CMD3;

There is a dependency between the directives, and the main judgment of this dependency lies in the correctness of the result of the previous instruction execution.
Command callback value: If the previous command executes correctly, a $?=0 value is returned under Linux
Use the callback value to determine whether the subsequent instructions are to be executed, by && and | |. Instruction execution order is from left to right.
CMD1 && CMD2
1. If the CMD1 is completed and executed correctly ($?=0), the CMD2 is started.
2. If CMD1 is executed and is error ($?≠0), CMD2 does not execute.
cmd1 | | Cmd2
1. If CMD1 is executed and executed correctly ($?=0), CMD2 does not execute.
2. If the cmd1 is executed and is error ($?≠0), the CMD2 execution begins.
Example: ls ~/hello | | mkdir ~/hello && Vim ~/hello/hi.c
If hello exists, then execution order is ls->vim,mkdir not executed
If Hello does not exist, the order of execution is Ls->mkdir->vim
Example: Assumptions: Command1 && Command2 | | Command3
If Command1 succeeds, execute Command2
If Command1 is unsuccessful, execute Command3
(Command2 and Command3 will be able to place instructions that can definitely be executed)

30
The pipeline command only handles standard output and is ignored for standard error output.
The pipeline command must be able to accept the data from the previous instruction as standard input to continue processing.

Linux Learning Notes

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.