Linux for Beginners


Linux Basics — Part 1

Introduction, Terminal, Commands, Users & Root Access


1. Introduction to Linux

What is Linux? Linux is a free, open-source operating system — like Windows or macOS, but built and maintained by a global community of developers. It powers everything from smartphones (Android) to web servers, supercomputers, and everyday laptops.

Why learn Linux?

  • It’s free and open — you can see and modify the code.
  • It’s the backbone of most servers, cloud platforms, and developer tools.
  • It teaches you how computers actually work “under the hood.”
  • It’s stable, secure, and doesn’t slow down over time the way some other systems can.

Key terms to know first:

TermMeaning
OS (Operating System)The software that manages hardware and lets you run programs
KernelThe core of Linux — manages memory, processes, and hardware
Distribution (Distro)A packaged version of Linux (e.g., Ubuntu, Fedora, Debian, Mint) — kernel + tools + software
ShellA program that takes your typed commands and tells the OS what to do
TerminalThe window/application where you type commands to talk to the shell
CLICommand Line Interface — text-based way of using the computer (as opposed to GUI)
GUIGraphical User Interface — the normal windows/icons/mouse way of using a computer

Common shells: bash (most common, default on many distros), zsh, sh, fish. Throughout this doc, we assume bash, since it’s the most widely used.


2. The Terminal — Your Main Tool

The terminal (also called console, shell prompt, or command line) is where you type text commands instead of clicking icons.

When you open a terminal, you’ll usually see a prompt that looks like this:

venkat@laptop:~$

Breaking this down:

  • venkat → the username you’re logged in as
  • laptop → the computer’s hostname (name of the machine)
  • ~ → your current location (folder). ~ means your home directory
  • $ → means you are a normal (non-root) user
  • # → if you see this instead of $, it means you are logged in as root (the administrator)

3. Anatomy of a Linux Command

Every Linux command generally follows this structure:

command  [options]  [arguments]

Example:

ls -l /home/venkat
PartValueMeaning
Commandls”list” — lists files and folders
Option (flag)-lModifies how the command behaves (here: “long/detailed listing”)
Argument/home/venkatTells the command what to act on (here: which folder)

Options (a.k.a. flags/switches)

  • Change the behavior of a command.
  • Usually start with - (short form) or -- (long/full-word form).
  • Can often be combined.
ls -l          # long listing
ls -a          # show hidden files too
ls -la         # combine both: long listing + hidden files
ls --all       # same as -a, but written in long form

Arguments

  • Tell the command what to work on — a file, folder, text, etc.
  • Can be zero, one, or multiple.
mkdir project        # 1 argument: folder name to create
cp file1.txt file2.txt backup/   # 3 arguments: source files + destination

Getting help for any command

man ls          # opens the full manual page (press 'q' to quit)
ls --help       # quick summary of options
whatis ls       # one-line description

4. A Few Essential Starter Commands

CommandPurposeExample
pwdPrint current folder (Print Working Directory)pwd
lsList files/foldersls -la
cdChange directorycd Documents
mkdirMake a new foldermkdir Photos
touchCreate an empty filetouch notes.txt
cpCopy files/folderscp a.txt b.txt
mvMove or rename filesmv old.txt new.txt
rmRemove (delete) filesrm file.txt
catShow file contentscat notes.txt
clearClear the terminal screenclear
echoPrint text to screenecho "Hello Linux"
whoamiShow current logged-in usernamewhoami

Tip for beginners: rm deletes permanently — there’s no Recycle Bin in the terminal by default. Always double-check before pressing Enter!


5. Command History

Linux remembers the commands you’ve typed, so you don’t have to retype them.

ActionHow
Move to previous commandPress ↑ (Up arrow)
Move to next commandPress ↓ (Down arrow)
View full history listType history
Re-run a specific command from historyType ! followed by its number, e.g. !45
Re-run the last commandType !!
Search history interactivelyPress Ctrl + R, then type part of the command
Clear historyhistory -c

Example:

history          # shows a numbered list like:
                  # 42  ls -la
                  # 43  cd Documents
                  # 44  pwd
!43               # re-runs "cd Documents"

6. Useful Terminal Keyboard Shortcuts

