Skip to content

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 -i

Check IP Address

bash
# Show IP address (modern method)
ip addr show

# Traditional method
ifconfig

# Only show IPv4 addresses
hostname -I

Install net-tools

bash
# Install net-tools package
sudo apt install net-tools

Check Hostname

bash
# Display hostname
hostname

# Display FQDN (Fully Qualified Domain Name)
hostname -f

# Check hosts file
cat /etc/hosts

Test Network Connectivity

bash
# Ping a destination
ping google.com

# Trace network path
traceroute google.com

# Check DNS resolution
nslookup google.com
dig google.com

Check Network Routes

bash
# Show routing table
route -n

# Modern command
ip route show

System Information

Check Ubuntu Version

bash
# Show Ubuntu release information
lsb_release -a

# Alternative method
cat /etc/os-release

# Kernel version
uname -r

Check System Resources

bash
# Show memory usage
free -h

# Check disk space
df -h

# Check CPU info
lscpu

Service Management

Check Running Services

bash
# List all services
systemctl list-units --type=service

# List only active services
systemctl list-units --type=service --state=running

Start/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_name

Enable/Disable Services at Boot

bash
# Enable service to start at boot
sudo systemctl enable service_name

# Disable service at boot
sudo systemctl disable service_name

Check 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_name

Open 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 :80

Scan 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.1

Check Firewall Status

bash
# Check UFW status
sudo ufw status

# Check iptables rules
sudo iptables -L

Finding Applications

Locate Applications

bash
# Find executable location
which application_name

# Find all related files
whereis application_name

# Detailed location search
locate application_name

Find 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_name

Install/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_name

User 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 username

Modify 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  # unlock

Add/Remove Groups

bash
# Create new group
sudo addgroup groupname

# Delete group
sudo delgroup groupname

Manage 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 groupname

Check 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 username

File Permissions and Attributes

View File Permissions

bash
# Show file permissions
ls -l filename

# Show with numeric permissions
stat -c "%a %n" filename

Change 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 filename

Special 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 filename

Setting Default Permissions

bash
# Display current umask
umask

# Set new umask (affects newly created files)
umask 022  # Gives 755 for directories, 644 for files