Skip to content

Instantly share code, notes, and snippets.

@aktau
Last active December 17, 2015 06:19
Show Gist options
  • Save aktau/5564427 to your computer and use it in GitHub Desktop.
Save aktau/5564427 to your computer and use it in GitHub Desktop.
useful shell scripts
#!/bin/sh
set -e
set -u
# find menu entries
grep ^menuentry /boot/grub/grub.cfg| cut -d "'" -f2
# adjust it
sudo sed -i 's/^\(GRUB_DEFAULT\)\(.*\)/\1="Debian GNU\/Linux, with Linux 3.2.0-4-amd64"/' /etc/default/grub
# regenerate
sudo update-grub
#!/bin/bash
set -u
id=${1:-"0"}
echo "looking for $id"
# find menu entries
if grep ^menuentry /boot/grub/grub.cfg | cut -d "'" -f2 | grep -q "$id"
then
echo "found $id"
# adjust it
sudo sed -i 's@^\(GRUB_DEFAULT\)\(.*\)@\1="'"$id"'"@' /etc/default/grub && sudo update-grub
else
echo "not found $id"
exit 1
fi
# 10 most memory hungry processes, can be useful to restart some leaking processes
# could restart the every hungry chromium...
ps -eo rss,%mem,pid,cmd --width 100 --sort=-rss | head -10
# for general observations
free
#!/bin/sh
sudo service redis-server stop
sudo service mongodb stop
#sudo service apache2 stop
sudo service td-agent stop
sudo service wicd stop
sudo service php5-fpm stop
sudo service nginx stop
sudo service atop stop
sudo service cron stop
sudo service ntp stop
sudo service acpid stop
sudo service saned stop
sudo service rpcbind stop
sudo service nfs-common stop
sudo service dbus stop
sudo service atd stop
mount -t debugfs none /sys/kernel/debug
while true
do
tail -n 1 /sys/kernel/debug/dri/0/i915_gem_gtt
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment