0
0
Linux CLIscripting~15 mins

useradd and userdel in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Managing Users with useradd and userdel Commands
📖 Scenario: You are a system administrator managing users on a Linux server. You need to add new users and remove users safely using command-line tools.
🎯 Goal: Learn how to create new users with useradd and delete users with userdel commands through a guided script.
📋 What You'll Learn
Use the useradd command to create users
Use the userdel command to delete users
Use variables to store usernames
Print confirmation messages after each operation
💡 Why This Matters
🌍 Real World
System administrators often need to add and remove users on Linux servers to manage access and security.
💼 Career
Knowing how to use user management commands like useradd and userdel is essential for Linux system administration roles.
Progress0 / 4 steps
1
Create a variable for the new username
Create a variable called new_user and set it to the exact string testuser.
Linux CLI
Need a hint?

Use new_user='testuser' to assign the username.

2
Create a variable for the username to delete
Create a variable called del_user and set it to the exact string olduser.
Linux CLI
Need a hint?

Use del_user='olduser' to assign the username to delete.

3
Add the new user and delete the old user
Use the useradd command with $new_user to add the new user, and use the userdel command with $del_user to delete the old user. Write both commands on separate lines.
Linux CLI
Need a hint?

Use useradd "$new_user" and userdel "$del_user" commands.

4
Print confirmation messages
Print the exact messages User testuser added successfully. and User olduser deleted successfully. on separate lines using echo commands.
Linux CLI
Need a hint?

Use echo "User testuser added successfully." and echo "User olduser deleted successfully.".