Note: A lot of these commands are unique and special to Debian or Ubuntu distributions. There are typically alternate forms of these expressions for other distributions.
uname -r
More detailed information
uname -a
lsb_release -a
List all kernel images installed:
dpkg --list | grep linux-image
how to run python scripts: https://www.geeksforgeeks.org/how-to-schedule-python-scripts-as-cron-jobs-with-crontab/
create a new python script
#!/usr/bin/env python3
import time
import os
with open(os.path.expanduser('~/crontest.txt'),'a') as f:
f.write(time.ctime()+'\n')
chmod +x test.py
crontab -e
# m h dom mon dow command
* * * * * $HOME/test.py
ctrl-h hides and shows “dot” files in nautilus like .config
or .ssh/
sudo reboot now
sudo shutdown now
gnome-session-quit
From https://fostips.com/lid-close-action-ubuntu-21-04-laptop/
edit /etc/systemd/logind.conf
to configure power options such as lid closing opening,
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
systemctl restart systemd-logind.service
/bin /boot /etc /home /lib /lib64 /opt /root /sbin /usr /var
https://askubuntu.com/questions/222326/which-folders-to-include-in-backup
For example, if “Image Viewer” is in the name of the icon:
find / -name '*.desktop' -exec grep -H 'Image Viewer' {} \; 2>/dev/null
derived from here: https://askubuntu.com/questions/1160737/how-to-find-desktop-file-location-for-a-particular-application:
Some default locations listed here: https://askubuntu.com/questions/1146307/which-desktop-files-belong-where:
/usr/share/applications/gnome-terminal.desktop
~/.local/share/applications/gnome-terminal.desktop
~/.config/gnome-panel/launchers/gnome-terminal.desktop
~/.gnome/apps/gnome-terminal.desktop
Files can be stuck in ~/.local/share/Trash/expunged when you delete from Nautilus a folder that belongs to you, but contains files which are belong to another user, and it is tricky for Nautilus to handle this situation correctly. To delete them try to use:
sudo -i
rm -rv /home/<desired_user_name>/.local/share/Trash/expunged/*
exit
see this page for more links
use pkexec to do things you would normally do with sudo, like
pkexec cp /path/to/sudo/backup /etc/sudoers
great advice from here: https://askubuntu.com/questions/438123/accidentally-deleted-etc-sudoers-file
unset HISTFILE && exit
or
history -c && history -w && exit
To find services
sudo systemctl list-units --type=service
To reload the service daemon
sudo systemctl daemon-reload
other common functions:
sudo systemctl edit <servicename>
sudo systemctl enable <servicename>
sudo systemctl start <servicename>
sudo systemctl status <servicename>
sudo systemctl stop <servicename>
sudo systemctl disable <servicename>
sudo systemctl reload <servicename>
sudo systemctl restart <servicename>