Skip to content

Instantly share code, notes, and snippets.

@okv
Last active January 18, 2019 08:52
Show Gist options
  • Save okv/6387290 to your computer and use it in GitHub Desktop.
Save okv/6387290 to your computer and use it in GitHub Desktop.

Disable linux account

Lock, expire and set no login shell for account:

(export user="someuser" && usermod -L "$user" && chage -E0 "$user" && usermod -s /sbin/nologin "$user" && echo "User $user is locked")

unlock:

(export user="someuser" && usermod -U "$user" && chage -m 0 -M 99999 -I -1 -E -1 "$user" && usermod -s /bin/bash "$user" && echo "User $user is unlocked")

details

Use swap only when 5% of memory left

# become root
sudo -s
# do the job
sysctl vm.swappiness=5 && echo "vm.swappiness=5" >> /etc/sysctl.conf

Remove ALL kernel versions except the current

sudo apt-get purge `dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | tr "\\n" " "`

Find out if the OS is running in a virtual environment

dmidecode -t system|grep 'Manufacturer\|Product'

other methods and details

Basic build tools for centos

yum install gcc-c++ make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment