🐧 Revisiting the Basics: Linux Commands & Networking Concepts 🌐
Today, I spent some time revising Linux commands and networking concepts that we use almost every day in our IT operations.
While working in issue troubleshooting, we come across situations where we need to check server health, investigate application issues, monitor logs, verify connectivity and troubleshoot a particular service.
I thought of putting together some of the commands and concepts I have revised today. Having everything in one place will help me refresh my memory whenever needed. Hopefully, it will be useful for others working in similar roles as well.
Here are some of the important things I went through. 👇
📂 1. A Few Important Directories in Linux/Unix
-
/home→ Where user files and personal projects are stored. -
/etc→ Contains system configuration files. -
/var→ Stores logs, caches, databases, and other frequently changing data. -
/usr→ Contains installed applications and libraries. -
/tmp→ Used for temporary files. -
/proc→ Provides information about running processes and the Linux kernel.
📍 2. Basic Directory Navigation
These are some of the commands we use regularly:
-
.→ Current directory. -
..→ Parent directory. -
~→ Home directory. -
pwd→ Check the current location. -
ls→ List files and directories. -
cd→ Move from one directory to another.
📁 3. Directory and File Management
During daily support activities, we frequently work with files, directories, and application logs.
Some useful commands:
-
mkdir -p→ Create directories, including parent directories. -
touch→ Create an empty file. -
cp→ Copy files or directories. -
mv→ Move or rename files. -
rm -rf→ Remove files or directories recursively and forcefully (always use carefully). -
rmdir→ Remove empty directories. -
cat→ Display file contents. -
less→ Read large files page by page. -
more→ Browse file contents page by page. -
head→ Display the first 10 lines by default. -
tail→ Display the last 10 lines by default. -
tail -f→ Keep monitoring a log file as new entries are added. -
grep→ Search for specific words or patterns inside files. -
find→ Search for files and directories. -
wc -l→ Count the number of lines. -
df -h→ Check available disk space. -
du -sh→ Check the size of a directory.
🗜️ 4. File Compression and Archiving
Sometimes, we need to compress application logs or transfer large files between servers.
-
tar→ Create and extract archives. -
gzip→ Compress individual files. -
gunzip→ Decompress compressed files. -
zip→ Create ZIP archives. -
unzip→ Extract ZIP files.
⚙️ 5. Service Management Using systemctl
Whenever an application or service is not responding, checking its status is one of the first things we generally do.
-
systemctl status nginx→ Check service status. -
systemctl start nginx→ Start a service. -
systemctl stop nginx→ Stop a service. -
systemctl restart nginx→ Restart a service. -
systemctl enable nginx→ Enable automatic startup during system boot. -
systemctl disable nginx→ Disable automatic startup. -
systemctl reload nginx→ Reload the service configuration without a full restart.
🌐 6. Network and Port Commands
Networking commands are particularly useful when investigating connectivity issues between applications and servers.
-
ip addr→ Check network interfaces and IP addresses. -
ping -c 1 hostname→ Check basic network reachability. -
ss -tulpn→ Check listening TCP/UDP ports. -
curl→ Test URLs, HTTP responses, and APIs. -
nslookup→ Verify DNS resolution. -
nc -zv hostname port→ Check connectivity to a specific port. -
ip route→ Check routing information. -
dig hostname→ Perform DNS queries. -
traceroute hostname→ Trace the network path to a destination. -
netstat -tulpn→ Check network connections and listening ports.
📦 7. Package Management in Linux (APT)
APT (Advanced Package Tool) is commonly used in Debian-based Linux distributions such as Ubuntu.
-
sudo apt update→ Refresh the package index. -
sudo apt upgrade→ Upgrade installed software. -
sudo apt install nginx→ Install an application. -
sudo apt remove nginx→ Remove an application. -
sudo apt autoremove→ Remove unused dependencies.
🐚 8. Bash Scripting
One of the useful things about Linux is that we can automate many repetitive activities using simple Bash scripts.
A few basic concepts:
-
#!/bin/bash→ Specifies the interpreter for the script. -
chmod +x script.sh→ Makes a script executable. - Variables → Store values.
- Functions → Reuse blocks of code.
- Conditions → Execute commands based on specific conditions.
- Loops → Automate repetitive tasks.
-
vi/nano→ Editors used to create and modify scripts.
For example, we can write simple scripts to check application status, monitor logs, validate incoming files, and generate daily reports.
🔐 9. Remote Server Connectivity – SSH
In support operations, connecting to remote servers and transferring files is a common activity.
Some commonly used ports:
- FTP → 20, 21.
- SSH / SFTP / SCP → 22.
- Telnet → 23.
Useful commands:
-
ssh user@host→ Connect to a remote server. -
ssh-keygen→ Generate public and private SSH keys. -
ssh-copy-id user@host→ Copy the public key to a remote server. -
scp→ Securely transfer files between machines. -
rsync→ Synchronize local and remote directory contents.
🔗 10. Pipes, Redirection and Command Chaining
Another interesting thing about Linux is how we can combine multiple commands to get the required output.
Instead of executing everything separately, the output of one command can be passed as input to another command.
A few examples I use or find useful:
-
ps aux | grep nginx→ Find processes related to Nginx. -
tail -f app.log | grep -i 'error'→ Monitor error messages in real time. -
ls > files.txt→ Save command output to a file. -
echo "Done" >> deploy.log→ Append information to an existing file. -
git pull && npm install && npm run build→ Execute commands one after another only when the previous command succeeds. -
command1 || command2→ Execute the second command if the first one fails.
🚨 11. Network Troubleshooting – What Should We Check?
Whenever a customer reports that an application is slow or unreachable, we should not immediately conclude that the server is down.
The issue could be related to DNS, network connectivity, firewall rules, application services, or backend dependencies.
These are some of the checks that help narrow down the issue:
- 🔍
ping→ Check basic network connectivity. - 🌐
dig / nslookup→ Verify whether DNS resolution is working. - 🔗
curl→ Check HTTP responses and API connectivity. - 🔌
ss -tulpn→ Verify which services are listening on which ports. - 📡
nc -zv hostname port→ Check whether a specific port is reachable. - 🛣️
traceroute→ Identify the network hops between source and destination. - 🔄
ip route→ Verify routing information.
A useful curl command to check HTTP response codes and response time:
curl -s -o /dev/null -w "Status: %{http_code} | Time: %{time_total}s\n" https://hostname
This gives us the HTTP response code along with the total response time.
🔌 12. Commonly Used Ports
A port helps identify the specific service or application endpoint running on a server.
- 22 → SSH.
- 25 → SMTP.
- 53 → DNS.
- 80 → HTTP.
- 443 → HTTPS.
- 1521 → Oracle Database.
- 1433 → Microsoft SQL Server.
- 5432 → PostgreSQL.
- 3306 → MySQL.
- 27017 → MongoDB.
- 3389 → RDP.
🌍 13. HTTP and HTTPS
Whenever we access a website or call an API, HTTP/HTTPS helps establish communication between the client and server.
Common HTTP Methods:
- GET → Retrieve data.
- POST → Create or submit data.
- PUT → Update or replace a resource.
- DELETE → Delete a resource.
- PATCH → Partially update a resource.
HTTP Status Codes:
- 1xx → Informational responses.
- 2xx → Successful responses.
- 3xx → Redirection.
- 4xx → Client-side errors.
- 5xx → Server-side errors.
HTTPS uses TLS encryption to secure communication and helps maintain data confidentiality and integrity during transmission.
🛡️ 14. Firewalls
A firewall plays an important role in securing servers and applications by controlling incoming and outgoing network traffic.
Some basic concepts:
- 📥 Inbound Traffic → Requests coming into the server.
- 📤 Outbound Traffic → Requests going out from the server.
- ✅ Allow Rules → Permit specific traffic.
- 🚫 Deny Rules → Block specific traffic.
- 🔐 Least Privilege → Allow only the access that is actually required.
⚖️ 15. Load Balancers
A load balancer distributes incoming application requests across multiple backend servers instead of sending all traffic to a single server.
Some important benefits:
- ⚖️ Distributes incoming traffic.
- ❤️ Performs backend server health checks.
- 🔄 Helps manage failover when a server becomes unhealthy.
- 🚀 Improves application availability.
- 📈 Supports application scalability.
These concepts are widely used in cloud platforms, Kubernetes, and modern production environments.
💡 A Small Learning Takeaway
While revising all these commands, one thing I realized is that we don't always need to learn something new to improve our troubleshooting skills.
Sometimes, going back to the basics and understanding how to use them effectively can make a big difference during production incidents.
📚 Keep learning, keep practicing the fundamentals! 🚀
Top comments (0)