Linux tips and tricks

🎃 Empty a file from command line

cat /dev/null > file

🍄 Shutdown Linux Ubuntu computer

here are the commands available to poweroff (not halt) a computer:

sudo poweroff
sudo shutdown -h now
sudo shutdown -P now
sudo halt -p
sudo init 0

shutdown -P now = poweroff or halt -p

init 0 = runlevel 0 (shut down)

shutdown forcefully:

sudo poweroff -f

😼 Change sh to bash on Ubuntu

$ls -l `which sh`
/bin/sh -> dash

$sudo dpkg-reconfigure dash #Select "no" when you're asked
[...]

$ls -l `which sh`
/bin/sh -> bash

🐠 Crontab to Power Off computer

$ crontab -e
*/30 * * * * HOUR=$(date +%H); if [ $HOUR -ge 21 ] || [ $HOUR -le 7 ]; then echo "$(date): poweroff..." >> /tmp/log/poweroff.log && poweroff; fi

🍮 Remove grayed out input method menu item

$sudo apt install dconf-editor
$dconf-editor
# edit org.gnome.desktop.input-sources

🚜 How to cancel Update Manager downloading flashplugin-installer

ps aux | grep http

This will result in 2 or 3 lines with the second column of each line being the pid of the process if the process is doing its job

Kill this process by running:

kill -9 pid

😸 How to resume or abandon an apt dist-upgrade after connection reset

ps -aux | grep apt
kill -9 pid

Configure previously already installed packages:

dpkg --configure --pending

If you are unable to continue because the system is broken, you could try to fix it with apt:

apt --fix-broken install

🏈 Unable connect to wifi after upgrade to Ubuntu 18.04

#work around DNS resolv bug
systemctl stop systemd-resolved
sed -i 's/#DNS=/DNS=202.141.162.123 192.168.1.254/' /etc/systemd/resolved.conf

#sed -i 's/#Domains=/Domains=abc.domain.edu def.domain.edu' /etc/systemd/resolved.conf

systemctl start systemd-resolved
systemctl restart NetworkManager

results matching ""

    No results matching ""