Linux指令笔记

本文详细介绍了Linux系统中常用的一些命令,包括帮助命令如man、help、info,以及pwd、ls、cd、mkdir、rmdir、rm、cp、mv、touch等文件和目录操作命令。此外,还涵盖了通配符的使用和文本查看命令,如cat、head、tail、wc、more、less。最后提到了打包与压缩命令tar以及文本编辑器vim的使用。
摘要由CSDN通过智能技术生成

本文概览

本篇文章主要记录下我们在日常使用Linux系统时一些经常使用的命令,作为自己的一个备忘录。内容主要包括:

  • 帮助命令
  • 有关目录和文件的操作命令
  • 有关用户的操作命令
  • 有关用户组的操作命令
  • 有关权限的相关操作命令

一、帮助命令:man、help、info

Linux命令非常的多,但大多数情况下我们不需要去死记硬背,主要是以理解为主,把握在什么情况下,应该使用哪方面的命令。

1、help

help的用法有两种:

  • 一种是针对内部命令

    • [root@VM-24-10-centos ~]# help cd
      cd: cd [-L|[-P [-e]]] [dir]
          Change the shell working directory.
      
          Change the current directory to DIR.  The default DIR is the value of the
          HOME shell variable.
      
          The variable CDPATH defines the search path for the directory containing
          DIR.  Alternative directory names in CDPATH are separated by a colon (:).
          A null directory name is the same as the current directory.  If DIR begins
          with a slash (/), then CDPATH is not used.
      
          If the directory is not found, and the shell option `cdable_vars' is set,
          the word is assumed to be  a variable name.  If that variable has a value,
          its value is used for DIR.
      
          Options:
              -L	force symbolic links to be followed
              -P	use the physical directory structure without following symbolic
          	links
              -e	if the -P option is supplied, and the current working directory
          	cannot be determined successfully, exit with a non-zero status
      
          The default is to follow symbolic links, as if `-L' were specified.
      
          Exit Status:
          Returns 0 if the directory is changed, and if $PWD is set successfully when
          -P is used; non-zero otherwise.
      
  • 一种是针对外部命令

    • [root@VM-24-10-centos ~]# ls --help
      用法:ls [选项]... [文件]...
      List information about the FILEs (the current directory by default).
      Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
      
      Mandatory arguments to long options are mandatory for short options too.
        -a, --all			不隐藏任何以. 开始的项目
        -A, --almost-all		列出除. 及.. 以外的任何项目
            --author			与-l 同时使用时列出每个文件的作者
        -b, --escape			以八进制溢出序列表示不可打印的字符
      ... 省略
      

我们可以清楚的看到当我们记住常用的命令时,通过help就可以快速准确的查到相应的选项来操作具体的文件(Linux一切接文件);上面提到了两个词:内部命令和外部命令,外部命令也称为文件系统命令,是 bash shell 之外的程序,它并不是 shell 的一部分,内部指令则是shell内的指令,一般是比较简单的指令。我们可以通过type command来区别该命令是内部还是外部,进而选择相应的help命令来查询命令选项

[root@VM-24-10-centos ~]# type cd
cd 是 shell 内嵌
[root@VM-24-10-centos ~]# type ls
ls`ls --color=auto' 的别名
[root@VM-24-10-centos ~]# type pwd
pwd 是 shell 内嵌
[root@VM-24-10-centos ~]# type mv
mv`mv -i' 的别名

2、man

虽然【help】命令已经相当好用,不过,help命令通常是来协助我们查询曾经使用的命令所具备的选项与参数而已,当我们要使用从来没有用过的命令或者要查询的根本就不是命令而是文件的格式时,那就要通过【man】命令来解决了

[root@VM-24-10-centos ~]# man ls
LS(1)                                        User Commands                                        LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).  Sort entries alphabeti‐
       cally if none of -cftuvSUX nor --sort is specified.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file

       -b, --escape
              print C-style escapes for nongraphic characters

       --block-size=SIZE
              scale sizes by SIZE before printing them; e.g., '--block-size=M' prints sizes in units of
              1,048,576 bytes; see SIZE format below

       -B, --ignore-backups
              do not list implied entries ending with ~

       -c     with  -lt:  sort  by,  and show, ctime (time of last modification of file status informa‐
              tion); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first

       -C     list entries by columns

       --color[=WHEN]
              colorize the output; WHEN can be 'never', 'auto', or 'always' (the  default);  more  info
              below

       -d, --directory
              list directories themselves, not their contents

       -D, --dired
              generate output designed for Emacs' dired mode

       -f     do not sort, enable -aU, disable -ls --color

       -F, --classify
              append indicator (one of */=>@|) to entries
