suコマンド

UNIXサーバ構築 OnTheVMware

unixコマンドについて使用例を用いて解説
HOME > 基本操作コマンド >

suコマンド

suコマンド


スポンサードリンク


【説明】
別のユーザへ変更する際に使用します。

一般的なLinuxディストリビューションでは、rootのパスワードさえ知っていれば、どんなユーザーでもsuコマンドでroot権限を取得することができ、セキュリティ上好ましくない。 最近のディストリビューションではPAMが利用されているので、suコマンドを実行することができるユーザーを限定できる。あるグループに属するユーザーだけがsuコマンドでスーパーユーザーになれるように設定するには、 まずrootでログインして、/etc/login.defsに以下の行を追加する。 次に、/etc/pam.d/suファイルに追加する。

【構文】
shutdown [オプション] [ユーザ名]

例 testユーザに切り替える。
[root@localhost ~]# id
uid=0(root) gid=0(root) 所属グループ=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
[root@localhost ~]# su -l test
[test@localhost ~]$ id
uid=1000(test) gid=1000(test) 所属グループ=1000(test)
idコマンドの詳細を見る

例 testユーザ権限でpingコマンドを実行する。
[root@localhost ~]# su test -c "ping 192.168.0.100"
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
64 bytes from 192.168.0.100: icmp_seq=0 ttl=64 time=0.082 ms
64 bytes from 192.168.0.100: icmp_seq=1 ttl=64 time=0.058 ms
64 bytes from 192.168.0.100: icmp_seq=2 ttl=64 time=0.046 ms
64 bytes from 192.168.0.100: icmp_seq=3 ttl=64 time=0.050 ms
64 bytes from 192.168.0.100: icmp_seq=4 ttl=64 time=0.050 ms
64 bytes from 192.168.0.100: icmp_seq=5 ttl=64 time=0.015 ms
64 bytes from 192.168.0.100: icmp_seq=6 ttl=64 time=0.055 ms

--- 192.168.0.100 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6004ms
rtt min/avg/max/mdev = 0.015/0.050/0.082/0.020 ms, pipe 2
[root@localhost ~]#
pingコマンドの詳細を見る

スポンサードリンク
 HOME / 免責事項 / サイトマップ /  問い合わせ
Copyright (C) 2008  UNIXサーバ構築 OnTheVMware  All rights reserved





スポンサードリンク