sudo hadoop vs su hadoop

时间:2014-03-10 11:10:04

标签: hadoop sudo su

有没有人遇到一个奇怪的环境问题,在调用hadoop命令时被迫使用SU而不是SUDO?

sudo su -c 'hadoop fs -ls /' hdfs
Found 4 items
drwxr-xr-x   - hdfs   hdfs          0 2014-02-11 12:33 /apps
drwx------   - mapred hdfs          0 2014-03-10 10:25 /mapred
drwxrwxrwx   - hdfs   hdfs          0 2014-03-10 10:26 /tmp
drwxr-xr-x   - hdfs   hdfs          0 2014-02-11 12:34 /user

环境允许查找可执行文件:

sudo -u hdfs 'hadoop' 
Usage: hadoop [--config confdir] COMMAND
where COMMAND is one of:
  namenode -format     format the DFS filesystem
...
  fs                   run a generic filesystem user client
...
...
Most commands print help when invoked w/o parameters.
sudo -u hdfs 'hadoop fs -ls /' 
sudo: hadoop fs -ls: command not found

我想知道这是否是一个环境问题,但这没有给我提示:

sudo su -c 'env' hdfs | sort >sudo_su.txt
sudo -u hdfs 'env' | sort >sudo.txt
diff sudo.txt sudo_su.txt
11a12
> PWD=/home/user
14c15,16
 SHLVL=1
> SUDO_COMMAND=/bin/su -c env hdfs
20a23
> _=/usr/bin/env

1 个答案:

答案 0 :(得分:12)

删除hadoop命令周围的引号:

sudo -u hdfs hadoop fs -ls /