Ubuntu常用命令

加粗的是命令  非加粗是变量

PV分析

  wc -l access.log    # 查看总访问量

PV分组

  awt '{print substr($4,2,11)}' access.log | sort | uniq -c    #  统计每天访问量

UV分析

  awt '{print $1}' access.log | sort | uniq | wc -l    # 统计唯一用户访问量

查看TIME_WAIT

  netstat -n | awk '/^tcp/ {++y[$NF]} END {for(w in y) print w, y[w]}'

查看CLOSE_WAIT

  netstat -an|grep CLOSE_WAIT|wc -l

查看TCP连接数

  netstat -anp |grep tcp |wc -l

查看TCP初始状态

   netstat -s |grep -E 'listen| resets sent| LISTEN'


操作文本 

  gedit hello.txt     # 创建一个hello.txt文件
  cat hello.txt    # 看hello.txt 里的内容(tac倒看)
  vi hello.txt     # 编辑hello.txt 的内容
  nl hello.txt     # 显示看hello.txt里的内容并且显示行号
  more hello.txt     # 一页页显示内容 (less相识, 但是可以往前翻页)

  wc -l hello.txt  # 查看总行数

  tail -n 5 hello.txt  # 查看最后5行

  top -n 5 hello.txt   # 查看头5行

  

修改时间

  touch -t ‘2 years old’ bashrc      # 修改文档时间

找文件
  locate [ir] filename     # 找指定文件 ir 忽略大小写
  find / -mtime 3   # 查找三天前24有改动的文件

压缩 、解压文件
  gzip -v hello.txt   # 压缩hello文件 后缀为gz文件
  gzip -d hello.txt   # 解压hello文件 并删除压缩包
  bzip2 -z hello.txt   # 压缩成后缀为bz2文件

  tar -xvf file.tar   //解压 tar包
  tar -xzvf file.tar.gz   //解压tar.gz

  tar -xvf -f hello.tar.bz2 -C 解压到的目录      # 解压
  tar -jcv -f hello.tar.bz2 要压缩的目录      # 压缩
 
  unrar e file.rar   //解压rar
  unzip file.zip   //解压zip

  whereis python     # 查看python所在的目录

  echo $PATH    # 查看环境变量

  vi ~/.bashrc       # 增加环境变量

    export PATH=/usr/bin/python/:usr/bin/python3:$PATH     #  在文件后面增加所要增加的环境

此时此刻,非我莫属
原文地址:https://www.cnblogs.com/taozhengquan/p/10122813.html