Linux常用命令🔥
[TOC]

运行脚本命令

  1. bash -c "cmd string"
  2. 等价于||
  3. /bin/bash cmd string

文件操作命令

  1. #从本地复制到远程
  2. scp local_file remote_username@remote_ip:remote_folder
  3. #复制目录命令格式
  4. scp -r local_folder remote_username@remote_ip:remote_folder
  5. #树形显示目录结构

网络命令

  1. # 查看磁盘io
  2. iotop -oP
  3. # 打包
  4. tar zcf target.tar.gz ./source
  5. # ssh密钥生成
  6. ssh-keygen -t rsa
  7. 示例:ssh-keygen -t rsa -b 4096 -C "anhusky@163.com"
  8. # 端口占用查看
  9. netstat -anp|grep 80
  10. # 查看网络配置
  11. cat /etc/sysconfig/network-script/ifcfg-eth0
  12. # 查看进程
  13. ps -aux| grep logstash
  14. # 查看shell执行过程
  15. sh -x test.sh

硬件信息查看命令

  1. # 物理cpu个数
  2. grep 'physical id' /proc/cpuinfo | sort -u
  3. # 物理cpu核数
  4. grep 'core id' /proc/cpuinfo | sort -u | wc -l
  5. # 逻辑cpu个数
  6. grep 'processor' /proc/cpuinfo | sort -u | wc -l
  7. # 查看系统版本:
  8. cat /etc/redhat-release

安装软件命令

ubuntu

  1. #安装node示例
  2. sudo apt-get install nodejs
  3. #安装jdk
  4. sudo apt-get install openjdk-8-jdk

centos

  1. #安装node示例
  2. yum install nodejs
  3. #安装jdk
  4. yum install java-1.8.0-openjdk-devel.x86_64

mac

查看进程

https://www.cnblogs.com/kaiye/archive/2013/05/25/3099393.html

后台运行程序

  • 语法:nohup command [arg…] [ &]

nohup 表示窗口关闭了也可以运行,&表示ctrl+c 后也可以运行

示例

  1. ~ nohup ping www.baidu.com &