美文网首页
Linux 常用命令

Linux 常用命令

作者: 顶宝麻麻 | 来源:发表于2019-07-19 17:14 被阅读0次
  • date 查看时间

  • date 0719112319.30 设置当前时间为2019-07-19 11:23:30

  • tar -cvf number.tar 1.txt 2.txt 把1.txt 2.txt 压缩为number.tar

  • tar -xvf number.tar 解压 number.tar

  • find . -name *.txt 查找当前目录所有以txt结尾的文件

  • find . -mtime +5 查找更改时间为5日以内的文件

  • find . -mtime -5 查找更改时间为5日以前的文件

  • find . -type d 查找当前目录下所有目录

  • find . -type f 查找当前目录下所有文件

  • find . -mtime +3 -print|xargs rm 删除更改时间为3日以内的文件

  • find . -mtime -3 -print|xargs rm 删除更改时间为3日以前的文件

  • find . -size 0 |xargs rm 删除文件大小为0的文件

  • mtime(modify time) 只有更改内容才会更新
    ctime (create time) 只有更名,属主等才会更新
    atime(access time) 只有查看文件内容的时候才会更新

  • wget -o isTester_logo.png http://51.istester.com/isTester.png 下载isTester.png 并存储为isTester_logo.png

  • wget -b http://51.istester.com/isTester.png 以后台形式下载isTester.png

  • sudo su 普通用户切换到root,使用su 会报鉴定故障

  • rm test.txt 删除test.txt文件(会询问是否删除)

  • rm -f test.txt 删除test.txt文件(不会询问是否删除)

  • rm -rf test/ 强行删除test文件夹(r 是递归)

  • rm -rf test/* 强行删除test文件夹下的所有文件

  • 新建文件的几种方式:
    touch hello.txt
    vim hello.txt
    echo 'hello' > hello.txt
    cp test.txt hello.txt
    ls > list.txt

  • touch hello{1..10}.txt 一次创建10个文件

  • 查看文件的几种方式
    cat 从第一行开始显示内容
    tac 从最后一行开始显示内容
    more 一页一页的显示内容
    less 同more类型,它可以向前翻页
    head 只看头几行
    tail 只看最后几行
    nl 显示的时候显示行号

    cat hello.txt 查看hello.txt所有内容
    head -n 20 nginx.log 查看前20行内容
    tail -n -30 nginx.log 查看最后30行内容
    head -n 30 nginx.log | tail -n 10 查看第20-30的内容
    nl nginx.log |head -n 10 显示前10行内容,并显示行号

  • scp installation.dat root@10.65.120.1:/root 从10.65.120.1服务器上拷贝installation.dat到root目录下

  • ifonfig / ip address 查看本机IP

  • df -h 查看服务器磁盘空间

  • free 查看内存情况
    total used free shared buff/cache available
    Mem: 995896 264720 92400 14028 638776 521212
    Swap: 2097148 264 2096884

    • total:总计物理内存的大小。
    • used:已使用多大。
    • free:可用有多少。
    • Shared:多个进程共享的内存总额。
    • Buffers/cached:磁盘缓存的大小。
  • du -sh test/ 查看test所占空间

  • chmod +x hello.py 使hello.py有可执行权限

  • netstat -anp | grep 端口号 查看端口号占用情况

  • netstat -nultp 查看所有已经使用的端口情况


参考文献:https://mp.weixin.qq.com/s/sefGpxN3eJ4YmhDW52LQ9g

相关文章

网友评论

      本文标题:Linux 常用命令

      本文链接:https://www.haomeiwen.com/subject/bzdjlctx.html