`ping` – Test Connectivity
The ping command checks whether your system can reach another host (computer, server, or website).
- Example:
ping google.com
This sends ICMP echo requests and shows replies, verifying network connectivity.
- Stop
ping:
Press CTRL + C.
- Use
-cto limit the number of packets:
ping -c 4 8.8.8.8
`ifconfig` – Network Interface Information (Legacy)
ifconfig (from the net-tools package) shows and configures network interfaces. It’s considered deprecated, but still found on some systems.
- Show all interfaces:
ifconfig
- Bring an interface up or down:
sudo ifconfig eth0 up
sudo ifconfig eth0 down
`ip` – Modern Networking Tool
The ip command (from the iproute2 package) is the modern replacement for ifconfig.
- Show IP addresses:
ip addr
- Show network interfaces:
ip link
- Show routing table:
ip route
- Assign an IP address:
sudo ip addr add 192.168.1.100/24 dev eth0
File Transfer (scp, rsync, wget, curl)
Linux provides several tools to copy files locally, transfer them across systems, and download from the internet. Each tool has its strengths.
`scp` – Secure Copy
scp copies files between local and remote systems over SSH.
- Copy from local to remote:
scp file.txt user@server:/home/user/
- Copy from remote to local:
scp user@server:/home/user/file.txt .
- Copy a directory (recursive):
scp -r project/ user@server:/home/user/
`rsync` – Efficient File Synchronization
rsync is more powerful than scp — it syncs files, only transferring changes.
- Copy local to remote:
rsync -avz project/ user@server:/home/user/project/
- Copy remote to local:
rsync -avz user@server:/home/user/project/ ./project/
- Key features:
a→ archive (preserve permissions, symlinks).v→ verbose.z→ compression.- Can resume interrupted transfers.
`wget` – Download from the Web
wget is a command-line downloader.
- Download a file:
wget https://example.com/file.zip
- Resume a partial download:
wget -c https://example.com/file.zip
- Download an entire website (mirroring):
wget -r -np -k https://example.com
`curl` – Transfer Data with URLs
curl is a versatile tool for fetching or sending data across protocols (HTTP, FTP, etc.).
- Download a file:
curl -O https://example.com/file.zip
- Save output to a custom file:
curl -o myfile.zip https://example.com/file.zip
- Test a website response:
curl -I https://example.com
- Send POST data:
curl -d "user=amr&pass=1234" https://example.com/login
- scp → secure file copy via SSH.
- rsync → sync directories efficiently.
- wget → simple web downloader.
- curl → advanced tool for HTTP/FTP requests and APIs.
SSH Basics (Secure Shell)
SSH (Secure Shell) is the standard way to securely connect to remote Linux systems over a network. It provides encrypted communication for running commands, transferring files, and managing servers.
What is SSH?
- A protocol for secure remote login and command execution.
- Replaces insecure tools like
telnetandrlogin. - Uses port 22 by default.
- Provides authentication via passwords or SSH keys.
Connecting to a Remote Server
Basic syntax:
ssh user@hostname
user→ the username on the remote system.hostname→ IP address or domain of the server.
Example:
ssh amr@192.168.1.50
Using SSH Keys (Recommended)
SSH keys provide secure, passwordless authentication.
- Generate a key pair:
ssh-keygen -t rsa -b 4096
- Copy public key to server:
ssh-copy-id user@hostname
- Connect without a password:
ssh user@hostname
Common SSH Options
- Specify a custom port:
ssh -p 2222 user@hostname
- Run a single command remotely:
ssh user@hostname "ls -l /var/log"
- Use a config file (
~/.ssh/config) for shortcuts:
Host myserver
HostName 192.168.1.50
User amr
Port 22
Then connect with:
ssh myserver