Professional Documents
Culture Documents
Linux
Linux
Problem Statement
LP1: Manage users/groups and control access to files/folders
WORKSHEET
IMPORTANT
Please complete the Lab Safety Acknowledgement for AY22 Semester 2 via this URL:
https://forms.office.com/r/spScG2CKU9
LEARNING OBJECTIVES
Describe the features of a Linux system
Explain the Linux File-system hierarchy to organize files and directories.
Perform file operations such as create, view, edit and delete files using Command
Line Interface (CLI) or text editor
Write simple Bash Scripts
Your lecturer will assign the AIO machine and IP address respectively. Do take note of the IP
address assigned to you.
You need to use the same AIO machine throughout the semester. For eLearning lessons
(week 2 and week 8) you need to RDP to access the AIO machine. For LOA students, your
lecturer will assign the IP address and need to RDP to access the AIO machine.
You are not allowed to access the AIO during non-lesson days as the AIO machines will used
by other classes
For this module you will use Red Hat Enterprise Linux (RHEL) 9.0. You can use the
below ways to access the lab. Refer to “Student Resources” folder for more
information.
During Lesson
- All-In-One Machine (AIO) – Refer to student resources folder “Accessing AIO
Machine.docx”
- Red Hat Academy Learning Portal (RHALP) – Refer the student resources folder to
access RHEL online learning resources. (Refer to the following documents)
o RHN ID creation.pdf
o Accessing Red Hat Platform.pdf
After Lesson
- Your own Virtual Machine – Refer to Lab Guide.docx to install VMware Workstation
and RHEL9.0
- Red Hat Academy Learning Portal (RHALP) – Refer the student resources folder to
access RHEL Labs.
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
Learning Phase 1
Discuss among your team and start working on the PDT to break down the problem
statement. Use the given template C330_LP01_PDT_Template.docx.
Upload the PDT into the MS Teams channel which you are assigned to. Do use the MS
Teams channel to collaborate with each other & work on the PDT internally.
Your input and contribution will be used as part of the assessment for collaborative
learning portion of your CA assessment.
Each team will be assigned a VM. Use the VM to build your solution for the problem
statement and you need to demonstrate the completion of tasks during week 4.
1. Based on your prior knowledge from C226 and C327, discuss within your team and
answer the following questions
a. What is virtualisation?
b. Explain the role of hypervisor. Give examples of hypervisor.
c. Do you have experience in using VMware Workstation to run multiple
operating systems on multiple virtual machines on your laptop? What are the
advantages of virtualisation?
Read RHALP RH124 Chapter 1: Getting Started with Red Hat Enterprise Linux and watch
the video in “C330 Module Overview for Students.pptx” to answer the questions below.
In the modern data center, Linux and Microsoft Windows are the major players, and Linux is
a growing segment in that space. Some of the many reasons to learn Linux include:
A Windows user needs to interoperate with Linux.
In application development, Linux hosts the application or its runtime.
In cloud computing, the cloud instances in the private or public cloud environment
use Linux as the operating system.
With mobile applications or the Internet of Things (IoT), the chances are high that
the operating system of your device uses Linux.
If you are looking for new opportunities in IT, Linux skills are in high demand.
Linux and DevOps share similar philosophies and perspectives such as customization
and scalability
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
3. What is Linux and what is a Linux distribution? How is RHEL different from other
Linux distributions?
(hint: https://en.wikipedia.org/wiki/List_of_Linux_distributions)
- Read RHALP RH124 Chapter 2: Accessing the Command Line and Chapter4: Get
Help in Red Hat Enterprise Linux and complete “C330 L1 Lab Guide.doc” to answer
the questions in this section.
4. Explore the features of a Linux system such as navigating around the desktop and
running simple commands to answer questions below (Refer to “C330 L1 Lab
Guide.doc”). Include screenshots from lab guide.
5. What are the different ways to get help in a Linux system? Include a screenshot to
show them. (Hint: man, info, --help, whatis)
a. Notice that there are two different prompts namely $ and #. What is the
difference between them?
b. What is the command to switch between users?
c. To list the contents of a directory, ls command is used. Try different options in ls
command such as -a, -l, etc., Include a screenshot and how do they differ from
each other?
d. A user’s home directory (Do not be confused this with /home directory!) is
represented by the Tilde (~) character. Try the below in your terminal. What does
it do?
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
Learning Phase 2
Read RHALP RH124 Chapter 3: Managing Files From the Command Line to answer the
questions below. Make use of additional resources as needed.
8. Name any 2 directories and files under /etc and explain the purpose of it.
11. You are currently in /home/student. Using absolute path, switch to /etc directory.
What is the absolute path to navigate to the /var/log from /etc directory. Include
the commands and screenshot of your answers.
12. You are currently in /home/student. What is the relative path to navigate to /etc
directory? Include the commands and screenshot of your answers.
13. Complete the guided exercise on “Managing Files Using Command-line Tools” using
RHALP lab and include a screenshot of your completed work.
(Hint: Refer to the RHALP Lab Guide to access Red Hat labs host on the cloud. You
are given only 60hrs. So, shutdown the VMs once you have completed to optimize
the lab usage)
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
14. Create a new directory <yourname_test> in your home folder. In <yourname_test>, create
another directory <yourclass_test>. (Hint: use man command to explore mkdir options to
create the two directories in a single command). Include a screenshot to showcase your
completed work.
15. From your home directory, what is the command to remove the two directories created in
the above question? (Hint: Use man command to see more options)
16. Try the below commands in command line. (Hint: Use man command to see more options)
Comman Usage Example
d
more
less
head
tail
file
touch
cp
mkdir
rmdir
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
mv
touch
18. Complete the following tasks and include a screenshot to show the completion of
your work.
a. Create a file one.txt and include a line “original contents”.
b. Create a soft link named /home/student/sl_one.txt that points to the
one.txt and append a line “testing soft link” to the file
/home/student/sl_one.txt
c. Verify the newly created soft link and its contents.
d. Now delete the file one.txt. Verify the newly created soft link and its
contents. What do you observe?
Globbing is a shell command-parsing operation that expands a wildcard pattern into a list of
matching path names. Command-line metacharacters are replaced by the match list prior to
command execution. Patterns that do not return matches display the original pattern
request as literal text. The following are common metacharacters and pattern classes.
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
19. Do a long listing of all the files in the /var/log/ directory which have at least one
“.”(dot) as part of their filename.
20. Do a list of all the files in the /var/log/ directory which have only a single character
after the “.”(dot) as part of their filenames.
21. Do a list of all the files in the /var/log/ directory which have more than a 3-letter
extension after the first “.” (dot) in their filenames. E.g. test.log file does not match
but test.log.log does.
22. What does the below command do? Include a screenshot to show the output.
23. Complete the guided exercise on “Managing Files from the Command Line” using
RHALP lab and include a screenshot of your completed work.
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
(Hint: Refer to the RHALP Lab Guide to access Red Hat labs host on the cloud. You
are given only 60hrs. So, shutdown the VMs once you have completed to optimize
the lab usage)
Learning Phase 3
Many simple, common system administration tasks are accomplished using command-line
tools. Tasks with greater complexity often require chaining together multiple commands
that pass results between them. Using the Bash shell environment and scripting features,
Linux commands are combined into shell scripts to easily solve repetitive and difficult real-
world problems.
25. Below is an example of a shell script. Open the editor and type the lines as per the
below screenshot. Save in a file first.sh and change the permission to executable by
typing the command chomd +x first.sh and type ./first.sh to execute it. What is the
output of first.sh?
(Hint: chmod command will be covered in subsequent lessons)
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
26. A positional parameter is a variable within a shell program; its value is set from an
argument specified on the command line that invokes the program. Positional
parameters are numbered and are referred to with a preceding ``$'': $1, $2, $3, and
so on. Observe the below program and explain how do we input the values of
positional parameters? How many positional parameters are there? What is the
output of the shell script, if we execute as ./pp.sh one two three?
27. Try the below and observe the output. What does a $ used for in the below output?
28. Write a single command to print the output below. (Hint –use --help to find out the
options for the date command and it should print the current date and time while
running the command).
31. Using for loop, write a script list.sh that lists all files in the current directory. Run the
script and include the script and the output of list.sh
(Note: You are rewriting the ls command without using it)
CHALLENGE YOURSELF!
You need to perform the following tasks on AIO in your assigned VM using Command Line
Interface (CLI) only. Verify your work after completing each step. (10 mins)
Use single command to create two directories target and achieve under /tmp/C330
(hint: check whether /tmp/C330 exists. If not, you need create it)
Create a file named <your-name>_target.sh inside “C330”
The content of the file <your-name>_targe.sh:
a. Line 1: My target is (Distinction/A/B/C/D/F) (Choose one) for C330 module
Using single command copy <your-name>_target.sh to <your-name>_achieve.sh
under the folder /tmp/C330
Without using a text editor, modify the file /tmp/C330/<your-name>_achieve.sh to
append the line “I will achieve my target”
Execute the following commands
a. ip addr
b. echo “your-name”
c. cat /tmp/C330/<your-name>_target
d. cat /tmp/C330<your-name>_achieve
Capture the results in a single screen.
LEARNING OBJECTIVES
Perform file operations such as create, view, edit and delete files using Command
Line Interface (CLI) or text editor
Differentiate the types of users and types of groups.
Create, modify and delete users and groups using CLI
Lesson 2 (from 25th to 31st Oct), will be conducted using Asynchronous E-Learning mode.
You will NOT be required to come to RP campus on the day of your Lesson 2
You will be given 3 days (including Sat, Sun & Public Holidays) to attempt and complete all
deliverables.
Attendance will be marked present and if you miss to submit the deliverables, your attend
will be marked as “ABSENT”
Read RHALP RH124 Chapter 5: Creating, Viewing, and Editing Text Files and Chapter 6:
Managing Local Users and Groups to complete week 2 worksheet.
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
LEARNING OBJECTIVES
Perform file operations such as create, view, edit and delete files using Command
Line Interface (CLI) or text editor
Differentiate the types of users and types of groups.
Create, modify and delete users and groups using CLI
Lesson 2 (from 25th to 31st Oct), will be conducted using Asynchronous E-Learning mode.
You will NOT be required to come to RP campus on the day of your Lesson 2
You will be given 3 days (including Sat, Sun & Public Holidays) to attempt and complete all
deliverables.
OVERVIEW
Use this worksheet as a guide to attempt indicated courses in RHALP learning
resources.
Include all required evidence of completion in your worksheet.
Ask your lecturer questions via chat or email.
Upload your completed (for Week 2) worksheet to LEO 2.0 Individual File
submission.
Deadline for submission is 23.59hrs, 3 days AFTER the day of your Lesson. 2
Ensure you are able to access RH124 materials and lab resources in RHALP
If you have any issues with the account, refer to LP1 Student Resources folder or
contact sharmila_kanna@rp.edu.sg for assistance.
Read RHALP RH124 Chapter 5: Creating, Viewing, and Editing Text Files and Chapter 6:
Managing Local Users and Groups to answer the questions below. Make use of additional
resources as needed.
1. View the contents of the below files and explain what information is stored in each
file.
/etc/passwd
/etc/group
/etc/shadow
2. You have used the two users accounts namely root and student frequently. What is
the difference between the two users?
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
3. Create a new user kelvin using useradd command and answer the following
questions.
a. What is the userid and groupid for kelvin?
b. Is there any passwd created for kelvin?
c. Is the home directory created for kelvin? (hint: /home)
d. What is the default shell prompt for kelvin?
4. Create a random password for user kelvin (hint: store the password in a text file) and
set the expiry date for the password to be one month later. (hint: chage command)
5. What is the command to force the user hakim to change the password at next login?
6. State the COMPLETE commands to create a new group teamX with groupid 4000 and
add your team members in into the group. Upon completion, include a screenshot to
verify your work. (Note: replace X in teamX with your team number)
7. Modify the user kelvin so that the primary group of user kelvin is group teamX.
8. With great power comes great responsibility! Root user is capable of doing everything
to the system, which also includes destroying the whole system! It is recommended
that for daily use, we do not use the root to log in. Then how do we run some
commands that only root user can run? Such as ls /root. Do a search online to find a
solution for this. (Hint: run command as root in Linux)
9. You may encounter the word “sudoers” by now. How can a “sudoer” run the
commands that only root user can run? (Hint: sudo command)
CHALLENG YOURSELF!
Hint:
XX is the total number of students in your class
use seq command to generate a sequence of numbers.
Academic Week 3
LEARNING OBJECTIVES
Learning Phase 1
Your lecturer will share an activity and complete the activity individually in your
assigned AIO machine. Students are randomly selected to demonstrate the tasks.
Learning Phase 2
2. What are the permissions for the file /etc/passwd? Can anyone else other than the
root user views this file?
3. The actual hashed and salted passwords are stored in /etc/shadow. Based on the
screenshot below. What are its permissions? Can anyone else other than the user
root views this file?
4. What is the reason for storing hashed and salted passwords in a file /etc/shadow?
5. Create a file called script.sh using touch command. What is its default permission?
(Note this!)
8. Show who is the owner and group for the file script.sh
9. Change both the owner and group to student for the file script.sh
10. Using the symbolic method, remove write permissions for owner, and all permissions
for group and other users for the file script.sh
11. Using the numeric method, allow only read+execute for all others, except the owner
who should have read+write+execute permissions for the file script.sh.
12. Using the numeric method, allow only read+write for owner, while all others do not
have any access to the file script.sh.
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
13. In root home directory, use touch to create a new file. Note down its default
permission.
14. In another terminal window, change to the student user to try and access the file.
15. Use chmod to allow the student user to access the file, and test it using the other
terminal window.
16. Use chown to allow the student user to access the file, and test it using the other
terminal window.
18. Now change to a non-privileged user su student and type in umask. What is the
umask now?
20. What is the umask value so that newly created directories are RWX only to the
owner? Newly created files/directories should not be accessible to others. Test it
out by creating a new directory and file.
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
21. Now use the umask command to set all created files having only read/write
permissions for the owner, read permissions for group while no permissions for all
other users. Test it by doing a touch on a new file and viewing the permissions in a
new Terminal. Include a screenshot to verify your work.
23. Complete the “RHALP RH134 Chapter 4: Controlling Access to Files with ACLs” lab in
Red Hat lab portal and include a screenshot on the completion of your work
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
b) Individual Worksheet (fully completed) –> individual submission folder in LEO 2.0 by
23:59, uploaded in DOC format.
a) Team presentation slides –> team submission folder in LEO 2.0 by 10.15am
b) Team Demonstration using Team VM do not delete any work done in your VM
c) Peer Evaluation (in LEO)
d) Self-Evaluation (in LEO)
The work done in Team VM will be deleted by end of the day. So, capture
screenshots to include in the team presentation slides.
Include the following in your presentation
a) PDT indicating breakdown & analysis of problem from MS Teams
b) A slide to elaborate the individual contribution percentage within the team
should be included. Below shows an example of the slide. This should be
mutually agreed by each of the members in the team.
c) Solution to the Problem Statement
d) Challenges faced
Example:
Member Name Individual Contribution within the team
to the solution(s) for the problem
statement
Member 1 50%
Member 2 30%
Member 3 15%
Member 4 5%
Member 5 0%
Learning Phase 1
Teams MUST do their own research and are NOT to use any media (images/videos) provided in
this worksheet.
Ensure that the delivered PPT solution for the team includes the PDT, as well as details on
individual contribution percentage.
Learning Phase 2
Republic Polytechnic - School of Infocomm
C330 Linux Administration and Virtualisation
AY2022 Semester 2
2nd/3rd/4th Team Presentation – 1 hour 30 minutes
Learning Phase 3