日常中的一些常用命令
1、找到项目里面的隐藏目录.svn然后删除
1
| [jikai@fenfa WebRoot]$ find ./ -depth -name ".svn" | xargs rm -rf
|
2、centos 7 上对新增硬盘进行扫描检出
1
| [root@node01 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
|
3、发现僵尸进程解决方案
1 2 3 4 5 6 7 8
| # 先使用命令查找出相对应的僵尸进程 [jikai@nginx-web1-11x5 ~]$ ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]' Z 15631 15668 [firefox] <defunct> Z 16318 16354 [firefox] <defunct> Z 27243 27279 [firefox] <defunct> [jikai@nginx-web1-11x5 ~]$ kill -HUP 15631 [jikai@nginx-web1-11x5 ~]$ kill -HUP 16318 [jikai@nginx-web1-11x5 ~]$ kill -HUP 27243
|
4、统计该tomcat进程内的线程个数
1 2
| ps -ef | grep qhXjxSales ps -Lf 29295 |wc -l
|
5、MySQL 5.7查询数据库中所有用户命令
1 2 3 4 5 6 7 8 9 10 11 12
| mysql> select User,Host,authentication_string from user; +-----------------+-----------+-------------------------------------------+ | User | Host | authentication_string | +-----------------+-----------+-------------------------------------------+ | root | localhost | *E65306C6ABB6A9AE7C8ADA352269955C5006F557 | | mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | | telSalesLottery | % | *73F79BD11EAF8B467D90359D924BDF41C0BC22BF | | tj_lboss | % | *20FEDFED84D179C40EB10FE8A96B0C8B94134B4E | | qh_control | % | *15AD21BFE7FF4304C30F48BBBBF5AFA7B88C8B2B | | nx_control | % | *15AD21BFE7FF4304C30F48BBBBF5AFA7B88C8B2B | +-----------------+-----------+-------------------------------------------+
|
6、centos7配置时区
1 2 3 4 5 6 7 8 9 10 11 12 13
| [root@mysql-server ~]# timedatectl set-timezone Asia/Shanghai # 安装ntp时间同步工具 [root@mysql-server ~]# yum -y install ntp # 与阿里云时间服务器进行同步,这里可以多同步几次,确保达到时间准确性 [root@mysql-server ~]# ntpdate ntp1.aliyun.com 14 Apr 11:06:40 ntpdate[28877]: adjust time server 120.25.115.20 offset -0.001292 sec [root@mysql-server ~]# ntpdate ntp1.aliyun.com 14 Apr 11:06:50 ntpdate[28878]: adjust time server 120.25.115.20 offset 0.000343 sec [root@mysql-server ~]# ntpdate ntp1.aliyun.com 14 Apr 11:06:57 ntpdate[28879]: adjust time server 120.25.115.20 offset 0.001980 sec # 同步后查看时间 [root@mysql-server ~]# date Tue Apr 14 11:06:59 CST 2020
|
7、Mysqldump导出指定库以及指定库的多张表
1 2 3 4 5 6 7
| [lboss@iZm5e6quhzjjqb1ebilawcZ mysql_bakup]$ mysqldump -uhb_lboss -p -P 3006 -hrm-m5eoj76y8wm735c31.mysql.rds.aliyuncs.com --databases hb_lboss > hb_lboss_0525.sql Enter password:
mysqldump -usx_lboss -p -P 3006 -hrm-m5eoj76y8wm735c31.mysql.rds.aliyuncs.com --databases sx_lboss sales_import_day sales_import_day_detail \ > sales_import_day_info sales_import_error_station_website sales_import_instant sales_import_instant_detail \ > sales_import_period_detail station_sale_amount_day station_sale_amount_day_total station_sale_lotto_amount \ > station_sale_lotto_amount_error station_sale_lotto_amount_total > sales_all.sql
|
8、查找停止进程T,并杀掉
1 2 3
| [jikai@nginx-web1-11x5 ~]$ ps -A -ostat,ppid,pid,cmd | grep -e '^[T]' T 19459 20790 tail -f ../logs/catalina-2020-05-29.out [jikai@nginx-web1-11x5 ~]$ kill -9 19459
|
9、新增磁盘分区
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| 1、先分区 [root@node02-dklwj ~]# fdisk /dev/sdb Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Command (m for help): p /dev/sdb1 2048 209715199 104856576 83 Linux Command (m for help): w 2、执行partprobe命令 [root@node02-dklwj ~]# partprobe [root@node02-dklwj ~]# partprobe 3、查看当前系统所有硬盘分区信息 [root@node02-dklwj ~]# lsblk 4、格式化文件系统 [root@node02-dklwj ~]# mkfs.xfs /dev/sdb1 5、创建挂载目录并挂载 [root@node02-dklwj ~]# mkdir /app [root@node02-dklwj ~]# mount /dev/sdb1 /app 6、最后使用df -h 查看当前磁盘挂载情况 [root@node02-dklwj ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 2.0G 0 2.0G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 8.9M 2.0G 1% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/sda3 46G 1.6G 44G 4% / /dev/sda1 509M 124M 386M 25% /boot tmpfs 396M 0 396M 0% /run/user/0 /dev/sdb1 100G 33M 100G 1% /app 7、实现开机自动挂载 [root@node02-dklwj ~]# vim /etc/fstab # # /etc/fstab # Created by anaconda on Tue Apr 21 11:11:45 2020 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=6cb4e3c4-11be-449c-928a-12ef089ebe60 / xfs defaults 0 0 UUID=5e3a67b5-271a-4ace-9990-6160d74f5496 /boot xfs defaults 0 0 UUID=dc602b5d-5dae-4083-b395-d10ab94fa826 swap swap defaults 0 0 UUID=6cb4e3c4-11be-449c-928a-12ef089ebe60 /app xfs defaults 0 0
|
10、修改centos时区为上海时区
1
| [root@192-168-31-172 conf.d]# timedatectl set-timezone Asia/Shanghai
|
11、acl权限设置
1 2 3
| # 如何把一个root管理员权限的目录增加普通用户的可执行操作 [root@192-168-31-66 data]# setfacl -m g:java:rwx -R webcad/ [root@192-168-31-66 data]# setfacl -m u:java:rw -R webcad/
|
12、查看系统所有开机自起列表
1
| root@mysql-server-98:/app/soft# systemctl list-unit-files|grep enabled
|