// Terminal Customisation

Write your first shell script

Make a reusable system-status report with safe defaults.

A shell script is a text file containing commands. Start with small tasks you understand, then automate the repetition.

Create a status script

Open ~/darkpc-status.sh in your text editor and enter:

#!/bin/sh
set -eu
printf '%s\n' '=== DarkPC status ==='
printf 'User: '; id -un
printf 'Date: '; date
printf 'Kernel: '; uname -r
printf '\nDisk usage:\n'
df -h "$HOME"

#!/bin/sh chooses a portable POSIX shell. set -e exits if an unhandled command fails; -u treats unset variables as errors. These options need care in larger scripts, but help with simple ones.

Run it

chmod u+x ~/darkpc-status.sh
~/darkpc-status.sh

Or run it as sh ~/darkpc-status.sh without making it executable.

Give your script a name

Keep your personal scripts in ~/bin if you like. Add that folder to your shell's PATH only after verifying it contains scripts you trust.

Safety rules

Never download and pipe a random script straight to a root shell. Read it first, verify the source, understand what files it edits, and test with harmless data.

Challenge: add free -h to the end to display memory usage on systems where the command is available.