Product SiteDocumentation Site

8.4. Pengguna dan Basisdata Kelompok

Daftar pengguna biasanya disimpan di berkas /etc/passwd, ketika berkas /etc/shadow menyimpan kata sandi ter-hash. Keduanya berupa berkas teks, dalam format yang relatif sederhana, yang dapat dibaca dan dimodifikasi dengan teks editor. Setiap pengguna terdaftar di sana dalam sebuah baris dengan beberapa field dipisahkan dengan titik dua (“:”).

8.4.1. Daftar Pengguna: /etc/passwd

Berikut ini daftar field dalam berkas /etc/passwd:
  • login, contohnya rhertzog;
  • password: this is a password encrypted by a one-way function (crypt), relying on DES, MD5, SHA-256 or SHA-512. The special value “x” indicates that the encrypted password is stored in /etc/shadow;
  • uid: nomor identifikasi unik tiap pengguna;
  • gid: nomor unik untuk kelompok utama pengguna (secara default Debian membuat kelompok khusus untuk tiap pengguna);
  • GECOS: field data biasanya berisi nama lengkap pengguna;
  • direktori login, diberikan ke pengguna ruang untuk berkas pribadi mereka (variabel lingkungan $HOME umumnya mengarah ke sini);
  • program yang dieksekusi ketika login. Ini biasanya berupa perintah interpreter (shell), memberikan kebebasan pada pengguna. Jika Anda menentukan /bin/false (yang tak melakukan apapun dan mengembalikan kontrol seketika), pengguna tidak dapat login.
As mentioned before, one can edit this file directly. But there are more elegant ways to apply changes, which are described in Bagian 8.4.3, “Memodifikasi Akun atau Password yang Ada”.

8.4.2. Berkas Kata Sandi Tersembunyi dan Terenkripsi: /etc/shadow

Berkas /etc/shadow berisi field-field berikut:
  • login;
  • kata sandi terenkripsi;
  • beberapa field mengelola masa kadaluarsa kata sandi.
One can expire passwords using this file or set the time until the account is disabled after the password has expired.

8.4.3. Memodifikasi Akun atau Password yang Ada

The following commands allow modification of the information stored in specific fields of the user databases: passwd permits a regular user to change their password, which in turn, updates the /etc/shadow file (chpasswd allows administrators to update passwords for a list of users in batch mode); chfn (CHange Full Name), reserved for the super-user (root), modifies the GECOS field. chsh (CHange SHell) allows the user to change their login shell; however, available choices will be limited to those listed in /etc/shells; the administrator, on the other hand, is not bound by this restriction and can set the shell to any program of their choosing.
Akhirnya, perintah chage (CHange AGE) mengizinkan administrator mengubah pengaturan masa kadaluarsa password (pilihan -l pengguna akan menampilkan pengaturan kini). Anda dapat pula memaksa masa kadaluarsa password menggunakan perintah passwd -e pengguna, di mana pengguna perlu mengganti password mereka ketika login berikutnya.
Besides these tools the usermod command allows to modify all the details mentioned above.

8.4.4. Menonaktifkan sebuah Akun

You may find yourself needing to “disable an account” (lock out a user), as a disciplinary measure, for the purposes of an investigation, or simply in the event of a prolonged or definitive absence of a user. A disabled account means the user cannot login or gain access to the machine. The account remains intact on the machine and no files or data are deleted; it is simply inaccessible. This is accomplished by using the command passwd -l user (lock). Re-enabling the account is done in similar fashion, with the -u option (unlock). This, however, only prevents password-based logins by the user. The user might still be able to access the system using an SSH key (if configured). To prevent even this possibility you have to expire the account as well using either chage -E 1user or usermod -e 1 user (giving a value of -1 in either of these commands will reset the expiration date to never). To (temporarily) disable all user accounts just create the file /etc/nologin.
You can disable a user account not only by locking it as described above, but also by changing its default login shell (chsh -s shell user). With the latter changed to /usr/sbin/nologin, a user gets a polite message informing that a login is not possible, while /bin/false just exits while returning false. There is no switch to restore the previous shell. You have to get and keep that information before you change the setting. These shells are often used for system users which do not require any login availability.

8.4.5. Daftar Kelompok: /etc/group

Kelompok terdaftar di berkas /etc/group, basisdata tekstuan sederhana dalam format mirip berkas /etc/passwd, dengan field sebagai berikut:
  • nama grup;
  • password (pilihan): Ini hanya digunakan untuk menggabungkan kelompok ketika seseorang bukan anggota yang biasa (dengan perintah newgrp atau sg, lihat bilah tepi KEMBALI KE DASAR Bekerja dengan beberapa kelompok);
  • gid: nomor identifikasi unik kelompok;
  • daftar anggota: daftar nama penggua yang merupakan anggota kelompok, dipisahkan dengan koma.
Perintah addgroup dan delgroup menambah dan menghapus kelompok, masing-masing. Perintah groupmod memodifikasi informasi kelompok (gid-nya atau identifier). Perintah gpasswd kelompok mengubah password untuk kelompok, sedangkan perintah gpasswd -r kelompok menghapusnya.