Part 1: Getting Started - Your First Commands
Table of Contents
Learn essential navigation and file operation commands in the Linux terminal Welcome to Part 1 of the Linux Command-Line Workshop! Haven’t set up your environment yet? Go back to Part 0: Setting Up Your Environment first! In this post, you’ll learn the fundamental commands that every developer needs to navigate and manipulate files in the terminal. Before we dive in, let’s understand what a command looks like: Example: Shows you where you currently are in the filesystem. Exercise 1.1: Open your terminal and run The most-used command. Shows files and folders in your current location. Basic usage: Important flags: Exercise 1.2: Pro tip: You can combine short flags: Move around the filesystem. Basic usage: Important paths: Exercise 1.3: Create new folders. Exercise 1.4: Creates a new empty file or updates timestamp of existing file. Exercise 1.5: Exercise 1.6: Exercise 1.7: ⚠️ Warning: There’s no trash/recycle bin. Deleted = gone forever! Exercise 1.8: Navigation in Exercise 1.9: Run Most commands support Ready to practice? Complete the hands-on challenge in the workshop repository: Challenge: Build a complete web project structure using only the commands you learned. The challenge includes: Clone the repository and give it a try: You’ve learned: These are the foundation of everything you’ll do in the terminal! In Part 2: Reading & Searching, we’ll learn how to:Navigation
The Anatomy of a Command
command -options argumentsls)-a, -l)ls -la /home/user
│ │ └─ argument (directory to list)
│ └─ options (long format + show hidden files)
└─ command (list directory contents)Navigation Commands
pwd - Print Working Directorypwd
# Output: /home/bakayupwd. What directory are you in?ls - List Directory Contentsls # List current directory
ls /home # List specific directory
ls Documents # List relative pathls -a # Show ALL files (including hidden ones starting with .)
ls -l # Long format (permissions, owner, size, date)
ls -h # Human-readable sizes (KB, MB, GB)
ls -la # Combine flags! Long format + hidden filesls in your home directoryls -a - do you see any new files? (Hint: look for .bashrc, .profile)ls -lh - what’s the size of your largest file?ls -lah is the same as ls -l -a -hcd - Change Directorycd Documents # Go to Documents (relative path)
cd /home/user # Go to absolute path
cd .. # Go up one level
cd ~ # Go to home directory
cd - # Go to previous directory/ - Root directory (top of filesystem)~ - Your home directory (shortcut for /home/username). - Current directory.. - Parent directorycd ~cd /lscd ~cd Documents (if it exists) then cd .. then cd -File Operations
mkdir - Make Directorymkdir myproject # Create one folder
mkdir -p path/to/deep/dir # Create nested folders (-p = parents)
mkdir dir1 dir2 dir3 # Create multiple folderscd ~
mkdir workshop-practice
cd workshop-practice
mkdir -p projects/web/frontend
ls -R # Recursively list all subdirectoriestouch - Create Empty Filetouch file.txt
touch index.html style.css script.js # Create multiple filescd ~/workshop-practice
touch README.md notes.txt
ls -lcp - Copy Filescp source destination # Copy file
cp -r folder/ backup/ # Copy directory (-r = recursive)
cp file.txt file_backup.txt # Copy and renamecd ~/workshop-practice
cp README.md README_backup.md
mkdir backup
cp -r projects/ backup/
ls backup/mv - Move/Rename Filesmv oldname newname # Rename
mv file.txt Documents/ # Move to directory
mv file.txt ~/backup/new.txt # Move and renamecd ~/workshop-practice
mv notes.txt important_notes.txt
mkdir archive
mv README_backup.md archive/
ls
ls archive/rm - Remove Filesrm file.txt # Delete file
rm -r folder/ # Delete directory (recursive)
rm -i file.txt # Interactive (asks confirmation)
rm -f file.txt # Force (no confirmation)cd ~/workshop-practice
touch test_delete.txt
ls
rm -i test_delete.txt # Type 'y' to confirm
ls # Verify it's goneGetting Help
man - Manual Pagesman ls # Open the manual for 'ls'
man cp # Open the manual for 'cp'man:SPACE to go down one pageb to go back one page/ to search (type your search term, press Enter)q to quitman ls and find what the -R flag does.--help Flag--help:ls --help
cp --helpHands-On Challenge
git clone https://github.com/bakayu/linux-tutorial.git
cd linux-tutorial/01-getting-started
cat README.mdSummary
pwd, ls, cdmkdir, touch, cp, mv, rmman, --helpNext Steps
cat, less, head, tail)grep)|)Quick Reference Card
# Navigation
pwd # Where am I?
ls -lah # What's here?
cd ~/Documents # Go somewhere
# File Operations
mkdir -p path/to/dir # Create folders
touch file.txt # Create file
cp -r src/ backup/ # Copy
mv old.txt new.txt # Rename/move
rm -i file.txt # Delete (careful!)
# Help
man command # Full manual
command --help # Quick help