![linux chmod+x](https://i-blog.csdnimg.cn/blog_migrate/31a4bea2684363e9aa229317ab6fd0a7.png)
linux chmod+x
chmod
is very useful tool to manage file modes like read write execute. One of the most used option for chmod
is +x
which stands for execution rights. In this tutorial we will look different use cases for user or owner, group and others roles.
chmod
是用于管理文件模式(如读写执行)的非常有用的工具。 chmod
最常用的选项之一是+x
,代表执行权限。 在本教程中,我们将介绍用户或所有者,组和其他角色的不同用例。
列出当前用户和文件组 (List Current User and Group Of A File)
We generally need to know given file current user and group. We will use ls
command with -al
options in order to list this information.
我们通常需要知道给定文件的当前用户和组。 我们将使用带有-al
选项的ls
命令以列出此信息。
$ ls -al app.sh
![List Current User and Group Of A File](https://i-blog.csdnimg.cn/blog_migrate/033c8b24ede97f1c1820a7bf466cfa8c.png)
更改用户的文件模式(Change File Mode For The User)
We can use u
user before the plus in order to enable user execution right of the given file. In this example we will enable user execution of file app.sh
我们可以在加号之前使用u
user,以启用给定文件的用户执行权。 在此示例中,我们将允许用户执行文件app.sh
$ chmod u+x app.sh
更改组的文件模式 (Change File Mode For Group)
We can use g
group before the plus in order to enable group execution right of the given file. In this examples we will enable group execution of file app.sh
我们可以在加号之前使用g
组,以启用给定文件的组执行权。 在此示例中,我们将启用文件app.sh
组执行
$ chmod g+x app.sh
更改其他文件模式 (Change File Mode For Other)
Others is special group which covers all users in a Linux system. We can enable the execution right of the all users in a file with o
like below.
其他是专门的小组,涵盖Linux系统中的所有用户。 我们可以使用如下所示的o
启用文件中所有用户的执行权。
$ chmod o+x app.sh
更改所有人的文件模式 (Change File Mode For All)
In some cases we can see the +x
without a definition. This is used for all which is equivalent for user
, group
and others
. Alternative is adding a
like below.
在某些情况下,我们可以看到没有定义的+x
。 这用于所有与user
, group
和others
等效的东西。 另a
是在下面添加a
类似。
$ chmod a+x app.sh
OR
要么
$ chmod +x app.sh
linux chmod+x