常用命令

linux杀死某个程序的多个进程

ps uax | grep 'you project process' | grep -v grep |awk '{print $2}' | xargs kill

mysql导出数据(数据量比较大,工具不好用的时候)

mysql -h 127.0.0.1 -uroot -P databases 3306 -e "select count(*) from user;"  > /tmp/tetst.xls

redis的auth命令,仅连接的时候输入一次,不需要每次重新输入

redis-cli -h 127.0.0.1 -p 6379 -a "auth_command"

no space left on disk

查看磁盘使用情况
    df

如果磁盘未满,查看inode是否满
    df -i        

添加mysql用户和权限

  1. 选择mysql库
    use mysql

  2. 添加用户
    create user zhangsan identified by ‘zhangsan’;
    或者
    insert into user (Host,User,Password) value(‘127.0.0.1’, ‘test’, password(‘123123’));
    或者
    grant all privileges on database.* to test@’127.0.0.1’ identified by ‘test’;

  3. 刷新系统权限表
    flush privileges;

查看进程句柄使用情况

查看php-fpm(pid为192)句柄使用情况
lsof -n -p 192

特定进程内运行的线程

top -H -p <PID>

查找文件内容,并进行折行处理(直接用于mysql in查询)

grep 'WARN' 1.txt  | grep 'exist' | awk '{print $7}' | grep -v "\\[" | tr "\n" ","

根据特定标识符分割,再排序去重

grep -v '从kafka获得数据' 1.txt  | awk '{print $4}' | awk -F : '{print $2}' | sort | uniq > game.txt    
坚持原创技术分享,您的支持将鼓励我继续创作!