Linux Operating System Basics

Source: Internet
Author: User
Tags clear screen

Continue to add some of the vim instruction points of knowledge, when you need to manipulate multiple files simultaneously, use the VIM command to open several files simultaneously to load into memory. The command format is vim file1 file2 file3, where different files are separated by whitespace characters, the default operation of the first file, when you need to manipulate other files, in the last line mode input: next/:p rev/:first/:last corresponding to the next, the previous, the first, The contents of the last document. When you need to view different file contents at the same time, use the option-o/o to display the file contents for the vertical screen/horizontal screen split screen. In the split-screen case, switch the current operation file using ctrl+w+ keys, CTRL before you can add a number to jump to the specified file. When you operate a file, if you need to display the contents of this file by using the shortcut key ctrl+w+s/v, a file horizontal/vertical split screen display, note s/v do not hold down the CTRL key, cut need to operate in edit mode. Need to save/exit all currently open file contents, enter in last line mode: Qa/:wa, cannot execute: Qwa/qawa this type of operation.

If you need to load additional file contents into the current file while manipulating the current file contents under Vim, use the: R path/to/somefiles command in the last line mode. When you need to interact with the shell under Vim, use the last-line mode:! Then you can interact with the command. If you need a partial save as operation, use in the last line mode: M/.,N/+NW can be saved to another file or saved to the current file, just add it later! Can.

What is a shell? The shell is the interface for the user to complete the command operation, providing users with an easy-to-use command-line interface. Some Linux operating systems use the default shell is bash, command cat/etc/shells can see the default system support shells, if you need to switch between different shells use, directly enter the shell name, execute.

Features of bash:

The function that defines the command alias, the (un) alias command can be used to (revoke) define and display the alias of the command, but the command defined with the alias command whose life cycle is only the current Shell's life cycle, that is, exit the current shell, the defined command alias is invalidated. However, you can change the alias of the command permanently by modifying the configuration file (~/.BASHRC), and the alias will not take effect immediately after the configuration file is changed, and the file needs to be reloaded (.. bashrc note white space characters) to memory and will take effect permanently. There are usually two ways to combine operations to ensure that the aliases of the settings take effect in a timely manner.

Second, the function of viewing the command history will save the command that the user has executed in the reply, so that the user can execute a command repeatedly. By using the history command file provided by bash to persist previously executed commands, each user has its own private history file. When you log in to the shell, Bash automatically reads all the commands recorded in the ~/.bash_history file. History Show historical Command, option-C empties history command in history buffer,-D #选项删除指定位置的历史列表. Use CTRL p/arrow/!! /!-#/!/!? The previous command can be executed repeatedly. Ctrl R searches the historical buffer for the target character;! $: Represents the last argument in the last command; ESC let go. =alt+. last parameter;! ^ Last command first parameter;! : #上个命令中的第 # of parameters;! The first few commands: the first few parameters. History-related BASH variables: histsize Sets the length of the history buffer, Histfilesize sets the Bash_history file length, Histtimeformat change the history of the command can display the time; Histcontrol history commands record control, Where ignoredups can ignore successive repeats of the command, Ignorespace can ignore the beginning of the blank character command, ignoreboth that the above two control modes open.

Third, the shortcut keys in Bash, CTRL abbreviated to C,ALT abbreviation for M,ESC abbreviated to E,del abbreviated to BACKSPACE. C+l Clear screen. C+a the cursor jumps to the beginning of the command line, c+e the cursor to the end of the command line, C+k removes the command line information from the cursor position to the end of the line,

C+u Delete command line information at the beginning of the cursor position, C+c end the foreground process, cancel the command run.

The command complement mechanism can be understood as two aspects: the completion of the string of the command itself and the completion of the parameter. The command completion can be completed by the TAB key, if the given string cannot be uniquely identified, bash does not complete, two tabs gives a reference list, and if too many references, asks if the list is displayed. The completion is based on the supplied parameter path, and if the parameter does not have any hint information, it is found by default from the working directory. Shell command Execution procedure: The shell will determine the user's input end according to the user type Enter, the shell will collect the command information, according to the white space character to fragment token, the first fragment is understood as the command field, to determine whether the first field is an internal command or an external command, If it is an internal command, run directly; if it is an external command, use the path information indicated by the path variable to find the relevant location to determine if there is a file with the same name, and if so, execute the error. Determine if the option is correct, and determine whether the parameter is correct.

