c is 291 Assignment 5
c is 291 Assignment 5
o In this step, I used the useradd command to create two new user
accounts, user3 and user4. The useradd command adds the specified users to the
system, creating their home directories and initializing necessary configuration files,
making them ready for system access.
o After creating the user accounts, I used the passwd command to set passwords for
both user3 and user4. The passwd command is used to assign secure passwords for
each user, ensuring their accounts are protected and accessible only by authorized
individuals.
Viewing User Information and Modifying User Groups Using cat, usermod, and groups
o To examine the user details, I used the cat /etc/passwd command. This command
displays the contents of the /etc/passwd file, which contains user account
information such as usernames, user IDs, group IDs, home directories, and login
shells. The output confirmed the presence of the newly created users along with
their default settings.
o I then used the usermod -g group1 user3 command to change the primary group
of user3 to group1. Similarly, I executed the command usermod -g group2 user4 to
set group2 as the primary group for user4. The usermod command allows
modification of user account properties, including group associations, ensuring that
each user is assigned the correct primary group.
o Next, I added supplementary groups to both users. For user4, I added group1 as an
additional group, while for user3, I assigned group2 as an additional group. This was
achieved by using the usermod -aG command, which appends the specified group
memberships to the users without removing any existing group associations. Adding
users to multiple groups provides them with the necessary permissions for different
system resources.
o To inspect the security-related information for user accounts, I used the cat
/etc/shadow command. This command displays the contents of the /etc/shadow file,
which contains encrypted password information, account expiration details, and
other security settings for each user. The output confirmed the presence of the user
accounts (user3 and user4) along with their password hashes and related security
settings, ensuring that the system's password management and security policies are
correctly configured.
o To verify the group memberships for user3 and user4, I used the id command for
each user (id user3 and id user4). This command displays the user's unique ID (UID),
primary group ID (GID), and the list of all groups the user is a member of. The output
confirmed that user3's primary group is group1, and user4's primary group
is group2, along with their respective secondary group memberships, ensuring that
the group modifications were successfully applied.
q.2
File Creation:
Two new files, file1 and file2, were created to demonstrate file ownership and permission
changes.
Permission Inspection:
The ls -l command was used to view the initial file permissions for file1 and file2. This
command displays file permissions, ownership, and other details.
Ownership Modification:
The ownership of each file was modified using the chown command:
These changes were verified using the ls -l command to confirm that the ownership updates
were successfully applied.
Permission Modification:
o The file permissions for file1 and file2 were altered using the chmod command to
control access rights:
For file1:
For file2:
o These changes were verified using the ls -l command to ensure the correct
permission settings were applied.
For file1:
The Set User ID (SUID) bit was added. This allows users executing the
file to temporarily inherit the file owner's privileges.
For file2:
The Sticky Bit was applied. This restricts file deletion within a
directory to only the file owner, even if others have write
permissions.
o The modifications were verified again using the ls -l command, confirming the
presence of the special bits:
o The getfacl command was used to inspect the current Access Control List (ACL)
of testfile.
Modifying ACLs:
For user1:
Verification of Changes:
o The getfacl command was executed again to verify that the new ACL settings had
been successfully applied.
The output confirmed that user1 was explicitly granted read and write
permissions.
o The chattr command was used with the +i flag on file1 to make it immutable:
Effect of the Immutable Attribute:
The output confirmed that the immutable attribute (i) was successfully
applied to file1.
o An attempt was made to write data to file1 using the echo command:
o The chattr command was used with the +a flag on file4 to make it append-only:
The output confirmed that the append-only attribute (a) was successfully
applied to file4.
o An attempt was made to append data to file4 using the echo command: