๐Ÿ“š Table of Contents

What Is a Shell?

Your terminal is a program that lets you type text-based commands and see their output.

But what runs those commands?

Thatโ€™s the shell.


๐Ÿ› ๏ธ What Does a Shell Do?

The shellโ€™s main job is to:

  • Interpret the commands you type
  • Execute those commands

๐Ÿ”„ Shells as REPLs

Shells are often called REPLs, which stands for:

  • Read
  • Eval (evaluate)
  • Print
  • Loop

In simple terms, a shell:

  1. Reads the command you type
  2. Evaluates it (runs the program or command)
  3. Prints the output
  4. Loops back, showing a new prompt for the next command

๐Ÿ’ก This cycle makes shells interactive and powerful command interpreters.

Filesystem Commands

These commands help you interact with your Linux filesystem โ€” navigate, read, modify, and search files or directories.


๐Ÿ”ธ echo $variable

Displays the value of a variable.

NAME="Adarsh"
echo $NAME
# Output: Adarsh

๐Ÿ”ธ whoami

Prints the current logged-in username.

whoami
# Output: your_username

๐Ÿ”ธ pwd

Prints the current working directory (stands for โ€œPrint Working Directoryโ€).

pwd
# Output: /home/user/projects

๐Ÿ”ธ cat

Displays the entire content of a file.

cat notes.txt

๐Ÿ”ธ head

Shows the first 10 lines of a file (default).

head log.txt

You can change line count:

head -n 5 log.txt

๐Ÿ”ธ tail

Shows the last 10 lines of a file (default).

tail log.txt

Watch file updates live:

tail -f log.txt

๐Ÿ”ธ mv

Moves or renames a file or directory.

mv old.txt new.txt       # Rename
mv file.txt /path/dir/   # Move

๐Ÿ”ธ cp

Copies files or directories.

cp a.txt b.txt           # Copy file
cp -r folder1 folder2    # Copy directory recursively

๐Ÿ”ธ grep

Searches for patterns inside files.

grep "error" logfile.txt

Case-insensitive search:

grep -i "error" logfile.txt

๐Ÿ”ธ find

Searches for files/directories in a path.

find . -name "*.py"

Find files modified in the last 1 day:

find . -mtime -1

๐Ÿ”ธ ls

Lists files and folders in a directory.

ls
ls -l        # Long format
ls -a        # Include hidden files

๐Ÿ”ธ rm

Deletes files or directories.

rm file.txt            # Delete file
rm -r folder/          # Delete folder and contents

โš ๏ธ Use with caution. No undo.


๐Ÿ”ธ touch

Creates an empty file or updates timestamp.

touch hello.txt

๐Ÿ”ธ mkdir

Creates a new directory.

mkdir new_folder


This site uses Just the Docs, a documentation theme for Jekyll.