Top
Several disks
Fdisk-l
Disk space Df-lh
Df-al
View process: Ps-ef "grep java
Kill process: kill-9 process number
More in Filter
More XXX |grep www.makaidong.com
Configure IP after installing Linux
Vim/etc/sysconfig/network-scripts/ifcfg-eth5
ipaddr=192.168.42.142
netmask=255.255.255.0
gateway=192.168.42.1
Start and close the NIC
Ifdown Eth5
Ifup Eth5
Service Network Restart First
2: Unable to configure DNS on the Internet
Vim/etc/resolv.conf
Dns
NameServer 8.8.8.8
NameServer 114.114.114.114
NameServer 223.5.5.5
NameServer 223.6.6.6
Test:
Ping www.makaidong.com
Yum Install software
Rpm
Yum-y install MySQL
Shell Basics
#!/bin/sh
#print Hello World in the console window
A= "Hello World!hello makaidong"
echo "Hi, $as"
It will not output "Hi, Hello Worlds", but output "Hi,". This is because the shell treats $as as a variable, and $as is not assigned a value, and its value is empty.
The correct method is:
echo "Hi, ${a}s"
Echo $a
Ps-aux|grep ' Ambari '
Tail-f-N-Add_run_7.sh.log
Switch to Root
sudo su-
Switch to another user
sudo su hive
Top
Df-lh
、
Find recursive lookup make file name
Find 201412/-type f-name "*.txt"
Installation
To copy a wildcard character
Cp-r *_result bak/
WordCount
Wc-l Statistics wildcard characters
Wc-l 3_net_*/*
Scp-r Makaidong [Email protected]:/mnt/
#!/bin/sh
a=10
B=20
if [$a = = $b]
Then
echo "A is equal to B"
Fi
if [$a! = $b]
Then
echo "A is not equal to B"
Fi
[-F "$file"] judging $file is a file
[!-F "$file"] judging $file is not a file
History low Great
[$a-lt 3] Determines whether the value of $ A is less than 3, and the same-gt and-le represent greater than or equal to or less than
Num1-eq num2 equals [3-eq $mynum]
Num1-ne num2 Not equal to [3-ne $mynum]
Num1-lt num2 less than [3-lt $mynum]
Num1-le num2 less than or equal to [3-le $mynum]
NUM1-GT num2 greater than [3-GT $mynum]
Num1-ge num2 greater than or equal to [3-ge $mynum]
[-N "$a"] determine if the variable $ A has a value, test the empty string with-Z
File comparison Operators
[-e FileName] true if filename exists [-e/var/log/syslog]
-D filename True if filename is a directory [-d/tmp/mydir]
-r filename If filename is readable, true [-r/var/log/syslog] Read
-W filename if filename is writable, true [-w/var/.txt] Write
-x filename if filename is executable
-Z String True if string length is zero [-Z ' $myvar ']
-N String if string length is nonzero, true [-n ' $myvar ']
string1= string2 If string1 is the same as string2, then true ["$myvar" = "One of the three"]
string1!= string2 If string1 differs from string2, true ["$myvar"! = "one, three"]
While [Cond1] && {| |} [Cond2] ...; Do
...
Done
for Var in ...; Do
...
Done
for ((COND1; cond2; cond3)) do
...
Done
Until [Cond1] && {| |} [Cond2] ...; Do
...
Done
Linux shell array creation and usage tips
Shell array +for loop
#!/bin/bash
For i in ip1 ip2 IP3 IP4
Do
echo ssh [email protected] $i
echo "restarted $i Apache service"
Done
Exit
Sh-x *.sh
Shell script to generate test data
data_create.sh
Rm-rf./data.txt
Touch Data.txt
For ((i=0;i<2000;i++))
Do
Str= ', name ';
Name=${i}${str}${i}
#echo $name
echo $name >> data.txt
Done
echo ' Show TestData '
More Data.txt
chmod u+x data_create.sh
Run the script
Sh-x data_create.sh
SED replacement recursion Regular
Sed-i "S/<div class=\" c_r_a c_r_13_a\ "><script language=\" javascript\ ">c_r_13_a ();<\/script>< \/div>//g "index.shtml
Sed-i "s/10.16.60.29/cloud1.xingtu.360.cn/g" *
Find/data-name "*"-print | Xargs-i sed-i ' s/<div class=\ "c_r_a c_r_14_a\" ><script language=\ "javascript\" >c_r_14_a (); <\/script ><\/div>//' {}
Find *-name "*"-print | Xargs-i sed-i ' s/<div class=\ "c_r_a c_r_14_a\" ><script language=\ "javascript\" >c_r_14_a (); <\/script ><\/div>//' {}
#正则
Find *-name "*"-print | Xargs-i sed-i ' s/<div class=\ "c_r_a c_r_.*_a\" ><script language=\ "javascript\" >c_r_.*_a (); <\/script ><\/div>//' {}
Find *-name "*"-print | Xargs-i sed-i ' s/<div class= "C_A_TB". * id=c_a_tb.*>.* c_a_tb.* ();<\/script> <\/div>//' {}
Find *-name "*"-print | Xargs-i sed-i ' s/<div class= "C_A_TB". * id=c_a_tb.>.* c_a_tb.* ();<\/script> <\/div>//' {}
9id=c_a_tb9><script type= ' Text/javascript ' > c_a_tb9 ();</script></div>
Crontab timed Execution shell
* * * * * sh-x/root/start.sh >> start.log 2>&1
Remote machine ping different native
This machine can ping the remote, that can be taken:
First Test to your own user directory:
On the target machine: CP tmpdir.sql.gz/home/makaidong/
Then on this machine:
scp-r [email protected]:/home/makaidong/\*.sql.gz.
Note: \* escape
Nohup
Nohup Hive--service hiveserver 2>&1 &
Dos2unix windows-linux Shell Format conversion
Find. -name "*.conf" | Xargs Dos2unix
Var.sh wrote: year=2015
Shell import Source introduces other shells
#!/bin/bash
#在其他目录: source./sh/var.sh #sh目录下 or source sh/var.sh
SOURCE var.sh
Rm-rf./data.txt
Touch Data.txt
For ((i=0;i< $year; i++))
Do
Str= ', name ';
Name=${i}${str}${i}
#echo $name
echo $name >> data.txt
Done
awk $ (awk-f "=" ' $1== {print $}
Compression:
Zip Recursive compressed folder (directory)
Zip-r./201412.zip./201412/*-R
How Linux compresses the retention source files:
gzip–c filename > filename.gz
How Linux unlocks the retention source file:
Gunzip–c filename.gz > FileName
Well, basically the four commands I use now are as follows:
Compress into gzip file:
TAR-ZCVF shell.tar.gz shell/
Unzip the gzip file:
TAR-ZXVF shell.tar.gz
Compress to bz2 file:
TAR-JCVF shell.tar.bz2 shell/
Unzip the bz2 file:
TAR-JXVF shell.tar.bz2
TAR-ZXVF makaidong.tar.gz-c/zzz/bbs
Gunzip makaidong.tar.bz2.gz
TAR-JXVF makaidong.tar.bz2
Linux introduction and Common commands using 4--linux advanced commands and tips