ShortcutAction
Ctrl + CCancel/stop the currently running command
Ctrl + ZPause (suspend) the current command
Ctrl + DExit the terminal / end input (logout of shell)
Ctrl + LClear the screen (same as typing clear)
Ctrl + AMove cursor to the beginning of the line
Ctrl + EMove cursor to the end of the line
Ctrl + UDelete everything before the cursor
Ctrl + KDelete everything after the cursor
Ctrl + WDelete the word before the cursor
Ctrl + RSearch through command history
TabAuto-complete file/folder/command names
Tab Tab (press twice)Show all possible completions
↑ / ↓Scroll through previous commands
Ctrl + Shift + C / VCopy / Paste in most terminal apps (since Ctrl+C is taken)

Tip: Get comfortable with Tab — it saves huge amounts of typing and avoids typos in file names.


7. Root User vs Normal User

Linux is a multi-user system with built-in permission levels for security.

Normal user

  • Created for everyday use (e.g., venkat).
  • Has access to their own home folder (/home/venkat) and limited system permissions.
  • Cannot modify system files, install software system-wide, or change other users’ data — without special permission.

Root user (a.k.a. superuser / administrator)

  • The most powerful account on a Linux system.
  • Can read, write, modify, or delete any file, install/remove software, manage all users, and change system settings.
  • Home folder is /root.
  • Prompt symbol is # instead of $.

Why not just always use root? Because a small typo (like an accidental rm -rf /) can destroy the entire system if you’re root. Normal users act as a safety net — mistakes are contained.

Checking who you are

whoami        # shows current username
id            # shows user ID (UID), group ID (GID) and group memberships
  • UID 0 always means root.
  • Any other UID is a normal user.

8. Gaining Root Access Safely — sudo

Instead of logging in directly as root, modern Linux systems use sudo (“SuperUser DO”) — it lets an approved normal user run a single command with root privileges, after entering their own password.

Basic usage

sudo <command>

Example:

sudo apt update            # updates package lists (needs root)
sudo apt install vlc       # installs software (needs root)
sudo nano /etc/hosts       # edits a protected system file

When you run sudo, it will ask for your own user password (not a separate root password) the first time, then remember it for a few minutes.

Becoming root for multiple commands

If you need to run several admin commands in a row:

sudo -i          # switch to a full root shell/session

or

sudo su          # similar effect — switch to root

You’ll notice the prompt changes from $ to #. Type exit to leave root mode and return to your normal user.

Running just one command as another/root user without a full switch

sudo -u username command     # run a command as a specific user

Important safety rules for beginners

  1. Only use sudo when a command specifically tells you it’s needed (e.g., install/update software, edit system config files).
  2. Never run sudo rm -rf / or similar broad delete commands — this is a common way beginners destroy their system.
  3. If unsure whether a command needs root, try it without sudo first — Linux will tell you with a “Permission denied” message if it’s needed.
  4. Not every user account has sudo privileges — only ones added to the sudo (or wheel, on some distros) group can use it.

Checking sudo privileges

sudo -l         # lists what commands your account is allowed to run with sudo
groups          # shows which groups your user belongs to (look for "sudo")

9. Quick Recap Table

ConceptKey Command / Shortcut
See current folderpwd
List filesls -la
Get helpman <command> or <command> --help
Repeat last command!! or ↑
Search historyCtrl + R
Stop a running commandCtrl + C
Clear screenCtrl + L or clear
Check current userwhoami
Gain temporary root accesssudo <command>
Full root sessionsudo -i

The Linux Filesystem, Demystified: Navigation, Search, VIM, and Links

If you’ve ever felt like the Linux terminal is a black box of cryptic two-letter commands, this post is for you. We’re going to walk through the filesystem the way a sysadmin actually thinks about it — starting with where am I, moving through how do I find things, and ending with the two most misunderstood concepts in the whole OS: hard links and symlinks.

Grab a terminal. Let’s go.


1. Absolute vs Relative Paths, pwd, cd, tree

Every file and directory in Linux hangs off a single root: /. How you refer to a location determines whether your path is absolute or relative.

  • Absolute path — starts from /, works no matter where you currently are.
    cd /home/venkat/projects/mlfuse
  • Relative path — starts from wherever you currently sit. Uses . (here) and .. (one level up).
    cd ../projects/mlfuse

pwd (print working directory) tells you exactly where you are right now:

