コンテキスト:

コンテキスト:

Ubuntu 14.04で "lfs"ユーザーを使用してソースコマンドを実行し、次のようにしました。

root@linux:~/lfs# su lfs - -c "source ~/.bash_profile"
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

どんなアイデアがありますか?

背景情報:私はLFSの本に従い、それでスクリプトを作成しています。したがって、sudoで実行されているスクリプトがこの部分に達すると、lfsユーザーとその.bashrcと.bashprofileを作成してから次のようになります。ロードしてください。

コンテキスト:

echo "info: create 'lfs' group and user..."
groupadd -f lfs
id -u lfs &>/dev/null || useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd -d -q lfs

echo "info: make 'lfs' own the 'tools' and 'sources' directories..."
chown lfs $LFS/tools
chown lfs $LFS/sources

echo "info: creating a clean '.bash_profile' as user 'lfs'..."
su lfs - -c "cat > ~/.bash_profile << \"EOF\"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF"

echo "info: creating a clean '.bashrc' as user 'lfs'..."
su lfs - -c "cat > ~/.bashrc << \"EOF\"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
EOF"

su lfs - -c "source ~/.bash_profile"

編集する:

誰かが私の構文が正しくないと提案しました。私は今Linuxボックスを使用していないので、機会があれば別の構文を試してみましょう。しかし、詳細はここの答えから構文を得ました。 https://serverfault.com/questions/411307/cannot-set-terminal-process-group-during-su-to-another-user-as-login-shell

ベストアンサー1

  • su - usernameusernameログインシェルを対話型シェルとして実行します。

  • su username command arguments走るcommand arguments 非対話型アカウントの下username

あなたのコマンドはユーザーとして実行することをsu lfs - -c "source ~/.bash_profile"意味します- -c "source ~/.bash_profile"lfs 非対話型。これで、シェルはそのオプションを表示し-、対話型ログインシェルとして実行して端末を初期化しようとしますが、su子プロセスは制御端末から切断されたと言います。

簡単に言えば、-間違った場所にあるか間違っています。

詳細については、次を参照してください。同じ質問サーバー障害時。

おすすめ記事