Filesystem and Basic Commands

Introduction

Linux organizes everything as files under a single tree starting at /. Paths are case-sensitive and use forward slashes. This chapter maps important directories, then practices the commands you use every day: ls, cd, cp, mv, rm, and simple search.

Prerequisites

Directory Layout (FHS Overview)

PathTypical contents
/Root of the whole tree
/home/usernameYour personal files (~)
/etcSystem and app configuration
/varLogs, databases, variable data
/tmpTemporary files (may clear on reboot)
/usrInstalled programs and libraries
/optOptional third-party bundles
/rootHome directory for root user

There is no C: drive—one filesystem tree, possibly spanning multiple disks mounted at folders like /data.

Paths: Absolute, Relative, and Special Names

FormMeaning
/etc/ssh/sshd_configAbsolute from root
docs/readme.mdRelative to current directory
~ or $HOMEYour home directory
.Current directory
..Parent directory
bash
# Print current directory
pwd
 
# Go to home
cd ~
cd
 
# Go to parent
cd ..
 
# Go to absolute path
cd /var/log

Warning

README.md and readme.md are different files on Linux. Watch capitalization in Git and deploy scripts.

List and Navigate

bash
# Long listing with hidden dotfiles
ls -la
 
# List /etc (system configs — look, rarely edit without reason)
ls /etc

Useful ls options:

OptionEffect
-lLong format (permissions, size, date)
-aInclude hidden names starting with .
-hHuman-readable sizes with -l

Create, Copy, Move, Delete

Warning

rm -rf deletes recursively without confirmation. Double-check paths. A typo like rm -rf / tmp/foo can destroy a system—there is no Recycle Bin.

View File Contents

bash
# Whole small file
cat /etc/os-release
 
# Page through large file
less /var/log/syslog
 
# First/last lines
head -n 20 /var/log/syslog
tail -n 20 /var/log/syslog
 
# Follow log live (Ctrl+C to stop)
tail -f /var/log/syslog

Find Files

bash
# Find by name under home (max depth feel with time on big trees)
find ~ -name "*.md" 2>/dev/null
 
# Find directories named logs
find /var -type d -name "log*" 2>/dev/null | head

locate is faster but uses a database updated by updatedb—optional on servers.

bash
# Create symlink
ln -s /var/log ~/logs
 
# List shows arrow to target
ls -l ~/logs

Symlinks are pointers—similar to Windows shortcuts. Hard links are advanced and rare in daily dev work.

Compare with Windows Habits

WindowsLinux
dirls
copycp
movemv
delrm
type filecat file
Explorer path C:\Users\.../home/user/...

Mini Example: Project Folder Layout

Mirror a small Java-style tree by hand:

bash
# Build tree under home
mkdir -p ~/hello-linux/src/main/java
mkdir -p ~/hello-linux/src/test/java
 
# Create a marker file
touch ~/hello-linux/src/main/java/.gitkeep
 
# Show tree (install tree package optional: sudo apt install tree)
find ~/hello-linux

Later, Maven or Gradle generate similar layouts automatically.

FAQ

How do I open the current folder in a GUI file manager?

On desktop Ubuntu: xdg-open . Servers often have no GUI—use SFTP/VS Code Remote SSH instead.

Tab completion?

Press Tab to complete paths and commands; Tab Tab shows choices.

Deleted file recovery?

Assume gone unless you use snapshots/backups. Be careful with rm.

What comes next?

Users, groups, and permissions.