⌨️ AlmaLinux Command Line Basics: Essential Commands for New Users
Ready to unlock the true power of Linux? 🚀 The command line might seem scary at first, but it’s actually your superpower! In this beginner-friendly guide, we’ll learn essential AlmaLinux commands that make you incredibly efficient. From basic navigation to powerful file operations - let’s master the terminal together! ⚡
🤔 Why Learn the Command Line?
The terminal is where Linux shines brightest! 🌟 Here’s why it’s worth learning:
- ⚡ Lightning Speed: Tasks in seconds vs minutes with GUI
- 🔧 Ultimate Power: Access to ALL system features
- 🤖 Automation: Script repetitive tasks easily
- 💼 Career Essential: Required for $80k+ Linux jobs
- 🌍 Universal: Same commands work on all Linux systems
- 🎯 Precision: Exact control over everything
- 📚 Problem Solving: Fix issues the GUI can’t
- 🚀 Feel Like a Hacker: Because you basically are!
Every Linux professional uses the command line daily! 🏆
🎯 What You Need
Let’s prepare for command line mastery! ✅
- ✅ AlmaLinux system (desktop or server)
- ✅ Terminal access (Ctrl+Alt+T opens it)
- ✅ Basic typing skills
- ✅ 30 minutes of practice time
- ✅ Willingness to experiment
- ✅ No fear of making mistakes!
- ✅ Optional: second screen for following guide
- ✅ Curiosity to explore! 🎉
Let’s become command line ninjas! 🥷
📝 Step 1: Opening and Understanding the Terminal
First, let’s get comfortable with the terminal! 🎯
Opening Terminal:
# Method 1: Keyboard shortcut
Ctrl + Alt + T
# Method 2: Applications menu
Activities → Search "Terminal"
# Method 3: Right-click desktop
Right-click → "Open in Terminal"
# Method 4: From file manager
Navigate to folder → F4 (or right-click → Open in Terminal)
Understanding the Prompt:
[username@hostname current-directory]$
# Example:
[john@almalinux ~]$
# What each part means:
john # Your username
almalinux # Computer name
~ # Current directory (~ means home)
$ # Regular user (# means root user)
Terminal Basics:
# Clear the screen
clear
# Or use: Ctrl + L
# Exit terminal
exit
# Or use: Ctrl + D
# Stop running command
Ctrl + C
# Get help for any command
command --help
man command
Perfect! 🎉 You’re in the terminal!
🔧 Step 2: Navigation Commands - Moving Around
Let’s learn to navigate like a pro! 🗺️
See Where You Are:
# Print working directory
pwd
# Example output:
/home/john
List Files and Folders:
# Basic listing
ls
# Detailed listing (long format)
ls -l
# Show hidden files too
ls -la
# Human-readable file sizes
ls -lh
# Sort by time (newest first)
ls -lt
# Example output:
drwxr-xr-x 2 john john 4.0K Sep 16 10:30 Documents
-rw-r--r-- 1 john john 1.2M Sep 16 09:15 photo.jpg
Change Directories:
# Go to home directory
cd
cd ~
# Go to specific directory
cd /home/john/Documents
# Go up one level
cd ..
# Go up two levels
cd ../..
# Go to previous directory
cd -
# Go to root directory
cd /
Navigation Shortcuts:
# Tab completion (your best friend!)
cd Doc[TAB] # Completes to Documents
ls photo[TAB] # Completes to photo.jpg
# Use history
history # See all previous commands
!! # Run last command again
!ls # Run last command starting with 'ls'
# Arrow keys
↑ ↓ # Navigate command history
← → # Edit current command
Amazing! 🌟 You can navigate anywhere now!
🌟 Step 3: File and Directory Operations
Master file management from the terminal! 📁
Creating Files and Directories:
# Create empty file
touch newfile.txt
touch file1.txt file2.txt file3.txt
# Create directory
mkdir newfolder
mkdir Documents/projects
# Create multiple directories
mkdir folder1 folder2 folder3
# Create directory with parents
mkdir -p projects/web/html
Copying Files and Folders:
# Copy file
cp source.txt destination.txt
# Copy file to directory
cp file.txt Documents/
# Copy directory (recursive)
cp -r sourcefolder/ destinationfolder/
# Copy with backup (if destination exists)
cp --backup file.txt Documents/
# Preserve permissions and timestamps
cp -p file.txt backup/
Moving and Renaming:
# Move file
mv oldlocation.txt newlocation.txt
# Rename file (same as move)
mv oldname.txt newname.txt
# Move multiple files to directory
mv file1.txt file2.txt file3.txt Documents/
# Move directory
mv oldfolder/ newfolder/
Deleting Files and Folders:
# Delete file
rm unwanted.txt
# Delete multiple files
rm file1.txt file2.txt
# Delete with confirmation
rm -i important.txt
# Delete directory (empty)
rmdir emptyfolder/
# Delete directory with contents (be careful!)
rm -r foldername/
# Force delete (no confirmation)
rm -rf foldername/
# Safe delete (move to trash)
# Install trash-cli first: sudo dnf install trash-cli
trash unwanted.txt
Excellent! ⚡ You’re a file management expert!
✅ Step 4: Viewing and Editing Files
Learn to work with file contents! 📄
Viewing File Contents:
# Display entire file
cat filename.txt
# Display file with line numbers
cat -n filename.txt
# View file page by page
less filename.txt
more filename.txt
# (Use Space for next page, q to quit)
# Display first 10 lines
head filename.txt
# Display first 20 lines
head -n 20 filename.txt
# Display last 10 lines
tail filename.txt
# Follow file changes (great for logs)
tail -f /var/log/messages
Searching in Files:
# Search for text in file
grep "search term" filename.txt
# Case-insensitive search
grep -i "Search Term" filename.txt
# Search in multiple files
grep "error" *.log
# Search recursively in directories
grep -r "function" /home/john/code/
# Count matching lines
grep -c "error" logfile.txt
# Show line numbers
grep -n "import" script.py
Simple Text Editing:
# Edit with nano (beginner-friendly)
nano filename.txt
# Ctrl+O to save, Ctrl+X to exit
# Edit with vim (powerful but complex)
vim filename.txt
# Press 'i' to insert, Esc then ':wq' to save and quit
# Create file with content
echo "Hello World" > newfile.txt
# Append to file
echo "Another line" >> newfile.txt
Perfect! 🏆 You can handle any file now!
🔧 Step 5: System Information Commands
Monitor your system like a pro! 📊
System Status:
# Show system information
uname -a
hostnamectl
# Check system uptime
uptime
# Display current date and time
date
# Show calendar
cal
# Check who's logged in
who
w
# Show current user
whoami
id
System Resources:
# Show memory usage
free -h
# Display disk usage
df -h
# Show directory sizes
du -h
du -sh *
# Display running processes
ps aux
top
htop
# Check CPU information
lscpu
cat /proc/cpuinfo
# Check system load
iostat
vmstat
Network Information:
# Show network interfaces
ip addr show
ip a
# Check connectivity
ping google.com
ping -c 4 8.8.8.8
# Show network connections
netstat -tuln
ss -tuln
# Download speed test
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python
Amazing! 🌟 You’re a system monitoring expert!
🎮 Quick Examples
Practice with real-world scenarios! 🎯
Example 1: Organizing Downloads Folder
# Navigate to Downloads
cd ~/Downloads
# See what's there
ls -la
# Create organized folders
mkdir {Images,Documents,Videos,Software,Archives}
# Move files by type
mv *.jpg *.png *.gif Images/
mv *.pdf *.doc *.txt Documents/
mv *.mp4 *.avi *.mkv Videos/
mv *.rpm *.deb *.AppImage Software/
mv *.zip *.tar.gz *.rar Archives/
# Check results
ls -la */
# Remove empty folders if any
find . -type d -empty -delete
Example 2: Basic System Maintenance
# Check system health
echo "=== System Information ==="
hostnamectl
echo ""
echo "=== Memory Usage ==="
free -h
echo ""
echo "=== Disk Usage ==="
df -h
echo ""
echo "=== Top 5 Processes by CPU ==="
ps aux --sort=-%cpu | head -6
echo ""
echo "=== System Load ==="
uptime
echo ""
echo "=== Recent Logins ==="
last -5
Example 3: Finding Large Files
# Find files larger than 100MB
find /home -type f -size +100M 2>/dev/null
# Find largest files in current directory
ls -lhS
# Find largest directories
du -sh */ | sort -hr
# Clean package cache
sudo dnf clean all
# Find and remove empty directories
find /home -type d -empty 2>/dev/null
Example 4: Working with Text Files
# Create a shopping list
cat > shopping_list.txt << EOF
Milk
Bread
Eggs
Apples
Cheese
EOF
# View the list
cat shopping_list.txt
# Add items
echo "Bananas" >> shopping_list.txt
echo "Coffee" >> shopping_list.txt
# Count items
wc -l shopping_list.txt
# Sort the list
sort shopping_list.txt > sorted_list.txt
# Search for specific items
grep -i "milk" shopping_list.txt
# Create backup
cp shopping_list.txt shopping_list_backup.txt
🚨 Fix Common Problems
Terminal troubleshooting made easy! 🔧
Problem 1: “Command not found”
Solution:
# Check if command exists
which command_name
whereis command_name
# Update PATH environment
echo $PATH
# Install missing software
sudo dnf search package_name
sudo dnf install package_name
# Check if it's a typo
ls /usr/bin/ | grep similar_name
Problem 2: “Permission denied”
Solution:
# Check file permissions
ls -l filename
# Change file permissions
chmod 755 filename
chmod +x script.sh
# Change ownership
sudo chown user:group filename
# Run with sudo for system files
sudo command
Problem 3: Terminal Frozen
Solution:
# Stop current command
Ctrl + C
# If completely frozen
Ctrl + Z (suspends process)
jobs (list suspended jobs)
kill %1 (kill job #1)
# Force quit terminal
Alt + F4
# Or reset terminal
reset
Problem 4: Can’t Find Files
Solution:
# Search for files by name
find / -name "filename" 2>/dev/null
locate filename
# Update locate database
sudo updatedb
# Search in specific directory
find /home -name "*partial_name*"
# Search by file type
find . -name "*.txt"
📋 Essential Commands Summary
Category | Command | Purpose |
---|---|---|
Navigation | pwd | Show current directory |
ls | List files | |
cd | Change directory | |
Files | cp | Copy files |
mv | Move/rename files | |
rm | Delete files | |
mkdir | Create directory | |
Viewing | cat | Display file content |
less | View file page by page | |
head/tail | Show beginning/end | |
Search | grep | Search in files |
find | Find files | |
locate | Quick file search | |
System | top | Show processes |
free | Show memory | |
df | Show disk space |
💡 Tips for Success
Master the command line faster! 🌟
- ⌨️ Use Tab Completion: Your fingers will thank you
- 📚 Practice Daily: 10 minutes a day builds muscle memory
- 🛡️ Test in Safe Folders: Practice in ~/practice/ first
- 📖 Read Man Pages:
man command
explains everything - 🔍 Use History: Arrow keys save typing
- 💾 Backup Important:
cp
before experimenting - 🤝 Ask for Help: Linux community is friendly
- 📝 Keep Notes: Document useful commands
- 🎯 Start Simple: Master basics before advanced
- 🔄 Combine Commands: Pipes
|
are powerful
🏆 What You Learned
Congratulations! You’re now command line capable! 🎉
- ✅ Opened and navigated the terminal
- ✅ Mastered file and directory operations
- ✅ Learned essential navigation commands
- ✅ Discovered system monitoring tools
- ✅ Practiced with real-world examples
- ✅ Gained troubleshooting skills
- ✅ Built foundation for advanced topics
- ✅ Unlocked Linux’s true power
🎯 Why This Matters
Your command line skills open incredible doors! 🚀
- 💼 Career Boost: Essential for system administration
- ⚡ Productivity: 10x faster than GUI for many tasks
- 🔧 Problem Solving: Fix issues others can’t
- 🤖 Automation: Script anything you do repeatedly
- 🌍 Universal Skills: Work on any Linux system
- 🎓 Foundation: Base for advanced Linux topics
- 💪 Confidence: Feel truly in control
- 🧠 Logical Thinking: Improves programming skills
You’ve taken the most important step in your Linux journey! 🏆
Keep practicing! 🙌