Wednesday, 17 December 2014

How to : Disable BeagleBone USR Heartbeat LED lights

The BeagleBone Black by default has 4 User LED's USR0, USR1, USR2 and USR3 that light up to show the board is alive. While useful it can be annoying.

There are 4 sub directories under /sys/class/leds which allow you to configure the LED behaviour. There is one directory per LED. Within each sub directory a trigger file details what triggers the LED e.g.

# cat /sys/class/leds/beaglebone\:green\:usr0/trigger
none nand-disk mmc0 mmc1 timer oneshot [heartbeat] backlight gpio cpu0 default-on transient

The [heartbeat] is what is showing the board is alive. This can be disabled via :

# echo none > /sys/class/leds/beaglebone\:green\:usr0/trigger
# echo none > /sys/class/leds/beaglebone\:green\:usr1/trigger
# echo none > /sys/class/leds/beaglebone\:green\:usr2/trigger
# echo none > /sys/class/leds/beaglebone\:green\:usr3/trigger

To light up the LED use the brightness file.

Turn USR0 on

# echo 1 > /sys/class/leds/beaglebone\:green\:usr0/brightness

Turn USR0 off

# echo 0 > /sys/class/leds/beaglebone\:green\:usr0/brightness


The LEDs will be reset on after reboot which is useful for troubleshooting. The /sys directory on Linux is a RAM based File system. For ease you could create a simple bash script to run as the last file on boot.

# cat
echo none > /sys/class/leds/beaglebone\:green\:usr0/trigger
echo none > /sys/class/leds/beaglebone\:green\:usr1/trigger
echo none > /sys/class/leds/beaglebone\:green\:usr2/trigger
echo none > /sys/class/leds/beaglebone\:green\:usr3/trigger

Tuesday, 16 December 2014

BeagleBone Black Debian image initial steps

This article details initial steps of a BeagleBone Black with a Debian image. For this setup I am using a 5V adapter for power and connecting the Ethernet port to my local LAN.

  • With power and Ethernet connected the BeagleBone is set to automatically run DHCP. You can ping the hostname of 'beaglebone' to show the connectivity

