在对一些软件或工具的安装过程中,一般是在root用户下,使用tar命名将安装包解压到/usr/local目录下,解压好文件的拥有者也将是root用户。如果后续操作在hadoop用户下进行,那么将会给操作到了很多不便,所以需要对文件的拥有者进行修改。
修改前,可以使用ll命令查看文件信息(下面信息是已经修改好的):
[hadoop@Slave1 local]$ ll
total 80
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin
drwxr-xr-x. 7 hadoop hadoop 4096 Oct 27 22:50 elasticsearch
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 8 hadoop hadoop 4096 Sep 28 20:16 flume
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 11 hadoop hadoop 4096 Aug 24 22:43 hadoop
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 4 hadoop hadoop 4096 Oct 27 19:35 java
drwxr-xr-x. 6 hadoop hadoop 4096 Sep 9 10:27 kafka
drwxr-xr-x. 7 hadoop hadoop 4096 Sep 8 13:12 kibana
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
drwxr-xr-x. 6 hadoop hadoop 4096 Oct 27 23:29 logstash
drwxr-xr-x. 3 hadoop hadoop 4096 Sep 5 18:21 mongodb
drwxr-xr-x. 2 hadoop hadoop 4096 Sep 17 23:49 mysql
drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin
drwxr-xr-x. 5 root root 4096 Aug 25 01:40 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
<span style="color:#ff0000;">drwxr-xr-x. 11 hadoop hadoop 4096 Oct 28 00:02 zookeeper</span>
[hadoop@Slave1 local]$
如果要对zookeeper文件的拥有者进行修改,可以使用chown命令
操作如下(为便于观察,将zookeeper的拥有者重新改成root):
[root@Slave1 local]# chown -R root:root zookeeper
[root@Slave1 local]# ll
total 80
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin
drwxr-xr-x. 7 hadoop hadoop 4096 Oct 27 22:50 elasticsearch
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 8 hadoop hadoop 4096 Sep 28 20:16 flume
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 11 hadoop hadoop 4096 Aug 24 22:43 hadoop
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 4 hadoop hadoop 4096 Oct 27 19:35 java
drwxr-xr-x. 6 hadoop hadoop 4096 Sep 9 10:27 kafka
drwxr-xr-x. 7 hadoop hadoop 4096 Sep 8 13:12 kibana
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
drwxr-xr-x. 6 hadoop hadoop 4096 Oct 27 23:29 logstash
drwxr-xr-x. 3 hadoop hadoop 4096 Sep 5 18:21 mongodb
drwxr-xr-x. 2 hadoop hadoop 4096 Sep 17 23:49 mysql
drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin
drwxr-xr-x. 5 root root 4096 Aug 25 01:40 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
<span style="color:#ff0000;">drwxr-xr-x. 11 root root 4096 Oct 28 00:02 zookeeper</span>
[root@Slave1 local]#
最后,再修改回来:
[root@Slave1 local]# chown -R hadoop:hadoop zookeeper
[root@Slave1 local]# ll
total 80
drwxr-xr-x. 2 root root 4096 Sep 23 2011 bin
drwxr-xr-x. 7 hadoop hadoop 4096 Oct 27 22:50 elasticsearch
drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc
drwxr-xr-x. 8 hadoop hadoop 4096 Sep 28 20:16 flume
drwxr-xr-x. 2 root root 4096 Sep 23 2011 games
drwxr-xr-x. 11 hadoop hadoop 4096 Aug 24 22:43 hadoop
drwxr-xr-x. 2 root root 4096 Sep 23 2011 include
drwxr-xr-x. 4 hadoop hadoop 4096 Oct 27 19:35 java
drwxr-xr-x. 6 hadoop hadoop 4096 Sep 9 10:27 kafka
drwxr-xr-x. 7 hadoop hadoop 4096 Sep 8 13:12 kibana
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib
drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib64
drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec
drwxr-xr-x. 6 hadoop hadoop 4096 Oct 27 23:29 logstash
drwxr-xr-x. 3 hadoop hadoop 4096 Sep 5 18:21 mongodb
drwxr-xr-x. 2 hadoop hadoop 4096 Sep 17 23:49 mysql
drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin
drwxr-xr-x. 5 root root 4096 Aug 25 01:40 share
drwxr-xr-x. 2 root root 4096 Sep 23 2011 src
<span style="color:#ff0000;">drwxr-xr-x. 11 hadoop hadoop 4096 Oct 28 00:02 zookeeper</span>
[root@Slave1 local]#
关于chown命令更详细的操作见:
http://blog.csdn.net/wang_zhenwei/article/details/49469103
关于ll命令和ls -l命令:
[root@Slave1 hadoop]# ll
total 129192
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Desktop
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Documents
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Downloads
-rwxr-xr-x. 1 hadoop hadoop 28510917 Oct 22 10:22 elasticsearch-1.7.3.tar.gz
-rwxr-xr-x. 1 hadoop hadoop 11787239 Oct 22 10:31 kibana-4.1.2-linux-x64.tar.gz
-rwxr-xr-x. 1 hadoop hadoop 91956015 Oct 22 11:50 logstash-1.5.4.tar.gz
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Music
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Pictures
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Public
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Templates
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Videos
[root@Slave1 hadoop]# ls -l
total 129192
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Desktop
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Documents
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Downloads
-rwxr-xr-x. 1 hadoop hadoop 28510917 Oct 22 10:22 elasticsearch-1.7.3.tar.gz
-rwxr-xr-x. 1 hadoop hadoop 11787239 Oct 22 10:31 kibana-4.1.2-linux-x64.tar.gz
-rwxr-xr-x. 1 hadoop hadoop 91956015 Oct 22 11:50 logstash-1.5.4.tar.gz
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Music
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Pictures
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Public
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Templates
drwxr-xr-x. 2 hadoop hadoop 4096 Aug 24 17:54 Videos
[root@Slave1 hadoop]# exit
exit
[hadoop@Slave1 local]$
ll命令可以看作是ls -l命令的别名。