The shell command line expands: The input ~,bash automatically expands it as the home directory of the currently logged-in user, the input ~string,bash automatically expands it to the home directory of the string user name, enters ~+, invokes the value of the shell variable pwd, and enters ~-, Call the value of the shell variable oldpwd; using {}, you can populate a list of paths that are split, and bash expands it into multiple independent paths.

Vi. Command Execution results: Any Linux command has two execution results, the normal output result and the status return value. Execution status return value ($?) stored in a special variable in bash, related to command execution: 0 means the command executes successfully; 1,2,127 is a built-in state return value, 1 indicates a minor problem, 2 indicates a serious problem, 127 indicates a problem with the command itself, and 3~126,128~255 the user to customize state information.

Seven, quote attribute: Double quotation mark (""), single quotation mark ('), anti-quotation mark ('). Where double quotation marks are weak references, some special characters still retain their special meanings in the content referenced by them, such as $, \, "", the single quotation mark is a strong reference, the content is referenced by it, bash treats it as ordinary character, ignores its special function, and the inverse quotation mark, also called the Command reference, can execute the referenced command, and Same

Eight, escape function: Bash definition \ is an escape character, after which a character loses special meaning, if the \ after entering a carriage return, you need to continue the input, the carriage return loses its execution function.

Nine, globbing file name wildcard character: *,? , [], ^. * matches any character of any length, except for some special. (hidden file) does not match;? Matches any single character, must and only one character is matched; [] matches any single character within the specified range, and only one character must be matched; ^ indicates an inverse match. [A-z] matches the character A,a,b,b,c,c......y,y,z, which should be noted here does not include uppercase Z;[a-z] the same, attention does not include lowercase a;[:lower:] denotes all lowercase letters; [: Upper:] denotes all uppercase letters; [:d Igit:] denotes all decimal digits; [: alnum:] denotes all uppercase and lowercase letters and decimal digits; [: Alpha:] denotes all uppercase and lowercase characters, equal to [a-z];[:space:] denotes all whitespace character; [:p UNCT:] denotes all punctuation Note that if you need to match all lowercase letters of any individual, write in the form [[: Lower:]]. Use the wildcard characters? The use frequency is not big, understands can.

X. Input and output redirection: When using a computer, the main body that implements a function is: program = instruction + data, data from file and IO device. Keyboard devices, file system of the regular files, network card devices, sound card devices, etc. are available for input devices, monitors, file systems, general files, network card devices, sound card devices, etc. are available for the output of the device. Each program, there are three forms of data flow: input data stream, output data stream, error data stream. The default input stream is the keyboard, the default output stream is the display, and the default error output data stream is also the monitor. That is, the data stream from the keyboard is called standard input, and the output stream from the monitor is called standard output, and the error stream output from the monitor is called the standard error output. Therefore, the concept of redirection, that is, the use of non-standard device file implementation of IO operations, called IO redirection. Input redirection is <, and output redirection has two representations of:> and >>,> called overwrite output redirection,>> for append output redirection. The set +/-c can be turned off/on with the anti-false override switch. Similarly, error redirection also has 2> and 2>>, for overriding and appending error redirection. There are two ways to combine the standard output and the standard error output redirection:&>,&>> and command>|>>/path/to/somefile 2>&1. If you focus only on the status return value and do not pay attention to the output, you can redirect the standard output to/dev/null (bit bucket) without consuming resources and devouring everything. When using TR, input redirection < is required.

Xi. Pipeline Concept: |, the output of the left command of the symbol is given the input to the right command for the symbol. Note that all commands for pipe connections should be commands that can have a standard output stream.

Linux Operating System Basics

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.