$ ping beaglebone
PING beaglebone.lan ( 56(84) bytes of data.
64 bytes from beaglebone.lan ( icmp_seq=1 ttl=64 time=0.964 ms
64 bytes from beaglebone.lan ( icmp_seq=2 ttl=64 time=0.630 ms

  • Next ssh as root (there is no password set)

  • Set a password for root :

# passwd

  • Update to the latest builds

# apt-get update
# apt-get upgrade

  • Set the correct Timezone
# dpkg-reconfigure tzdata

  • Confirm correct date

# date

  • Check that the web server is listening on port 80

# netstat -an | grep -i 80
tcp6 0 0 :::8080 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN

  • In a web browser (not IE) open the IP address of your Beaglebone to display the default page
  • Enjoy your Beaglebone!

Monday, 15 December 2014

How to : Delete files securely using shred from Nemo

The Linux command line tool shred is a fantastic way to securely remove files. It can be used from the command line e.g.

$ shred --force --remove --verbose --zero examplefile3
shred: examplefile3: removing
shred: examplefile3: renamed to 000000000000
shred: 000000000000: renamed to 00000000000
shred: 00000000000: renamed to 0000000000
shred: 0000000000: renamed to 000000000
shred: 000000000: renamed to 00000000
shred: 00000000: renamed to 0000000
shred: 0000000: renamed to 000000
shred: 000000: renamed to 00000
shred: 00000: renamed to 0000
shred: 0000: renamed to 000
shred: 000: renamed to 00
shred: 00: renamed to 0
shred: examplefile3: removed


  • --force : change permissions to allow writing if necessary
  • --remove : truncate and remove file after overwriting
  • --verbose : show progress
  • --zero : add a final overwrite with zeros to hide shredding

The default is to overwrite the file 3 times but you can override this with –iterations=N, setting N to be the number of iterations.

Its useful to be able to quickly remove files securely using the File manager for Cinnamon Nemo. First its useful to review the Nemo Actions sample file :

$ vim /usr/share/nemo/actions/sample.nemo_action

Define the settings you require e.g.

$ cat /usr/share/nemo/actions/shred.nemo_action
[Nemo Action]
Name=Shred file
Comment=securely delete a file
Exec=/usr/bin/shred --force --remove --verbose --zero %F

  • Start nemo, right click on file and select 'Shred file'

    Note – This method will only work if the file name does not contain any spaces

How to : Password protect a zip file on Linux

Its useful to quickly password either one or a number of files on Linux. For example to transit some files between sites on a USB drive. The encrypt option on the zip command line tool will encrypt the contents of the zip archive using a password which is entered on the terminal in response to a prompt

Note : The Zip encryption is not very strong and could be cracked so use with caution

  • To encrypt a single file :

$ zip --encrypt examplefile1
Enter password:
Verify password:

  • To encrypt a multple files :

$ zip --encrypt examplefile1 examplefile2 examplefile3
Enter password:
Verify password:

  • Tu uncompress the zip file :

$ unzip
[] examplefile1 password:

Sunday, 20 July 2014

vrms (Virtual Richard M. Stallman)

I was intrigued by the sound of the vrms (Virtual Richard M. Stallman) program when I was surfing the web. It analyses the packages you have installed on your Linux machine and reports all of those that are non free. Originally developed for Debian you can get it on Arch from the AUR. If you use 'packer' you can simple install with :

$ packer -S vrms-arch

The program when run enumerates non-free packages which officially is "under licenses not considered by OSI, FSF, and/or the DFSG to be Free Software".

More info on the license categorization is found via

$ vi /usr/lib/python3.4/site-packages/vrms_arch/

List non-free packages and count 'ambiguously licensed packages that vrms cannot certify.'

$ vrms

Check all packages in locally synced package repositories (does not and cannot include the AUR), not just locally installed packages:

 $ vrms -g

The caveats with this method in Arch are because many packages in Arch, both free and non-free, use custom as the license field value. This means that it does not use an exact copy of one of the licences includes in the core licences packages which you can view under :

$ ls /usr/share/licenses/common/

Some common licenses like BSD and MIT are not included in the common licenses packages as they require to be edited for a specific project.

Desite these cavets I found it a useful tool to run on my various Arch systems!

Vim Awesome a great way to find vim plugins

Vim is a great text editor with many plugins that have been developed over the years and continue to be developed. One issue I have found is that its difficult to keep track of plugins. Fortunately there is now a great site called that makes it easy. The data comes from GitHub, and user submissions.

The entries are categorised on the site so you can find plugins in areas you are interested in.

The site also displays the star rating from GitHub as well as the number of GitHub users so you can get a good idea of how well used and thought of the plugin is.

Wednesday, 16 July 2014

Combine bash history across multiple terminals

I use tmux (and many people also use screen) for multiple terminals. On slight down side is that by default the history command does not remember the commands between sessions on the same server. After some research and experimenting I found the following works really well in my .bashrc :

export HISTFILE=~/.bash_history
export HISTFILESIZE=500000
export HISTSIZE=500000

export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
export PROMPT_COMMAND="history -n;
history -w;history -c;history -r;$PROMPT_COMMAND"

Using 'Ctrl + R' will have the previous entries.

Note - if you are on session A run a command and move to session B you must either just press enter or another command before the entry in session A appears

Here is each line with some comments

  • Define where the history file is saved
export HISTFILE=~/.bash_history
  • How many commands to save in the HISTFILE
export HISTFILESIZE=500000
  • How many commands to save in the current session
export HISTSIZE=500000
  • Do not save duplicate commands and erase any previous duplicates
export HISTCONTROL=ignoredups:erasedups
  • How the history list is written to the HISTFILE. The '-s' option sets the option to append the history list of the current session to HISTFILE
shopt -s histappend
  • Clear current value of PROMPT_COMMAND
  • Contents of PROMPT_COMMAND are run just before Bash displays a prompt. This will save and reload the history after every command
  •  -n : Append the new history lines
  •  -w : Write history which will cause 'erasedups' to occur
  •  -c : Clear the history list
  •  -r : read the current history file 
export PROMPT_COMMAND="history -n;history -w;history -c;history -r;$PROMPT_COMMAND"

 Hope you find this as useful as I have :)