Linux常用命令

网络配置命令

查看当前网卡信息

  • ifconfig -a

修改网卡名称,需重启

  • vi /etc/udev/rules.d/70-persistent-net.rules

修改网卡配置信息

  • vi /etc/sysconfig/network-script/ifccfg-eth0

临时配制IP地址信息

  • ifconfig eth0 192.168.0.188 netmask 255.255.255.0
  • route add default gw 192.168.0.1

修改主机名

  • sudo nano /etc/sysconfig/network
  • sudo nano /etc/hosts

用户和用户组操作

将普通用户添加sudo权限

  • chmod u+w /etc/sudoers
  • vim /etc/sudoers
  • root ALL=(ALL) ALL xxx ALL=(ALL) ALL
  • chmod u-w /etc/sudoers

查看用户列表

  • cat /etc/passwd

查看用户组列表

  • cat /etc/group

查看活跃的用户

  • w

强制踢掉登录用户

  • pkill -kill -t [tty]

进程和端口

显示正在监听的端口

  • netstat -l

找出程序运行的端口

  • netstat -ap | grep ssh

找出运行在指定端口的进程

  • netstat -anp | grep ':80'

查看防火墙是否开启指定端口

  • iptables -L -n|grep 5432

查看指定的进程是否在运行

  • ps -ef|grep postgres

其他命令

给指定用户发消息

  • write [username] [tty]

查看内核版本信息

  • cat /proc/version
  • uname -a

查看发行版本信息

  • cat /etc/issue

将history加上日期

  • HISTTIMEFORMAT='%F%T '
  • history
原文地址:https://www.cnblogs.com/Tiago/p/5680900.html