Loose-Info.com
Last Update 2014/03/11
TOP - Unix系OS - Linux - sudo(8)

他のユーザーでコマンドを実行します。(指定無しの場合はroot権限)

sudo オプション1 コマンド1 オプション1(任意) -u : root以外のユーザーを指定 コマンド1(必須) 他のユーザーで実行するコマンド

※ オプションなどは個人的に重要と考えられるものを記述しており、記載の無いものは、manページや関連書籍などを参照願います。
※ 実行例の記述は、不要と考えられる部分の削除などの修正を行ったものを掲載しています。
※ 実行例の実行環境はUbuntu 12.10です。

(例)オプションなし
$ sudo cp test.txt test2.txt

実行前
$ ls -l -rw-r--r-- 1 testuser testuser 9 MMM d hh:mm test.txt

実行結果
$ ls -l -rw-r--r-- 1 testuser testuser 9 MMM d hh:mm test.txt -rw-r--r-- 1 root root 9 MMM d hh:mm test2.txt

(例)オプション -u
$ sudo -u testuser2 cp test.txt test2.txt

実行前
$ ls -l -rw-r--r-- 1 testuser testuser 9 MMM d hh:mm test.txt

実行結果
$ ls -l -rw-r--r-- 1 testuser testuser 9 MMM d hh:mm test.txt -rw-r--r-- 1 testuser2 testuser2 9 MMM d hh:mm test2.txt