Summary of important Linux knowledge points-understanding and learning bash

Source: Internet
Author: User
Tags builtin uppercase character
Summary of important Linux Knowledge & mdash; understand and learn about bash hardware, kernel, and shell. we must use shell to communicate the input commands with the kernel, so that the kernel can control the hardware to work correctly. The operating system www.2cto.com is actually a group of software, because this group of software is under control... summary of important Linux knowledge points-to understand and learn bash hardware, kernel and shell, we must use "shell" to communicate our input commands with the kernel, so that the kernel can control the hardware to work correctly. The operating system www.2cto.com is actually a group of software, because this group of software is controlling the entire hardware and management system activity monitoring, if this group of software is operated by the user at will, if the user's application is improper, this will cause the entire system to crash. Any interface that can operate an application can be called a shell. Shell in the narrow sense refers to the command line software. In the broad sense, shell includes graphic interface software. Advantages of shell: the shell on the command line interface is also remotely managed: the command line interface is a shell (/etc/shells file) that can be used in Linux to manage the legitimate shell and/etc/shells functions of key systems of the system quickly ): /bin/bash (Bourne Again SHell, the default shell in Linux)/bin/ksh (Kornshell developed by AT&T Bell lab and compatible with bash)/bin/tcsh (integrating C shell, provide more functions)/bin/zsh (based on ksh, more powerful) when the user gets shell work and the user's default shell record in the/etc/passwd file www.2cto.com bash shell functional command memory (history) command and file complementing functions (the benefit of the Tab button) command alias setting function (alias) job control, foreground, Background control (job control, forexhaust Ound, background) shell script (shell script) Wildcard (Wildcard) bash shell built-in commands: type understanding commands are from external commands (refer to other commands not provided by bash) or the built-in type [-tpa] name parameter: type: When no parameter is added, the type will show whether the name is an external command or the bash built-in command-t: type indicates the meaning of the following words of name: file: represents the bit external command alias: represents the name set by this command for the command alias builtin: represents the built-in command-p: if the name followed by an external command is used, the complete file name-a: The PATH defined by the PATH variable will be displayed, and all the commands with the name will be listed, variable function variables that contain the alias command execution backslash (\) transfer character shell variability and convenience affect the bash environment operation variables: the PATH variable before entering the shell, because the system requires some variables To provide access to his data (or set the parameter values of some environments, such as whether to display the color), so some so-called "environment variables" need to be read into the system. To differentiate the environment variables from custom variables, the environment variables usually show and set variables that are a good helper for script programming (shell script) with uppercase characters: echo, to display the echo of unset variables, you only need to add $ Before the variable name, or display the echo in the form of $ {variable. Set or modify the variable content: Use the equal sign (=) to connect the variable to its content in bash. when a variable name has not been set, the default content is "null. Variable setting rules: variables and variables are connected by an equal sign "=". The two sides of the equal sign cannot be directly connected with a space character. the variable name can only be English letters and numbers, but the start character cannot be a number variable. if there is a space character, you can use it. double quotation marks or single quotes combine variable content, however, special characters such as $ in double quotation marks can retain their original features. special characters in single quotation marks are only common characters (plain text) the escape character "\" can be used to convert special characters into general characters. in the genetic command, you also need to provide information through other commands, you can use the 'command' or '$ (command)' quotation marks )". If the variable is added to the variable content, you can use "$ variable name" or "$ {variable}" to accumulate the content. if the variable needs to be executed in other sub-processes, you must use export to convert the variable into an environment variable. generally, uppercase characters are used as the system default variables, you can use lower-case characters to conveniently determine whether to cancel a variable by using the "unset variable name" sub-process: in the current case of shell, it opens another shell, the new shell is a sub-process. In general, the custom variables of the parent process cannot be used within the child process. However, after the environment variable is programmed through export, it can be used under the sub-process. Use environment to view environment variables and common environment variables HOSTNAME: the host name of this host, TERM = what type of SHELL is used by this terminal? shell = which program is used in this environment? HISTSIZE = the number of command records, in CentOS, you can record 1000 USER = USER name LS_COLORS = some color display MAIL = and the USER's mailbox location PATH: execute the file command to find the path INOUTERC = is related to the keyboard function, you can set the special button PWD = the current working directory of the user LANG = the HOME related to the language family = the main folder of the user _ = the last parameter of the last command used last time (or the command itself) RANDOM: RANDOM number variable with content ranging from 0 ~ Between 32767, use set to view all variables (including environment variables and custom variables). HISTFILE = the placement file of historical Command Records, hide the file MAILCHECK = scan the mailbox every 60 seconds to see if there is a new mail PS1 = command prompt setting value PS2 = prompt after the second line using the escape symbol $ current PID used by this shell? Generally, no matter whether the return code is an environment variable or not, the variables related to the current shell interface operation are usually set to uppercase characters, that is, basically, in Linux by default, the variable set with {uppercase character} is generally the variable specified in the system. PS1 (prompt settings) $ (about the shell PID )? (About the return code of the previous command) in general, if the command is successfully executed, a 0 value will be returned. If an error occurs during execution, the "error code" will be returned ", in general, it is to replace export with a non-zero value: the difference between a custom variable and an environment variable: whether the variable will be used by the quilt process. The child process will only inherit the environment variables of the parent process. The child process will not inherit the custom variables of the parent process and affect the language variables (locale) of the displayed results) the effective range of locale variables environment variables can be referenced by the quilt process, but other custom variables will not exist in the child process. when a shell is started, the operating system will allocate a memory block to shell. the variables in this memory class can be used by sub-processes. If an export function is used by the parent process, the user-defined variables can be written to the above memory blocks (environment variables). when loading another shell, the sub-shell can import the memory block of the environment variable of the parent shell to its own environment variable block. the reading, array, and declaration of the variable keyboard are as follows: read, array, and declarer. Ead: Read the variable parameter from the keyboard input:-p: followed by the prompt message-t: followed by the waiting "seconds" declare/typeset: declare the variable type parameter:-: array type-I: Integer-x: environment variable-r: readonly type. the variable cannot be changed or reset to the default value, bash has several basic definitions for variables: the default value of the variable type is the numerical operation in the "string" bash environment. by default, the maximum value of the variable type can be the restricted relationship between the integer type and the file system and program: ulimitulimit [-SHacdfltu] [quota] parameter:-H: hard limit. strict settings must not exceed the value of-S: soft limit. warning settings, this value can be exceeded, but if it is exceeded, there is a warning-a: list all limits-c: When some processes encounter errors, the system will write the information of the process in the memory as a file (for troubleshooting). This file is called a core file, which limits the maximum capacity of each kernel file- F: the maximum file capacity (generally 2 GB) that can be created by this shell, measured in KB-d: The maximum broken memory (segment) capacity available to processes-l: memory used for lock-t: maximum CPU time available-u: maximum process available for a single user) delete, replace, and replace command alias of quantity variable content set: alias, unalias history Command: history [n] history [-c] history [-raw] histfiles parameter: n: number, is to list the most recent n command lines-c: delete all the current shell history content-a: add the newly added history Command to histfiles, if histfiles is not added, logs are written by default ~ /. Bash_history-r: read the content of histfiles to the current shell history memory-w: write the current history memory into histfiles (default value ~ /. Bash_history) when logging out, the latest HISTSIZE will be recorded in the record file! Number: the number of commands executed! Command: Find the command whose name starts with command and execute the latest command !!: Execute the path of the operating environment and command query sequence of the previous command Bash Shell: execute the command in a relative/absolute path. alias finds that the command is executed by the built-in bash (builtin) command to execute the first command found in the order of the variable $ PATH to execute bash login and welcome information:/etc/issue, /etc/motdbash environment configuration file login and no-login shelllogin shell: complete login process is required when bash is obtained. read/etc/profile (overall system settings ),~ /. Bash_profile or ~ /. Bash_login or ~ /. Profile (set by the user) no-login shell: obtains the bash interface and does not need to log on again. read ~ /. Bashrc source reads other related configuration files in the environment configuration file/etc/man. config: specifies the path of man page to search ~ /. Bash_history: History Command Records ~ /. Bash_logout: record the operating terminal environment settings completed by the system after bash is deregistered: stty, set wildcard and special symbol data stream redirection when executing a command, this command may be read from the file, then output the data to the screen. Standard output: standard output. the correct information returned by the command execution is standard error output. after the command execution fails, the returned error message data stream redirection can transmit standard output (stdout) and standard error output (stderr) to other files or devices respectively, the special characters used for transmission are as follows: standard input (stdin): The code is 0. <或<<;标准输出(stdout):代码为1,使用> Or >>; standard error output (stderr): The code is 2, use 2> or 2 >>; 1>: output the correct data to the specified file or device in overwriting mode. 1 >>: output the correct data to the specified file or device in the accumulative way./dev/null garbage bin black hole device and special writing. if you know the error will happen, ignore error messages without displaying them or store errors and correct data to a file: 2> & 1 can also be &> standard input: <与<<将原本需要由键盘输入的数据改由文件内容替代 <<代表结束输入的意思 使用命令输出重定向的原因: 屏幕输出的信息很重要,而且需要将它存下来后台执行中的程序,并不希望它干扰屏幕正常的输出结果一些系统的例行命令的执行结果,希望它可以存下来时一些执行命令的可能已知错误信息时,想以“2> /Dev/null "indicates the judgment basis for command execution when the error information and the correct information need to be output separately: cmd; cmd (continuous command execution regardless of command relevance) $? (Command return code) and & | cmd1 & cmd2: if cmd1 is completed and executed correctly ($? = 0), then run cmd2 cmd1 | cmd2: If the execution of cmd1 is complete and executed correctly ($? = 0), then cmd2 does not execute general books. suppose there are three types of writing: cmd1 & cmd2 | cmd3, cmd2 and cmd3 place the command pipeline command "|" that can certainly be successfully executed, which can only process the correct information sent through the previous command, that is, the standard output information, there is no direct processing capability for standard error output. The first data followed by each MPs queue must be a "command", and this command must be able to accept standard input data before selecting the command: cut: cut a piece of information, and the processed information is separated by the cut-d character '-f fields (the nth segment) in the unit of "line) cut-c character range (remove a fixed character range in units of characters) grep: analyzes the information of a row. if necessary, take this row out. grep [-acinv] [-color = auto] 'searches for the string 'filename' parameter:-a: searches for data in the text file of the binary file-c: calculate the number of times The 'query String' is found-I: case-insensitive-n: output row number-v: reverse selection, that is, the row without the 'search string' content is displayed -- color = auto: add the keyword section to the color display sorting command: sort: sorting command, sort by different data types uniq: list duplicate data only one display wc: the number of words in the file, dual targeting of the number of rows and number of characters: tee sends data streams to the file and screen at the same time, while stdout outputs to the standard screen, allow the next command to continue to process tee-a file: add the data to the file in the accumulative way. character conversion command: tr: delete the text in a piece of information, or convert text information to the tr [-ds] set1 parameter;-d: delete the set1 string in the information-s: replace the repeated character col [-xb] parameter: -x: replace the tab key with the equivalent space key-B: There is a backslash (/) in the text (/) col is often used to convert man pages into plain text files for convenient query, add the row with the same data in the two files to join [-ti12] file1 file2 parameter:-t: join data is separated by space characters by default, compare the "first field" data-I: case-insensitive-1: indicates which field is used for analysis in the first file-2: indicates which field is used for analysis in the second file
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.