System Configuration

Change System Hostname

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 1. Set the hostname
sudo hostnamectl set-hostname new_name

# 2. Update hostname file
sudo vim /etc/hostname
# Replace old name with new_name

# 3. Update hosts file
sudo vim /etc/hosts
# Replace old name with new_name in the line:
# 127.0.1.1 old_name

# 4. Apply changes
sudo reboot

# 5. Verify changes
hostnamectl

Package Management

APT Commands

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Update package list and upgrade system
sudo apt update
sudo apt upgrade

# Install packages
sudo apt install package_name

# Remove packages
sudo apt remove package_name
sudo apt purge package_name  # Remove package and config
sudo apt autoremove         # Remove unused dependencies

# Search packages
apt search package_name
apt show package_name

# List installed packages
apt list --installed
dpkg -l | grep package_name

Java Installation and Management

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Install Java
sudo apt install openjdk-17-jdk-headless
sudo apt install openjdk-11-jdk-headless  # Alternative version

# List installed Java versions
sudo update-alternatives --list java

# Configure default Java version
sudo update-alternatives --config java
sudo update-alternatives --config javac

# Remove Java
sudo apt purge openjdk-*
sudo apt autoremove

# Check Java version
java -version
javac -version

User Management

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Create new user
sudo adduser username

# Add user to sudo group
sudo usermod -aG sudo username

# Switch user
su - username

# Change password
sudo passwd username

# Delete user
sudo userdel -r username  # -r removes home directory

Network Configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Show network interfaces
ip addr
ifconfig

# Configure network interface
sudo vim /etc/netplan/01-netcfg.yaml

# Apply network changes
sudo netplan apply

# Show network status
networkctl status

# Configure firewall
sudo ufw status
sudo ufw enable
sudo ufw allow 22/tcp  # Allow SSH

Service Management

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# View service status
systemctl status service_name

# Start/Stop services
sudo systemctl start service_name
sudo systemctl stop service_name

# Enable/Disable service at boot
sudo systemctl enable service_name
sudo systemctl disable service_name

# Restart service
sudo systemctl restart service_name

# View service logs
journalctl -u service_name

System Monitoring

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# System resources
top
htop
free -h
df -h

# System logs
tail -f /var/log/syslog
journalctl -f

# Process monitoring
ps aux | grep process_name
pgrep process_name

Storage Management

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# List block devices
lsblk
fdisk -l

# Mount device
sudo mount /dev/sda1 /mnt/mydrive

# Auto-mount (edit fstab)
sudo vim /etc/fstab

# Check disk usage
du -sh /path
ncdu /path  # Interactive disk usage

System Updates

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Update package list
sudo apt update

# Upgrade packages
sudo apt upgrade
sudo apt dist-upgrade

# Auto-remove unused packages
sudo apt autoremove

# Clean package cache
sudo apt clean

Security

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Update SSH configuration
sudo vim /etc/ssh/sshd_config

# View auth logs
sudo tail -f /var/log/auth.log

# Check listening ports
sudo netstat -tulpn
sudo ss -tulpn

# Configure firewall rules
sudo ufw status
sudo ufw allow from 192.168.1.0/24
sudo ufw deny 23

Performance Tuning

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# View system limits
ulimit -a

# Modify system limits
sudo vim /etc/security/limits.conf

# View running processes
ps aux --sort=-%cpu  # Sort by CPU usage
ps aux --sort=-%mem  # Sort by memory usage

# Monitor I/O operations
iostat
iotop

Backup and Recovery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create backup
sudo tar -czf backup.tar.gz /path/to/backup

# Restore from backup
sudo tar -xzf backup.tar.gz -C /path/to/restore

# Create system snapshot (if using LVM)
sudo lvcreate -L10G -s -n snap01 /dev/vg0/root

# Rsync backup
rsync -av --progress /source /destination

Troubleshooting

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Check system logs
journalctl -xe
tail -f /var/log/syslog

# Check disk errors
sudo fsck /dev/sda1

# Memory issues
free -h
vmstat 1

# CPU issues
top
mpstat 1

# Network issues
ping google.com
traceroute google.com
mtr google.com