Merge pull request #1471 from su-kaiyao/master

完成翻译 20140807 Command Line Tuesdays--Part Seven.md
This commit is contained in:
Xingyu.Wang 2014-08-09 17:16:54 +08:00
commit 57bc7537b3
2 changed files with 79 additions and 84 deletions

View File

@ -1,84 +0,0 @@
[su-kaiyao]翻译中
Command Line Tuesdays Part Seven
================================================================================
Heya geekos. Ive checked the curriculum, and were at part 7 of 8 as of today. Which means there will be one more and sadly final CLT next tuesday. So for today, lets 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 lets 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 youd 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 thats not empty, theres a 1, and for every empty one theres 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 youd 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, theres a program called **su**, or substitute user. You just have to type in
su
and type your superuser password, and youre in. However, a word of warning: dont remember to log out and use it for a short period of time.
Also theres an option probably more used in openSUSE and Ubuntu, and its called sudo. Sudo is only different in the aspect, that its a special command thats allocated to one specific user. So unlike su, with sudo you can use your user password instead of the superusers 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 Id 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 thats it.
### Next time ###
As I already stated, next time well have a photo-finish of sorts. And after that, youll be on your own (along with me, wandering through the terminals 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/

View File

@ -0,0 +1,79 @@
命令行星期二 第七部分
==============================================================================================================
Heyageekos我已经检查了我们的课程今天我们在八章课程里的第七部分。这意味着下周二我们还有一次课程但也是最后一次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它叫做sudosudo只是在某些方面和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/