...省略

# 只知道名字,不知道是命令还是文件,可以用这个命令
[root@VM-24-10-centos ~]# man -a passwd
# 指定章节,1一般不用写,可省略
[root@VM-24-10-centos ~]# man 1 passwd

细心的同学可能会发现【man page】中的LS((1))字眼,这个((1))代表什么呢?它代表的是"用户指令",在man命令中一共分为以下几个数字(其中下面的1,5,8要特殊掌握,特别重要):

代号代表内容
1用户在shell环境中可以操作的命令或可执行文件
2系统内核可调用的函数与工具等
3一些常用函数(function)与函数库(library),大部分为C的函数库(libc)
4设备文件的说明,通过在/dev下的文件
5配置文件或是某些文件的格式
6游戏
7惯例与协议等,例如Linux文件系统、网络协议、ASCII代码等的说明
8系统管理员可用的管理命令
9跟内核有关的文件

通过上面的man命令我们可以看到,全英文哈哈,下面再提供个汉化版,可以操作一下:

3、info

在所有的UNIX-like系统当中,都可以利用man来查询命令或是相关文件。但是,在Linux里面则又额外提供了一种在线求助的方法-info,它是help的补充

[root@VM-24-10-centos ~]# info ls

二、pwd命令

打印当前工作目录的名字

[root@VM-24-10-centos ~]# help pwd
pwd: pwd [-LP]
    打印当前工作目录的名字。

    选项:
      -L	打印 $PWD 变量的值,如果它命名了当前的
    	工作目录
      -P	打印当前的物理路径,不带有任何的符号链接

    默认情况下,`pwd' 的行为和带 `-L' 选项一致

    退出状态:
    除非使用了无效选项或者当前目录不可读,否则
    返回状态为0。

三、ls命令

ls命令的选项非常多,我们选择几个常用的选项来进行记录学习

1、ls -a [path]

展示指定路径下的所有文件(包括隐藏文件 **.**开头的)

[root@VM-24-10-centos ~]# ls -a ~/
.   .bash_history  c        etc                       markus            .tcshrc
..  .bash_logout   .cache   .lesshst                  .pip              vim_demo1.txt
a   .bash_profile  .config  manpages-zh-1.5.1         .pydistutils.cfg  .vim_demo.txt.swp
b   .bashrc        .cshrc   manpages-zh-1.5.1.tar.gz  .ssh              .viminfo

2、ls [path] [path] …

展示多路径下的文件

[root@VM-24-10-centos ~]# ls ~/ /home/markus
/home/markus:

/root/:
a  b  c  etc  manpages-zh-1.5.1  manpages-zh-1.5.1.tar.gz  markus  vim_demo1.txt

3、ls -l [path]

展示指定路径下的文件详细信息

[root@VM-24-10-centos ~]# ls -l
总用量 1924
drwxrwxrwx 5 lighthouse lighthouse    4096 130 22:17 manpages-zh-1.5.1
-rw-r--r-- 1 root       root       1965336 1217 2010 manpages-zh-1.5.1.tar.gz
# ls -lh 展示文件大小时,以M为单位展示
[root@VM-24-10-centos ~]# ls -lh /tmp/etc-backup.tar*
-rw-r--r-- 1 root root 11M 131 22:15 /tmp/etc-backup.tar.gz

这里多提一下,展示的详细信息如下图所示:

在这里插入图片描述

4、ls -r [path]

倒序展示指定路径下文件列表

# 普通展示
[root@VM-24-10-centos ~]# ls -l
总用量 1924
drwxrwxrwx 5 lighthouse lighthouse    4096 1月  30 22:17 manpages-zh-1.5.1
-rw-r--r-- 1 root       root       1965336 12月 17 2010 manpages-zh-1.5.1.tar.gz
# 逆序展示
[root@VM-24-10-centos ~]# ls -rl
总用量 1924
-rw-r--r-- 1 root       root       1965336 12月 17 2010 manpages-zh-1.5.1.tar.gz
drwxrwxrwx 5 lighthouse lighthouse    4096 1月  30 22:17 manpages-zh-1.5.1

