Linux Mastery, Practical Exercises for Effective Command Line Skills

7 months ago 37
BOOK THIS SPACE FOR AD
ARTICLE AD

Muhammad Riva

Welcome to interactive Linux command line tutorial! Whether you’re gearing up to master the basics or brushing up on advanced operations, this set of exercises will test your skills and deepen your understanding of Linux system management. Let’s dive into each task with step-by-step guidance to reinforce your learning!

Exercise 1: Display Current Directory

Question: How do you display the current working directory in a Linux terminal?

Command:

pwd

This command prints the current working directory path, helping you orient yourself in the filesystem.

Exercise 2: Search for a Specific File

Question: How can you find a file named laporan.txt in the directory /home and its subdirectories?

Command:

find /home -name laporan.txt

This command searches through /home and all directories within it for a file named laporan.txt.

Exercise 3: Change Directory

Question: How do you change the working directory to /var/www?

Command:

cd /var/www

This command changes your current directory to /var/www.

Exercise 4: Create and Delete a Directory

Question: Create a directory named ProjekBaru in your home directory, then delete it.

Commands:

mkdir ~/ProjekBaru
rm -r ~/ProjekBaru

This sequence creates a new directory and then removes it, along with any contents it might have.

Exercise 5: Copy a File

Question: How do you copy the file contoh.txt from the current directory to the directory /home/kali/backup?

Command:

cp contoh.txt /home/kali/backup

This command copies contoh.txt into the specified backup directory.

Exercise 6: Move and Rename a File

Question: How do you move the file data.txt from the current directory to /home/kali/data, and rename it to data_backup.txt?

Command:

mv data.txt /home/kali/data/data_backup.txt

This command moves data.txt to a new location and renames it during the move.

Exercise 7: Creating a New File

Question: Create a directory named LatihanLinux in the home directory and a new file named notes.txt with the text “Ini adalah file latihan” inside it. Use ls to display the contents of LatihanLinux.

Commands:

mkdir ~/LatihanLinux
echo "Ini adalah file latihan" > ~/LatihanLinux/notes.txt
ls ~/LatihanLinux

This series of commands sets up a new directory and file, then lists the contents to verify.

Exercise 8: Display Directory Contents

Question: How do you display all files and directories, including hidden ones, in the current directory?

Command:

ls -a

This command lists all contents of a directory, including files that start with a dot, which are hidden by default.

Exercise 9: Search Files by Size

Question: How can you find all files larger than 10MB in the /var/log directory?

Command:

find /var/log -type f -size +10M

This command searches for files exceeding 10 megabytes in /var/log.

Exercise 10: Copy a Directory

Question: How do you copy the src directory and all its contents to a new directory named dest?

Command:

cp -r src dest

This command recursively copies the src directory and its contents to a new directory dest.

Exercise 11: Install Apache2 on a Debian-based System

Question: What are the steps to install Apache2 on a Debian-based Linux system (like Ubuntu)?

Command:

sudo apt update
sudo apt install apache2

These commands update your package lists and install Apache2.

Exercise 12: Verify Apache2 Installation

Question: How do you verify that Apache2 is running correctly on your system?

Command:

systemctl status apache2

This command checks the status of the Apache2 service to ensure it’s active and running.

Exercise 13: Adding a Custom Web Page

Question: Create a file index.html in the directory /var/www/html with the contents “Welcome to My Apache Server”. What are the steps to do this?

Command:

echo "Welcome to My Apache Server" | sudo tee /var/www/html/index.html

This command creates or overwrites index.html with a welcome message.

Exercise 14: Using Redirection and Pipe

Question: Search for all files containing the word “error” in the directory /var/log, redirect the output to a file named error_logs.txt in the home directory, and then use grep to search for “failed” in error_logs.txt and wc -l to count the lines found.

Commands:

grep -r "error" /var/log > ~/error_logs.txt
grep "failed" ~/error_logs.txt | wc -l

These commands first capture all mentions of “error”, filter for lines containing “failed”, and count those lines.

Exercise 15: Remove Apache2

Question: How do you remove Apache2 and its configuration from your Linux system?

Command:

sudo apt purge apache2

This command completely removes Apache2 and its configuration files.

Exercise 17: Install Golang 1.21+

Question: After learning about Apache2, how do you install the Go programming language for pentesting tool development?

Command:

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
sudo apt install golang-go

This installs a specific version of Go from a backports repository.

Exercise 18: Install Docker

Question: How do you install Docker to build your own simple pentest labs?

Command:

sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker

These commands install Docker and ensure it starts on boot.

Exercise 19: Build a Simple bWAPP Web Pentest Lab

Question: After installing Docker, how do you set up a simple bWAPP lab to sharpen your web pentesting skills?

Command:

docker pull raesene/bwapp
docker run -d -p 80:80 raesene/bwapp

This pulls a bWAPP container image and runs it, making the lab accessible via web browser.

I hope these exercises challenge you and enhance your Linux command line skills. Remember, practice makes perfect, and every command you master takes you one step closer to becoming a Linux pro. Keep exploring and happy learning!

Read Entire Article