Lab Performance Test Solution: Shell Commands
Task 1: User and Group Management
1. Create two users named ‘user1’ and ‘user2’:
sudo useradd user1
sudo useradd user2
2. Create a group named ‘project_group_x’:
sudo groupadd project_group_x
3. Add both ‘user1’ and ‘user2’ to the ‘project_group_x’:
sudo usermod -aG project_group_x user1
sudo usermod -aG project_group_x user2
Task 2: Project Directory Setup
4. Create a project directory ‘/home/projects/ProjectX’:
sudo mkdir -p /home/projects/ProjectX
5. Change the group ownership of the ‘/home/projects/ProjectX’ directory to
‘project_group_x’:
sudo chown :project_group_x /home/projects/ProjectX
6. Set permissions so only members of ‘project_group_x’ can read, write, and execute
files in ‘/home/projects/ProjectX’:
sudo chmod 770 /home/projects/ProjectX
Task 3: File Creation
7. Switch to ‘user1’ and create a file named ‘[Link]’ in ‘/home/projects/ProjectX’. Add
the text "ProjectX Progress Report" to the file:
su - user1
echo "ProjectX Progress Report" > /home/projects/ProjectX/[Link]
8. Create a text file ‘[Link]’ in ‘/home/projects/ProjectX’ with the specified content:
cat << EOF > /home/projects/ProjectX/[Link]
Error: File not found
Warning: Low disk space
Info: System update completed
Error: Connection timed out
EOF
Task 4: Grep Command Application
9. Extract all lines from ‘[Link]’ that contain the word "Error":
grep "Error" /home/projects/ProjectX/[Link]
10. Count the total number of lines in ‘[Link]’ containing the word "Error":
grep -c "Error" /home/projects/ProjectX/[Link]