5、ls -t [path]

按照时间顺序显示(最后修改时间由近及远)

[root@VM-24-10-centos ~]# ls -lt
总用量 1948
-rw-r--r--  1 root       root            81 21 21:29 vim_demo1.txt
drwxr-xr-x  2 root       root          4096 130 22:46 a
drwxr-xr-x  2 root       root          4096 130 22:46 b
drwxr-xr-x  2 root       root          4096 130 22:46 c
drwxr-xr-x  2 root       root          4096 130 22:45 markus
drwxrwxrwx  5 lighthouse lighthouse    4096 130 22:17 manpages-zh-1.5.1
drwxr-xr-x 95 root       root          4096 129 22:21 etc
-rw-r--r--  1 root       root       1965336 1217 2010 manpages-zh-1.5.1.tar.gz
# 可以增加-r选项,按照时间顺序倒序显示(时间由远及近)
[root@VM-24-10-centos ~]# ls -lrt
总用量 1948
-rw-r--r--  1 root       root       1965336 1217 2010 manpages-zh-1.5.1.tar.gz
drwxr-xr-x 95 root       root          4096 129 22:21 etc
drwxrwxrwx  5 lighthouse lighthouse    4096 130 22:17 manpages-zh-1.5.1
drwxr-xr-x  2 root       root          4096 130 22:45 markus
drwxr-xr-x  2 root       root          4096 130 22:46 c
drwxr-xr-x  2 root       root          4096 130 22:46 b
drwxr-xr-x  2 root       root          4096 130 22:46 a
-rw-r--r--  1 root       root            81 21 21:29 vim_demo1.txt

6、ls -R [path]

递归展示当前目录下的所有目录下的所有文件

[root@VM-24-10-centos a]# ls -R
.:
b  c

./b:
d  e

./b/d:

./b/e:

./c:

四、cd命令详解

cd 更改当前的操作目录

  • cd /path/to/… 绝对路径 根目录下开始
  • cd ./path/to/… 相对路径 当前目录下开始
  • cd …/path/to/… 相对路径 上级目录下开始
  • cd path/to… 相对目录 当前目录下开始
  • cd - 切换到上一次操作的目录

五、文件操作命令

1、mkdir [选项] 目录…

mkdir的功能是创建目录,我们先来看下常规使用

[root@VM-24-10-centos ~]# mkdir ~/a/a_mkdir
[root@VM-24-10-centos ~]# cd a
[root@VM-24-10-centos a]# ls
a_mkdir  b  c
# 创建多个目录
[root@VM-24-10-centos a]# mkdir d e f g
[root@VM-24-10-centos a]# ls
a_mkdir  b  c  d  e  f  g

如果我们想一次性创建多级目录,可通过 -p选项来支持,否则会提示没有文件或目录的错误

[root@VM-24-10-centos ~]# mkdir a/b/c/d/f/g
mkdir: 无法创建目录"a/b/c/d/f/g": 没有那个文件或目录
# 增加 -p 选项
[root@VM-24-10-centos ~]# mkdir -p a/b/c/d/e/f/g
# 递归展示文件验证
[root@VM-24-10-centos ~]# ls -R a
a:
a_mkdir  b  c

a/a_mkdir:

a/b:
c  d  e

a/b/c:
d

a/b/c/d:
e

a/b/c/d/e:
f

a/b/c/d/e/f:
g

a/b/c/d/e/f/g:

a/b/d:

a/b/e:

a/c:

2、rmdir [选项] 目录…

rmdir 删除空目录,如果是非空目录会有操作失败的提示

[root@VM-24-10-centos a]# rmdir b
rmdir: 删除 "b" 失败: 目录非空
[root@VM-24-10-centos a]# rmdir g
[root@VM-24-10-centos a]# ls
a_mkdir  b  c  d  e  f

3、rm [选项]… 文件…

rm 删除目录,通常有两个常用选项:

  • -r 删除目录时会进行提示
  • -r -f 删除目录不会进行提示,有点强制删除的意思,所以操作时要谨慎
