Linux Learning Notes--shell Basics (eight)

Source: Internet
Author: User

+++++++++++++++++++++++++ +++++shell Foundation +++++++++++++++++++++++++++++++ 1. Shell overviewShell definition:The Shell is a command-line interpreter that provides users with an interface system-level program that sends a request to the Linux kernel to run the program, allowing the user to start, suspend, stop, and even write programs with the shell.                                                                            The shell is also a very powerful programming language, easy to write and debug. The shell is the scripting language that interprets execution, and the Linux system commands can be invoked directly in the shell.      Shell Categories:Bourne shell:sh ksh bash PSH zsh (now using the Linux is bash, which is compatible with SH)c shell:csh tcsh (syntax structure and C language very similar) Linux-supported Shellby viewing the file:/etc/shells can tell which shells Linux supports  2. How shell scripts are executedoutput command: echo [options] [Output CONTENT]option:-E supports character conversions for backslash control               Support Color output:               First script:VI hello.shthe #!/bin/bash logo below is written in shell script#第一个脚本 Notesecho "Hello World" output statementScript Execution:The first method: 1) Change the execution permission; 2)./hello.shThe second method: Execute script with bash call--bash hello.shNote: Convert Windows file format to Linux--dos2unix file name  3. Bash's basic featuresHistorical command: History [options] [history command save file]option:-C clears the history command-W writes the history command in the cache to the history command to save the file ~/.historyNote: The history command saves 1000 by default and can be modified in the environment variable configuration file/etc/profile     Invocation of the history command:          Command completion: Press the TAB key to complete the completion automatically aliases for commands:set command alias--alias alias = ' original command 'Query command alias--aliasNote: Command execution order               make aliases permanent: VI/ROOT/.BASHRCRemove alias: Unalias alias bash Common shortcut keys:           standard input and output:          Output Redirect: Example--ls >> abc.txt                     Note: LS &>/dev/null will throw the result into the trash, without any processing. Input Redirection: (Enter the contents of the file as a command)               sequential execution of multiple commands:          pipe break: The correct output of command 1 as the operand of command 2command format: Command 1 | command 2, example: ls-l/etc | more wildcard character: (used to match file name)          Other special symbols:             4. Bash Variablesuser-defined variables: variables when a computer memory unit, where the stored value can be changedvariable Setting rules: Letters, numbers, underscores, cannot be the beginning of a number. The default type of a variable is a string type, and if you want to perform a numeric operation, the mandatory variable type is numeric. the variable is connected by an equal sign and cannot have spaces on either side. If there are spaces to the right of the equals sign, you must enclose them in single or double quotation marks. If you assign the result of the command to a variable, you must use the inverse quotation mark or the $ () containing commandenvironment variable name recommended capitalization, easy to distinguish          Variable Classification:               Local Variables: (that is, user-defined variables)                         Environment variables:concept-user-defined variables take effect only in the current shell, while environment variables take effect in the current shell and shell. If the environment variable is written to the appropriate configuration file, the environment variable will take effect in all shells. Note: The difference from a custom variable-essentially, is the difference in scope.           Set Environment variables: Export variable name = variable Value #声明变量Env #查询环境变量unset #删除变量PATH environment variable--the system looks for the command;PS1: Defining a variable at the system prompt                 positional parameter variables:            Predefined variables: Pre-defined variables in the system, positional parameter variables are actually one of the predefined variables           receive keyboard input: read [options] [variable name]option:-P "prompt message": Output prompt when waiting for read inputthe-t read command waits for user input, using this option to specify the wait timethe-n read command receives only the specified number of characters and executes-S hidden input data for confidential information input  5. Bash's operators declaring variable type: Declare          Numeric operations:method One:              method Two: expr or let numeric arithmetic tool               method Three: "$ ((expression)) or $[expression]"               Operator:               variable testing vs. Content substitution:               6. Environment variable configuration fileProfile : A configuration file that is primarily used to store system default environment variables, such as Path PS1. main environment variable configuration file:/etc/profile/etc/profile.d/*.sh~/.bash_profile~/.BASHRC/ETC/BASHRCSource command: Force the current configuration file to take effect directlyformat: Source configuration fileor. configuration file     the role of the environment variable configuration file:Call Order table for environment variable configuration file          the role of/etc/profile          ~/.bash_profile           the role of ~/.BASHRC           the role of/ETC/BASHRC                Additional configuration files:environment variable profile--~/.bash_logout in effect when logging offconfiguration file for history command: ~/.bash_history     Shell Login Information:Local Terminal Login welcome information--/etc/issue          Remote Terminal Login Welcome information--/etc/issue.net          Post-Login Welcome information:/ETC/MOTDNote: This welcome message can be displayed either locally or remotely.+++++++++++++++++++++++++ +++++shell Foundation +++++++++++++++++++++++++++++++ 

Linux Learning Notes--shell Basics (eight)

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.