linux
This is an old revision of the document!
Table of Contents
Linux
Popular Topics
Miscellaneous
Suppressing the Service Restart prompt for "apt install"
/etc/needrestart/needrestart.conf
$nrconf{verbosity} = 0;
$nrconf{restart} = 'a';
export DEBIAN_FRONTEND=noninteractive
export APT_LISTCHANGES_FRONTEND=none
export NEEDRESTART_MODE=a # default is "i"nteractive; change to "a"utomatic ; see: /etc/needrestart/needrestart.conf
export NEEDRESTART_SUSPEND=1
# echo 'libc6 libraries/restart-without-asking boolean true' | debconf-set-selections
sudo apt-get remove apt-listchanges --assume-yes --force-yes
sudo apt-get --force-yes -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" -fuyq install package-name-here
Upgrade to Ubuntu 24.04 LTS
sudo apt install -y ubuntu-release-upgrader-core # Ensure "Prompt=lts" in "/etc/update-manager/release-upgrades" (instead of "Prompt=normal") do-release-upgrade # Pass "-d" to upgrade before officially supported # apt dist-upgrade
Limiting Resources
mkdir /sys/fs/cgroup/myapp CPU_QUOTA=50 CPU_PERIOD=100 echo "$CPU_QUOTA $CPU_PERIOD" > /sys/fs/cgroup/myapp/cpu.max RAM_QUOTA="1024M" echo "$RAM_QUOTA" > /sys/fs/cgroup/myapp/memory.max cp /var/run/myappdb/myappd.pid /sys/fs/cgroup/myapp/cgroup.procs #rm -Rf /sys/fs/cgroup/myapp With tools: apt install -y cgroup-tools cgcreate -g cpu,memory:/myapp cgset -r cpy.max="50 100" myapp cgset -r memory.max="1024M" myapp cgclassify -g cpu,memory:myapp $(cat /var/run/myappdb/myappd.pid) cgexec -g cpu,memory:myapp /usr/bin/myappd --dbpath . #cgdelete -g cpu,memory:myapp systemd-run -u myappd -p CPUQuota=50% -p MemoryMax=1024M /usr/bin/myappd systemd-cgls --all systemd-cgtop /etc/systemd/system/myapp.slice [Slice] CPUQuota=50% MemoryMax=1024M systemctl edit --full myappd.service Slice=myapp.slice #Add to the [Service] section systemd-run -u myappd --slice=myapp.slice /usr/bin/myappd # To run with Docker docker run -d --name db --cgroup-parent=myapp.slice myappimg
ssh-copy-id
ssh-keygen -f key_file_name # To make it non-interactive (we cannot pass the StrictHostKeychecking so we direct the "yes") sshpass -p mypassword ssh-copy-id -i key_file_name.pub myuser@myserver <<< yes # ssh-copy-id doesn't directly support auth with another key # ...but it passes along options to ssh ssh-copy-id -i ~/.ssh/id_rsa.nondefault -o 'IdentityFile ~/vm-key' user@remote # This can also be done with ssh-agent eval $(ssh-agent -s) # Start the agent ssh-add ~/vm-key # Add the key to the agent ssh-copy-id -i ~/.ssh/id_rsa.nondefault user@remote eval $(ssh-agent -k) # Stop the agent
linux.1772392942.txt.gz · Last modified: by reddy
