Basic terminal structure and commands | Bash

The terminal, with its cryptic prompts and blinking cursors, might seem intimidating at first. But fear not, for it's actually a powerful tool waiting to be unleashed! In this guide, we'll explore the basic structure and essential commands of the Bash shell, your gateway to the digital world.

Navigating the Landscape

Imagine the terminal as a vast file system, organized into hierarchical directories and subdirectories. At the top sits the root directory (/), followed by branches like home (your personal space) and etc (system settings). Each directory contains files and folders, representing programs, documents, and other data.

Basic Terminal Structure

Prompt

The prompt is the text or symbol that indicates the terminal is ready to receive a command. It often includes information like the username, hostname, current working directory, or a specific symbol.

user@hostname:~/current_directory$

Command Line

This is where you type your commands.Commands are entered after the prompt and are executed by pressing the Enter key.

user@hostname:~/current_directory$ ls

Output

After executing a command, the terminal displays the output of that command. Output can include text, data, or error messages.

file1.txt file2.txt folder1

Basic Bash Commands

pwd (Print Working Directory)

Displays the current working directory.

$ pwd /home/user/current_directory
ls (List)

Lists files and directories in the current directory.

$ ls file1.txt file2.txt folder1
cd (Change Directory)

Changes the current working directory.

$ cd folder1
mkdir (Make Directory)

Creates a new directory.

$ mkdir new_folder
cp (Copy)

Copies files or directories.

$ cp file1.txt /path/to/destination
mv (Move)

Moves or renames files or directories.

$ mv file1.txt new_folder/
rm (Remove)

Deletes files or directories.

$ rm file1.txt
cat (Concatenate)

Displays the content of a file.

$ cat file1.txt
echo

Prints text or variables to the terminal.

$ echo "Hello, World!"
man (Manual)

Displays the manual or documentation for a command.

$ man ls

These are just some fundamental commands. Bash provides a wide range of commands and features for managing files, processes, and more..

Points to Remember
  1. Safety first: The terminal can be a powerful tool, so always be mindful of the commands you execute. Avoid running commands you don't understand.
  2. Practice makes perfect: Don't be afraid to experiment! The more you use the terminal, the more comfortable you'll become.
  3. Resources abound: There are countless online resources and communities dedicated to teaching you the magic of the terminal. Don't hesitate to seek help when needed.

Conclusion

The terminal has a prompt, command line, and displays command outputs. Basic Bash commands include pwd for current directory, ls for listing files, cd for changing directories, and others like cp, mv, rm for file manipulation.