chownコマンド

UNIXサーバ構築 OnTheVMware

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

chownコマンド

chownコマンド


スポンサードリンク


【説明】
ファイルの所有者とグループを変更する際に使用します。

指定されたそれぞれのファイルのユーザおよびグループ、もしくはいずれかの所有権を、オプションではない最初の引数に従って変更します。ユーザ名 (もしくは数値の user ID) のみを指定した場合、それぞれのファイルの所有者は指定したユーザになり、グループは変わりません。ユーザ名に続けてコロンもしくはドットとグループ名 (もしくは数値の group ID) を間にスペースを入れずに指定した場合、同じようにそれらのフ ァイルのグループ所有権も指定したグループに変わります。

【構文】
chown [オプション] [ユーザ:グループ] [ファイル]

例 test.txtの所有者をtestユーザに変更します。
[root@localhost ~]# ls -l test.txt
-rw-r--r-- 1 root test 20 6月 17 07:59 test.txt
[root@localhost ~]#
[root@localhost ~]# chown test test.txt
[root@localhost ~]#
[root@localhost ~]# ls -l test.txt
-rw-r--r-- 1 test test 20 6月 17 07:59 test.txt

例 aaa.txtのシンボリックリンク先であるtest.txtの所有者とグループをtestに変更します。
[root@localhost ~]# ls -l *.txt
lrwxrwxrwx 1 root root 8 6月 17 08:09 aaa.txt -> test.txt
-rw-r--r-- 1 root root 20 6月 17 07:59 test.txt
[root@localhost ~]#
[root@localhost ~]# chown --dereference test:test aaa.txt
[root@localhost ~]#
[root@localhost ~]# ls -l *.txt
lrwxrwxrwx 1 root root 8 6月 17 08:09 aaa.txt -> test.txt
-rw-r--r-- 1 test test 20 6月 17 07:59 test.txt
[root@localhost ~]#
lnコマンドの詳細を見る

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





スポンサードリンク