HADOOP04---Shell

Source: Internet
Author: User
Tags free ssh

After MySQL installation on Linux uninstall is not clean, ping server ping does not pass the ICMP protocol is closed, Ping is using the ICMP protocol. Export is a global variable that all users can log in to use.
Introduction to 1.iptables firewall iptables also known as NetFilter is a free and excellent packet-filtering-based firewall tool that comes with Linux, which is powerful and flexible enough to control the packets that flow into, out, and through the server. The iptables is an integrated module in the Linux2.4 and 2.6 cores. 2.Iptables Service-related commands 1. View iptables status Service iptables status2. Turn iptablesservice iptables startservice iptables on/off Stop3. See if Iptables starts Chkconfig iptables--list4. Set iptables boot/Not start chkconfig iptables onchkconfig iptables off
Introduction to the 1.iptables principle the structure of the 1.1.iptables has four tables in iptables, the filter, Nat, mangle, and raw each contain their own different chains, the most commonly used is the filter table.
The filter table: Filter is the default table used by Iptables, which is responsible for filtering incoming and outgoing packets, which defines 3 chains:    Inpout is     responsible for filtering all packets that are local to the destination address, or filtering the packets that enter the host. The    FORWARD    is responsible for forwarding the packets that flow through the machine but not into the local computer, and plays the role of forwarding. The    OUTPUT is    responsible for processing all packets from the source address that are native addresses, or packets sent from the host.
The shell is an interface that users interact with the kernel, and the most popular shell called Bash Shellshell is also a programming language<interpreted programming language>, a shell script can have multiple shells in a system, and you can view the shell installed in the system through the Cat/etc/shells command. Different shells may support command syntax that is not the same as how shell scripts are executed: The first: the absolute path or relative path of the input script is first given to the +x permission/root/helloworld.sh./helloworld.sh or, without giving +x permission, While the interpreter interprets the execution sh helloworld.sh second: Bash or sh + script sh/root/helloworld.sh sh helloworld.sh third: Add "before the path of the script." "    . /root/helloworld.sh. ./helloworld.sh differences: The first and second will open a new bash, different bash variables cannot share variables in the shell: variables in the Linux shell are divided into "system variables" and "user-defined variables", The system variables can be viewed through the SET command: $HOME, $PWD, $SHELL, $USER, and so on display all variables in the current SHELL: Set definition variable: variable = value (e.g. str= ABC) equals cannot have a space variable name on either side of the general habit is the uppercase double quotation mark and the single quotation mark have the difference, the double quotation marks will only take the space, the single quotation mark will take all special characters str= "Hello World" a=9unset A revocation variable areadonly b=2 declares the static variable b=2, You cannot unsetexport a variable name to promote a variable to a global environment variable, which can be used by other shell programs to assign the return value of a command to a variable: a= ' ls-la ' counter quote, run the command inside, and return the result to the variable aa=$ (LS-LA) Equivalent to a special variable in the shell of the:$?  represents the status of the last command exit $$  represents the current process number, and the current script name $n represents the n position of the input parameter (n represents the number, N>=1) $# represents the number of parameters, often used for looping $* and [ Email protected] All indicate that the parameter list  $* differs from [email protected]: both $* and [email protected] represent all arguments passed to the function or script, not double quotes " "When included, all parameters are output in the form of $ ... $n. When they are enclosed by double quotation marks," $* "will make all parametersFor a whole, output all parameters in the form of "$ $ $n"; "[email protected]" will separate the parameters to "$" "$" ...     Output all parameter operators as "$n": Format: expr m + N or $ ((m+n)) Note that there is a space between the expr operators, for example, the value of (2 +3) x4 is calculated as 1. Step Into s= ' expr 2 + 3 ' expr $S \* 42. One step to complete the calculation Expr ' expr 2 + 3 ' \* 4 echo ' expr \ ' expr 2 + 3\ ' \* 4 ' or $ ((2+3)) for loop: first: For N in 1 2 3do Echo $Ndo NE or for N in 1 2 3; do Echo $N; Done or for N in {1..3}; do Echo $N;  Done the second type: for ((i = 0; i<= 5; i++)) Do echo ' welcome $i times ' done or for ((I= 0;I <= 5;i++)); Do echo "Welcome $i times"; Donewhile Cycle: The first while expressiondocommand...done the second type I=1While ((i<=3))Do echo $i let i++donecase statement: Format case $ instart) echo "starting";; Stop) echo "stoping";; *) echo "usage: {start|stop}" esacread command: READ-P (hint statement)-N (number of characters)-T (wait time) read-p "Please input your name:" Name Use example : If judgment syntax if condition then statements [elif condition then statements ...] [Else statements] Fiif example #!/bin/bashread-p "Please input your name:" name#printf '%s\n ' $NAMEif [$NAME= root] then echo "Hello ${name}, welcome!" elif [$NAME= Itcast] then echo "Hello ${name}, welcome!" else echo "SB, get out here!" FI judgment statement: [Condition] (note condition before and after a space) #非空返回true, you can use $? Verify (0 is true,>1 is false) [itcast] #空返回false [] judgment statement: [condition] && echo OK | | echo notok condition satisfies, executes the following statement common judgment Condition: = string comparison-lt less than -le is less than or equal to-eq equals-gt greater than-ge greater than or equal to-ne is not equal to the Common criteria:-R has Read permission-W has Write permission-X has the permission to execute the-F file exists and is a regular file-s file exists and is not empty-D file exists and is a directory-B file exists and is a block set    The standby-l file exists and is a link shell custom function: syntax [function] funname [()]{action; [return int;]} function start ()/function Start/start () Note 1. The function must be declared before the function is called, and the shell script runs on a row-by-line basis. Not pre-compiled like any other language 2. function return value, only through $? System variables are obtained, can be displayed plus: return returns, if not added, will run the result as the last command, as the return value, the return value can only be int. return followed by value N (0-255) script debug: Sh-vx helloworld.sh or add set-x in script

Linux inside the hardware are files (network card,CPU, CD-ROM),

install JDK script: #!/bin/bashbase_server=172.16.203.100yum install-y wgetwget $BASE _server/soft/ JDK-7U45-LINUX-X64.TAR.GZTAR-ZXVF jdk-7u45-linux-x64.tar.gz-c/usr/localcat >>/etc/profile<< EOF#EOF是文件的开始和结束, append the text content to the/etc/profile file. Export Java_home=/usr/local/jdk1.7.0_45Export PATH=\ $PATH: \ $JAVA _home/binEOF password-free SSH login: #!/bin/bashservers= "node-3.itcast.cn node-4.itcast.cn"PASSWORD=123456Base_server=172.16.203.100auto_ssh_copy_id () {#expect-C is waiting for the system prompt, prompting yes/no to enter Yes, prompting password to enter the second parameter, Expect-c followed by the string #set timeout-1 is never timed out, EO             F no input on Exit expect-c "set timeout-1;        Spawn Ssh-copy-id $;            Expect {* (yes/no) * {send--yes\r;exp_continue;}            *assword:* {send--$2\r;exp_continue;}        EOF {exit 0;} }";} Ssh_copy_id_to_all () {$SERVERS #要安装机器的列表 do auto_ssh_copy_id $SERVER $PASSWORD #第一个参数是遍历的每一  Server, Done}ssh_copy_id_to_allfor server in $SERVERSdo SCP install.sh [email protected] $SERVER:/root ssh [email Protected] $SERVER/root/install.shdone

HADOOP04---Shell

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.