Linux 入門 - ディスクおよびファイル管理コマンド

ディスクおよびファイル管理コマンド

システムカタログのご紹介

/:ルート ディレクトリ。通常、ルート ディレクトリにはディレクトリのみが保存され、ファイルは保存されません。/etc、/bin、/dev、/lib、/sbin は、ルート ディレクトリ /bin(binary) と同じパーティションに配置する必要があります。 / usr/
bin : 一般的なコマンド ls、tar、mv、cat などの実行可能バイナリ ファイルのディレクトリ。
/boot: Linux システムの起動時に使用されるいくつかのファイルを配置します。/boot/vmlinuz は Linux のカーネル ファイルで、/boot/grub です。個別にパーティションを作成することをお勧めします。パーティションのサイズは 100M
/dev です。Linuxシステムにデバイス ファイルを保存し、このディレクトリ内のファイルにアクセスします。これは、特定のデバイスにアクセスするのと同じです。一般的な方法は CD をマウントすることです。 -ROM ドライブは /dev/cdrom /mnt をマウントします。
/etc: システム構成ファイルが保管されるディレクトリ。このディレクトリに実行可能ファイルを保管することはお勧めできません。重要な構成ファイルには、/etc/inittab、/etc/fstab、/etc/init.d、/etc/X11、 /etc 構成ファイルを変更する前に、/sysconfig、/etc/xinetd.d を必ずバックアップしてください。注: /etc/X11 には、X ウィンドウに関連する設定が保存されます。
/home:システムのデフォルト (通常の) ユーザー ホーム ディレクトリ。新しいユーザー アカウントを追加すると、ユーザーのホーム ディレクトリがこのディレクトリに保存され、現在のユーザーのホーム ディレクトリを示し、 test はユーザー test のホーム ディレクトリを示します。ユーザーがデータを保存しやすいように、個別にパーティションを作成し、より大きなディスク領域を設定することをお勧めします
/lib: /usr/lib:/usr/local/lib: システムが使用する関数ライブラリのディレクトリ プログラムの実行中に、いくつかの追加関数を呼び出す必要があります。パラメータには関数ライブラリの支援が必要です。より重要なディレクトリは /lib/modules です。
/mnt: /メディア:デバイスのデフォルトのマウント ポイント。通常、CD は /mnt/cdrom にマウントされますが、必ずしも必要ではありません。マウントする場所は任意に選択できます。 /
opt:ホスト用の追加ソフトウェアがインストールされるディレクトリ。例: FC4 で使用される Fedora コミュニティ開発ソフトウェア。新しい KDE デスクトップ ソフトウェアを自分でインストールする場合は、このディレクトリにソフトウェアをインストールできます。
以前の Linux システムでは、/usr/local ディレクトリ/procに配置するのが一般的でした:このディレクトリ内のデータは、システム コア、外部デバイス、ネットワーク ステータスなどのメモリ内にあります。メモリ、ディスク領域を占有しません。より重要なディレクトリ プロセスには、/proc/cpuinfo、/proc/interrupts、/proc/dma、/proc/ioports、/proc/net/* などが含まれます。 /root: ホーム(root) システム管理者のルート、システムのディレクトリ。
最初のブート パーティションは / なので、/root と / を 1 つのパーティションの下に配置するのが最善です。
/sbin: /usr/sbin:/usr/local/sbin: fdisk、shutdown、mount など、システム管理者の root が使用する実行可能コマンドを配置します。/bin との違いは、これらのディレクトリはシステム管理者 root 向けのコマンドであり、一般ユーザーは「参照」のみで設定・使用はできないことです。
/tmp :一般ユーザーや実行中のプログラムがファイルを一時的に保存するディレクトリ 誰でもアクセス可能 重要なデータをこのディレクトリに置くことはできません /srv
: Webページなどサービス起動後にアクセスが必要なデータディレクトリwww サービスがアクセスする必要があるデータ /srv/www
/usr に保存されます:アプリケーション格納ディレクトリである /usr/bin にはアプリケーション プログラムが格納され、/usr/share には共有データが格納され、/usr/lib には直接実行できないが多くのプログラムの実行に必要な関数ライブラリ ファイルが格納されます。/usr/local: ソフトウェア アップグレード パッケージを保存します。/usr/share/doc: システム記述ファイルが保存されるディレクトリ。/usr/share/man: プログラム記述ファイルが保存されているディレクトリ。man ls を使用すると、/usr/share/man/man1/ls.1.gz の内容が照会されます。個別にパーティション化することをお勧めします。より大きなディスク容量を設定します /
var:随時変更されるログ ファイルなど、実行中に頻繁に変更されるシステム ファイルを配置します。 変数 /var/log、/var/log/message: すべてのログイン ファイルを保存するディレクトリ、/var/ spool/mail: メールを格納するディレクトリ、/var/run : プログラムまたはサービスの起動

コマンド形式

コマンド [-オプション] [パラメータ]
例: ls -la /usr

コマンドカテゴリとヘルプ

内部コマンド: シェル パーサーの一部 (cd pwd)、実行速度が速くなります。
外部コマンド: シェル パーサーから独立したファイル プログラム (ls mkdir)、実行速度が遅くなります (外部コマンドを実行するたび) 、シェル解析が必要です。最初にパーサーをロードしてから実行します)
内部コマンド: help + コマンド (help cd)
外部コマンド: man (マニュアル ヘルプ マニュアル) + コマンド (man ls)
コマンドのヘルプ ドキュメントを表示します。長い場合は、Enter キーを押して 1 行ずつ読み、スペース (スペース) キーを押して文字 q (終了) をページごとに読み、ヘルプ文書を終了します

共通コマンド

  • ディレクトリの内容を表示する
  ls     list directory contents          列出目录内容
      选项:
        -a    all   do not ignore entries starting with .     
        在linux系统中以.开头的文件或者目录是隐藏文件   -a 显示所有内容,包括隐藏文件
        -l    use a long listing format    使用长的列表格式显示目录或者详情
        -t    sort by modification time, newest first    按照更新时间排序   越新的越在前面倒叙排序文件内容
简单练习:
        touch .a      创建.a文件
        touch .b      创建.b文件
        mkdir .aaa   创建.aaa目录
        mkdir .bbb
         ls           查看不到.开头目录文件
         ls  -a       显示所有的   
        
         ls  -l       显示内容详细信息
         ll           是ls -l 的简化写法
         ls  -a -l    多个选项一起使用     显示所有内容的详情  
         ls  -al      多个选项可以合并使用
         ls  -la      
     
         ls
         ls -t        发现显示文件顺序不同
         ls -a -l -t  发现确实按照更新时间倒叙排序
         ls -alt    
         ls -lat    
        
         ls -alt  /   显示根目录所有内容详情,倒叙排序
         ls -lta  /etc/   
         ls -la  /etc/sysconfig/network-scripts/
         ls   -l   ../             相对目录       ../上级目录
         cd  /etc/sysconfig/network-scripts/      进入该目录
         ls ../../../root/         相对路径显示   选项可以随意加
  • ディレクトリを切り替える
cd   Change the shell working directory      改变工作目录
      具体使用:
      cd  /etc/sysconfig/network-scripts/    切换到指定目录
      cd  ../                                切换上级目录
      cd ../../                              切换到上两级目录
      cd                                     什么都参数都不加 切换到当前用户的根目录
      cd  /etc/sysconfig/network-scripts/
      cd  ~                                  和上面什么参数都不加一样   切换到当前用户的根目录    
  • ディレクトリを作成する
mkdir     make directories             创建单个/多个目录
     选项:
         -p    parents     no error if existing, make parent directories as needed  
         一次创建多级目录,使用-p会按照需要创建父目录,不会让创建错误
     具体用法:
          mkdir spring                 创建单个目录
          mkdir  mybatis  springboot   创建多个目录
          mkdir  spring/ioc   spring/aop   spring/mvc      一次在某一个目录下创建多个目录
          ls spring 
          mkdir ../var/aaa ../var/bbb  相对路径创建多个目录
          ls /var/
          mkdir aa/bb/cc/dd            错误的  因为创建dd时,cc不存在。。。。
          mkdir -p  aa/bb/cc/dd        正确写法
  • ファイルを作成する
 touch      change file timestamps     改变文件时间戳
             A FILE argument that does not exist is created empty    
             当touch命令后根的参数文件不存在时,会创建一个空文件
		     具体用法:
		     	ll                查看a.txt的创建时间
		    	touch  a.txt      改变a.txt的文件更新时间
		        ll                发现a.txt的更新时间编程当前时间
		        touch  b.txt      b.txt不存在就会创建一个空的b.txt
		        ll                发现b.txt被创建,内容为0
  • ファイルの内容を表示する

cat: ファイルを連結して標準出力に出力 ファイルを連結して標準出力に出力し、ファイルのすべての内容を表示します

简单练习: 
	  touch  a.txt
      touch  b.txt
      touch  c.txt
      echo  'hello'            正常显示标准输出   echo=  display a line of text
      echo 'hello' > a.txt     > 写入   把hello内容写入到a.txt
      echo 'world' > b.txt    
      echo 'bye' > b.txt 
      ll 
      cat a.txt b.txt c.txt    串联3个文件,并把内容打印
      cat a.txt      
      cat b.txt     

      touch tomcat.log         创建一个tomcat.log文件
      echo 'abc' > tomcat.log  写入abc
      cat   tomcat.log
      echo '123' > tomcat.log  写入123
      cat  tomcat.log          发现写入会覆盖原来内容
      date                     显示当前时间
      date >> tomcat.log       >>追加  不会覆盖原来内容,在原来内容的下一行进行追加
      cat  tomcat.log
      date >> tomcat.log       多次执行  发现都是追加
      cat  tomcat.log          当我们执行多次后,文件不再一页   cat的弊端就显示出来,只能看到文件的最后一页内容

頭:

 output the first part of files       显示文件的开始部分选项:
               -n   lines      print the first K lines instead of the first 10;---如果指定了n的值为k  打印 前K 代替前10行
       具体用法:
              head tomcat.log         默认显示文件的前10行
              head -5 tomcat.log      显示前5行
              head -2 tomcat.log 
              head -20 tomcat.log 

しっぽ:

 output the last part of files     输出文件的末尾部分
          选项: 
            -n                     显示文件尾部指定行
            -f                     follow    output appended data as the file grows --文件增长时显示追加数据   
            -F                     和-f    只不过带retry(重试)功能  
           具体用法:
            tail tomcat.log        默认显示后10行
            tail -2  tomcat.log
            tail -20  tomcat.log
            tail -f tomcat.log     查看tomcat.log追加部分   会阻塞不动,另外启动一个会话窗口,在里面执行
            echo 'appened111'  >>  tomcat.log 
            echo 'appened222'  >>  tomcat.log 
            date>>tomcat.log       多次执行    观察原窗口的变化

           tail -F   tomcat.log    带重试功能,在web项目中都会记录日志,通常记录日志时,如果日志是按照日志每天生成的, 当前的文件是tomcat.out   今天过完把tomcat.log变为tomcat.2022-08-12.log文件,最新的仍然是tomcat.out   继续追踪最新文件 
           ctrl+c                  退出

もっと:

file perusal filter for crt viewing       分页显示数据
             具体用法:
                 more   settings.xml
                     enter                键 一行一行显示
                     space                空格键   向下翻页
                     ctrl+f               向下翻页
                     ctrl+b               向上翻页
                     q                    退出

以下:

 opposite of more                        分页显示数据
            具体用法:
                 less    settings.xml
                     enter               键 一行一行显示
                     space               空格键   向下翻页
                     ctrl+f              向下翻页
                     ctrl+b              向上翻页
                     q                   退出
                     可以使用 /关键字      进行搜索  高亮关键字    
  • ファイルをコピーする
cp    opy files and directories     复制和目录    相当于windows下的ctrl+c  + ctrl+v
        选项:
              -r     recursive      递归     copy directories recursively   递归复制目录
        具体用法:
             ls
             cp   a.txt   spring    复制a.txt到spring目录
             ls 
             ls  spring             发现存在了
             ls  /tmp
             cp  /root/a.txt  /tmp  复制a.txt到/tmp目录下
             ls  /tmp
             cp ../etc/sysconfig/network-scripts/ifcfg-ens33   /tmp/   相对路径复制
             ls  /tmp
             cat  /tmp/ifcfg-ens33
             mkdir    frames        创建一个框架目录
             cp spring frames/      cp 不可以直接复制目录
             mkdir spring/aop/aspect
             mkdir spring/aop/pointcut
             cp -r  spring  frames/ 复制spring目录到frames目录下
             ls frames/spring/
             ls frames/spring/aop/
  • 現在の作業ディレクトリを表示する
 pwd    print name of current/working directory        打印当前工作目录的名称
         具体用法:
            pwd    回车 ,默认显示当前工作目录的位置
            cd /etc/sysconfig/network-scripts/
            pwd
            cd ../
            pwd 
            cd ../../ 
            pwd  
  • ファイルの移動または名前変更
 mv    move (rename) files           移动/重命名   文件        相当于windows中的ctrl+x ctrl+v
          具体用法:
                ls
                ls spring
                mv  b.txt   spring   移动b.txt 文件到  目录中
                ls                   发现b.txt没有了
                ls  spring           发现b.txt
                ls /var/log/ 
                mv  /root/c.txt   /var/log/   移动c.txt到 /var/log/
                ls                   发现c.txt没有了
                ls /var/log/         发现c.txt
                ls 
                mv springboot/ frames/        移动目录到另外一个目录中
                ls  
                ls   /frames         发现springboot目录

                ls
                mv  a.txt   aaa.txt  把a.txt重命名为aaa.txt    aaa.txt目录不存在
                ls
                mv  frames/ frameset 把目录frames重命名为frameset
                ls        
  • 空のディレクトリを削除する
rmdir     remove empty directories    删除空目录
      具体用法:
       ls
       rmdir mybatis/     直接删除空目录mybatis
       ls
       rmdir frameset/    不能删除非空目录
       ls
       mkdir bb cc dd 
       ls
       rmdir bb cc dd     删除多个空目录
       ls
       mkdir -p bb/cc/dd
       rmdir bb           无法删除
  • ファイルの削除
rm   remove files or directories   移除为你教案或者目录
      选项:
         -r  recursive         递归的  remove directories and their contents recursively
         递归删除目录及目录下所有内容
         -f   force  强制的     ignore nonexistent files and arguments, never prompt  
         不带提示信息,直接删除
      具体用法:
        ls
        rm 中文.txt             删除  中文.txt   有提示信息    需要确认是否删除   y/n
        ls
        rm -f  aaa.txt         直接删除aaa.txt不带提示
        ls
        mkdir   -p  bb/cc/dd
        rm   -f    bb          无法删除目录
        rm   bb                无法删除目录
        ls
        rm -rf  bb             不带提示递归删除目录bb 及其下的所有内容
        ls 
        无论是文件或者目录,都可以使用   rm -rf    强制删除
        touch frameset/a   frameset/b   frameset/c.log   在frameset下创建3个文件
        ls  frameset           有目录也有文件
        rm -rf frameset/*      * 为通配符,通配所有内容
        ls  frameset 
        ls
        rm -rf  aa  spring/  settings.xml     移动多个文件和目录
        ls  
  • ファイル統計
wc    (word count)  print newline, word, and byte counts for each file    打印每个文件行数,单词数和字节数
     选项:
       -l       print the newline counts   打印行数
       -c       print the byte counts      打印字节数
       -m       print the character counts 打印字符数(utf-8时一个中文1个字符  3个字节)
       -w       print the word counts      打印单词数
      具体用法:
          touch a.log
          echo 'hello'>>a.log
          wc  a.log           结果为1 1 6 a.log     行数    单词数(以换行或者空格分割)  字节数(一个空格和换行都按照1个字节计算   1个中文汉字占3个字节utf-8)    文件名字
          echo '中国'>>a.log
          cat a.log     
          wc   a.log          2  2  13    22单词   13字节
          echo 'hello AAA'>>a.log
          cat  a.log
          wc a.log            3   4   23    34单词   23 字节   
          wc -l a.log   打印行数
          wc -c a.log   打印字节数
          wc -w  a.log  打印单词数
          wc -m  a.log  打印字符数 (一个中文占3个字符) 
  • ファイルまたはディレクトリを検索する
find   search for files in a directory hierarchy    按照目录层次查询文件
           具体用法:
           find   -name   '*t*'              列出当前目录下所有名称含有t的文件或者目录
           find  /etc   -name   '*audit*'    查找/etc下  所有名称含有audit的文件或者目录
           find  /etc   -name   '*t*'  
           find  /etc   -name   '*audit*' 
           find  /etc   -name   '*audit*' |  wc -l     查找/etc下  所有名称含有audit的文件或者目录 并统计行数      
           find  /etc   -name   '*t*'     |  wc -l     | 管道符   连接多个命令的     通常后一个命令把前一个命令的执行结果作为参数
  • ファイルの内容をフィルタリングする
grep(global  regular  expression  print)      print lines matching a pattern    全局按照正则表达式查找匹配内容,并把查找结果打印到标准数据
grep(缩写来自Globally search a Regular Expression and Print)是一种强大的文本搜索工具,它能使用特定模式匹配(包括正则表达式)搜索文本,并默认输出匹配行。(百度百科)
         具体用法:
            cat  tomcat.log            查看所有内容
            grep  22:  tomcat.log      查找含有22:的所有行,并打印
            grep This  settings.xml
            grep a  settings.xml
            grep a  settings.xml |  wc -l   从 settings.xml文件中查找含有a的行,并统计行数
            find  /etc   -name   '*t*'  | grep  pos    从find的查找结果查找含有pos的行并打印
            find  /etc   -name   '*t*'  | grep  pos | wc -l   从find的查找结果查找含有pos的行并打印,并统计行数
  • ショートカットの作成 (ソフトリンクとハードリンクの作成)
 ln    make links between files      在文件之间创建连接
         选项:
           -s    make symbolic links instead of hard links      为文件或者目录创建象征性的连接         软链接 (相当于windows下的快捷方式)
           -d    allow  the superuser to attempt to hard link directories     
           硬链接   给源文件创建一个副本文件,当源文件删除,对副本文件没有任何影响     
         具体用法:
            mkdir -p  /tmp/aaa/bbb/ccc
            ln -s /tmp/aaa/   aaa.lnk    为/tmp下aaa目录创建软连接到当前用户主目录下
            ls -l                        发现aaa.lnk连接到/tmp/aaa
            ls  aaa.lnk/                 测试是否可以使用   直接看到bbb
            rm -rf /tmp/aaa              删除源目录
            ll                           发现aaa.lnk变红色   不可用了
            mkdir -p  /tmp/aaa/bbb/ccc   再次创建目录
            ll    发现又可以使用
            ls   aaa.lnk 查看内容
            cat  a.log
            ln -d a.log  a.log.lnk       为a.log创建硬连接a.log.lnk
            cat a.log.lnk                直接查看内容
            rm -rf  a.log                删除源文件
            cat a.log.lnk                删除源文件对连接文件没有任何影响
  • ファイル
    gzip を圧縮および解凍します。
compress or expand files
          选项:
             -d    Decompress     解压缩
          具体用法:
          gzip   tomcat.log       压缩tomcat.log文件   产生一个tomcat.log.gz   源文件消失
          gzip -d   tomcat.log.gz 解压   压缩包消失,源文件出现     

bzip2:

  最小化安装,只安装了gzip  没有安装bzip2 
  在线安装bzip2 压缩解压方法
  ping www.baidu.com    看网络是否通畅
  yum -y install bzip2  自动分析依赖,在线安装软件bzip2
  a block-sorting file compressor,a block-sorting file compressor  压缩解压文件
     选项:
          -d  decompress       解压缩
     具体操作:
          ls
          bzip2  tomcat.log    压缩tomcat.log 产生tomcat.log.bz2   源文件消失
          ls
          bzip2  -d  tomcat.log.bz2   解压   压缩包消失   源文件出现
          ls 
          gzip frameset/
          bzip2  frameset/     
          这两个命令都无法直接对目录进行压缩  
  • ディレクトリ/ファイルの圧縮と解凍 圧縮されたパッケージの表示
tar:
     GNU  `tar'  saves many files together into a single tape or disk archive,
     and can restore individual files from the archive
     把许多文件保存到一起到一个单独磁带或者磁盘档案上,可以从档案中恢复文件,和windows下的压缩解压是一个意思
      选项:
           -c       create    创建   create a new archive     创建压缩
           -t       list      列表   list the contents of an archive    查看压缩包
           -x       extract   提取   extract files from an archive    从压缩包提取文件   解压缩
           上面3个选项中  都不可以共同使用
           -z   gzip   filter the archive through gzip   通过gzip方式进行过滤(压缩,查看压缩包,解压)
           -j   bzip2  filter the archive through bzip2  通过bzip2方式进行过滤(压缩,查看压缩包,解压)
           上面2个选项不能共同使用(不能压缩,查看或者解压过程中换方式)
           -v   verbose verbosely list files processed    显示文件详情   可选的,不要也可以
           -f   file    use archive file or device ARCHIVE     文档名称  
           -C   change  to directory DIR      改变目录   指定解压文件位置
 具体用法:既可以对文件进行操作 ,也可以对目录进行操作(本质tar 打包,打包可以打包目录,在打包过程使用gzip,bzip2进行压缩或者解压)
         ls
         mkdir  frameset
         mkdir  frameset/spring  frameset/springboot  frameset/mybatis  frameset/hibernate
         mkdir  frameset/spring/ioc  frameset/spring/aop  frameset/spring/mvc
          touch frameset/spring/ioc/a.log
          touch frameset/spring/ioc/b.log
          touch frameset/spring/aop/aa.log
          touch frameset/spring/aop/bb.log
          tar   -czvf  frameset.tar.gz   frameset/   压缩文件夹frameset,压缩之后的名称为frameset.tar.gz    因为带了v   所以会显示压缩过程  
          ls     发现和windows下一样,压缩后,源目录依然存在,产生frameset.tar.gz文件
          rm -rf frameset.tar.gz     删除,再压缩,演示不带v
          tar -czf  frameset.tar.gz  frameset     依然压缩,不再显示详细信息
          ls
          tar -tzvf frameset.tar.gz    查看压缩包(带v显示详情)
          tar -tjvf frameset.tar.gz    错误  压缩文件使用的gzip方式压缩的,不能使用bzip2的方式进行查看
          tar -tzvf frameset.tar.gz    查看压缩包(不带v不显示详情)
          ls 
          rm -rf frameset  删除源目录
          tar -xjvf frameset.tar.gz    解压错误  压缩文件使用的gzip方式压缩的,不能使用bzip2的方式进行解压
          tar -xzvf frameset.tar.gz    解压   没有-C  默认解压到当前目录
          ls    
          ls  /tmp  
          tar -xzvf  frameset.tar.gz  -C  /tmp/    解压到指定目录
          ls  /tmp 
          ls  /tmp/frameset    
    
          tar -cjvf frameset.tar.bz2  frameset    使用bzip2方式进行压缩
          ls
          tar -tjvf frameset.tar.bz2     查看压缩包
          rm -rf frameset     删除源目录
          ls   查看
          tar -xjvf frameset.tar.bz2    解压到当前目录
          ls 
          ls frameset
          ls  /var
          tar -xjvf frameset.tar.bz2  -C /var/   解压到指定的/var目录
          ls /var/
          ls /var/frameset/

役割、特権、コマンド

4 つの役割:

ここに画像の説明を挿入
ビット 1: ファイルタイプ (d ディレクトリ、- 通常ファイル、l リンクファイル)
「-」は通常ファイル、
「d」はディレクトリ、
「l」はリンクファイル、
「p」は管理ファイル、
「b」はブロックデバイスを意味しますファイル;
"c" はキャラクタ デバイス ファイルを意味します;
"s" はソケット ファイルを意味します;
2 ~ 4 桁目: ユーザー権限、u (ユーザー) を使用して表します。
5 ~ 7 桁目: グループ権限、g (グループ) を使用して表します
8桁目から10桁目:その他のユーザー権限を表し、o(other)で表します。
2桁目から10桁目:すべての権限を表し、a(all)で表します。

3 つの基本的な権限:
r 読み取り権限 (読み取り)
w 書き込み権限 (書き込み)
x 実行権限 (実行)
chmod ファイル権限変更コマンド (モード変更)
パラメータ: -R 次のファイルとサブディレクトリは同じ権限操作を実行します (再帰的再帰)

例如:
chmod  u[go/a]+/-x[rw]  a.log
touch  a.log
[root@basic ~]# chmod u+x a.log
[root@basic ~]# ll a.log
-rwxr--r--. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod g+wx a.log
[root@basic ~]# ll a.log
-rwxrwxr--. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod o+wx a.log
[root@basic ~]# ll a.log
-rwxrwxrwx. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod a-rwx a.log
[root@basic ~]# ll a.log
----------. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod ug+rw a.log
[root@basic ~]# ll a.log
-rw-rw----. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod aug-rw a.log
[root@basic ~]# ll a.log
----------. 1 root root 16 812 16:43 a.log```

3 桁の 2 進数認証
3 桁の 2 進数を使用して 10 進数の 0 ~ 8 を識別します

10進数 3桁 2進数
0 000
1 001
2 010
3 011
4 100
5
101 6 110
7 111
8 1000

chmod 7 7 7 a.log
111 111 111
2 3 4
010 011 100
-w- -wx r–

 5   6   7
 101 110 111
 r-x rw- rwx
例如:
[root@basic ~]# chmod 777 a.log
[root@basic ~]# ll a.log
-rwxrwxrwx. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod 000 a.log
[root@basic ~]# ll a.log
----------. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod 234 a.log
[root@basic ~]# ll a.log
--w--wxr--. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod 238 a.log
chmod: 无效模式:"238"
Try 'chmod --help' for more information.
[root@basic ~]# chmod 777 a.log
[root@basic ~]# ll a.log
-rwxrwxrwx. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod 234 a.log
[root@basic ~]# ll a.log
--w--wxr--. 1 root root 16 812 16:43 a.log
[root@basic ~]# chmod 567 a.log
[root@basic ~]# ll a.log

開花が終わりました、また会いましょうノラ

おすすめ

転載: blog.csdn.net/weixin_44834205/article/details/126398382