Skip to content

nemati-ceo/linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Ubuntu Optimization: Updating, Swap, and Disabling Unnecessary Services


🛠 Updating Ubuntu

sudo apt update -y
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y

all in one line

sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y

📋 Check Current Swap Usage

sudo swapon --show

Check System RAM

free -h

🧊 Create Swap File

sudo fallocate -l 8G /swapfile
# OR if fallocate is unsupported:
sudo dd if=/dev/zero of=/swapfile bs=1M count=8192

🔒 Set Permissions

sudo chmod 600 /swapfile

🔧 Configure Swap

sudo mkswap /swapfile

🚀 Activate Swap

sudo swapon /swapfile

🔄 Make Swap Permanent

sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

📝 Adjust Swappiness (Optional)

sudo nano /etc/sysctl.conf

Add or modify:

vm.swappiness=10

Apply:

sudo sysctl --system

📊 Monitor Swap Usage

htop
free -h

🔌 Identify Running Services

systemctl
service --status-all
chkconfig --list

🔍 Review Services to Stop or Disable


📴 Disable & Stop Services (Systemd)

Disable at boot:

sudo systemctl disable <service-name>

Stop immediately:

sudo systemctl stop <service-name>

📴 Disable & Stop Services (SysVinit)

Disable at boot:

sudo update-rc.d -f <service-name> remove

Stop immediately:

sudo service <service-name> stop

🔁 Verify Services are Stopped

systemctl status <service-name>
service <service-name> status

📋 Review Impact

✅ Make sure no critical services are stopped.


🔄 Optional: Reboot

sudo reboot

📈 Monitor Performance

✅ Check CPU, memory, and disk usage after changes:

htop
free -h
df -h

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •