Linux Basics

Linux is a powerful open-source operating system kernel used in servers, desktops, and embedded systems.

What is Linux?

Linux is a Unix-like operating system kernel created by Linus Torvalds in 1991. It's the core of various Linux distributions like Ubuntu, CentOS, Fedora, and Debian.

Basic Commands

File Navigation

# Print working directory
pwd

# List files
ls -la

# Change directory
cd /path/to/directory

# Create directory
mkdir my-folder

# Remove file
rm filename

# Remove directory
rmdir folder

File Operations

# Copy file
cp source.txt destination.txt

# Move/rename file
mv old-name.txt new-name.txt

# Create empty file
touch newfile.txt

# View file content
cat filename.txt

# View file with pagination
less filename.txt

File Permissions

Linux uses a three-digit permission system:

# Change permissions
chmod 755 script.sh

# Change owner
chown user:group filename

Permission breakdown:

  • 7 (owner): read, write, execute
  • 5 (group): read, execute
  • 5 (others): read, execute

Users and Groups

# Create new user
sudo useradd username

# Add user to group
sudo usermod -aG groupname username

# Switch user
su - username

# View current user
whoami

Package Management

Ubuntu/Debian

# Update package list
sudo apt update

# Install package
sudo apt install package-name

# Remove package
sudo apt remove package-name

CentOS/RHEL

# Install package
sudo yum install package-name

# Update system
sudo yum update

Process Management

# List running processes
ps aux

# View processes in real-time
top

# Kill process
kill -9 process-id

# Background/foreground jobs
jobs
fg
bg

Next Steps

  • Learn about shell scripting
  • Understand file system hierarchy
  • Master networking commands
  • Explore system administration