Skip to main content

Linux Fundamentals

Duration: 2 hours | Foundation Track


Learning Objectives

  • Understand why Linux is important in business environments
  • Navigate the Linux file system and directory structure
  • Use essential Linux commands for file and system management
  • Configure users, groups, and file permissions
  • Manage Linux services and processes
  • Perform basic system administration tasks

Why Linux Matters in Business

Linux Success Stories

Web Infrastructure:

  • Google runs on Linux
  • Facebook uses Linux servers
  • Amazon Web Services primarily Linux
  • 96% of top 1 million web servers use Linux

Business Benefits:

  • Cost: No licensing fees (can save thousands per server)
  • Reliability: Many Linux servers run for years without reboot
  • Security: Less malware and fewer security vulnerabilities
  • Performance: Efficient use of hardware resources
  • Flexibility: Can be customized for specific business needs

Common Linux Distributions for Business

Ubuntu Server

  • Best for: Beginners, small to medium businesses
  • Why choose it: Easy to use, excellent documentation, free support community
  • Used by: Netflix, Spotify, Wikipedia

Red Hat Enterprise Linux (RHEL)

  • Best for: Large enterprises needing professional support
  • Why choose it: Professional support, certified applications, long-term stability
  • Used by: Banks, government agencies, Fortune 500 companies

CentOS (Community Enterprise OS)

  • Best for: Businesses wanting RHEL features without cost
  • Why choose it: RHEL compatibility, no licensing fees, stable
  • Used by: Web hosting companies, development environments

Linux File System Structure

Linux Directory Structure

Unlike Windows with drive letters (C:, D:, E:), Linux has one unified file system starting from root (/).

