Linux操作系统的常用命令

基础命令
  1. 基本信息
    uname -a
    uptime
    last
    cat /etc/redhat-release
    cat /proc/cpuinfo
    free -m
  2. 磁盘管理
    df
    du
    fdisk
    mkfs
    fsck
    mount
    umount
  3. 网络信息
    ifconfig
    route -n
    iftop
    iptables -L
    netstat -lntp
    telnet
    wget
    dig
    nslookup
  4. 用户和组
    cut -d: -f1 /etc/passwd
    cut -d: -f1 /etc/group
    id <username>
    w
    user*
    group*
    passwd
  5. 应用进程
    yum
    rpm -qa
    systemctl
    top/htop
    ps aux
    kill
    pkill
    killall
  6. 文件目录
    cat
    more
    vi
    pwd
    tree
    touch
    mkdir
    cp
    mv
    rm
    tar
    zip
  7. 文件查找
    find
    locate
    whereis
    which
  8. 字符处理
    sed
    awk
    grep
    sort
    uniq
  9. 内容效验
    md5sum
    cksum
    diff
  10. 重启关机
    reboot
    init 6
    shutdown -r now
    halt
    init 0
    shutdown -h now
常用命令
序号说明命令补充
1查找软件安装位置whereis nginx
2查看端口占用lsof -i:80netstat -lntp | grep :80
3删除乱码文件(通过指定文件节点编号删除)ls -l
find -inum -delete xxx
4查看排除注释行和空行的文件grep -v "^#" file | grep -v "^$"
5将文件中的注释行和空行删除sed '/ \*#/d; /^$/d' file
6将文件中的AA替换为BBsed 's/AA/BB/g' file
8查看两个文件的并集sort file1 file2 | uniquniq -u删除交集,uniq -d取出交集
9查看目标服务器与本机时间差clockdiff x.x.x.x
10

评论

暂无评论