Lab Task
Lab Task
•Describe the purpose of each permission (read, write, execute) in Linux file permissions?
In Linux file permissions, there are three basic permissions: read, write, and execute. These
permissions determine what actions can be performed on a file or directory by the owner of the
file, members of the group that the file belongs to, and other users.
Here's the purpose of each permission:
Read (r):
• For Files: Allows users to view the contents of the file.
• For Directories: Allows users to list the contents of the directory (i.e., see which files
and subdirectories are contained within it).
Write (w):
• For Files: Allows users to modify the contents of the file, including appending, editing,
or deleting its content.
• For Directories: Allows users to create, delete, or rename files within the directory, as
well as modify the directory's attributes.
Execute (x):
• For Files: Allows users to execute the file if it is a program, script, or binary executable.
For non-executable files, this permission is irrelevant.
• For Directories: Allows users to access the contents of the directory and traverse into
subdirectories. Without execute permission, users cannot access files or subdirectories
within the directory, even if they have read permission on those files.
•Explain the difference between user, group, and other permissions in a file's permission
settings?
In Linux file permission settings, there are three distinct categories of permissions: user
(owner), group, and others (sometimes referred to as world or everyone else). These
permissions determine what actions can be performed on a file or directory by different
entities on the system.
• User (Owner) Permissions: Determine what the person who owns the file can do with it.
For example, read it, write to it, or run it if it's a program.
• Group Permissions: Affect people who belong to the same group as the file. They
specify what these group members can do with the file.
• Other (World) Permissions: Apply to everyone else who is not the owner of the file and
not in the group. These permissions control what actions all other users can take with the
file.
Each category (user, group, and others) can have permissions for reading, writing, and executing
the file. These permissions dictate who can do what with the file.
2) Setting Permissions:
•Use the chmod command to set the permissions of a file named "data.txt" to 644. Describe
the resulting permissions in symbolic notation.
The permission characters are "r" for read, "w" for write, and "x" for execute.
So, the symbolic notation for the permissions "644" is:
• Owner: "rw-" (read and write, but no execute)
• Group: "r--" (read-only)
• Others: "r--" (read-only)
•Describe the significance of the execute permission for a directory and provide an example
scenario where it's essential?
The execute permission for a directory is significant because it controls whether users can
access the contents of the directory and perform operations such as listing its contents,
accessing files within the directory, or traversing into subdirectories. Without execute
permission, users won't be able to interact with the directory effectively.
Here's why the execute permission is important for a directory:
• Accessing Contents: The execute permission allows users to access the contents of the
directory. Without execute permission, even if users have read permission for the
directory, they won't be able to see the contents or access any files within it.
• Executing Programs: In Unix-like systems, directories are treated as files. When a
directory has the execute permission set, users can execute programs that reside within
that directory. This is useful for running scripts or programs stored in a directory.
Example scenario where execute permission is essential:
Let's consider a scenario where you have a directory called "documents" with the following
permissions:
drw-r--r--
In this scenario:
The owner of the directory has read, write, and execute permissions.
Other users have only read permissions.
Now, if a user wants to list the contents of the "documents" directory or access files within it,
they won't be able to do so because they don't have execute permission. Even though they
have read permission, they can't traverse into the directory to see its contents or access any
files within it.
3) User Management:
Creating Users:
• Demonstrate how to create a new user named "student" with a home directory and default
settings?
Modifying Users:
• Use the usermod command to add the user "student" to the "sudo" group.
• sudo: This command allows you to execute the usermod command with superuser
privileges, necessary for modifying user settings.
• usermod: This command is used to modify user account settings.
• -aG sudo: This option tells usermod to append (-a) the user to the specified group (-G),
in this case, the "sudo" group.
• student: This is the username of the user you want to add to the "sudo" group.
4) Deleting Users:
• Explain the potential consequences of deleting a user account using the userdel command?
When you use the userdel command to delete a user account on a Unix-like system, such as
Linux, there are several potential consequences, some of which could impact the system and its
users significantly:
• Data Loss: Files and folders belonging to the user might get deleted, so any important
stuff stored in their account could be lost forever.
• Service Disruption: Some services on the system might rely on that user account.
Deleting it could cause those services to stop working correctly.
• Permission Problems: Files and folders previously owned by the deleted user might
cause permission issues for other users or services.
• Running Programs: If the user has any programs running when their account is deleted,
those programs might misbehave or stop working altogether.
• Security Risks: The deletion might leave behind vulnerable files or services, posing
security risks to the system.
• System Instability: If other parts of the system depend on the user account, deleting it
could cause the system to become unstable or fail.
• Describe the difference between userdel and deluser commands for deleting users in
Ubuntu?
• userdel: It's like using a basic tool. It deletes the user account but doesn't handle related
tasks like removing the user's home directory or prompting for confirmation. It's more
direct and doesn't have extra features.
• deluser: It's like using a more advanced tool. It not only deletes the user account but also
takes care of related tasks such as removing the user's home directory, managing group
memberships, and confirming the deletion with the user. It's more user-friendly and
comprehensive.
So, if you just want to quickly delete a user account without worrying about extra stuff, you can
use userdel. But if you want a smoother and safer user deletion process with additional features,
deluser is the better choice.
5) Process Management:
Viewing Processes
• Use the ps command to display a list of all processes running on the system. Explain the
meaning of each column in the output?
• PID (Process ID): This column shows the unique numerical identifier assigned to each
process running on the system. Each process has its own PID.
• TTY (Terminal): This column indicates the terminal associated with the process. If a
process is running in the background or does not have a terminal associated with it, this
field might show a question mark or a dash (-).
• TIME: This column shows the total CPU time consumed by the process since it started.
It's displayed in hours:minutes:seconds format.
• CMD (Command): This column displays the command or executable name associated
with the process. If the command or path is longer than the available space, it may be
truncated.
• Compare the output of ps with ps aux. What additional information does ps aux provide?
• ps: Shows processes associated with the current user only.
• ps aux: Shows processes for all users on the system.
• PID (Process ID):Both commands display the PID of each process.
• %CPU (CPU usage):Both commands display the percentage of CPU time used by each
process.
• %MEM (Memory usage):Both commands display the percentage of physical memory
(RAM) used by each process.
• VSZ (Virtual memory size):Both commands display the total virtual memory usage of
each process in kilobytes.
• RSS (Resident Set Size):Both commands display the amount of physical memory
(RAM) used by each process in kilobytes.
• TTY (Terminal):
ps: Shows the terminal associated with the process, if any.
ps aux: Also shows the terminal associated with the process, if any.
• STAT (Process state):Both commands display the current state of each process.
• START (Start time):Both commands display the time when each process started.
• TIME (CPU time):Both commands display the total CPU time consumed by each
process.
• COMMAND (Command or executable):Both commands display the command or
executable name associated with each process.
The main difference is that ps aux provides information about processes from all users, while ps
typically shows processes for the current user only. This makes ps aux particularly useful for
system-wide process analysis and troubleshooting.
• Use top to monitor system uptime and load averages. Explain the significance of load
averages in system performance monitoring?
• System uptime is typically displayed near the top of the top output, usually next to "up"
or "since" indicating how long the system has been running.
• Load averages are displayed near the top as well. They're usually presented in three
values representing the load average over 1 minute, 5 minutes, and 15 minutes
respectively.
Here's what load averages represent:
Load averages indicate the average number of processes in the run queue over a certain period of
time. This queue includes both running processes and those waiting for CPU time.
The load averages over 1, 5, and 15 minutes offer insights into system utilization over different
time scales.
For example, a load average of 0.50 means, on average, there's half of a process waiting for CPU
time over the specified time period.
Load averages greater than 1 indicate that there are more processes waiting for CPU time than
available CPU cores. This suggests a higher level of demand on the system than it can handle
immediately.