Tutorial 2

Shell Scripting Basics

File management, permissions, and writing your first bash script.

1 Remove a File

Use the rm command to remove files. Specify the absolute path.

bash
rm /home/tom/Desktop/hello.txt

2 Move a Directory

Navigate to your home directory, then move the folder.

bash
cd ~
mv firstfolder/ /home/tom/Desktop/

3 Create a Script File

Navigate to the moved directory and create a new script using nano.

bash
cd Desktop/firstfolder
nano script.sh

4 Writing Your First Bash Script

Add this content to your script.sh file:

bash
#!/bin/bash
echo "Hello! $(whoami)"
echo "The current date/time is: $(date)"

#! #!/bin/bash — Shebang specifying the Bash interpreter

echo Prints messages to the console

$( ) Command substitution — executes the command inside

5 Make & Run the Script

First make it executable, then run it.

bash
chmod a+x script.sh
./script.sh

Expected Output:

Hello! tom
The current date/time is: Thu Jul 9 12:00:00 UTC 2026

Congratulations!

You've successfully learned to manage files, set permissions, and create your first bash script!

Home Buy Me a Beer