pwd
# /home/venkat/projects/mlfuse

cd (change directory) moves you around:

cd /var/log        # absolute jump
cd ..               # up one level
cd ~                # home directory
cd -                # back to the previous directory

tree gives you a visual map of a directory structure instead of navigating blind:

tree -L 2 ~/projects
projects
├── mlfuse
│   ├── data
│   └── src
└── portfolio-site
    ├── assets
    └── index.html

The -L 2 flag limits depth to two levels — handy for large trees.


2. ls, File Types, ls -F, cat, less, tail, head, watch

ls lists directory contents. The real power is in the flags:

ls -l      # long format: permissions, owner, size, date
ls -la     # include hidden files (dotfiles)
ls -lh     # human-readable sizes (K, M, G)

ls -F appends a symbol to each entry so you can identify file types at a glance:

ls -F
  • / → directory
  • * → executable
  • @ → symbolic link
  • | → named pipe (FIFO)
  • = → socket

cat dumps a whole file to the terminal — great for small files:

cat notes.txt

less opens a file for paged, scrollable viewing without loading it all into memory — the go-to for big files or logs:

less /var/log/syslog

Navigate with arrow keys, /searchterm to search, q to quit.

head and tail show the beginning or end of a file:

head -n 20 access.log     # first 20 lines
tail -n 20 access.log     # last 20 lines
tail -f access.log        # "follow" mode — live updates as the file grows

watch repeatedly runs a command and refreshes the output on screen — perfect for monitoring:

watch -n 2 df -h    # re-check disk usage every 2 seconds

3. touch, mkdir, cp, mv, rm, shred, Piping, Redirection, wc, cut, tee

Creating things:

touch file.txt          # create empty file, or update its timestamp
mkdir new_folder        # make a directory
mkdir -p a/b/c           # make nested directories in one shot

Copying and moving:

cp source.txt dest.txt       # copy a file
cp -r source_dir dest_dir    # copy a directory recursively
mv old_name.txt new_name.txt # rename (mv is also how you rename in Linux!)
mv file.txt /tmp/            # move to another location

Deleting — the careful way:

rm file.txt         # delete a file
rm -r folder/       # delete a directory and its contents
rm -rf folder/      # force delete, no confirmation — use with real caution

shred goes a step further than rm: it overwrites a file’s data multiple times before deletion, so it can’t easily be recovered from disk — useful for sensitive files:

shred -u -z -v secrets.txt
# -u: delete after shredding, -z: zero out at the end, -v: verbose

Piping (|) feeds the output of one command as input to another:

ls -la | grep ".txt"

Redirection sends output to a file instead of the screen:

echo "hello" > file.txt     # overwrite file with output
echo "again" >> file.txt    # append output to file
sort names.txt > sorted.txt

wc (word count) counts lines, words, and characters:

wc -l file.txt    # line count
wc -w file.txt    # word count

cut extracts columns/fields from text — great with delimited data:

cut -d',' -f2 data.csv    # print the 2nd comma-separated field

tee writes output to a file and prints it to the screen at the same time — useful in the middle of a pipeline:

ls -la | tee listing.txt | grep ".log"

4. which, plocate, find, exec, grep, Binary String Search, cmp, diff, sha256

which tells you the exact path of an executable that a command will run:

which python3
# /usr/bin/python3

plocate (the modern replacement for locate) searches a pre-built index of the entire filesystem — near-instant, but the index needs periodic updates (sudo updatedb):

plocate nginx.conf

find searches the filesystem live, in real time, with far more precision than locate:

find /home -name "*.py"              # by name
find . -type d -name "node_modules"  # directories only
find . -mtime -7                      # modified in the last 7 days
find . -size +100M                    # files larger than 100MB

-exec lets find run a command on every match it finds:

find . -name "*.tmp" -exec rm {} \;

Here {} is replaced by each matched file, and \; terminates the command.

grep searches inside files for a pattern:

grep "ERROR" app.log             # matching lines
grep -r "TODO" ./src             # recursive search across a directory
grep -i "warning" app.log        # case-insensitive
grep -c "ERROR" app.log          # count matches

Searching for strings inside binary files — normally grep on a binary spits out garbage, so use strings first, or grep -a to force text mode:

strings /bin/ls | grep "version"
grep -a "some_text" binary_file

