🐧 Linux Basics

Get started with Linux — the most popular OS for servers. Learn essential commands and file permissions.

📟 Essential Commands
Q1What is Linux?Beginner

Linux is a free, open-source operating system kernel created by Linus Torvalds in 1991. It forms the basis of many operating systems (called "distributions" or "distros") such as Ubuntu, Debian, CentOS, and Fedora.

Linux dominates the server world — over 96% of the world's top 1 million web servers run Linux. It's known for stability, security, and flexibility.

💡 When you rent a VPS or cloud server, it almost certainly runs Linux. Learning basic Linux commands is essential for anyone working with servers or hosting.
Q2What does the ls command do?Beginner

The ls command lists files and directories in the current directory (or a specified path).

ls              # list files
ls -l           # long format (permissions, size, date)
ls -la          # include hidden files (starting with .)
ls /var/www     # list files in a specific path
💡 ls -la is one of the most commonly used commands — it shows all files including hidden ones, with full details.
Q3What are the most important Linux commands for beginners?Beginner

Here are the essential commands every beginner should know:

pwd             # Print Working Directory (where am I?)
ls              # List files
cd /path        # Change Directory
mkdir mydir     # Create a new directory
cp file1 file2  # Copy a file
mv file1 file2  # Move or rename a file
rm file         # Delete a file (careful — no recycle bin!)
cat file.txt    # Display file contents
nano file.txt   # Edit a file (simple text editor)
sudo command    # Run a command as administrator
⚠️ rm permanently deletes files with no undo. Always double-check before using it, especially with -rf flag (recursive force).
🔑 File Permissions
Q4How do I change file permissions in Linux?Intermediate

Use the chmod command to change file permissions. Linux permissions are split into three groups: Owner, Group, and Others. Each can have Read (r=4), Write (w=2), and Execute (x=1) permissions.

chmod 755 myfile    # rwxr-xr-x (owner: full, group/others: read+execute)
chmod 644 myfile    # rw-r--r-- (owner: read+write, others: read only)
chmod +x script.sh  # Add execute permission
chmod -w file.txt   # Remove write permission

The number 755 means: Owner=7 (4+2+1=rwx), Group=5 (4+1=r-x), Others=5 (r-x).

💡 Web server files are typically set to 644 (files) and 755 (directories). Never set files to 777 (everyone can write) on a production server — it's a security risk.
Q5What is sudo and why is it needed?Beginner

sudo stands for "Superuser Do". It allows a permitted user to run a command as the administrator (root) without fully logging in as root.

sudo apt update         # Update package list (needs admin rights)
sudo apt install nginx  # Install software
sudo systemctl restart apache2  # Restart a service
⚠️ Running as root all the time is dangerous — one wrong command can break the whole system. sudo lets you have admin power only when you need it.