我x.sh在目录中创建了一个文件,/etc/profile.d/以便所有用户都可以访问它。我期望当我使用 command 在终端(登录用户)中更改当前用户时sudo su other_user,我在x.sh文件中设置的那些变量应该可以访问,但它们不是。如何根据需要设置可访问的变量?
我想在 Ubuntu 服务器 16.04 启动后(而不是登录后)在名为Zookeeper的用户下启动 Zookeeper 守护进程。所以我改变了文件/etc/rc.local如下:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 'never'; defrag_file_pathname
su -c '$ZOOKEEPER_HOME/bin/zkServer.sh start' zookeeper & …Run Code Online (Sandbox Code Playgroud)