[root@VM-24-10-centos a]# rm -r b
rm:是否进入目录"b"? y
rm:是否进入目录"b/c"? y
rm:是否进入目录"b/c/d"? y
rm:是否进入目录"b/c/d/e"? y
rm:是否进入目录"b/c/d/e/f"? y
rm:是否删除目录 "b/c/d/e/f/g"?y
rm:是否删除目录 "b/c/d/e/f"?y
rm:是否删除目录 "b/c/d/e"?y
rm:是否删除目录 "b/c/d"?y
rm:是否删除目录 "b/c"?y
rm:是否删除目录 "b/e"?y
rm:是否删除目录 "b/d"?y
rm:是否删除目录 "b"?y
[root@VM-24-10-centos a]# mkdir -p b/c/d/e/f/g
[root@VM-24-10-centos a]# rm -rf b
[root@VM-24-10-centos a]# ls
a_mkdir  c  d  e  f

4、cp [选项]… [源文件] [目标文件]

cp 即为拷贝,常用选项如下所示:

  • -r 递归复制目录及其子目录内的所有内容
  • -v 显示详细的进行步骤,也就是复制进度
  • -p 保持指定的属性(默认:用户、所有权、时间戳)
  • -a 等于-dR --preserve=all(保持默认属性以及新增的链接等所有权限,以及递归赋值目录)
[root@VM-24-10-centos ~]# ls
a  b  c  etc  manpages-zh-1.5.1  manpages-zh-1.5.1.tar.gz  markus  vim_demo1.txt
[root@VM-24-10-centos ~]# cp manpages-zh-1.5.1.tar.gz a/manpages_backup.tar.gz
[root@VM-24-10-centos ~]# ls a
a_mkdir  c  d  e  f  manpages_backup.tar.gz

5、mv [选项]… [源文件] [目标文件]

mv 即移动,也为重命名

[root@VM-24-10-centos a]# mv manpages_backup.tar.gz manpages_backup_mv.tar.gz
[root@VM-24-10-centos a]# ls
a_mkdir  b  c  d  e  f  manpages_backup_mv.tar.gz

6、touch [选项]… 文件

touch 即创建文件

[root@VM-24-10-centos a]# touch touch_demo.txt
[root@VM-24-10-centos a]# ls
a_mkdir  b  c  d  e  f  manpages_backup_mv.tar.gz  touch_demo.txt

六、通配符

用于操作文件,通常是有规律的文件

  • * 匹配任何字符串
  • ? 匹配1个字符串
  • [xyz] 匹配xyz任意一个字符
  • [a-z] 匹配一个范围
  • [!xyz] 或者 [^xyz] 不匹配xyz任何一个字符

七、文本查看命令

1、cat [选项] [文件]

cat 即连接文件并在标准输出上输出

[root@VM-24-10-centos a]# cat -n touch_demo.txt
     1	111111111111
     2	222222222222
     3	333333333333
     4	444444444444
     5	555555555555

2、head [选项] [文件]

head 即输出文件的开始部分

[root@VM-24-10-centos a]# head -n 10 touch_demo.txt
111111111111
222222222222
333333333333
444444444444
555555555555111111111111
222222222222
333333333333
444444444444
555555555555111111111111
222222222222
[root@VM-24-10-centos a]# head -n 1 touch_demo.txt
111111111111

3、tail [选项] [文件]

tail 即输出文件的末尾部分

[root@VM-24-10-centos a]# tail -10f touch_demo.txt
555555555555111111111111
222222222222
333333333333
444444444444
555555555555111111111111
222222222222
333333333333
444444444444
555555555555
666666666666

4、wc [选项] [文件]

wc 即输出文件中的行数、单词数、字节数,常用选项:

  • -c 输出字节统计数
  • -l 输出换行符统计数
  • -L 输出最长的行的行数
  • -w 输出单词统计数
# 不带选项事,输出 顺序为 行数 单词数 字节统计数
[root@VM-24-10-centos a]# wc touch_demo.txt
 46  46 718 touch_demo.txt
[root@VM-24-10-centos a]# wc -w touch_demo.txt
46 touch_demo.txt
[root@VM-24-10-centos a]# wc -l touch_demo.txt
46 touch_demo.txt
[root@VM-24-10-centos a]# wc -L touch_demo.txt
24 touch_demo.txt
[root@VM-24-10-centos a]# wc -c touch_demo.txt
718 touch_demo.txt
[root@VM-24-10-centos a]#

