Linux Foundation second week
IO Redirection and piping
Standard output (STDOUT)
If the file does not exist, it is created and the correct output is populated, overwriting the original content if the file already exists
> If the file does not exist, it is created and the correct output is populated, and if the file already exists, the content is appended
Standard error (STDERR)
2> If the file does not exist, it is created and the wrong output is populated, overwriting the original content if the file already exists
2>> If the file does not exist, it is created and the wrong output is populated, and if the file already exists, the content is appended
Standard input (stdin)
The input data that the < command takes at execution time is obtained through it.
&> If the file does not exist, it is created, and all the output is populated, overwriting the original content if the file already exists
&>> If the file does not exist, it is created, and all output content is populated, and if the file already exists, the content is appended
Pipeline |
| Just pass the correct result to the command on the right
2>&1 error results to correct results
|& Pass both right and wrong to the right command
1>&2 the correct result to the wrong result
Users, Groups, permissions
File permissions:
R: Readable, you can use similar commands such as cat to view the contents of the file;
W: writable, can edit or delete this file;
X: Executable, exacutable, can be at the command prompt as a command to submit to the kernel to run;
Directory Permissions:
R: You can perform LS on this directory to list all internal files;
W: Files can be created in this directory;
X: You can switch to this directory using a CD, or you can use Ls-l to view the details of the internal files;
0---: No permissions
1 001--x: Execution
2 010-w-: Write
3 011-wx: Write and Execute
4 r--: Read-only
5 101 R-x: Read and Execute
6 rw-: Read and Write
7 111 rwx: Read and write execution
User Category
Admin: 0
Normal User: 1-65535, System User: 1-499, general User: 500-60000
User Group Category
Administrators group
Normal group: System Group, General Group
User Group Category
Private group: When a user is created, a group with the same name as the user name is automatically created if the group to which it belongs is not specified
Basic group: Default group for users
Additional groups, additional groups: groups other than the default group
Three types of users:
U: Owner
G: Genus Group
O: Other users
grep: Searches for text based on patterns and displays lines of text that conform to the pattern.
Regular expressions
The file name wildcard character * denotes 0 or more arbitrary characters? Represents any single character
. Represents any character
[] matches any single character within the specified range
[^] matches any single character outside the specified range
[: Alnum:] Letters and numbers
[: Alpha:] represents any English uppercase and lowercase characters, i.e. A-Z, A-Z
[: Lower:] lowercase letter [A-z]
[: Upper:] Capital Letter [A-z]
[: Blank:] white space characters (spaces and tabs)
[: Space:] Horizontal and vertical white space characters (more than [: blank:] contains a wide range)
[: Cntrl:] non-printable control characters (backspace, delete, alarm ...) )
[:d igit:] decimal number [0-9]
[: xdigit:] hexadecimal digits
[: Graph:] printable non-whitespace characters
[:p rint:] printable characters
[:p UNCT:] Punctuation
[a-z0-9] denotes uppercase characters or numbers
Number of occurrences: used after the number of characters to be specified, to specify the number of occurrences of the preceding character
- Matches the preceding character any time, including 0 times
Greedy mode: Match as long as possible
. * Any character of any length
\? Match its preceding character 0 or 1 times
+ match the characters in front of it at least 1 times
{n} matches the preceding character n times
{M,n} matches the preceding character at least m times, up to N times
{, n} matches the preceding character up to n times
{N,} matches the preceding character at least n times
Position anchoring: positioning where it appears
^ Beginning of the line anchor, for the leftmost mode
$ line End anchor for the right side of the pattern
^pattern$ for pattern matching entire row
^$ Empty Line
^[[:space:] "$ blank Line
Grep-v "^[[:space:]" $ "passwd remove blank lines in file
\< or \b The first anchor for the left side of the word pattern
\> or \b ending anchor; for the right side of the word pattern
\<pattern\> Match Whole Word
Linux Foundation second week