Learn Linux step by step — from setup to commands, permissions, automation, and basic web hosting.
This repository is a practical Linux learning guide for beginners. It follows a clear sequence: understand Linux, set up a learning environment, learn daily commands, manage users and permissions, automate with cron, and deploy with Nginx.
- Students starting Linux for development or DevOps
- Windows/macOS users who want a Linux practice setup
- Beginners preparing for cloud, backend, or sysadmin learning
Follow this exact sequence:
- What is Linux?
- History of Linux
- Getting an online Linux Server
- Installing Linux through VirtualBox on Windows
- Installing Linux on Windows using WSL
- Installing Linux through VirtualBox on Mac
- Basic Linux Commands
- Creating Users
- Package Management
- Groups & Permissions
- Processes & Services
- Environment Variables, PATH and Bashrc
- Archives and Compression
- Cronjobs
- Understanding Linux Filesystem
- Understanding Nginx
- Using FileZilla to Transfer Files
- Conclusion
Linux is a free and open-source operating system kernel that manages a computer's hardware and allows software to interact with it.
The kernel is the core component of an operating system. It manages essential resources such as the CPU, memory, storage, and running processes.
User → Applications / Shell → Linux Kernel → Hardware
| Component | Purpose |
|---|---|
| Hardware | Physical components such as CPU, RAM, and storage. |
| Kernel | Manages hardware resources and communication with software. |
| Shell | Allows users to interact with the operating system through commands. |
| Applications | Programs that perform tasks for users. |
| Resource | Responsibility |
|---|---|
| CPU | Schedules processes and allocates processing time. |
| Memory | Manages RAM allocation between programs. |
| Storage | Supports filesystem operations and access to storage devices. |
| Processes | Creates, schedules, and terminates running programs. |
| Permissions | Enforces access controls for users and processes. |
Technically, Linux refers to the kernel, not the complete operating system.
A Linux distribution (distro) combines the Linux kernel with system utilities, a package manager, and other software to provide a usable operating system.
Popular Linux distributions include Ubuntu, Debian, Fedora, Arch Linux, and Kali Linux.
Example: Ubuntu is a complete operating system built around the Linux kernel.
Run these commands in your Linux terminal:
uname -s # Display the kernel name
uname -r # Display the kernel release
uname -a # Display detailed system information
cat /etc/os-release # Identify your Linux distributionLinux is widely used in servers, cloud computing, cybersecurity, DevOps, software development, and Android devices. Learning Linux helps you understand how modern computing infrastructure works and how to manage systems through the command line.
Linux was inspired by Unix, combined with tools from the GNU Project, and developed into one of the most widely used foundations for operating systems today.
Unix (1969) → GNU (1983) → Linux Kernel (1991) → Linux Distributions → Android & Cloud Computing
| Year | Milestone | Significance |
|---|---|---|
| 1969 | Unix developed at Bell Labs by Ken Thompson and Dennis Ritchie. | Introduced multi-user, multitasking, and hierarchical filesystem concepts. |
| 1983 | Richard Stallman announced the GNU Project. | Developed free software tools such as GCC, Bash, and core utilities. |
| 1991 | Linus Torvalds created the Linux kernel at the University of Helsinki. | Started Linux as a personal project that grew through community contributions. |
| 1993–1994 | Debian and Red Hat emerged. | Helped make Linux accessible through packaged operating systems called distributions. |
| 2004 | Ubuntu was released. | Introduced a Debian-based Linux distribution focused on usability. |
| 2005 | Google acquired Android Inc. | Helped bring the Linux kernel into mainstream mobile computing. |
The Linux kernel manages hardware and system resources, while GNU provides many essential tools needed to operate the system.
Linux Kernel + GNU Tools + System Software
↓
Linux Distribution
↓
Ubuntu, Debian, Fedora
Note: Linux is Unix-like, not Unix itself. It follows many Unix design principles but was independently developed.
- Open Source: Users can study, modify, and distribute the Linux kernel under its license.
- Cost-Effective: Most Linux distributions are available without operating system license fees.
- Customizable: Developers can modify and configure systems according to their needs.
- Widely Adopted: Linux powers servers, cloud infrastructure, supercomputers, Android devices, and embedded systems.
Today, Linux is a fundamental technology for software development, cloud computing, DevOps, cybersecurity, and system administration.
A VPS (Virtual Private Server) is a virtual machine hosted in the cloud that you can access remotely through the internet.
It allows you to practice Linux, deploy websites, run applications, and automate tasks without installing Linux on your personal computer.
For this tutorial, we will use Hostinger as an example.
- Visit Hostinger and select a suitable VPS hosting plan.
- Choose Ubuntu LTS (Long Term Support) as your operating system.
- Complete the purchase and configure your VPS.
- Set a strong root password and store it securely.
- Wait for the VPS installation to complete.
Note: You can use any VPS provider that supports Linux. A small VPS is sufficient for practicing basic Linux commands.
SSH (Secure Shell) allows you to securely access and manage a remote Linux server through your terminal.
Open PowerShell, Windows Terminal, or your macOS/Linux terminal and run:
Replace `203.0.113.10` with your VPS's actual public IP address.
Other SSH connection methods:
# Connect using a specific port
ssh -p 22 [email protected]
# Connect using an SSH private key
ssh -i ~/.ssh/id_rsa [email protected]On your first connection, SSH may ask you to verify the server's identity. Confirm that its fingerprint matches the one provided by your hosting provider before accepting it.
Enter your root password when prompted. Your password will not appear on the screen while typing.
Security Tip: SSH key authentication is recommended for long-term server access. After initial setup, use a regular user with sudo privileges instead of working as root for everyday tasks.
Once connected, run the following commands:
hostname # Display the server's hostname
uname -a # Display kernel and system information
cat /etc/os-release # Identify your Linux distribution
whoami # Display the currently logged-in userIf the commands return your server information, you have successfully connected to your Linux VPS.
Remember: Commands executed through SSH run on your remote Linux server, not your personal computer. Your VPS continues running even after you close your terminal.
If you cannot connect to your VPS, open your hosting provider's dashboard and verify the server status, IP address, SSH port, and login credentials.
Most VPS providers also offer a browser-based terminal for accessing your server when SSH is unavailable.
Virtualization allows you to run another operating system inside your existing computer without replacing Windows.
Using VirtualBox, you can create a Virtual Machine (VM) to run Ubuntu Linux independently.
- Host OS: Your original operating system (Windows).
- Guest OS: The operating system running inside VirtualBox (Ubuntu Linux).
- Visit the official VirtualBox Downloads page.
- Download VirtualBox for Windows hosts.
- Run the installer and follow the installation instructions.
- Complete the installation and launch VirtualBox.
- Visit the official Ubuntu Desktop Download page.
- Select an Ubuntu LTS (Long Term Support) release.
- Download the AMD64 (Intel/AMD 64-bit) ISO file.
Note: The ISO file contains the Ubuntu operating system required to install Linux inside your virtual machine.
- Open VirtualBox and click New.
- Enter a name for your VM, such as `Ubuntu`.
- Select the downloaded Ubuntu ISO file.
- Set your username and password.
- Allocate the following resources according to your computer's available hardware:
| Resource | Recommended Allocation |
|---|---|
| RAM | 4 GB (or 50% of your Memory) |
| CPU | 2 Cores (or 50% of your CPU) |
| Storage | 35 GB minimum; allocate more if available |
| Operating System | Ubuntu LTS (64-bit) |
- Complete the VM configuration and click Finish.
- Start your virtual machine and complete the Ubuntu installation.
Important: Do not allocate all your computer's RAM or CPU cores to the VM. Windows needs enough resources to continue running smoothly.
Once Ubuntu starts, log in with your username and password.
Open the terminal using:
Ctrl + Alt + T
Alternatively, search for Terminal in Ubuntu's Activities menu.
Run these commands inside the Ubuntu terminal:
uname -a # Display kernel and system information
cat /etc/os-release # Identify your Linux distribution
ls # List files and directories
ls -l # Display detailed file information
ls -la # Include hidden files and directoriesRemember: Windows Terminal runs commands on your Windows host, while the Ubuntu terminal runs commands inside your Linux virtual machine. Use the Ubuntu terminal throughout this handbook.
WSL (Windows Subsystem for Linux) allows you to run Linux directly inside Windows without installing a separate operating system or creating a virtual machine using VirtualBox.
WSL is ideal for beginners who want to practice Linux commands, Bash scripting, and development through the terminal.
- Open Windows PowerShell as Administrator.
- Run the following command:
wsl --installThis installs WSL along with the default Linux distribution, typically Ubuntu.
To view available Linux distributions:
wsl --list --onlineTo install Ubuntu explicitly:
wsl --install -d UbuntuNote: You do not need to run both installation commands. Use `wsl --install -d Ubuntu` when you specifically want Ubuntu. Restart Windows if prompted.
- Open Ubuntu from the Windows Start menu.
- Wait for the initial installation to complete.
- Create your Linux username and password.
- Once configured, the Ubuntu terminal will be ready to use.
Important: Your Linux username and password are separate from your Windows login credentials.
Run these commands inside the Ubuntu terminal:
uname -a # Display kernel and system information
cat /etc/os-release # Identify your Linux distribution
ls -la # List files, including hidden filesRun these commands in Windows PowerShell:
| Command | Purpose |
|---|---|
wsl --list --online |
List available Linux distributions. |
wsl --list --verbose |
Display installed distributions and their WSL versions. |
wsl -d Ubuntu |
Launch Ubuntu. |
wsl --shutdown |
Shut down all running WSL distributions. |
Windows drives are accessible inside WSL through the mnt directory.
For example, to access your Windows C drive:
cd /mnt/c
lsRemember: WSL runs Linux locally on your Windows computer. It is not a cloud VPS or a publicly accessible Linux server by default.
VirtualBox allows you to run Ubuntu Linux inside macOS as a virtual machine without replacing your existing operating system.
- Host OS: macOS (your original operating system).
- Guest OS: Ubuntu Linux (running inside VirtualBox).
- Visit the official VirtualBox Downloads page.
- Download VirtualBox for your supported macOS system.
- Follow the installation instructions and launch VirtualBox.
Visit the official Ubuntu Downloads page and download an Ubuntu LTS ISO compatible with your Mac's processor.
| Mac Processor | Ubuntu Architecture |
|---|---|
| Intel Mac | AMD64 (x86-64) |
| Apple Silicon (M1/M2/M3/M4, etc.) | ARM64 (aarch64) |
Important: Ensure that your VirtualBox version supports your Mac's processor and the selected Ubuntu guest architecture.
- Open VirtualBox and click New.
- Name your virtual machine, such as
Ubuntu. - Select the downloaded Ubuntu ISO file.
- Configure your username and password.
- Allocate RAM, CPU cores, and storage according to your Mac's available resources.
- Click Finish and start the virtual machine.
- Complete the Ubuntu installation and log in.
Note: Leave sufficient RAM and CPU resources for macOS to run smoothly.
Once Ubuntu starts, open the terminal using:
Ctrl + Alt + T
Alternatively, open Activities → Terminal inside Ubuntu.
Run these commands inside the Ubuntu terminal:
uname -m # Display CPU architecture
uname -a # Display kernel and system information
cat /etc/os-release # Identify your Linux distribution
ls -la # List files, including hidden filesThe uname -m command typically returns:
x86_64for Intel/AMD 64-bit Linux.aarch64for ARM64 Linux.
Remember: The macOS Terminal runs commands on your Mac, while the Ubuntu terminal runs commands inside your Linux virtual machine. Use the Ubuntu terminal throughout this handbook.
Linux commands allow you to navigate directories, create and manage files, edit content, and interact with your operating system through the terminal.
Displays the full path of your current directory.
Syntax:
pwdExample Output:
/home/zeeshan
Allows you to navigate between directories in the Linux filesystem.
| Command | Purpose | Example |
|---|---|---|
cd <directory> |
Move into a specific directory. | cd Documents |
cd .. or cd ../ |
Move one directory up. | cd .. |
cd ../.. |
Move two directories up. | cd ../.. |
cd ../<directory> |
Move into another directory inside the parent directory. | cd ../Downloads |
cd ~ |
Navigate to your home directory. | cd ~ |
cd / |
Navigate to the filesystem root. | cd / |
cd . |
Stay in the current directory. | cd . |
cd |
Return to your home directory. | cd |
Understanding Directory Shortcuts
/ → Filesystem root
~ → Current user's home directory
. → Current directory
.. → Parent directory
../.. → Two directories up
For example, suppose your current directory is:
/home/zeeshan/projects
Running:
cd ..Takes you to:
/home/zeeshan
Running it again takes you to:
/home
Note
/ represents the filesystem root, while ~ represents the current user's home directory. They are not the same location.
Displays the files and directories available inside a directory.
Syntax:
lsUseful Examples:
| Command | Purpose |
|---|---|
ls |
List files and directories in the current directory. |
ls -l |
Display detailed file information. |
ls -la |
Include hidden files and directories. |
ls . |
List the contents of the current directory. |
ls ~ |
List the contents of your home directory. |
Tip: Press
Tabwhile typing a file or directory name to autocomplete it when possible.
Creates a new directory in the Linux filesystem.
Syntax:
mkdir <directory-name>Example:
mkdir projectsTo create multiple nested directories:
mkdir -p folder1/folder2/folder3The -p option creates missing parent directories automatically.
Creates a new empty file if it does not already exist.
Syntax:
touch <filename>Example:
touch notes.txtNote: If the file already exists,
touchupdates its timestamps without deleting its contents.
Copies a file from one location to another.
Syntax:
cp <source> <destination>Example:
cp notes.txt backup.txtThis creates a copy of notes.txt named backup.txt.
Important
Copying to an existing destination file may overwrite its contents.
Vim is a terminal-based text editor used to create and modify files directly inside Linux.
Syntax:
vim <filename>Example:
vim notes.txtIf Vim is not installed:
sudo apt update
sudo apt install vimAfter installation, open your file again:
vim notes.txtHow to Edit a File Using Vim
- Press
ito enter Insert Mode. - Type or modify your content.
- Press
Escto return to Normal Mode. - Type
:wqand pressEnterto save and exit.
| Vim Command | Purpose |
|---|---|
i |
Enter Insert Mode. |
Esc |
Return to Normal Mode. |
:w |
Save the file. |
:q |
Exit if there are no unsaved changes. |
:wq |
Save and exit. |
:q! |
Exit without saving changes. |
The cat command is commonly used to display the contents of a file directly in the terminal.
Syntax:
cat <filename>Example:
cat hello.txtExample Output:
Hello Linux!
Welcome to my first Linux file.
Useful cat Commands
| Command | Purpose |
|---|---|
cat file.txt |
Display the contents of a file. |
cat file1.txt file2.txt |
Display multiple files consecutively. |
cat -n file.txt |
Display file contents with line numbers. |
cat > file.txt |
Create or overwrite a file using terminal input. |
cat >> file.txt |
Append content to the end of a file. |
Example: Display File Content with Line Numbers
cat -n hello.txtOutput:
1 Hello Linux!
2 Welcome to my first Linux file.
Example: Create a File Using cat
cat > hello.txtEnter your content:
Hello Linux!
This is my first file.
Press Ctrl + D to finish writing and return to the terminal.
Example: Append Content to an Existing File
cat >> hello.txtType additional content and press Ctrl + D when finished.
Warning
cat > file.txt overwrites existing content, while cat >> file.txt appends content without removing what is already there.
The less command allows you to read, scroll through, and search large files without printing everything into the terminal at once.
Syntax:
less <filename>Example:
less hello.txtNavigation Inside less
| Key | Purpose |
|---|---|
| ↑ / ↓ | Move one line up or down. |
Space |
Move one page down. |
b |
Move one page up. |
Enter |
Move one line down. |
g |
Go to the beginning of the file. |
G |
Go to the end of the file. |
/word |
Search for a specific word. |
n |
Jump to the next search result. |
q |
Quit and return to the terminal. |
Example: Searching Inside a File
Open a file:
less hello.txtType /Linux and press Enter to search for the word Linux.
Press n to navigate to the next matching result.
cat vs. less
| Command | Best Used For |
|---|---|
cat |
Quickly displaying small files. |
less |
Reading and searching large files interactively. |
Clears the visible terminal screen.
Syntax & Example:
clearDisplays previously executed commands in your terminal session's available history.
Syntax & Example:
historyTip: Use the ↑ and ↓ arrow keys to navigate through previous commands instead of typing long commands repeatedly.
Linux is a multi-user operating system, meaning multiple users can have separate accounts, home directories, files, and permissions.
The whoami command displays the username of the currently logged-in user.
Syntax & Example:
whoamiExample Output:
zeeshan
To view additional information about your account:
idThis displays your User ID (UID), Group ID (GID), and group memberships.
The adduser command creates a new user account in Ubuntu.
Syntax:
sudo adduser <username>Example:
sudo adduser johnLinux will ask you to set a password and optionally provide additional user information.
A home directory is also created:
/home/john
Note:
sudoallows an authorized user to execute commands with elevated privileges, usually as root.
The su command allows you to switch to another user account.
Syntax:
su - <username>Example:
su - johnThe - starts a login shell, loading John's environment and taking you to his home directory.
Verify the current user and directory:
whoami
pwdExpected Output:
john
/home/john
To return to your previous shell:
exitUse id to display information about a specific user.
Syntax:
id <username>Example:
id johnExample Output:
uid=1001(john) gid=1001(john) groups=1001(john)
| Field | Meaning |
|---|---|
| UID | User ID that uniquely identifies the user. |
| GID | Primary Group ID associated with the user. |
| groups | Groups the user belongs to. |
By default, a newly created standard user does not necessarily have administrative privileges.
On Ubuntu, you can add an authorized user to the sudo group to grant administrative access.
Syntax:
sudo usermod -aG sudo <username>Example:
sudo usermod -aG sudo johnJohn can then execute administrative commands using sudo, for example:
sudo apt updateImportant
Adding a user to the sudo group grants significant administrative privileges. The user may need to log out and log back in before the new group membership takes effect.
The command:
sudo usermod -aG sudo johnCan be broken down as follows:
| Component | Purpose |
|---|---|
sudo |
Execute with elevated privileges. |
usermod |
Modify an existing user account. |
-a |
Append to existing supplementary groups. |
-G |
Specify supplementary groups. |
sudo |
Group to which the user will be added. |
john |
Username to modify. |
Why is -aG important?
Suppose John belongs to these groups:
john developers docker
Using:
sudo usermod -G sudo johnCan replace his existing supplementary group memberships with sudo.
Instead, use:
sudo usermod -aG sudo johnThis adds John to the sudo group while preserving his existing supplementary groups.
The passwd command allows an administrator to set or change another user's password.
Syntax:
sudo passwd <username>Example:
sudo passwd johnEnter and confirm the new password when prompted.
The groups command displays the groups associated with a user.
Syntax:
groups <username>Example:
groups johnExample Output:
john : john sudo
This indicates that John belongs to the john and sudo groups.
The userdel command removes an existing user account.
Syntax:
sudo userdel <username>Example:
sudo userdel johnTo remove the user along with their home directory and mail spool:
sudo userdel -r johnCaution
The -r option deletes the user's home directory and its contents. Back up important data before using this command. Files owned by the user outside their home directory may remain on the system.
Package Management is the process of installing, updating, removing, and managing software on a Linux system.
Ubuntu and Debian use APT (Advanced Package Tool) to manage software packages through configured repositories.
The apt update command refreshes the list of available packages and their versions from configured software repositories.
Syntax & Example:
sudo apt updateNote:
apt updateonly refreshes package information. It does not upgrade your installed software.
The apt upgrade command downloads and installs available updates for packages already installed on your system.
Syntax & Example:
sudo apt upgradeRecommended Workflow:
sudo apt update
sudo apt upgradeYou can also combine both commands:
sudo apt update && sudo apt upgradeThe && operator executes the second command only if the first command succeeds.
Understanding update vs. upgrade:
| Command | Purpose |
|---|---|
sudo apt update |
Check for available package updates. |
sudo apt upgrade |
Download and install available updates. |
Important
Package upgrades can introduce compatibility issues. Back up important data before major upgrades, especially on production servers.
APT provides two methods for upgrading installed packages.
| Command | Purpose |
|---|---|
sudo apt upgrade |
Upgrades packages without removing installed packages. |
sudo apt full-upgrade |
Allows larger dependency changes, including removing packages when necessary. |
Examples:
sudo apt upgrade
sudo apt full-upgradeWarning
Review the proposed changes before confirming full-upgrade, as it may remove existing packages.
The apt search command searches available software repositories for packages matching a keyword.
Syntax:
apt search <package-name>Example:
apt search nginxThe apt show command displays details about a package, including its version, description, dependencies, and download size.
Syntax:
apt show <package-name>Example:
apt show nginxThe apt install command downloads and installs software from configured repositories.
Syntax:
sudo apt install <package-name>Example:
sudo apt install nginxYou can also install multiple packages using a single command:
sudo apt install git curl wgetThis installs Git, cURL, and Wget together.
APT provides two common methods for uninstalling software.
| Command | Purpose |
|---|---|
sudo apt remove nginx |
Remove Nginx while generally preserving its configuration files. |
sudo apt purge nginx |
Remove Nginx and its package-managed configuration files. |
Examples:
sudo apt remove nginx
sudo apt purge nginxRemember:
removeuninstalls the software, whilepurgealso removes its package-managed configuration files.
The apt list --installed command displays packages currently installed on your system.
Syntax & Example:
apt list --installedTo search for a specific package in the installed list:
apt list --installed | grep nginxThe | operator, called a pipe, sends the output of one command to another. Here, grep filters the list for packages containing nginx.
The apt policy command displays installed and available package versions along with their repository information.
Syntax:
apt policy <package-name>Example:
apt policy nginxThis is useful when troubleshooting package versions and update availability.
APT provides commands to remove unnecessary dependencies and downloaded package files.
| Command | Purpose |
|---|---|
sudo apt autoremove |
Remove automatically installed dependencies that are no longer needed. |
sudo apt clean |
Clear downloaded package files from the local APT cache. |
Examples:
sudo apt autoremove
sudo apt cleanNote: Review the package list before confirming
autoremoveto avoid removing anything you still need.
A repository is a configured source from which APT retrieves software packages and updates.
When you run:
sudo apt install nginxAPT follows this general process:
Software Repository
↓
APT Package Information
↓
Download Package
↓
Install Package
Ubuntu stores repository configuration in locations such as:
/etc/apt/sources.list
/etc/apt/sources.list.d/
Ubuntu and Debian provide both apt and apt-get for package management.
| Tool | Purpose |
|---|---|
apt |
User-friendly command-line interface for everyday package management. |
apt-get |
Established package-management interface commonly used in scripts and automation. |
Both remain supported. This handbook uses apt for beginner-friendly examples.
Linux uses users, groups, ownership, and permissions to control who can access files and directories.
For example:
/home/harry/private.txt
/home/project/app.py
/etc/nginx/nginx.conf
Linux needs to decide who can read, modify, or execute each resource.
Every person or process in Linux operates as a user.
Check the current user:
whoamiExample Output:
harry
View a user's UID, GID, and groups:
id harryExample Output:
uid=1000(harry) gid=1000(harry) groups=1000(harry),27(sudo)
- UID → User ID
- GID → Primary Group ID
- groups → Groups the user belongs to
Groups allow multiple users to share the same permissions.
developers
├── Alice
├── Bob
└── Charlie
Check a user's groups:
groups harry
id harryCreate a group:
sudo groupadd developersAdd a user to the group:
sudo usermod -aG developers harryHere:
-a→ Append the user without removing existing group memberships.-G→ Specify supplementary groups.
Note
After changing group membership, the user may need to log out and log back in before the change appears in the current session.
View file permissions:
ls -lExample:
-rwxr-xr-- 1 harry developers 1234 Aug 24 app.sh
The permission section:
-rwxr-xr--
││ │ │
││ │ └── Others
││ └───── Group
│└──────── Owner
└───────── File type
Linux permissions are divided into three categories:
| Category | Meaning |
|---|---|
| Owner | User who owns the file |
| Group | Group associated with the file |
| Others | Everyone else |
| Permission | Symbol | Meaning |
|---|---|---|
| Read | r |
Read file contents |
| Write | w |
Modify the file |
| Execute | x |
Execute the file |
Example:
rwx | r-x | r--
Owner | Group | Others
This means:
- Owner: read, write, execute
- Group: read and execute
- Others: read only
The first character in ls -l output identifies the file type.
- → Regular file
d → Directory
l → Symbolic link
Example:
-rwxr-xr--
The - means it is a regular file.
For directories:
| Permission | Meaning |
|---|---|
r |
List directory contents |
w |
Create, delete, or rename entries |
x |
Enter or traverse the directory |
Create a test directory:
mkdir testView its permissions:
ls -ld testCheck a file's permissions:
ls -l script.shYou might see:
-rw-r--r-- script.sh
Make it executable:
chmod +x script.shThen run it:
./script.shchmod u+x script.sh
chmod g+w file.txt
chmod o-r file.txt
chmod g=rx file.txt| Symbol | Meaning |
|---|---|
u |
User / owner |
g |
Group |
o |
Others |
a |
All users |
+ |
Add permission |
- |
Remove permission |
= |
Set exact permissions |
Examples:
u+x → Add execute permission to owner
g+w → Add write permission to group
o-r → Remove read permission from others
g=rx → Set group permissions to read + execute only
Linux permissions can also be represented using numbers.
r = 4
w = 2
x = 1
Common combinations:
| Permission | Value |
|---|---|
rwx |
7 |
rw- |
6 |
r-x |
5 |
r-- |
4 |
-wx |
3 |
-w- |
2 |
--x |
1 |
--- |
0 |
The three digits represent:
Owner | Group | Others
Generic syntax:
chmod 755 filechmod 755 script.sh7 = rwx → Owner: read + write + execute
5 = r-x → Group: read + execute
5 = r-x → Others: read + execute
chmod 644 file.txt6 | 4 | 4
rw- | r-- | r--
- Owner → read + write
- Group → read
- Others → read
chmod 700 private.txtrwx | --- | ---
Only the owner has access.
chmod 777 fileMeans:
rwx | rwx | rwx
Everyone can read, modify, and execute the file.
Warning
Do not solve permission problems by blindly using chmod 777. Give users only the permissions they actually need.
Suppose:
-rw-r--r-- 1 harry developers app.py
Change the owner to Alice:
sudo chown alice app.pyChange both owner and group:
sudo chown alice:developers app.pyGeneric syntax:
chown OWNER:GROUP FILEChange only the group:
sudo chgrp developers app.pychown → Change ownership
chgrp → Change group
chmod → Change permissions
Suppose your project contains:
project/
├── app.py
├── config.txt
└── logs/
└── app.log
Change ownership of only the project directory:
sudo chown lovish:developers projectChange ownership recursively for the directory and everything inside it:
sudo chown -R lovish:developers projectCaution
-R means recursive. Verify the path carefully because it can change ownership of a large number of files.
Example:
drwxr-x--- 3 harry harry 4096 Aug 23 10:21 harry
| Part | Meaning |
|---|---|
d |
Directory |
rwxr-x--- |
Permissions |
3 |
Hard-link count |
First harry |
Owner |
Second harry |
Group |
4096 |
Directory size reported by ls |
Aug 23 10:21 |
Last modification time |
Final harry |
Directory name |
To view the total disk usage of the directory:
du -sh harrySuppose:
-rwxr----- 1 harry developers app.py
Permissions are:
Owner → rwx
Group → r--
Others → ---
Linux checks permissions in this order:
Is the user the owner?
↓
YES → Use OWNER permissions
↓ NO
Is the user in the file's group?
↓
YES → Use GROUP permissions
↓ NO
Use OTHERS permissions
Linux does not combine these permission sets.
Create two users:
sudo adduser alice
sudo adduser bobCreate a developers group:
sudo groupadd developersAdd both users:
sudo usermod -aG developers alice
sudo usermod -aG developers bobCreate a project file:
sudo touch /opt/project.txtSet Alice as the owner and developers as the group:
sudo chown alice:developers /opt/project.txtCheck ownership and permissions:
ls -l /opt/project.txtSet permissions:
sudo chmod 640 /opt/project.txt640 means:
6 → Owner: read + write
4 → Group: read
0 → Others: no permissions
Therefore:
Owner → Alice
Group → developers
Others → Everyone else
Linux uses processes to run programs and services to manage long-running background applications.
Program → Code stored on disk
Process → A running instance of a program
Service → A background application managed by systemd
For example, running:
python app.pystarts a Python process. Even a short command such as:
lsruns as a process and exits when its work is complete.
Every running process has a unique PID (Process ID).
Use ps to view processes associated with your current terminal:
psExample Output:
PID TTY TIME CMD
1234 pts/0 00:00:00 bash
5678 pts/0 00:00:00 ps
Here, 5678 is the PID of the ps command itself.
For a more detailed process list:
ps auxImportant columns include:
| Column | Meaning |
|---|---|
USER |
Process owner |
PID |
Process ID |
%CPU |
CPU usage |
%MEM |
Memory usage |
STAT |
Process state |
START |
Start time |
TIME |
CPU time used |
COMMAND |
Program or command |
Search the process list for Nginx:
ps aux | grep nginxThe | symbol is a pipe. It sends the output of ps aux to grep, which searches for nginx.
A cleaner option is:
pgrep nginxThis returns matching PIDs.
To display both the PID and command:
pgrep -a nginxps gives you a snapshot. top continuously updates process information:
topUse it to identify processes consuming high CPU or memory.
A more interactive alternative is:
htopIf htop is not installed:
sudo apt install htopps → Process snapshot
top → Live monitoring
htop → Interactive live monitoring
To request that a process shuts down gracefully:
kill 1234or generally:
kill PIDBy default, kill sends SIGTERM, allowing the process to clean up before exiting.
To force a process to stop immediately:
kill -9 1234or:
kill -9 PID-9 sends SIGKILL, which the process cannot ignore.
kill PID → Graceful termination request
kill -9 PID → Force immediate termination
Warning
Try normal kill first. Use kill -9 only when the process does not terminate normally.
To terminate processes by name:
pkill nginxCaution
pkill can terminate multiple processes matching the given name. Make sure you are targeting the correct application.
A service is software that normally runs in the background and provides functionality to the system or other applications.
Examples:
nginx → Web server
ssh → Remote access
mysql → Database
cron → Scheduled tasks
Many Linux systems use systemd to manage services.
systemd
↓
systemctl
↓
Services such as nginx
Check whether Nginx is running:
systemctl status nginxCommon states include:
active (running) → Service is running
inactive (dead) → Service is stopped
failed → Service failed to start or stopped unexpectedly
Start Nginx:
sudo systemctl start nginxStop Nginx:
sudo systemctl stop nginxRestart Nginx:
sudo systemctl restart nginxReload its configuration without fully stopping the service:
sudo systemctl reload nginxrestart → Stop + start the service
reload → Reload configuration while keeping the service running
Note: Not every service supports
reload.
Enable Nginx to start automatically during system boot:
sudo systemctl enable nginxDisable automatic startup:
sudo systemctl disable nginxstart → Start service now
stop → Stop service now
enable → Start automatically at boot
disable → Do not start automatically at boot
Disabling a service does not necessarily stop a service that is already running.
To enable and start it immediately:
sudo systemctl enable --now nginxTo disable automatic startup and stop it immediately:
sudo systemctl disable --now nginxThe --now option applies the boot configuration change and immediately starts or stops the service.
List currently loaded service units:
systemctl list-units --type=serviceList available service definitions and their enablement state:
systemctl list-unit-files --type=serviceCheck whether Nginx is currently active:
systemctl is-active nginxCheck whether it is enabled at boot:
systemctl is-enabled nginxLinux systems using systemd provide journalctl for viewing service logs.
View Nginx logs:
journalctl -u nginxShow the latest 50 log entries:
journalctl -u nginx -n 50Follow new log entries in real time:
journalctl -u nginx -fHere:
-u → Select a systemd unit
-n 50 → Show the latest 50 entries
-f → Follow new log entries
The -f behavior is similar to:
tail -f <file>If your Nginx website is not working, use this sequence:
1. Check service status
sudo systemctl status nginx2. Start it if it is stopped
sudo systemctl start nginx3. Check recent logs if it failed
sudo journalctl -u nginx -n 504. Check whether Nginx processes exist
ps aux | grep nginx5. Check system resource usage
topA process is a specific running instance of a program identified by a PID.
A service is an application managed by the system's service manager and may contain multiple processes.
nginx.service
│
├── nginx process PID 1234
├── nginx process PID 1235
└── nginx process PID 1236
Process → Running program identified by PID
Service → Managed background application
systemctl → Controls systemd services
journalctl → Reads system and service logs
Environment variables store configuration values used by the shell and programs. PATH tells Linux where to search for commands, while .bashrc stores Bash settings that should persist across shell sessions.
An environment variable is a named value stored in the shell environment.
Check common variables:
echo $HOME
echo $USER
echo $SHELLExample:
HOME=/home/harry
USER=harry
SHELL=/bin/bash
View environment variables:
printenv
envThe $ symbol means: get the value stored in this variable.
For example:
echo $HOMEprints the value of HOME, while:
echo HOMEsimply prints:
HOME
Create a shell variable:
name="Harry"Display its value:
echo $nameImportant
Do not place spaces around =.
Correct:
name="Harry"Incorrect:
name = "Harry"The incorrect version is interpreted differently by the shell and produces an error.
A normal variable exists only in the current shell:
name="Harry"To make it available to programs launched from that shell, use export:
export name="Harry"
export APP_ENV="production"You can also write:
export APP_ENV=productionEnvironment variables are commonly used for application configuration, such as:
DATABASE_URL
API_KEY
PORT
APP_ENV
DEBUG
Warning
Environment variables are not automatically secure. Sensitive values may be exposed through logs, debugging, process inspection, or incorrect configuration.
PATH contains the directories Linux searches when you enter a command.
Check it with:
echo $PATHExample:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
The directories are separated by :.
PATH
├── /usr/local/sbin
├── /usr/local/bin
├── /usr/sbin
├── /usr/bin
├── /sbin
└── /bin
When you run commands such as:
ls
cat
sudothe shell searches directories in PATH to find them.
Find the executable used by a command:
which lsExample output:
/usr/bin/ls
A better shell-aware method is:
command -v lsYou can also use:
type lstype can tell you whether something is an alias, function, shell builtin, or external command.
For example:
type cdmay return:
cd is a shell builtin
Suppose you have a script named hello.sh.
Make it executable:
chmod +x hello.shRunning:
hello.shmay produce:
command not found
But this works:
./hello.sh./ means:
Run
hello.shfrom the current directory.
The current directory (.) is normally not included in PATH, partly for security reasons.
Suppose your scripts are stored in:
/home/harry/scripts
Add that directory to the existing PATH:
export PATH="$PATH:/home/harry/scripts"Check the updated value:
echo $PATHNow commands stored in that directory can be executed without typing their full path.
For example:
command -v backupWarning
Do not replace your entire PATH like this:
export PATH="/home/harry/scripts"Doing so removes the existing directories from PATH, which can make commands such as ls, cat, and sudo unavailable by their normal names.
A command such as:
export APP_ENV=productionnormally lasts only for the current shell session.
To make Bash settings persistent, add them to:
~/.bashrc
For example:
export APP_ENV=production
export PATH="$PATH:$HOME/scripts"Reload .bashrc without opening a new terminal:
source ~/.bashrcThe shorthand form is:
. ~/.bashrcHere, . acts as the source command.
Check your current PATH:
echo $PATHCreate a scripts directory:
mkdir -p ~/scriptsCreate a file named:
~/scripts/hello
Add:
#!/bin/bash
echo "Hello from my script!"Make it executable:
chmod +x ~/scripts/helloRunning the full path works:
~/scripts/helloBut this may not work yet:
helloAdd the scripts directory to PATH:
export PATH="$PATH:$HOME/scripts"Now run:
helloVerify where Linux finds it:
command -v helloExample output:
/home/harry/scripts/hello
Archiving and compression are related but different:
- Archiving combines multiple files and directories into one file.
- Compression reduces the size of data.
tarmainly creates archives.gzipcompresses files.zipgenerally archives and compresses at the same time.
Example:
project/
├── app.py
├── config.py
├── index.html
├── styles.css
└── images/
├── logo.png
└── banner.jpg
project/ → project.tar → gzip → project.tar.gz
tar stands for Tape Archive and is commonly used to combine files and directories into a single archive.
General Syntax:
tar [options] archive-name filestar -cf project.tar project/-c → Create archive
-f → Specify archive file
Check the archive size:
ls -lh project.tarList the contents without extracting:
tar -tf project.tar-t → List archive contents
-f → Specify archive file
Extract the archive:
tar -xf project.tarExtract while displaying filenames:
tar -xvf project.tarCreate an archive in verbose mode:
tar -cvf project.tar project/| Option | Purpose |
|---|---|
c |
Create archive |
x |
Extract archive |
t |
List archive contents |
v |
Verbose — display files being processed |
f |
Specify archive file |
z |
Use gzip compression |
Compress a TAR archive:
gzip project.tarThis normally creates:
project.tar.gz
and replaces the original project.tar.
Decompress it:
gunzip project.tar.gzThis restores:
project.tar
gzip → Compress
gunzip → Decompress
Instead of creating a .tar file and compressing it separately, tar can do both operations together.
Create a gzip-compressed TAR archive:
tar -czf project.tar.gz project/c → Create
z → Compress using gzip
f → Specify archive file
Extract it:
tar -xzf project.tar.gzx → Extract
z → Decompress gzip
f → Specify archive file
A .tar.gz file means:
.tar → TAR archive
.gz → gzip compression
.tar.gz → A TAR archive compressed with gzip
You may also encounter:
.tar.bz2
.tar.xz
These use different compression methods but follow the same general archive-and-compress idea.
Unlike plain tar, ZIP generally combines archiving and compression in one format.
Create a ZIP archive from a directory:
zip -r project.zip project/The -r option means recursive, allowing directories and their contents to be included.
Extract a ZIP archive:
unzip project.zipExtract into a specific directory:
unzip project.zip -d extracted/List archive contents without extracting:
unzip -l project.zip-r → Recursively include directories
-d → Choose extraction destination
-l → List archive contents
| Tool / Format | Archive Files? | Compress Data? |
|---|---|---|
tar |
Yes | No, by itself |
gzip |
No | Yes |
tar.gz |
Yes | Yes |
zip |
Yes | Yes |
tar → Combine files into one archive
gzip → Compress data
tar.gz → TAR archive + gzip compression
zip → Archive + compression
Create a project directory:
mkdir projectCreate some files:
touch project/app.py project/config.py project/index.htmlCreate a TAR archive:
tar -cf project.tar project/List its contents:
tar -tf project.tarCompress it:
gzip project.tarDecompress it:
gunzip project.tar.gzExtract the TAR archive:
tar -xf project.tarCreate a compressed TAR archive directly:
tar -czf project.tar.gz project/Extract it:
tar -xzf project.tar.gzCreate a ZIP archive:
zip -r project.zip project/Extract it:
unzip project.zipCron jobs automatically run commands or scripts at scheduled times.
Examples include:
- Creating backups every night
- Running scripts every hour
- Cleaning files every Sunday
- Generating reports automatically
A scheduled task is called a cron job, and the background service that runs these tasks is called cron.
Check whether cron is running:
systemctl status cronYou should see:
Active: active (running)
If cron is not running:
sudo systemctl start cronEnable it to start automatically when the system boots:
sudo systemctl enable cronA crontab is a file containing scheduled tasks for a user.
List your current cron jobs:
crontab -lEdit your cron jobs:
crontab -eExample:
*/5 * * * * echo "Hello" >> /home/harry/cron.logThis appends Hello to cron.log every 5 minutes.
A cron job contains five scheduling fields followed by a command:
* * * * * command
│ │ │ │ │
│ │ │ │ └── Day of week (0-7)
│ │ │ └──── Month (1-12)
│ │ └────── Day of month (1-31)
│ └──────── Hour (0-23)
└────────── Minute (0-59)
* means every possible value.
For example:
* * * * * commandruns the command every minute.
Run every 5 minutes:
*/5 * * * * /home/harry/backup.shRun at the beginning of every hour:
0 * * * * /home/harry/backup.shRun every day at 2:30 AM:
30 2 * * * /home/harry/backup.shRun every Sunday at 3:00 AM:
0 3 * * 0 /home/harry/backup.shRun at midnight on the first day of every month:
0 0 1 * * /home/harry/report.shRun at 9:00 AM on Monday, Wednesday, and Friday:
0 9 * * 1,3,5 /home/harry/report.shRun at 9:00 AM from Monday to Friday:
0 9 * * 1-5 /home/harry/report.shUseful cron patterns:
* → Every value
*/5 → Every 5
1,5,10 → Specific values
1-5 → Range
Days of the week:
0 or 7 → Sunday
1 → Monday
2 → Tuesday
3 → Wednesday
4 → Thursday
5 → Friday
6 → Saturday
Instead of placing a large command directly inside crontab, create a script.
Create the script:
nano /home/harry/backup.shExample script:
#!/bin/bash
tar -czf /home/harry/backup.tar.gz /home/harry/projectMake it executable:
chmod +x /home/harry/backup.shSchedule it to run every day at 2:00 AM:
0 2 * * * /home/harry/backup.shNote
Cron has a more limited environment than your normal terminal. Prefer absolute paths when running scripts and commands.
Find the full path of a command using:
which taror:
command -v tarCron output does not normally appear in your terminal.
Redirect output to a log file:
* * * * * /home/harry/test.sh >> /home/harry/cron.log 2>&1Here:
>> → Append normal output to the file
2>&1 → Send error output to the same file
View the log:
cat /home/harry/cron.logor:
tail /home/harry/cron.logCron jobs belong to individual users.
Your user's crontab:
crontab -eList your jobs:
crontab -lRoot has a separate crontab:
sudo crontab -eWarning
Root cron jobs run with administrative privileges. Incorrect commands can make significant system changes.
Edit the crontab and manually remove a job:
crontab -eTo remove the entire current user's crontab:
crontab -rCaution
crontab -r removes all cron jobs for the current user. Use it carefully.
If a job does not run, first check your scheduled tasks:
crontab -lCheck the log file:
tail /home/harry/cron.logCheck whether cron is running:
systemctl status cronCron uses the server's configured timezone, so make sure the schedule matches the system timezone.
A simple test job is:
*/5 * * * * echo "Cron works!" >> /home/harry/cron.logAfter a few minutes, check:
cat /home/harry/cron.logIf Cron works! appears repeatedly, cron is running correctly.
Practice Resource: crontab.guru is a useful website for learning and practicing cron job schedules.
Linux organizes files in a single directory tree starting from /, unlike Windows, which commonly uses separate drive letters such as C:\ and D:\.
/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
You do not need to memorize every directory. Start with the most important ones.
/ is the top-level directory of the entire Linux filesystem. Everything exists somewhere underneath it.
Move to the root directory:
cd /List its contents:
ls /Note
/ and /root are different:
/ → Root of the entire filesystem
/root → Home directory of the root user
Normal users usually store their personal files inside /home.
/home
├── harry
├── alice
└── bob
If your username is harry, your home directory is usually:
/home/harry
You can return to your home directory using:
cd ~or simply:
cdWhen logged in as harry:
~ = /home/harry
/etc stores system-wide configuration files.
Common examples:
/etc/ssh/
/etc/apt/
/etc/systemd/
/etc/passwd
/etc/hosts
View hostname and IP mappings:
cat /etc/hostsView user account information:
cat /etc/passwd/etc → System configuration
/var stores data that changes frequently while Linux is running.
Common locations include:
/var/log
/var/cache
/var/lib
View available log files:
ls /var/logCommon log files may include:
/var/log/syslog
/var/log/auth.log
When troubleshooting a server, /var/log is often one of the first places to check.
/var → Frequently changing data, logs, and caches
/usr contains a large amount of installed software, commands, libraries, and shared resources.
Common directories include:
/usr/bin
/usr/sbin
/usr/lib
/usr/share
List commands stored in /usr/bin:
ls /usr/binFind where Python 3 is installed:
which python3You may see:
/usr/bin/python3
Other commands may also exist here:
/usr/bin/grep
/usr/bin/curl
/usr → Installed user-space programs and resources
/bin traditionally contains essential commands such as:
ls
cp
mv
cat
rm
Check what /bin points to:
ls -ld /binOn many modern Linux systems, /bin is a symbolic link to:
/usr/bin
/bin → Essential command location, commonly merged with /usr/bin
/tmp is used by programs for temporary storage.
Move into it:
cd /tmpCreate a temporary file:
touch test.txtWarning
Do not store important files in /tmp. Its contents may be removed during reboot or automatic cleanup.
/tmp → Temporary files
| Directory | Purpose |
|---|---|
/boot |
Files required to boot Linux |
/dev |
Devices represented as files |
/proc |
Information about processes and the kernel |
/sys |
Kernel and device information |
/run |
Runtime data created since boot |
/mnt |
Temporary or manual mount points |
/media |
Common location for removable media |
/opt |
Optional or third-party software |
/sbin |
Traditionally system administration commands |
/root |
Home directory of the root user |
Start from the root:
cd /List its contents:
lsExplore important directories such as:
/home
/etc
/var
/usr
/tmp
Check your current location at any time:
pwd/ → Everything starts here
/home → Users' personal files
/etc → System configuration
/var → Changing data and logs
/usr → Programs and shared resources
/bin → Essential commands
/tmp → Temporary files
Nginx is a web server that listens for HTTP/HTTPS requests, usually on ports 80 and 443, and returns web pages or other responses.
On a Linux VPS:
Browser → Port 80/443 → Nginx → Website Files
You can check the Nginx service with:
systemctl status nginxUpdate the package list:
sudo apt updateInstall Nginx:
sudo apt install nginxEnable Nginx at boot and start it immediately:
sudo systemctl enable --now nginxCheck its status:
systemctl status nginxCheck whether it is active:
systemctl is-active nginxView running Nginx processes:
ps aux | grep nginxSeveral Nginx processes running under one service are normal.
From the Linux server, test Nginx using:
curl http://127.0.0.1or:
curl http://localhostThese commands display the HTML returned by Nginx.
To view only HTTP headers:
curl -I http://127.0.0.1A successful response may include:
HTTP/1.1 200 OK
Server: nginx
From your own computer, open:
http://YOUR_SERVER_IP
in a web browser.
Check whether something is listening on port 80:
sudo ss -tlnp | grep ':80'Test the Nginx configuration:
sudo nginx -tView the latest Nginx service logs:
sudo journalctl -u nginx -n 50ss → Check listening ports
nginx -t → Test Nginx configuration
journalctl → View service logs
Common Nginx paths on Ubuntu:
/etc/nginx/nginx.conf → Main Nginx configuration
/etc/nginx/sites-available/ → Available site configurations
/etc/nginx/sites-enabled/ → Enabled site configurations
/var/www/html/ → Default website files
List available sites:
ls /etc/nginx/sites-availableList enabled sites:
ls /etc/nginx/sites-enabledView enabled-site links in detail:
ls -l /etc/nginx/sites-enabledEnabled sites are commonly symbolic links to configuration files stored in sites-available.
Check the default web directory:
ls -l /var/www/htmlEdit the default HTML page:
sudo nano /var/www/html/index.htmlAdd simple HTML such as:
<!DOCTYPE html>
<html>
<head><title>Hello</title></head>
<body><h1>Hello from Nginx</h1></body>
</html>Save the file and test it:
curl http://127.0.0.1For normal static HTML changes, Nginx does not need to be restarted because it reads the file when a request arrives.
When you change Nginx configuration files, test them first:
sudo nginx -tThen reload Nginx:
sudo systemctl reload nginxIf a full restart is required:
sudo systemctl restart nginxreload → Reload configuration without fully stopping Nginx
restart → Stop and start Nginx again
Note
For configuration changes, prefer reload when possible. Editing static HTML inside /var/www/html normally requires only refreshing the browser.
Warning
Do not use chmod 777 on the web root just to solve permission problems. Fix the correct ownership or group permissions instead. On Ubuntu, Nginx commonly runs as www-data.
A simple Nginx server block defines which port to listen on and which files to serve.
server {
listen 80;
server_name _;
root /var/www/html;
index index.html;
}listen 80 → Listen for HTTP traffic
server_name _ → Match the server name
root /var/www/html → Website files location
index index.html → Default page
The default Ubuntu Nginx configuration already provides this basic setup.
For additional websites, the typical flow is:
sites-available
↓
Create/Edit Site Configuration
↓
Link into sites-enabled
↓
Test with nginx -t
↓
Reload Nginx
Disabling a site usually means removing its symbolic link from sites-enabled while keeping the original configuration in sites-available.
Follow this troubleshooting sequence:
1. Check whether Nginx is running
systemctl status nginx2. Test the configuration
sudo nginx -t3. Test the website locally from the server
curl http://127.0.0.1If local curl works but the website does not open from your computer, check the firewall or VPS provider's security settings.
Check UFW status:
sudo ufw statusAllow HTTP traffic:
sudo ufw allow 80/tcpAllow HTTPS traffic:
sudo ufw allow 443/tcpNote
These UFW commands apply only if your server uses UFW. Some VPS providers manage firewall rules through their hosting dashboard instead.
FileZilla provides a graphical way to transfer files between your computer and a Linux VPS.
SSH → Command-line access
FileZilla → Visual file transfer
For a VPS, use SFTP (SSH File Transfer Protocol) over port 22, the same connection used by:
sshLaptop → SFTP (Port 22) → Linux VPS
- Install the FileZilla Client from filezilla-project.org.
- Open File → Site Manager or use Quickconnect.
- Enter your server connection details.
- Choose SFTP, not FTP.
- Connect and accept the server host key on the first connection.
| Field | Typical Value |
|---|---|
| Protocol | SFTP |
| Host | 203.0.113.10 (your server IP) |
| Port | 22 |
| User | root, ubuntu, or your SSH user |
| Password / Key | Same credentials used for SSH |
After connecting:
Local side → Files on your laptop
Remote side → Files on your VPS
Drag a file to the remote side to upload it, or drag it back to download it.
Warning
Use SFTP on port 22 instead of old unencrypted FTP on port 21.
Useful server directories include:
/home/harry
/var/www/html
/etc/nginx
For example, files uploaded to:
/var/www/html
can be served by Nginx.
You can also edit files directly on the server using:
nanoUploaded files still follow Linux ownership and permission rules.
Use:
chownto change ownership, and:
chmodto change permissions.
Avoid blindly using:
chmod 777 <file>A file owned by root with restrictive permissions such as 600 may not be readable by Nginx's usual www-data user.
FileZilla is optional. You can also use scp, sftp, or rsync.
Using SCP:
scp page.html [email protected]:/var/www/html/Using SFTP:
sftp [email protected]Using rsync:
rsync -av page.html [email protected]:/var/www/html/scp → One-shot file copy
sftp → Interactive file-transfer session
rsync → Efficient repeated synchronization
After connecting with:
sftp [email protected]you can use:
put index.html
get index.html
ls
cd
bye| Command | Purpose |
|---|---|
put index.html |
Upload a file |
get index.html |
Download a file |
ls |
List remote files |
cd |
Change remote directory |
bye |
Exit the SFTP session |
Using SCP:
scp [email protected]:/var/www/html/index.html .Using SFTP:
sftp [email protected]Then:
get index.htmlUsing rsync:
rsync -av [email protected]:/var/www/html/index.html .Here, . means the current local directory.
Using SCP:
scp -r site/ [email protected]:/var/www/html/Using rsync:
rsync -av site/ [email protected]:/var/www/html/-r → Copy recursively
-a → Preserve attributes such as permissions and timestamps
-v → Verbose output
Note
With rsync, trailing slashes matter. site/ copies the directory's contents, while site can result in the directory itself being placed inside the destination.
Use an SSH private key with SCP:
scp -i ~/.ssh/id_rsa page.html [email protected]:/var/www/html/With SFTP:
sftp -i ~/.ssh/id_rsa [email protected]With rsync:
rsync -av -e "ssh -i ~/.ssh/id_rsa" page.html [email protected]:/var/www/html/| Tool | Best For |
|---|---|
| FileZilla | Visual browsing and occasional uploads |
| SCP | Quickly copying one file or a small directory |
| SFTP | Interactive file transfer through SSH |
| rsync | Repeatedly synchronizing project folders |
All of these transfer files to the same Linux server. Nginx does not care whether index.html arrived through FileZilla, scp, rsync, or nano; it serves whatever is inside the configured web root.
You started by understanding the difference between a kernel, operating system, and Linux distribution, and finished with a Linux system you can manage through a VPS, VirtualBox, or WSL.
The environment may change, but the core Linux commands remain the same.
ls → List files and directories
systemctl → Manage services
Cron → Run scheduled tasks
Nginx → Serve web content
You can now:
- Understand the difference between the Linux kernel and a Linux distribution.
- Connect to a remote Linux server using:
ssh- Navigate files and directories using:
ls- Create users, manage groups, and understand permissions such as:
-rwxr-xr--
- Install and manage software using APT:
aptUnderstand the difference between:
apt update
apt upgradeupdate → Refresh available package information
upgrade → Install available package updates
- Manage Linux services using:
systemctl- Monitor running processes and system resources using:
top-
Configure and understand the
PATHenvironment variable. -
Archive and compress files using:
tar
gzip
zip- Schedule automated tasks with cron.
- Understand important Linux directories such as:
/
/home
/etc
/var
/usr
- Deploy an
index.htmlfile inside:
/var/www/html
- Transfer files using FileZilla or:
scpTest your Nginx configuration before reloading it:
nginx -tTry graceful process termination first:
kill <PID>Use force termination only when necessary:
kill -9 <PID>Use appropriate permissions such as:
chmod 644 <file>
chmod 755 <file-or-directory>Avoid blindly using:
chmod 777 <file-or-directory>When adding a user to a supplementary group, prefer:
usermod -aG <group> <username>instead of:
usermod -G <group> <username>because -aG appends the group without replacing existing supplementary group memberships.
Follow a simple troubleshooting path:
Service Status
↓
Logs
↓
Process List
↓
top
Linux may seem large at first, but the basic structure remains consistent:
Filesystem starts at /
Shell searches PATH
Kernel manages system resources
Commands let you control the machine
You now have the foundation to use Linux intentionally, troubleshoot problems, manage services, automate tasks, and work with Linux servers.
Click the box below to visit the author's GitHub profile and explore more projects, open-source work, and contributions.
Muhammad Zeeshan Islam 💻 📖 |