cmp compares two files byte-by-byte and reports the first difference:

cmp file1.txt file2.txt

diff shows the actual line-by-line differences between two files — the tool behind every code review:

diff old.txt new.txt
diff -u old.txt new.txt    # unified diff format, git-style

sha256sum generates a cryptographic checksum — the standard way to verify a file hasn’t been corrupted or tampered with:

sha256sum ubuntu.iso
# compare the output against the checksum published by the source

5. VIM: Shortcuts and Moving Around

VIM is a modal editor — the same keys do different things depending on which mode you’re in. This trips up almost everyone at first.

The three core modes:

  • Normal mode (default, on open) — for navigation and commands
  • Insert mode — for actually typing text (i to enter it)
  • Command mode — for saving, quitting, search-and-replace (: to enter it)

Entering insert mode:

i    insert before cursor
a    insert after cursor
o    open a new line below and insert
O    open a new line above and insert

Press Esc to return to normal mode from any of these.

Moving around (normal mode):

h j k l     left, down, up, right (the classic arrow-key substitute)
w           jump to next word
b           jump back a word
0           start of line
$           end of line
gg          top of file
G           bottom of file
:42         jump to line 42

Editing:

dd     delete (cut) current line
yy     yank (copy) current line
p      paste after cursor
u      undo
Ctrl+r redo
x      delete character under cursor

Saving and quitting (command mode, prefixed with :):

:w        save
:q        quit
:wq       save and quit
:q!       quit without saving

The learning curve is real, but muscle memory kicks in fast — and once it does, editing text at terminal speed is hard to give up.


6. tar and gzip

tar (tape archive) bundles multiple files/directories into a single archive file — it does not compress by default, just packages:

tar -cvf archive.tar folder/     # create
tar -xvf archive.tar             # extract
tar -tvf archive.tar             # list contents without extracting

c = create, x = extract, v = verbose, f = specify filename.

gzip compresses a single file (and replaces the original with a .gz version):

gzip file.txt        # produces file.txt.gz
gunzip file.txt.gz   # decompress back

Combined — the classic .tar.gz:

tar -czvf archive.tar.gz folder/   # create + gzip-compress in one step
tar -xzvf archive.tar.gz           # extract a gzip-compressed tarball

The z flag tells tar to pipe through gzip automatically.


Every file on a Linux filesystem is actually two separate things:

  1. The data itself, stored in blocks on disk
  2. An inode — a metadata record (permissions, owner, size, timestamps, and pointers to the data blocks) identified by a unique inode number

A filename is just a label that points to an inode. This is the key insight that makes hard links make sense.

A hard link creates a second filename pointing to the exact same inode — not a copy, not a shortcut, but a second, equally valid name for the same underlying data:

ln original.txt hardlink.txt

Check it with:

ls -li original.txt hardlink.txt

You’ll see identical inode numbers for both. Edit either file and the change appears in both, because there’s really only one file with two names. The data is only actually freed from disk when every hard link to that inode is deleted.

Hard links can’t cross filesystems (inodes are only unique within a single filesystem) and can’t point to directories.


A symbolic link (symlink) is fundamentally different: it’s a small special file that just contains a path string pointing to another file:

ln -s original.txt symlink.txt
Hard LinkSymlink
What it isAnother name for the same inodeA separate file containing a path
Inode numberSame as originalDifferent from original
Crosses filesystemsNoYes
Can link to a directoryNoYes
If original is deletedData survives (still has a name)Link breaks (“dangling” symlink)
Shows in ls -lLooks like a normal fileShown with l prefix and -> pointing to target

You can spot a symlink instantly in a listing:

ls -l symlink.txt
# lrwxrwxrwx 1 venkat venkat 12 Aug 8 10:00 symlink.txt -> original.txt

The practical rule of thumb: use symlinks for almost everything (they’re flexible, cross filesystems, and can point to directories) — reach for hard links only when you specifically need multiple names to guarantee the same data survives even if one name is deleted.


Wrapping Up

Once pwd, find, and grep become second nature, and once VIM’s modal editing clicks, the terminal stops feeling adversarial and starts feeling like the fastest tool on your machine. Hard links and inodes are the one piece of trivia that quietly explains why half of this works the way it does — worth sitting with until it clicks.

Happy hacking.