Introduction
In this challenge, you will practice essential file management skills. An important system file, sources.list, is located somewhere within the /etc/ directory. Your goal is to locate this file, take ownership of it, and restrict its access permissions so that only your user account can read and write to it. This exercise will help you become more comfortable with navigating the Linux file system and managing file security.
Locate and Secure a System File
Your mission is to find the sources.list file and adjust its ownership and permissions.
Tasks
- Find the full path of the
sources.listfile within the/etc/directory. - Change the owner of the file to the current user,
labex. - Set the file's access permissions so that only the owner (
labex) has read and write access, and no other users have any access.
Hints
- Use the
findcommand to search for files by name. You can specify the starting directory for the search. - The
chowncommand is used to change the owner of a file. - The
chmodcommand modifies file permissions. You can use octal notation (e.g.,600) for this. - Since you are modifying a system file, you will need to use
sudobefore your commands to gain the necessary administrative privileges.
Example
After you have successfully completed all tasks, checking the file's details with ls -l should produce output similar to this:
$ ls -l <path-you-found-in-step-1>
-rw------- 1 labex root 2403 Feb 6 10:14 <path-you-found-in-step-1>
Note that the permissions are -rw------- and the owner is labex. The group, size, and date may vary.
Summary
Congratulations on completing this challenge! You have successfully used fundamental Linux commands to locate a system file, change its ownership with chown, and modify its permissions with chmod. These are critical skills for any Linux user, especially for system administration and ensuring the security of your files and system.



