mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #1471 from su-kaiyao/master
完成翻译 20140807 Command Line Tuesdays--Part Seven.md
This commit is contained in:
commit
57bc7537b3
@ -1,84 +0,0 @@
|
||||
[su-kaiyao]翻译中
|
||||
|
||||
Command Line Tuesdays – Part Seven
|
||||
================================================================================
|
||||
Heya geekos. I’ve checked the ‘curriculum’, and we’re at part 7 of 8 as of today. Which means there will be one more – and sadly final – CLT next tuesday. So for today, let’s deal with some **permissions**!
|
||||
|
||||
As we all know, we can have many users using one machine. To protect the users from each other, permissions have been devised. And we have already discussed file permissions, so let’s refresh our memories with a single [click][1].
|
||||
|
||||
![](http://linuxcommand.org/images/file_permissions.png)
|
||||
|
||||
### chmod ###
|
||||
|
||||
The **chmod** command is used for changing permissions on a directory or a file. To use it, you first type the chmod command, after that you type the permissions specification, and after that the file or directory you’d like to change the permissions of. It can be done in more way, but mr Shotts focuses on the octal notation method.
|
||||
|
||||
Imagine permissions as a series of bits. For every permission slot that’s not empty, there’s a 1, and for every empty one there’s a 0. For example:
|
||||
|
||||
rwx = 111
|
||||
|
||||
rw- = 110
|
||||
|
||||
etc.
|
||||
|
||||
And to see how it looks in binary:
|
||||
|
||||
rwx = 111 —> in binary = 7
|
||||
|
||||
rw- = 110 —> in binary = 6
|
||||
|
||||
r-x = 101 —> in binary = 5
|
||||
|
||||
r– = 100 —> in binary = 4
|
||||
|
||||
Now, if we would like to have a file with read, write and executing permissions for the file owner and for the group owner of the file, but make it unavailable to all other users, we do:
|
||||
|
||||
chmod 770 example_file
|
||||
|
||||
…where example_file is any file you’d like to try this command on. So, you always have to enter three separate digits, for three separate groups known already from our second lesson. The same can be done for directories.
|
||||
|
||||
### su and sudo ###
|
||||
|
||||
It is sometimes needed for a user to become a super user, so he can accomplish a task (usually something like installing software, for example). For temporary accessing to the super user mode, there’s a program called **su**, or substitute user. You just have to type in
|
||||
|
||||
su
|
||||
|
||||
and type your superuser password, and you’re in. However, a word of warning: don’t remember to log out and use it for a short period of time.
|
||||
|
||||
Also there’s an option probably more used in openSUSE and Ubuntu, and it’s called sudo. Sudo is only different in the aspect, that it’s a special command that’s allocated to one specific user. So unlike su, with sudo you can use your user password instead of the superuser’s password. Example:
|
||||
|
||||
sudo zypper in goodiegoodie
|
||||
|
||||
### Changing file and group ownership ###
|
||||
|
||||
To change the owner of the file, you have to run **chown** as a superuser. For example, if I’d want to change ownership from ‘nenad’ to ‘suse’, I do it this way:
|
||||
|
||||
su
|
||||
|
||||
[enter password]
|
||||
|
||||
chown suse example_file
|
||||
|
||||
I can also accomplish the same with changing group ownership, but with a slightly different command **chgrp**. Easy peasy:
|
||||
|
||||
chgrp suse_group example_file
|
||||
|
||||
…and that’s it.
|
||||
|
||||
### Next time ###
|
||||
|
||||
As I already stated, next time we’ll have a photo-finish of sorts. And after that, you’ll be on your own (along with me, wandering through the terminal’s darkness, with only a blinking green cursor as a lighthouse :) ). Until then geekos, remember to…
|
||||
|
||||
…have a lot of fun!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.opensuse.org/2014/08/05/command-line-tuesdays-part-seven/
|
||||
|
||||
作者:[Nenad Latinović][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://news.opensuse.org/author/holden87/
|
||||
[1]:https://news.opensuse.org/2014/07/01/command-line-tuesdays-part-three/
|
@ -0,0 +1,79 @@
|
||||
命令行星期二 – 第七部分
|
||||
==============================================================================================================
|
||||
Heya,geekos,我已经检查了我们的课程,今天我们在八章课程里的第七部分。这意味着下周二我们还有一次课程,但也是最后一次CLT课程。所以,今天,我们讨论一些关于**权限**的问题!
|
||||
|
||||
众所周知,一台机器可能会有多名用户共同使用。为了保证用户之间互不干扰,权限会被分配。我们已经讨论了文件权限的问题,所以让我们用一个简单的[点击](1)回顾一下
|
||||
|
||||
![](http://linuxcommand.org/images/file_permissions.png)
|
||||
|
||||
### chmod ###
|
||||
|
||||
**chmod**命令被用来修改目录或者文件的权限。为了使用它,首先你得输入chmod命令,之后你得输入规范的权限修改,然后你就可以把目录或者文件的权限修改成你想要的。这可以采用多种方式完成,但是Shotts先生关注八进制表示法
|
||||
|
||||
把权限想象成一系列的位,每一个不为空的权限槽就是1,空的权限槽就是0。举个例子:
|
||||
|
||||
rwx = 111
|
||||
|
||||
rw- = 110
|
||||
|
||||
etc.
|
||||
|
||||
看一下二进制表示法:
|
||||
|
||||
rwx = 111 —> in binary = 7
|
||||
|
||||
rw- = 110 —> in binary = 6
|
||||
|
||||
r-x = 101 —> in binary = 5
|
||||
|
||||
r– = 100 —> in binary = 4
|
||||
|
||||
现在,如果你想把一个文件的权限改为:文件所有者和文件所有组拥有读,写,执行权限,但是其他用户没有该文件任何权限,我们可以这样做:
|
||||
|
||||
chmod 770 example_file
|
||||
|
||||
### su 和 sudo ###
|
||||
|
||||
有些时候普通用户想要成为超级用户,这样才能完成一些任务(通常是一些安装软件任务)。为了暂时的获取超级用户权限,我们可以使用**su**程序,输入:
|
||||
|
||||
su
|
||||
|
||||
输入你的超级用户密码,你就成为超级用户了。但是,警告:别忘记退出超级用户模式,仅仅使用它一小段时间
|
||||
|
||||
也有一些选择可能更多的应用于openSUSE和Ubuntu,它叫做sudo,sudo只是在某些方面和su不同,它是分配给制定用户的特殊命令,不像su,你可以用你自己用户的密码执行sudo,而不需要超级用户密码,举个例子:
|
||||
|
||||
sudo zypper in goodiegoodie
|
||||
|
||||
### 修改文件和组所有权 ###
|
||||
|
||||
想要改变文件的所有者,你可以在超级用户模式下运行**chown**,举个例子,如果我想把文件的所有权从‘nenad’改为‘suse’,我可以这样做:
|
||||
|
||||
su
|
||||
|
||||
[enter password]
|
||||
|
||||
chown suse example_file
|
||||
|
||||
同样地,我也可以改变组的所有权,但是是使用稍有不同的**chgrp**命令,很简单:
|
||||
|
||||
chgrp suse_group example_file
|
||||
|
||||
### 下一次 ###
|
||||
|
||||
正如我所阐述的,下一次我们会有各种各样的终点,在这之后,你会有自己的选择(和我一起徜徉在终端的黑暗之中,只有一个绿色的闪烁光标作为灯塔)。在那之前,geekos,记住
|
||||
|
||||
....享受更多的乐趣!
|
||||
|
||||
---------------------------------------------------------------
|
||||
|
||||
via: https://news.opensuse.org/2014/08/05/command-line-tuesdays-part-seven/
|
||||
|
||||
作者:[Nenad Latinović][a]
|
||||
译者:[su-kaiyao](https://github.com/su-kaiyao)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://news.opensuse.org/author/holden87/
|
||||
[1]:https://news.opensuse.org/2014/07/01/command-line-tuesdays-part-three/
|
||||
|
Loading…
Reference in New Issue
Block a user