Tag Archives: Shell

Save a list of installed packages on Ubuntu / Debian

In case your laptop crashes during your thesis writing it would be nice to have a list of which packets have been installed.

In Ubuntu / Debian or other some other distros there is a tool called dkpg which offers a small command that can be very helpful:

dpkg --get-selections | grep -v deinstall

Saving that list in your backup routine (e.g. of your /home/ dir) every hour using crontab (linux scheduled tasks)

crontab -e
#follow the dialog and add this line to your crontab
0 1 * * * dpkg --get-selections | grep -v deinstall > ~/packages.txt

Set vim filetype by its file extension

For my project I am constantly edition ROS .launch files, which are some kind of xml.

If I want to use syntax highlighting for better readability, I used to type :set filetype=xml . Which works, but gets kinda annoying in case you’ve got to type it multiple times a day.

In case you want to open .launch files with xml syntax by default, create a file in your .vim-folder:

mkdir $HOME/.vim/ #create the folder in case it doesn't exist yet
vim $HOME/.vim/filetype.vim #open it in vim

Change into insert mode (press i) and paste following code into it:

if exists("did_load_filetypes")
  finish
endif
augroup filetypedetect
  au! BufNewFile,BufRead *.launch setf xml
augroup END

Thats’s it, after that your vim will change:

before and default

before and default

after edits or set filetype=xml

after edits or set filetype=xml

Howto control CubieTruck onboard LEDs

Today I wanted to know, what this little blinking lights on my [amazon &title=CubieTruck&text=CubieTruck] mean.

There are four, which you find out if you use:

root@cubietruck:/# ls /sys/class/leds/

blue:ph21:led1 green:ph07:led4 orange:ph20:led2 white:ph11:led3

(or just look at it while it is running, usually it blinks a lot)

IMG_20140520_123004

So if you want to know what each blink means you can ask the [amazon &title=CubieTruck&text=CubieTruck] like that:

root@cubietruck:cd /sys/class/leds/
root@cubietruck:/sys/class/leds# ls
blue:ph21:led1  green:ph07:led4  orange:ph20:led2  white:ph11:led3
root@cubietruck:/sys/class/leds# cat green:ph07:led4/trigger
none rfkill0 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online [mmc0] mmc1 timer heartbeat cpu0 cpu1 default-on rfkill1 rfkill2 
root@cubietruck:/sys/class/leds# cat blue:ph21:led1/trigger
none rfkill0 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 mmc1 timer [heartbeat] cpu0 cpu1 default-on rfkill1 rfkill2 
root@cubietruck:/sys/class/leds# cat orange:ph20:led2/trigger
none rfkill0 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 mmc1 timer heartbeat [cpu0] cpu1 default-on rfkill1 rfkill2 
root@cubietruck:/sys/class/leds# cat white:ph11:led3/trigger
none rfkill0 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid ac-online usb-online mmc0 mmc1 timer heartbeat cpu0 [cpu1] default-on rfkill1 rfkill2 

So by default the

  • green LED is indicating if there is any read write with the SD Card
  • blue LED is heartbeating
  • orange LED is CPU0 load
  • white LED is CPU1 load

In case you want to turn off the LEDS, use this code:

# turn off LEDs
echo 0 > /sys/class/leds/blue:ph21:led1/brightness
echo 0 > /sys/class/leds/green:ph07:led4/brightness
echo 0 > /sys/class/leds/white:ph11:led3/brightness
echo 0 > /sys/class/leds/orange:ph20:led2/brightness

See here for more information.