linux 学习笔记 day1

  1. tree (需要安装)
  2. ls
  3. cd
    ~:当前用户home 目录
  4. pwd
  5. mkdir
  6. touch file
    文件存在:更新文件时间戳
    文件不存在:创建文件
  7. rmdir 空目录
  8. rm dir
    -r 递归方式
    -i 提示
    -f 强制
  9. cp
    (1)cp file1 file2
    file2不存在: 先创建file2,再将file1的内容复制过去
    file2存在:复制file1的内容到file2

  10. mv
    (1)改名 mv file1/dir1(存在) file2/dir2(不存在)
    (2)移动 mv file(存在) dir(存在)
    mv dir1(存在) dir2(存在)
    (3)覆盖 mv file1(存在) file2(存在)
  11. 查看文件
  • cat (适用文件小的情况)
  • more (只能向下浏览)
  • less
    滚动一行:向下:回车/ctrl+n 向上:ctrl+p
    滚动一页:向下:空格/pageDown 向上:pageUp
  • head -n file (默认n=10)
  • tail -n file (默认n=5)
  1. 软硬链接 ln
    (1)软链接:快捷方式
    ln -s file/dir linkName
    file/dir使用绝对路径,否则移动后会失效
    (2)硬链接:
    ln file/dir linkName
  • 原理:如下图file1和file3
    硬链接
  • 应用场景:在多个目录管理同步管理同一个文件
  1. chmod
    chmod[+|-|=]mode file
    r:4 w:2 x:1 -:0
    ps:目录没有执行权限的话无法cd进去
  2. chown/chgrp
    (1)chown user file
    (2)chown user:group file
  3. find 路径 参数 内容
    高级:find -dir args | xargs ls -l
  4. grep 内容 路径
    17.解压缩
    tar
    rar
    zip

猜你喜欢

转载自www.cnblogs.com/longl/p/9643118.html