Linux Server Configuration


Chapter 3: Mange File Ownership


Download 493.5 Kb.
bet16/48
Sana16.06.2023
Hajmi493.5 Kb.
#1495871
1   ...   12   13   14   15   16   17   18   19   ...   48
Bog'liq
0501-linux-server-configuration

Chapter 3: Mange File Ownership




3.1 Users and Groups


Anyone using a Linux computer is a user. The system keeps track of different users, by username. Security features allow different users to have different privileges. Users can belong to groups, allowing security to be managed for collections of people with different requirements. We use the su command to switch to a different user. It is quicker than logging off and back on again. The command su prompts us for the user’s password:


$ su - bob


Password:

The – option makes su behave as if we’ve logged in as that user.




3.2 The Superuser: Root


Every Linux system has a user called ‘root’. The root user is all-powerful. It can access any files. The root user account should only be used for system administration, such as installing software. When logged in as root, the shell prompt usually ends in #. It is usually best to use su for working as root:


$ whoami


fred
$ su -
Password:
# whoami
root

3.3 Changing File Ownership: chown


The chown command changes the ownership of files or directories. This is a security feature. Only the superuser can change the ownership of a file. Simple usage follows:


# chown bob logfile.txt


The above command makes logfile.txt to be owned by the user bob.


We can specify any number of files or directories as arguments in the command.


3.4 Changing File Ownership: chgrp


The chgrp command changes the group ownership of files or directories. Simple usage follows:


# chgrp staff report.txt


The above command makes staff be the group owner of the file logfile.txt


As for chown, we can specify any number of files or directories. The superuser can change the group ownership of any file to any group. The owner of a file can also change its group ownership. But only to a group of which the owner is a member



Download 493.5 Kb.

Do'stlaringiz bilan baham:
1   ...   12   13   14   15   16   17   18   19   ...   48




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling