DEV Community

Cover image for Keep calm and learn Linux
Osagie Anolu
Osagie Anolu

Posted on • Edited on

4

Keep calm and learn Linux

Comprehensive Guide to Essential Linux Commands

Image description

Essential Linux Commands: A Practical Guide

Linux's power lies in its command-line interface (CLI), making it a favorite among developers and system administrators. This guide covers the fundamental commands you'll need for effective system management.

Basic Navigation

pwd     # Print working directory
cd      # Change directory
cd ..   # Move up one level
cd ~    # Go to home directory
Enter fullscreen mode Exit fullscreen mode

File and Directory Operations

Listing and Creating

ls      # List files and directories
ls -lah # Detailed list (long format, all files, human-readable sizes)
touch   # Create empty file
mkdir   # Create directory
mkdir -p # Create nested directories
Enter fullscreen mode Exit fullscreen mode

Manipulating Files

cp file1 file2     # Copy files
cp -r dir1 dir2    # Copy directories recursively
mv old new         # Move or rename
rm file           # Delete file
rm -r dir         # Delete directory recursively
Enter fullscreen mode Exit fullscreen mode

File Permissions

chmod 755 file    # Set permissions (rwxr-xr-x)
chmod u+x file    # Add execute permission for user
chown user:group file  # Change ownership
Enter fullscreen mode Exit fullscreen mode

Text File Operations

Viewing Content

cat file          # Display entire file
less file         # Page through file
head -n 10 file   # Show first 10 lines
tail -n 10 file   # Show last 10 lines
Enter fullscreen mode Exit fullscreen mode

Text Editing

  • nano: Beginner-friendly editor
  • vim: Advanced editor with powerful features
  • grep "term" file: Search within files
  • grep -i "term" file: Case-insensitive search

Process Management

ps aux           # List all processes
top             # Real-time process monitor
kill PID        # Terminate process by ID
killall name    # Terminate process by name
Enter fullscreen mode Exit fullscreen mode

Network Operations

ip addr         # Show network interfaces
ping host       # Test connectivity
netstat -tuln   # Show network connections
ss             # Modern alternative to netstat
Enter fullscreen mode Exit fullscreen mode

System Information

df -h           # Disk space usage
du -h           # Directory space usage
uname -a        # System information
uptime         # System uptime and load
Enter fullscreen mode Exit fullscreen mode

Pro Tips

  1. Use Tab completion to avoid typing full paths
  2. Access command history with up/down arrows
  3. Chain commands with && (AND) or || (OR)
  4. Use man command for detailed documentation
  5. Combine commands with pipes (|) for powerful operations

Remember: Linux commands are case-sensitive, and most can be modified with flags (options) that start with - or --. When in doubt, use --help or man to learn more about any command.

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (1)

Collapse
 
joseph_ibeh profile image
Joseph Ibeh

Nice. Weldon brother

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay