Back to DevOps

Linux Command Line

Master Linux command line fundamentals. Learn file management, permissions, and system administration.

Video Tutorial

Introduction to Linux

Linux is a free and open-source operating system kernel. It's the foundation of many operating systems (distributions) like Ubuntu, CentOS, and Debian.

Examples:

uname -a
cat /etc/os-release

Display system information and Linux distribution

File System Navigation

Understanding the Linux file system is crucial. Everything in Linux is a file, and the file system starts at the root directory (/).

Examples:

pwd
ls
ls -la
cd /home/user
cd ..
cd ~

Navigate the file system

mkdir my-folder
mkdir -p parent/child
rmdir my-folder
rm -rf my-folder

Create and remove directories

File Operations

Linux provides powerful commands for creating, copying, moving, and deleting files.

Examples:

touch myfile.txt
echo "Hello" > myfile.txt
echo "World" >> myfile.txt

Create and write to files

cat myfile.txt
less myfile.txt
head myfile.txt
tail -f myfile.txt

Read file contents

cp source.txt dest.txt
cp -r folder1 folder2
mv old.txt new.txt
rm myfile.txt

Copy, move, and delete files

File Permissions

Linux uses a permission system to control access to files and directories.

Examples:

ls -l myfile.txt
chmod 755 myfile.txt
chmod u+x myfile.txt
chown user:group myfile.txt

View and modify file permissions

Process Management

Processes are running programs. Linux provides tools to view, manage, and control processes.

Examples:

ps aux
ps aux | grep nginx
top
htop

View running processes

kill 1234
kill -9 1234
killall nginx
command &

Manage processes

Package Management

Package managers help install, update, and remove software.

Examples:

sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo apt remove nginx

APT package manager (Ubuntu/Debian)

sudo yum update
sudo yum install nginx
sudo dnf install nginx

YUM/DNF package manager (CentOS/RHEL)

Networking Commands

Linux provides powerful networking tools for troubleshooting and managing network connections.

Examples:

ip addr show
ping google.com
ping -c 4 google.com

View network configuration and test connectivity

nslookup google.com
dig google.com
netstat -tuln
ss -tuln

DNS queries and port monitoring

wget https://example.com/file.zip
curl -O https://example.com/file.zip
scp file.txt user@server:/path/

Download and transfer files

Text Processing

Linux excels at text processing with powerful command-line tools.

Examples:

grep "error" log.txt
grep -r "TODO" ./src/
find /home -name "*.txt"
sed 's/old/new/g' file.txt

Search and process text

Quick Reference

Essential Commands

  • ls - List files
  • cd - Change directory
  • grep - Search text
  • chmod - Change permissions

Best Practices

  • ✓ Use sudo carefully
  • ✓ Regular backups
  • ✓ Keep system updated
  • ✓ Use strong passwords