Linux Terminal Practice Exercises
Intro to Linux
Objective
These exercises are designed to introduce you to common Linux terminal commands. Follow each prompt
in your terminal and observe the output. Try to understand what each command does.
Instructions
Open a terminal window. Type each command as instructed, then answer any related questions or perform
the tasks as required.
Exercises
1. View the Calendar
• Command: cal
• What month and year is displayed?
2. Clear the Screen
• Command: clear
• What happens in your terminal window?
3. Show the Current Date and Time
• Command: date
• What day of the week is today?
4. Display a Custom Message
• Command: echo "Welcome to Linux!"
• Try replacing the message with your name.
5. Show the Hostname
• Command: hostname
• What hostname is shown?
6. View System Uptime
• Command: uptime
• How long has the system been running?
7. Display Your Current Directory
• Command: pwd
• What is your current directory path?
1
8. List Files and Directories
• Command: ls
• What items are listed?
9. View CPU Information
• Command: lscpu
• What is the model name of the CPU?
10. Show Free Memory
• Command: free -h
• How much free memory is available?
11. Print Kernel and OS Info
• Command: uname -a
• What kernel version do you see?
12. Review Command History
• Command: history
• What was the first command you entered today?
13. Echo a Variable
• Run:
MYNAME="Student"
echo "Hello, $MYNAME"
• Change the value of MYNAME and try again.
14. List Files in Long Format
• Command: ls -l
• What additional information is shown?
15. List All Files, Including Hidden
• Command: ls -a
• What files begin with a dot (.)?
16. Print a Blank Line, Then a Message
• Command:
echo ""
echo "This is a new line"
17. Combine Commands
• Command: echo "Today is:" && date
• What output do you see?
18. Try an Invalid Command
• Type: blahblah
• What error message do you receive?
2
19. Run passwd
• This changes your login password.
20. Exit the Terminal (Last Step)
• Command: exit
• Close your terminal after completing all exercises.
Challenge (Optional)
Try combining a few commands in one line:
clear && echo "System Info:" && uname -a && uptime