Ubuntu System Administration Guide
Network Troubleshooting
Check Network Interface Information
bash
# Show all network interfaces
ip a
# Show specific interface details
ip a show eth0
# Check network interface statistics
netstat -iCheck IP Address
bash
# Show IP address (modern method)
ip addr show
# Traditional method
ifconfig
# Only show IPv4 addresses
hostname -IInstall net-tools
bash
# Install net-tools package
sudo apt install net-toolsCheck Hostname
bash
# Display hostname
hostname
# Display FQDN (Fully Qualified Domain Name)
hostname -f
# Check hosts file
cat /etc/hostsTest Network Connectivity
bash
# Ping a destination
ping google.com
# Trace network path
traceroute google.com
# Check DNS resolution
nslookup google.com
dig google.comCheck Network Routes
bash
# Show routing table
route -n
# Modern command
ip route showSystem Information
Check Ubuntu Version
bash
# Show Ubuntu release information
lsb_release -a
# Alternative method
cat /etc/os-release
# Kernel version
uname -rCheck System Resources
bash
# Show memory usage
free -h
# Check disk space
df -h
# Check CPU info
lscpuService Management
Check Running Services
bash
# List all services
systemctl list-units --type=service
# List only active services
systemctl list-units --type=service --state=runningStart/Stop/Restart Services
bash
# Start a service
sudo systemctl start service_name
# Stop a service
sudo systemctl stop service_name
# Restart a service
sudo systemctl restart service_name
# Reload service configuration
sudo systemctl reload service_nameEnable/Disable Services at Boot
bash
# Enable service to start at boot
sudo systemctl enable service_name
# Disable service at boot
sudo systemctl disable service_nameCheck Service Status
bash
# Display service status
sudo systemctl status service_name
# Check if service is active
sudo systemctl is-active service_name
# Check if service is enabled at boot
sudo systemctl is-enabled service_nameOpen Ports and Connections
Check Open Ports
bash
# Show all listening ports
sudo netstat -tuln
# Alternative with ss command
sudo ss -tulpn
# Check specific port
sudo lsof -i :80Scan Ports with nmap
bash
# Install nmap
sudo apt install nmap
# Scan localhost
nmap localhost
# Scan specific host
nmap 192.168.1.1
# Scan a specific port range
nmap -p 1-1000 192.168.1.1Check Firewall Status
bash
# Check UFW status
sudo ufw status
# Check iptables rules
sudo iptables -LFinding Applications
Locate Applications
bash
# Find executable location
which application_name
# Find all related files
whereis application_name
# Detailed location search
locate application_nameFind Installed Packages
bash
# List all installed packages
dpkg -l
# Search for specific package
dpkg -l | grep package_name
# Check if package is installed
apt list --installed | grep package_nameInstall/Remove Applications
bash
# Install application
sudo apt install package_name
# Remove application
sudo apt remove package_name
# Remove application and configuration
sudo apt purge package_nameUser and Group Management
Add/Remove Users
bash
# Add a new user
sudo adduser username
# Add user with minimal setup
sudo useradd username
# Delete user
sudo deluser username
# Delete user and their home directory
sudo deluser --remove-home usernameModify Users
bash
# Change user password
sudo passwd username
# Modify user properties
sudo usermod -options username
# Lock/unlock user account
sudo usermod -L username # lock
sudo usermod -U username # unlockAdd/Remove Groups
bash
# Create new group
sudo addgroup groupname
# Delete group
sudo delgroup groupnameManage Group Membership
bash
# Add user to group
sudo usermod -aG groupname username
# Add user to multiple groups
sudo usermod -aG group1,group2 username
# Remove user from group
sudo deluser username groupnameCheck User/Group Information
bash
# Show user info
id username
# List all users
cat /etc/passwd
# List all groups
cat /etc/group
# Show groups a user belongs to
groups usernameFile Permissions and Attributes
View File Permissions
bash
# Show file permissions
ls -l filename
# Show with numeric permissions
stat -c "%a %n" filenameChange File Permissions
bash
# Change permissions (symbolic method)
chmod u+x filename # Give owner execute permission
chmod g+w filename # Give group write permission
chmod o-r filename # Remove read permission from others
chmod a+r filename # Give read permission to all
# Change permissions (numeric method)
chmod 755 filename # rwx for owner, rx for group and others (755)
chmod 644 filename # rw for owner, r for group and others (644)Change File Ownership
bash
# Change file owner
sudo chown username filename
# Change file group
sudo chgrp groupname filename
# Change owner and group
sudo chown username:groupname filename
# Change recursively for directories
sudo chown -R username:groupname directory/Make Files Executable
bash
# Add execute permission
chmod +x filename
# For a script to be executed by owner only
chmod u+x filenameSpecial File Attributes
bash
# Display file attributes
lsattr filename
# Make file immutable (cannot be modified/deleted)
sudo chattr +i filename
# Remove immutable attribute
sudo chattr -i filename
# Append-only mode (can only add content)
sudo chattr +a filenameSetting Default Permissions
bash
# Display current umask
umask
# Set new umask (affects newly created files)
umask 022 # Gives 755 for directories, 644 for files