Chown: cara menggunakan

From OnnoWiki
Revision as of 04:28, 18 June 2017 by Onnowpurbo (talk | contribs)
Jump to navigation Jump to search

sumber: http://www.linfo.org/chown.html

Perintah chown digunakan untuk mengubah pemilik / owner dan group dari file, direktori dan link.

Secara default, pemilik objek filesystem adalah pengguna yang membuatnya. Grup adalah kumpulan pengguna yang memiliki izin akses yang sama (yaitu, baca, tulis dan eksekusi) untuk objek itu.

Sintaks dasar untuk menggunakan chown untuk mengubah owner adalah

chown [option] new_owner object(s)

New_owner adalah nama pengguna atau ID pengguna numerik (UID) dari pemilik baru, dan objek adalah nama dari file target, direktori atau link. Kepemilikan sejumlah objek dapat berubah secara simultan.

Misalnya, berikut ini akan mentransfer kepemilikan file bernama file1 dan sebuah direktori bernama dir1 ke pemilik baru bernama alice:

chown alice file1 dir1

Untuk menjalankan perintah di atas, sebagian besar sistem dikonfigurasi secara default untuk meminta akses ke akun root (yaitu administrator sistem), yang dapat diperoleh di komputer pribadi dengan menggunakan perintah su (subtitute user). Pesan kesalahan akan dikembalikan jika pengguna tidak memiliki hak akses yang benar atau bahwa pemilik atau target baru yang ditentukan tidak ada (atau dieja dengan tidak benar).

The ownership and group of a filesystem object can be confirmed by using the ls command with its -l (i.e., long) option. The owner is shown in the third column and the group in the fourth. Thus, for example, the owner and group of file1 can be seen by using the following:

ls -l file1

The basic syntax for using chown to change groups is

chown [option] :new_group object(s)

or

chown [option] .new_group object(s)

The only difference between the two versions is that the name or numeric ID of the new group is preceded directly by a colon in the former and by a dot in the latter; there is no functional difference. In this case, chown performs the same function as the chgrp (i.e., change group) command.

The owner and group can be changed simultaneously by combining the syntaxes for changing owner and group. That is, the name or UID of the new owner is followed directly (i.e., with no intervening spaces) by a period or colon, which is followed directly by the name or numeric ID of the new group, which, in turn, is followed by a space and then by the names of the target files, directories and/or links.

Thus, for example, the following would change the owner of a file named file2 to the user with the user name bob and change its group to group2:

chown bob:group2 file2

If a user name or UID is followed directly by a colon or dot but no group name is provided, then the group is changed to that user's login group. Thus, for example, the following would change the ownership of file3 to cathy and would also change that file's group to the login group of the new owner (which by default is usually the same as the new owner):

chown cathy: file3

Among chown's few options is -R, which operates on filesystem objects recursively. That is, when used on a directory, it can change the ownership and/or group of all objects within the directory tree beginning with that directory rather than just the ownership of the directory itself.

The -v (verbose) option provides information about every object processed. The -c is similar, but reports only when a change is made. The --help option displays the documentation found in the man online manual, and the --version option outputs version information


Referensi