Note: you'll want to set up pub-key ssh auth. Gives you a quick means of changing volume/tracks/etc for rhythmbox on a remote machine. E.g.: rc --next # Play next track rc --print-playing # Grab the name rc --volume-down rc --help
Prepending env LC_CTYPE=C fixes a problem with bad bytes in /dev/urandom on Mac OS X
Feel free to put this in your ~/.profile:
random(){ cat /dev/urandom | env LC_CTYPE=C tr -dc $1 | head -c $2; echo; }
Then use it to generate passwords:
random [:alnum:] 16
Or DNA sequences:
random ACGT 256
KDE apps expect certain variables to be set, and unfortunately pkexec doesn’t set them by default. So, by setting this alias, it becomes possible to run, e.g. “pkexec kate” or “pkexec dolphin” and it’ll actually run.
This command is suitable to use as application launching command for a desktop shortcut. It checks if the application is already running by pgrepping its process ID, and offer user to kill the old process before starting a new one. It is useful for a few x11 application that, if re-run, is more likely a mistake. In my example, x2vnc is an x11 app that does not quit when its connection is broken, and would not work well when a second process establish a second connection after the first broken one. The LC_ALL=C for xmesseng is necessary for OpenSUSE systems to avoid a bug. If you don't find needing it, remove the "env LC_ALL=C" part
setting gdb with this option / breakpoint before running the process will cause it to break whenever an memory allocation operation is not kosher.
Usage example: display output of a command running in the background at desired time
The example in details: report disk quotas and that backup process will start soon
In my /etc/crontab file I added following four lines for weekly automatic incremental backup:
.
52 13 * * 7 root mount /dev/sda3 /media/da2dc69c-92cc-4249-b2c3-9b00847e7106
.
53 13 * * 7 knoppix5 df -h >~/df.txt
.
54 13 * * 7 knoppix5 env DISPLAY=:0 /usr/bin/gedit ~/df.txt && wmctl -a gedit
.
55 13 * * 7 root /home/knoppix5/rdiff-backup.sh
.
line one: as root mount media for backup on Sunday 13:52
line two: as user knoppix5 write out to text file in home directory the free space of all mounted disks on Sunday 13:53
line three: in front of you open and display a very simple text editor (I prefer gedit) with content of previously reported disk usage at Sunday 13:54
wmctl -a gedit means (from the manual):
-a Switch to the desktop containing the window , raise the window, and give it focus.
line four: as root run incremental backup script rdiff-backup.sh as root on Sunday 13:54
.
my rdiff-backup.sh, with root permissions backups in short time (writes only changes from the last backup) the etire linux system (except excluded - i.e. you don't want backup recursively your backup disk), looks like this (Show sample output):
Show Sample Output
From a local node, retrieve the date from server A and set that time on server B. When ntpd is not an option and you need to get closest clock sync between two nodes Replace SRC_SRV with yout source server and DST_SRV with your destination server. You must have ssh access to both and sudo access to the the destination to set the date. Show Sample Output
Can't see it here, but the non-breaking space is highlighted :)
Of course,
cat -t -e
achieves something similar, but less colourful.
Could add more code points from https://en.wikipedia.org/wiki/Space_%28punctuation%29#Spaces_in_Unicode
Show Sample Output
Every 20 minutes ping host with IP address 192.168.0.14. If it's not 'alive' or not reachable, then display something eye-catching (here xeyes) on the desktop.
Hint for newbies: edit crontab with
crontab -e
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: