Linux administration
last updated 2019-11
reset Compiz to default settings
gconftool-2 --recursive-unset /apps/compiz
and restart
enable and start sendmail
if you're getting "stat=Deferred: Connection refused by [127.0.0.1]" log messages from sendmail, try adding the following line to your /etc/mail/sendmail.mc file:
DAEMON_OPTIONS(`Port=smtp, Addr=127.0.0.1, Name=MTA')
under the "General defines" section
also, make sure the sendmail daemon is running:
ps aux | grep sendmail
if not, run it using
sendmail -bd -q1m
where the -q parameter chooses how often the email queue's new messages should be processed (here, every minute)
to test if this all works, use
echo -e "Subject: Hello\nTesting the mailer..." | sendmail -f [email protected] [email protected]
the advantage of sendmail over mail is that the from address need not be a valid email address… well… advantage?
installing sendmail
on most systems, sendmail comes as a package, and typically gets started during the boot from the init.d/rc.d scripts
if you want/need to start sendmail manually, or it has died, use
sendmail -bd
or, for debugging purposes
sendmail -bD
that will start the sendmail daemon, but will keep it in the foreground, so you can see its output
sending emails using sendmail
the easiest way is to create the message file with all the necessary definitions, e.g.
To: Mr. Recipient <[email protected]>
Subject: This is a fine example of a subject
Date: 2011-08-15 20:00:00 +0000
From: Mr. Sender <[email protected]>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
User-Agent: My email service
The body of the message comes here, after a single blank line...
and then feed this file to sendmail:
sendmail -t < message_file.txt
find and mark bad blocks
to test partition /dev/sdXN (such as /dev/sda1) for bad blocks simply run:
$ sudo badblocks -sv /dev/sdXN > ~/bad-blocks-list
$ fsck -l ~/bad-blocks-list /dev/sdXN
using TLP to optimize battery lifetime
# check TLP status and system info
$ sudo tlp-stat -s
--- TLP 1.1 --------------------------------------------
+++ System Info
[...]
+++ TLP Status
State = enabled
Last run = 09:13:49, 403 sec(s) ago
Mode = battery
Power source = battery
# get battery information
$ sudo tlp-stat -b
--- TLP 1.1 --------------------------------------------
+++ Battery Status
/sys/class/power_supply/BAT0/manufacturer = CPT-COS
/sys/class/power_supply/BAT0/model_name = L17C4PB0
/sys/class/power_supply/BAT0/cycle_count = (not supported)
/sys/class/power_supply/BAT0/energy_full_design = 45520 [mWh]
/sys/class/power_supply/BAT0/energy_full = 44540 [mWh]
/sys/class/power_supply/BAT0/energy_now = 37370 [mWh]
/sys/class/power_supply/BAT0/power_now = 20057 [mW]
/sys/class/power_supply/BAT0/status = Discharging
Charge = 83.9 [%]
Capacity = 97.8 [%]
# CPU temperature and fan speed
$ sudo tlp-stat -t
# CPU info
$ sudo tlp-stat -p
# warnings
$ sudo tlp-stat -w
Ubuntu, Debian and GNOME
restrict the GNOME app switcher to the current workspace
gsettings set org.gnome.shell.app-switcher current-workspace-only true
restore or undelete a (config) file or directory
# 1. check what package file or folder belongs to
$ dpkg -S /path/my.conf
# 2.a replace the config file; if it exists, will offer diff
$ sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall <package-name>
# 2.b restore the directory
$ sudo apt-get -o Dpkg::Options::="--force-confask" install --reinstall $(dpkg -S /etc/some/directory | sed 's/,//g; s/:.*//')
increase the number of inotify watchers
$ cat /proc/sys/fs/inotify/max_user_watches
8192
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p
$ cat /proc/sys/fs/inotify/max_user_watches
524288
up-to-date versions of packages
Python
Ubuntu 18.04 ships with Python 3.6, but Amazon Linux uses 3.7, so e.g. to use and build Lambda layers and match those against packages you deploy, you need to install 3.7:
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.7 python3.7-venv
since these do not override the default python and python3 links (and better not!), you should create corresponding venvs as:
$ python3.7 -m venv [env-dir]
npm, node.js, etc.
the default apt npm version is awfully outdated
update - available as a snap as well, no need to add apt sources - https://node.dev/node-binary
add the NodeSource APT repo - setup_lts.x gives the current LTS, for a specific version, e.g. 22.x, change it to setup_22.x
$ curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
$ sudo apt update
$ sudo apt install nodejs