5、more [选项] [文件]

more 命令类似 cat ,不过会以一页一页的形式显示,更方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 b 键就会往回(back)一页显示,而且还有搜寻字串的功能(与 vi 相似)

# +NUM -NUM 
[root@VM-24-10-centos etc]# more +20 services
#
# service-name  port/protocol  [aliases ...]   [# comment]

tcpmux          1/tcp                           # TCP port service multiplexer
tcpmux          1/udp                           # TCP port service multiplexer
rje             5/tcp                           # Remote Job Entry
rje             5/udp                           # Remote Job Entry
echo            7/tcp
echo            7/udp
discard         9/tcp           sink null
discard         9/udp           sink null
systat          11/tcp          users

进入到more命令后,可以通过 num+enter来选择一下翻过多少行的操作

6、less [选项] [文件]

less 与more命令类似,它可以随意浏览文件,支持翻页和搜索,向上翻页和向下翻页,通常我是通过该命令查询日志中的某些异常信息,通过/匹配,然后通过n N向下向上搜索文本

[root@VM-24-10-centos ~]# less -N /etc/services
1 # /etc/services:
2 # $Id: services,v 1.55 2013/04/14 ovasik Exp $
3 #
4 # Network services, Internet style
5 # IANA services version: last updated 2013-04-10
6 #
7 # Note that it is presently the policy of IANA to assign a single well-known
8 # port number for both TCP and UDP; hence, most entries here have two entries
9 # even if the protocol doesn't support UDP operations.
10 # Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports
11 # are included, only the more common ones.
12 #
13 # The latest IANA port assignments can be gotten from

八、打包与压缩命令

  • tar 打包命令
    • c 执行打包,建立新的存档
    • f 打包为文件
    • z 结合gzip压缩指令 将指定文件(linux一切接文件)打包压缩为.tar.gz双拓展文件
    • j 结合bzip2压缩指令 将指定文件打包压缩为.tar.bz2双拓展文件
    • x 结合gizp或者bzip2解压缩指令,将压缩文件解压
    • -C 指定路径解压
  • gzip bzip2 压缩与解压缩命令
[root@VM-24-10-centos ~]# tar czf /tmp/etc-backup.tar.gz /etc
tar: 从成员名中删除开头的“/”
[root@VM-24-10-centos ~]# tar cjf /tmp/etc-backup.tar.bz2 /etc
tar: 从成员名中删除开头的“/”
[root@VM-24-10-centos ~]# tar cf /tmp/etc-backup.tar /etc
tar: 从成员名中删除开头的“/”
[root@VM-24-10-centos ~]# ls -lh /tmp/etc-backup.tar*
-rw-r--r-- 1 root root  30M 131 22:23 /tmp/etc-backup.tar
-rw-r--r-- 1 root root 9.1M 131 22:23 /tmp/etc-backup.tar.bz2
-rw-r--r-- 1 root root  11M 131 22:15 /tmp/etc-backup.tar.gz
[root@VM-24-10-centos ~]# tar xf /tmp/etc-backup.tar.bz2 -C /root
[root@VM-24-10-centos ~]# ls
a  b  c  etc  manpages-zh-1.5.1  manpages-zh-1.5.1.tar.gz  markus

九、文本编辑器vim

vim命令有四种模式,分别为:

  • 正常模式
  • 插入模式
  • 命令模式
  • 可视模式

1、正常模式

执行 vim 命令会进入正常模式,在正常模式下,经常会用到的快捷键如下:

  • h 光标向左移动
  • j 光标向下移动
  • k 光标向上移动
  • l 光标向右移动
  • yy 复制当前行的数据
  • y$ 复制当前光标到行尾的数据
  • dd 剪切当前行的数据
  • d$ 剪切当前光标到行尾的数据
  • u 撤销(可多次执行)
  • ctrl+r 重做(可多次执行)
  • x 删除光标所在的元素
  • r 替换光标所在的元素
  • g 光标移至第一行开头位置
  • G 光标移至最后一行开头位置
  • num+G 光标移至指定行数的开头位置
  • ^ 行的开头
  • $ 行的结尾

2、插入模式

