From Athenaeum
Revision as of 08:34, 20 April 2019 by James8562 (talk | contribs)

Jump to: navigation, search

Random Info

  • To get the key-id and fingerprint of a gpg key use: gpg --with-fingerprint /path/to/gpgfile
  • Reset XFCE panels: xfce4-panel --quit ; pkill xfconfd ; rm -rf ~/.config/xfce4/panel ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml ; xfce4-panel;
  • Sys load explained here

Creating a Template

  1. Install open-vm-tools or OSP tools
  2. Clean the package cache
    # aptitude clean or yum clean all or pacman -Scc
    # rm -rvf /var/lib/apt/lists/*
  3. Remove ssh host keys
    # rm -rfv /etc/ssh/ssh_host_*
  4. If the server has sssd installed remove its cache
    service sssd stop; rm -rvf /var/lib/sss/db/*
  5. Remove any unique strings from the network config file or udev rules.
  6. Clear all system logs
    for logs in `find /var/log -type f`; do > $logs; done
    find /var/log -type f -iname "*.log.[0-9]" -exec rm -fv {} \;
    find /var/log -type f -iname "*.gz" -exec rm -fv {} \;
  7. Clear the temp directory
    rm -rvf /tmp/*
  8. Delete the Satellite ID (If Present)
    rm -fv /etc/sysconfig/rhn/systemid
  9. Delete previous bash history
    rm -fv .bash_history
  10. Delete current bash history
    history -c
  11. Shutdown and create the template
    shutdown -h now

Random Commands

Set safe permissions on directories and files:

find /var/www/cdn/ -type d -exec chmod 755 {} \;
find /var/www/cdn/ -type f -exec chmod 644 {} \;

Determine disk usage and sort by highest

du -h --max-depth=2 --exclude=/proc --exclude=/run --exclude=/sys --exclude=/dev / | sort -h -r

Get memory info

lshw -short -C memory | grep DIMM

Get port stats

netstat -ant | grep 10080 | awk '{print $6}' | sort | uniq -c | sort -n

Disk Related

  • To copy one partition to another partition
partclone.ext4 -N -b -s /dev/sdd2 -O /dev/sde2

Resize a Disk

  1. echo 1 > /sys/class/block/sdb/device/rescan
  2. parted /dev/sdb
    1. `print` to confirm the size increased
    2. resizepart
  3. resize2fs /dev/sdb1


How to view swap statistics

vmstat 1 15

In certain cases the kernel will use swap even when there is ram left. This is determined by the swappiness value specified in /etc/sysctl.conf. By default Ubuntu sets this to 60 which means when 60 of ram is used for long periods it will start swapping. Setting this value to 0 will effectively disable swap except in extreme cases. You can check the swappiness value with this command:

cat /proc/sys/vm/swappiness

You can change this value by editing /etc/sysctl.conf and adding or changing the value of vm.swappiness = X. After making changes you will need to reboot.


After something has destroyed your boot entry you can do one of two things.
1. mount /dev/nvme0n1p1 /boot/efi/ and then run refind-install
2. mount /dev/nvme0n1p1 /boot/efi/ and then run refind-mkdefault