美文网首页
linux命令备忘

linux命令备忘

作者: 也许________ | 来源:发表于2020-05-29 10:28 被阅读0次
    查看当前目录路径
    pwd
    
    创建文件夹并赋权限
    mkdir -m 777 test
    
    清空文件内容
    cat /dev/null > test.txt
    
    查看文件内容
    head -n 20 test.txt 查看文件前20行内容
    tail -n 50 test.txt 查看文件最后50行内容
    cat test.txt 查看文件内容
    tail -f test.txt 可查看文件的动态内容
    使用tail时,ctrl + s 暂停滚动 ctrl + q 恢复滚动 ctrl + c结束查看
    
    查找文件
    find /opt -name '*.txt' 在opt目录下查找后缀为txt的文件
    find -name '*.sh' 在当前目录下查找后缀为sh的文件
    find /home -name '*.jar' -size +10M 在home目录下查找后缀为jar并且文件大于10M的文件
    

    cd命令

    cd / 回到根目录
    cd - 回到上次使用的目录,这个命令很实用,切换不同的目录时免去写入全路径
    cd -- 回到用户家目录 /home/xxx
    

    相关文章

      网友评论

          本文标题:linux命令备忘

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