操作如下按键进入插入模式:

  • i 进入插入模式,光标在当前位置
  • I 进入插入模式,光标在当前行的开头位置
  • a 进入插入模式,光标在当前位置的下一位
  • A 进入插入模式,光标在当前行的结尾位置
  • o 进入插入模式,在当前光标上面插入一行
  • O 进入插入模式,在当前光标下面插入一行

3、命令模式

操作 : 进入命令模式,常用命令如下:

  • :set nu 显示文本行数
    • vim /etc/vimrc 设置指令 set nu 全局展示文件的行号
  • :set nonu 取消显示文本行数
  • :set nohlsearch 取消文本高亮
  • : w fileName 保存到指定路径下的文件(还可以通过vim file 后续编辑文件后进行 : w即可)
  • : q 退出
  • :!command 在文本编辑器中执行其他指令
  • /x 搜索文本当中的x文本
  • 😒/old/new 替换光标所在行的第一个old文本到new文本
  • :%s/old/new 替换光标所在行的old文本到new文本
  • :%s/old/new/g 全局替换文本
  • :3,5s/old/new 文本3-5行替换文本old到new

4、可视模式

在正常模式下,操作如下按键进入可视模式:

  • v 字符可视模式
  • V 行可视模式
  • ctrl+v 块可视模式
    • 配合d和I(大写i)命令可以进行块的便利操作

十、用户与权限管理命令

1、用户管理常用命令

  • useradd 新建用户(root用户才有权限)
    • cat /etc/password
    • tail -10 /etc/shadow
    • id user
    • useradd -g gourp user
  • userdel 删除用户
    • userdel user 删除指定用户
    • userdel -r user 删除指定用户及其用户目录
  • passwd 修改用户密码
    • passwd user设置密码
    • passwd 更改当前用户的密码
  • usermod 修改用户属性
    • usermod -d path w
    • usermod -g group user
  • chage 修改用户属性

2、组管理常用命令

  • groupadd 新建用户组
  • groupdel 删除用户组

3、用户切换命令

  • su 切换用户
    • su - user 表示切换到user用户下,- 起到的作用是切换过程中将环境一并切换
    • su user 不完全切换
  • sudo 以其他用户身份执行命令
    • visudo 设置需要使用sudo的用户(组)

4、用户配置文件

vim /etc/passwd 用户配置文件

ntp:x:38:38::/etc/ntp:/sbin/nologin
# /sbin/nologin 不允许当前用户登录终端
lighthouse:x:1000:1000::/home/lighthouse:/bin/bash
用户名:登录是否需要密码:uid:gid:用户日志:家目录:用户的命令解释器

vim /etc/shadow 用户密码相关配置文件

密码就不展示了

vim /etc/group 用户组配置文件

# 用户组:是否需要密码登录:gid:其他组设置
lighthouse:x:1000:lighthouse
mail:x:12:postfix

5、文件类型

  • - 普通文件
  • d 目录文件
  • b 快特殊文件
  • c 字符特殊文件
  • | 符号链接
  • f 命名管道
  • s 套接字文件

5、文件权限

  • r 表示可读
  • w 表示可写
  • x 表示可执行
  • r=4
  • w=2
  • x=1
# 第一个字符 表示文件类型
# 第2-10个字符 三个为一组 分别为文件属主的权限、文件属组权限、其他用户权限
-rw-r--r--  1 root       root            81 21 21:29 vim_demo1.txt

创建新文件有默认权限,根据umask值计算,属主和属组根据当前进程的用户来设定 <666-umask = 默认权限>

7、目录权限

  • x 表示进入目录
  • rx 显示目录内的文件名
  • wx 修改目录内的文件名

8、修改权限

  • chmod 可以修改、目录权限
    • u 给属主修改权限
    • g 给属组修改权限
    • o 给其他用户修改权限
    • + 增加权限
    • - 删除权限
    • = 替换权限
    • 还可以利用数字修改权限,4 2 1 代表 r w x
      • 例如 chmod 777 xxx
  • chown 更改属主、属组
[root@VM-24-10-centos test]# ls -l
总用量 0
-rw-r--r-- 1 root root 0 27 22:52 aFile
[root@VM-24-10-centos test]# chown user1:group1 aFile
[root@VM-24-10-centos test]# ls -l
总用量 0
-rw-r--r-- 1 user1 group1 0 27 22:52 aFile
  • chgrp 可以单独更改属组,但是不常用
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值