Introduction:
Linux administration and networking are critical skills for IT professionals. This comprehensive guide covers essential commands for system administration and network management in Linux environments. Whether you’re a beginner or looking to refresh your knowledge, these commands will help you effectively manage Linux systems and networks.
- sudo
Explanation: Executes a command with superuser privileges.
Example:
sudo apt-get update
- systemctl
Explanation: Controls the systemd system and service manager.
Examples:
systemctl start apache2
systemctl status ssh
- journalctl
Explanation: Queries the systemd journal.
Example:
journalctl -u nginx.service --since today
- useradd / userdel
Explanation: Adds or deletes user accounts.
Examples:
sudo useradd -m newuser
sudo userdel -r olduser
- passwd
Explanation: Changes user passwords.
Example:
sudo passwd username
- chown
Explanation: Changes file ownership.
Example:
sudo chown user:group file.txt
- chmod
Explanation: Modifies file permissions.
Example:
chmod 755 script.sh
- ip
Explanation: Shows and manipulates routing, devices, policy routing and tunnels.
Examples:
ip addr show
ip link set eth0 up
ip route add 192.168.1.0/24 via 192.168.0.1
- ss
Explanation: Another utility to investigate sockets.
Example:
ss -tuln
- ping
Explanation: Sends ICMP ECHO_REQUEST to network hosts.
Example:
ping -c 4 google.com
- traceroute
Explanation: Prints the route packets trace to a network host.
Example:
traceroute google.com
- netstat
Explanation: Displays network connections, routing tables, interface statistics.
Example:
netstat -tuln
- nmap
Explanation: Network exploration tool and security scanner.
Example:
nmap -p 1-65535 192.168.1.1
- tcpdump
Explanation: Dumps traffic on a network.
Example:
tcpdump -i eth0 port 80
- iptables
Explanation: Administration tool for IPv4 packet filtering and NAT.
Examples:
sudo iptables -L
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
- ifconfig
Explanation: Configures a network interface (older command).
Example:
ifconfig eth0
- iwconfig
Explanation: Configures a wireless network interface.
Example:
iwconfig wlan0
- hostname
Explanation: Shows or sets the system’s host name.
Examples:
hostname
hostname new-server-name
- dig
Explanation: DNS lookup utility.
Example:
dig google.com
- nslookup
Explanation: Queries Internet name servers interactively.
Example:
nslookup google.com
- route
Explanation: Shows / manipulates the IP routing table.
Example:
route -n
- mtr
Explanation: A network diagnostic tool combining ping and traceroute.
Example:
mtr google.com
- nc (netcat)
Explanation: Reads and writes data across network connections.
Examples:
nc -l 1234 # Listen on port 1234
nc 192.168.1.1 1234 # Connect to host on port 1234
- curl
Explanation: Transfers data from or to a server.
Example:
curl https://api.example.com
- wget
Explanation: Retrieves files using HTTP, HTTPS, and FTP.
Example:
wget https://example.com/file.zip
- arp
Explanation: Manipulates the system ARP cache.
Example:
arp -a
- ethtool
Explanation: Queries or controls network driver and hardware settings.
Example:
ethtool eth0
- rsync
Explanation: Efficiently transfers and synchronizes files.
Example:
rsync -avz /source/ /destination/
- top
Explanation: Displays and updates sorted information about processes.
Example:
top
- df
Explanation: Reports file system disk space usage.
Example:
df -h
Conclusion:
Mastering these Linux admin and networking commands is crucial for effective system management and troubleshooting. Regular practice and exploration of these commands will greatly enhance your Linux administration skills. Remember to always refer to the man pages (using the man
command) for detailed information on each command, as functionality may vary slightly between different Linux distributions and versions.
Note: Many of these commands, especially those related to system configuration and network settings, require root or sudo privileges to execute. Always use caution when running commands with elevated privileges, as they can significantly impact system operation.