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 {} \; 

 ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -n 20 

https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/

 

#sort ip address

sort -t . -k 3,3n -k 4,4n /path/to/file

 

#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=3306/tcp --permanent   # 开放5672端口
firewall-cmd --zone=public --remove-port=3306/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

 

 

https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/

 

posted @ 2021-01-12 09:59  sam_wang10  阅读(64)  评论(0编辑  收藏  举报