/ (root - top of everything)
├── home/ (user home directories)
│ ├── john/ (John's personal files)
│ └── mary/ (Mary's personal files)
├── etc/ (system configuration files)
├── var/ (variable data - logs, databases)
│ ├── log/ (system logs)
│ └── www/ (web server files)
├── usr/ (user programs and applications)
├── bin/ (essential system commands)
├── sbin/ (system administrator commands)
└── tmp/ (temporary files)

Key Directories Explained:

  • /home: Like "Users" folder in Windows - personal files
  • /etc: Like Windows Registry/Control Panel - configuration
  • /var/log: Like Windows Event Viewer - log files
  • /usr: Like "Program Files" in Windows - installed software

Understanding File Paths

Absolute Path Examples:
/home/john/documents/report.txt
/etc/apache2/apache2.conf
/var/log/syslog

Relative Path Examples:
documents/report.txt (from /home/john/)
../mary/pictures/ (go up one level, then to mary/pictures)
./scripts/backup.sh (current directory, then scripts folder)

Essential Linux Commands

# Where am I?
pwd # Print Working Directory
# Output: /home/john

# What's in this directory?
ls # List files and folders
ls -l # List with details (permissions, size, date)
ls -la # List including hidden files

# Move around
cd /home # Change to /home directory
cd ~ # Go to my home directory
cd .. # Go up one directory
cd - # Go back to previous directory

File and Directory Management

# Create directories
mkdir projects # Make directory called "projects"
mkdir -p work/documents # Make nested directories

# Create files
touch newfile.txt # Create empty file
echo "Hello" > greeting.txt # Create file with content

# Copy files and directories
cp file1.txt file2.txt # Copy file
cp -r folder1 folder2 # Copy directory and all contents

# Move/rename files
mv oldname.txt newname.txt # Rename file
mv file.txt /home/john/ # Move file to different location

# Delete files and directories
rm file.txt # Delete file
rm -r directory # Delete directory and contents

Viewing File Contents

# View file contents
cat file.txt # Show entire file
less file.txt # View file page by page (q to quit)
head file.txt # Show first 10 lines
tail file.txt # Show last 10 lines
tail -f /var/log/syslog # Follow log file in real-time

Searching and Finding

# Find files
find /home -name "*.txt" # Find all .txt files in /home
find /etc -name "apache*" # Find files starting with "apache"

# Search inside files
grep "error" /var/log/syslog # Find lines containing "error"
grep -i "failed" /var/log/syslog # Case-insensitive search
grep -r "password" /etc/ # Search recursively in directory

User and Permission Management

Linux Users and Groups

User Types:

  • Regular Users: Normal employees (john, mary, bob)
  • System Users: Used by applications (www-data for web server)
  • Root User: Administrator with unlimited power (like Local Admin in Windows)

Group Concept:

# Common business groups
marketing # Marketing department users
finance # Finance department users
developers # Software development team
admins # System administrators

File Permissions - Simple Explanation

Every file and directory has permissions for three categories:

  • Owner: The person who created the file
  • Group: People in the same group as the owner
  • Others: Everyone else

Permission Types:

  • r (read): Can view file contents or list directory
  • w (write): Can modify file or add/remove files in directory
  • x (execute): Can run program or enter directory

Understanding Permission Display

ls -l file.txt
# Output: -rw-r--r-- 1 john marketing 1024 Dec 1 10:30 file.txt
# │││ │││ │││
# ││└─┼┼┼─┼┼┼─ Others: read only
# │└──┼┼┼─┼┼┼─ Group: read only
# └───┼┼┼─┼┼┼─ Owner: read and write

Permission Examples:

# File permissions
-rw-r--r-- # Regular file: owner can read/write, others read only
-rwxr-xr-x # Executable: owner full access, others read/execute
-rw------- # Private file: only owner can read/write

# Directory permissions
drwxr-xr-x # Directory: owner full access, others read/list contents
drwx------ # Private directory: only owner can access
drwxrwxr-x # Shared directory: owner and group can modify

Managing Users and Permissions

# User management (requires sudo/root)
sudo useradd -m john # Add user with home directory
sudo passwd john # Set password for john
sudo usermod -G marketing john # Add john to marketing group
sudo userdel john # Delete user account

# Change file permissions
chmod 644 file.txt # Owner read/write, others read only
chmod 755 script.sh # Owner full access, others read/execute
chmod +x program # Make file executable

# Change file ownership
chown john:marketing file.txt # Change owner to john, group to marketing

System Administration Basics

Process Management

# View running processes
ps aux # Show all processes
ps aux | grep apache # Find Apache processes
top # Live view of processes (like Task Manager)
htop # Enhanced process viewer (if installed)

# Control processes
kill 1234 # Stop process with ID 1234
killall apache2 # Stop all apache2 processes
jobs # Show background jobs
bg # Send job to background
fg # Bring job to foreground

System Information

# System details
uname -a # System information
whoami # Current user
id # User ID and groups
uptime # System uptime and load
free -h # Memory usage
df -h # Disk space usage
du -sh /home/* # Directory sizes

Network Information

# Network configuration
ip addr show # Network interfaces (modern command)
ifconfig # Network interfaces (older command)
ping google.com # Test connectivity
netstat -tuln # Show listening ports
ss -tuln # Modern alternative to netstat

Linux Services Management

Systemd - Modern Service Manager

Modern Linux uses systemd to manage services (background programs).

# Check service status
systemctl status apache2 # Check web server status
systemctl status ssh # Check SSH service status

# Control services
sudo systemctl start apache2 # Start web server
sudo systemctl stop apache2 # Stop web server
sudo systemctl restart apache2 # Restart web server
sudo systemctl reload apache2 # Reload configuration

# Enable/disable services at boot
sudo systemctl enable apache2 # Start automatically at boot
sudo systemctl disable apache2 # Don't start automatically

# View all services
systemctl list-units --type=service --state=running

Common Business Services

# Web Services
apache2 # Apache web server
nginx # Nginx web server
mysql # MySQL database server
postgresql # PostgreSQL database server

# Network Services
ssh # Secure remote access
dhcpd # DHCP server
bind9 # DNS server
ntp # Network time synchronization

# System Services
cron # Scheduled tasks
rsyslog # System logging
ufw # Uncomplicated firewall
fail2ban # Intrusion prevention

File System Management

Disk and Storage

# Check disk usage
df -h # File system usage
du -h /var/log # Directory usage
lsblk # List block devices

# Mount and unmount drives
sudo mount /dev/sdb1 /mnt/backup # Mount external drive
sudo umount /mnt/backup # Unmount drive

# File system check
sudo fsck /dev/sdb1 # Check and repair file system

Log File Management

# System logs location
/var/log/syslog # General system messages
/var/log/auth.log # Authentication attempts
/var/log/apache2/ # Web server logs
/var/log/mysql/ # Database logs

# Reading log files
sudo tail -f /var/log/syslog # Follow system log
sudo grep "error" /var/log/syslog # Find errors
sudo journalctl -f # Follow systemd logs
sudo journalctl -u apache2 # Show Apache logs

Business Use Cases and Examples

Web Server Administration

# Install and configure Apache
sudo apt update
sudo apt install apache2

# Start and enable Apache
sudo systemctl start apache2
sudo systemctl enable apache2

# Check if working
curl http://localhost
sudo systemctl status apache2

# Configure virtual hosts for multiple websites
sudo nano /etc/apache2/sites-available/company.conf
sudo a2ensite company.conf
sudo systemctl reload apache2

Database Server Setup

# Install MySQL
sudo apt install mysql-server

# Secure installation
sudo mysql_secure_installation

# Create business database
mysql -u root -p
CREATE DATABASE company_crm;
CREATE USER 'crmuser'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON company_crm.* TO 'crmuser'@'localhost';

Backup Automation

# Create backup script
#!/bin/bash
# Daily backup script for business data

BACKUP_DIR="/backup"
DATE=$(date +%Y%m%d)

# Create backup directory
mkdir -p $BACKUP_DIR/$DATE

# Backup important directories
tar -czf $BACKUP_DIR/$DATE/home_backup.tar.gz /home/
tar -czf $BACKUP_DIR/$DATE/etc_backup.tar.gz /etc/

# Backup databases
mysqldump -u root -p company_crm > $BACKUP_DIR/$DATE/database_backup.sql

# Log backup completion
echo "$(date): Backup completed successfully" >> /var/log/backup.log

Hands-on Activity: Linux Administration Basics

Time: 40 minutes

Objective

Practice essential Linux administration tasks

Prerequisites

Ubuntu Server virtual machine from Module 1

Part A: File System Exploration (10 minutes)

  1. Navigate the file system:

    pwd                    # Where am I?
    ls / # See root directory structure
    ls -la /home # Look at home directories
    cd /var/log # Go to log directory
    ls -la # See log files
  2. View system information:

    uname -a              # System information
    whoami # Current user
    id # User ID and groups
    cat /etc/os-release # Operating system version
    df -h # Disk usage
    free -h # Memory usage

Part B: User and Group Management (15 minutes)

  1. Create users and groups:

    sudo groupadd marketing        # Create marketing group
    sudo groupadd finance # Create finance group

    sudo useradd -m -s /bin/bash john # Create john with home directory
    sudo useradd -m -s /bin/bash mary # Create mary with home directory

    sudo passwd john # Set password for john
    sudo passwd mary # Set password for mary
  2. Assign users to groups:

    sudo usermod -G marketing john  # Add john to marketing
    sudo usermod -G finance mary # Add mary to finance

    groups john # Check john's groups
    groups mary # Check mary's groups

Part C: File Permissions Practice (10 minutes)

  1. Create shared directories:

    sudo mkdir /shared
    sudo mkdir /shared/marketing
    sudo mkdir /shared/finance
  2. Set appropriate permissions:

    # Marketing folder - marketing group can read/write
    sudo chown root:marketing /shared/marketing
    sudo chmod 770 /shared/marketing

    # Finance folder - finance group can read/write
    sudo chown root:finance /shared/finance
    sudo chmod 770 /shared/finance
  3. Test permissions:

    sudo -u john touch /shared/marketing/john_file.txt    # Should work
    sudo -u john touch /shared/finance/john_file.txt # Should fail

    ls -la /shared/marketing/ # Verify file creation

Part D: Service Management (5 minutes)

  1. Check system services:

    systemctl status ssh          # SSH service status
    systemctl list-units --type=service --state=running # Running services
  2. View system logs:

    sudo journalctl -n 20             # Last 20 log entries
    sudo tail -f /var/log/syslog # Follow system log (Ctrl+C to stop)

Reflection Questions

  • How is Linux file permission system different from Windows?
  • What are the advantages of command-line management?
  • When would you choose Linux over Windows for a business server?
  • How do groups help with permission management in large organizations?

Knowledge Check

8 questions, 12 minutes

  1. You need to see what files are in the current directory. Which command do you use?

    • a) pwd
    • b) ls
    • c) cd
    • d) cat
  2. A user can read a file but cannot modify it. What permission do they need?

    • a) Read permission
    • b) Write permission
    • c) Execute permission
    • d) Delete permission
  3. You want to view the last few lines of a log file that's constantly growing. Which command is best?

    • a) cat logfile.txt
    • b) head logfile.txt
    • c) tail -f logfile.txt
    • d) ls logfile.txt
  4. How do you change to your home directory from anywhere in the system?

    • a) cd /home
    • b) cd ~
    • c) cd ..
    • d) pwd
  5. A web service has stopped working. How do you restart it?

    • a) systemctl restart service-name
    • b) ls service-name
    • c) cat service-name
    • d) pwd service-name
  6. What does the root user represent in Linux?

    • a) A regular employee user
    • b) A user with no permissions
    • c) The administrator with full system access
    • d) A locked account
  7. You need to create a new directory called 'reports'. Which command do you use?

    • a) touch reports
    • b) mkdir reports
    • c) ls reports
    • d) rm reports
  8. A file shows permissions as 'rw-r--r--'. What does this mean?

    • a) Everyone can read and write
    • b) Owner can read/write, others can only read
    • c) No one can access the file
    • d) Only root can access the file

Answers

  1. b) ls
  2. b) Write permission
  3. c) tail -f logfile.txt
  4. b) cd ~
  5. a) systemctl restart service-name
  6. c) The administrator with full system access
  7. b) mkdir reports
  8. b) Owner can read/write, others can only read

Key Takeaways

What You Learned

✅ Linux provides cost-effective, reliable server solutions for businesses
✅ The command line is powerful for system administration tasks
✅ File permissions provide granular security control
✅ Systemd manages services efficiently in modern Linux
✅ Linux skills are essential for web servers and cloud infrastructure

Business Applications

  • Web Hosting: Most web servers run on Linux for cost and performance
  • Development Environments: Linux provides excellent development tools
  • Cloud Infrastructure: Major cloud platforms are primarily Linux-based
  • Database Servers: MySQL and PostgreSQL perform excellently on Linux
  • Network Services: DNS, DHCP, and other network services run well on Linux

Practical Skills

  • Navigate Linux file system confidently
  • Manage users, groups, and file permissions
  • Control system services and processes
  • Monitor system performance and logs
  • Perform basic troubleshooting and maintenance
  • Implement security best practices

Common Business Tasks You Can Now Handle

  • Set up web servers for company websites
  • Create user accounts for new employees
  • Configure file sharing with proper permissions
  • Monitor system logs for security issues
  • Manage database servers and backups
  • Troubleshoot connectivity and service problems

Next Steps

In the next section, we'll build on these Linux fundamentals to explore command line mastery, including automation, scripting, and advanced system administration techniques that will make you more efficient and productive in managing Linux systems.