echo "This will go into the body of the mail." | mail -s "Hello world" firstname.lastname@example.orgOr, if you wish to send to a remote SMTP server, install the heirloom-mailx package and:
mailx -s "some subject" email@example.com
some random body text
This also works well in a cron job.
This is particularly interesting in the context of RetroShare, and the prevention of Man-In-The-Middle (MITM) attacks:
gpg --with-fingerprint file-containing-public-key.rsc
Both sides of the key exchange should generate a fingerprint for both keys, and then compare the fingerprints over another communication channel (definitely NOT using RetroShare!).
So my laptop received a pretty hard knock while being turned on, and a part of the disk was destroyed. Having gotten everything I could off the thing (I did not lose anything important) my thoughts now turn to "can I fix it". It is, after all, a newish 500G disk with a non-trivial price tag. Let's try:
First put the thing in a USB enclosure, hook it up, and use your favorite partition editor to divide it into several partitions (I chose five 100G partitions). Then start testing the partitions one by one, with a read/write test, ie.:
e2fsck -k -c -c /dev/sdb1
dumpe2fs -b /dev/sdb1
Remove any partitions that have errors. Then install Debian in the ones that are left, using LVM to stitch them all together. Wish me luck....
Especially when the page runs off the screen and a screenshot just will not do the job:
wkhtmltopdf http://blog.langex.net/ /tmp/webpage.pdf
And really useful for those of us whose primary CV is a web page.
Recently seen on Amazon AWS' "Linux" distribution: mosh would not install because of a broken dependency on libprotobuf. This was a soluble problem, because an installable version of mosh existed in the epel repo, but yum insisted on installing the most recent version from the AWS repo, even though it was broken. The fix is to restrict yum to consider only packages from epel, and ignore all other repos:
yum --disablerepo "*" --enablerepo "epel" install protobuf mosh
Suppose, for instance, you want to remove all i386 packages from an amd64 install:
apt-get remove $(wajig list-installed | grep i386)
This displays the Unix time in seconds:
$ date +%s
This converts time in seconds 1190000000 to a readable date/time:
$ date -d @1190000000
This is actually more of a scripting thing, but what is a bash script except a collection of command lines....
To send a bit of text to /var/log/syslog:
logger Hello logging world!!
If you wish the output of a particular line in the script to be logged:
mysql -V | logger
will send the MySQL version to syslog. If you wish to also capture errors (STDERR) output, this will do it:
mysql < /path/to/a/sql/script.sql 2>&1 | logger
will send both script and error output to syslog.
To find out what groups a user belongs too:
The easiest way to add a group to a user:
adduser username groupname
However, this does not work on all Linux distributions (CentOS?). A more general method:
usermod -a -G groupname username
When unmounting a partition / device, for example
One might encounter a "busy" error, which indicates some process is still using the partition in question. To perhaps find out who / what is using the partition and do something about it:
lsof | grep '/media/thumb'
And as a last resort, kill all process accessing the partition:
fuser -km /media/thumb