common linux cmd


关闭指定名称进程

ps -ef| grep -i mysql|grep -v grep | awk '{print $2}'|xargs kill -9

rpm -Uvh --force --nodeps *.rpm 

vim  ~/.ssh/authorized_keys

for i in {6..9};do echo 330$i; mysql -S /data/mysqldata/p330$i/mysql330$i.sock  -e 'show processlist';done;

find /backup/mysqldump  -maxdepth 1  -name "*.dmp.gz" -type f -mtime +3 -exec rm -f {} \; 

#create file of certain size

fallocate -l  $((5*1024*1024))   test.txt

tar -cvf FileName.tar DirName

tar -xvf FileName.tar

#array
list=(user1 user2 user3);for item in "${list[@]}";do echo $item;done

#search from hundred files for specific str
find -maxdepth 2 -type f -exec  sed -n '/password/p' {} \;  -print
#read file line by line
while IFS= read -r line
do
  command1 on $line
  .. ....
  commandN
done < "/path/to/filename"
while IFS= read -r line;do  echo $line ; done < "/path/filename"
service firewalld start

1、开放端口
firewall-cmd --zone=public --add-port=5672/tcp --permanent   # 开放5672端口
firewall-cmd --zone=public --remove-port=5672/tcp --permanent  #关闭5672端口
firewall-cmd --reload   # 配置立即生效

#or
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT" >> /etc/sysconfig/iptables



2、查看防火墙所有开放的端口
firewall-cmd --zone=public --list-ports