Understand and modify user and group permissions and ownership.
Context: Generic GNU/Linux certification command examples.
Understand and modify user and group permissions and ownership.
To understand and modify user and group permissions and ownership in a GNU/Linux system, you can use various commands and utilities. Here are some examples:
- View file/directory permissions and ownership:
ls -l file_or_directory
This command will display the permissions, ownership, and other details of the specified file or directory.
- Change ownership of a file/directory:
chown new_owner file_or_directory
Replace new_owner
with the desired owner of the file or directory, and file_or_directory
with the path to the file or directory.
- Change group ownership of a file/directory:
chown :new_group file_or_directory
Replace new_group
with the desired group owner of the file or directory.
- Change permissions using octal notation:
chmod 755 file_or_directory
This example sets the file's permissions to read, write, and execute for the owner, and read and execute for the group and others. Replace file_or_directory
with the path to the file or directory you want to modify.
- Change permissions using symbolic notation:
chmod u=rw,g=r,o=r file_or_directory
This example grants read and write permissions to the user, read permissions to the group, and read permissions to others. Replace file_or_directory
with the path to the file or directory you want to modify.
- Modify permissions recursively:
chmod -R permissions file_or_directory
The -R
option ensures that permissions are modified recursively for all files and subdirectories within the specified directory.
Note: Modifying permissions and ownership requires appropriate privileges. Make sure to execute these commands with root/administrator privileges or use the sudo
command if necessary.