Appunti su Ubuntu

Preparazione di una chiatte USB bootstrappabile

Questa procedura usa un PC Windown per preparare la chiavetta

  • Scaricare una immagine di Ubuntu da
  • Scaricare l'utility per Windows UNetbootbin e segure le istruzioni per creare con questa una chiavetta bootstrappabile partendo dall'immagine ISO di Ubuntu

Creare una ramfs

$ sudo mkdir /mnt/ramdisk
$ sudo mount -t ramfs -o size=1.5g tmpfs /mnt/ramdisk
$ sudo chmod 777 /mnt/ramdisk

Ricerche su file

Cerca la stringa pattern nei file con estensione .c e .h

$ find -name "*.[ch]" | xargs -r grep -n "pattern"

Cerca tutti i file con estensione .h e .c

$ find -name "*.[ch]"

Accedere a minicom da un qualsiasi utente

Edit /etc/udev/rules.d/50-ttyusb.rules:

$ sudoedit /etc/udev/rules.d/50-ttyusb.rules

and add


Detach and insert again the ttyUSB adapter.

Rigenerare la chiave ssh

# rm target-rootfs/etc/ssh/ssh_host_*_key*
# dpkg-reconfigure openssh-server

Montare una directory remota via ssh

$ sudo apt-get install sshfs
$ sudo usermod -a -G fuse [user_name]
$ exec su -l $USER
$ sshfs my_user@remote_host:/path/to/directory [local_mount_point]

Lancio di comandi remoti via ssh

$ ssh "ls /var/www/new-acme-website"


$ watch ifconfig
$ watch "dmesg | tail -20"

Crea file pattern

Crea un file da 256MB con contenuto casuale

$ dd if=/dev/urandom of=pattern bs=1 count=256M

Confronta due file binari

$ xxd file1.bin > file1.hex
$ xxd file2.bin > file2.hex
$ diff file1.hex file2.hex


$ rsync -avc foxg20-modules/lib/. root@

Disattivare un account

$ sudo passwd -l username

Per riattivarlo:

$ sudo passwd -u username

Accedere a minicom da user

$ sudo usermod -G dialout -a tanzilli

Maurizio Scarpa

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Abilita il forwarding di pacchetti non locali - FONDAMENTALE

# echo 1 > /proc/sys/net/ipv4/ip_forward

Ignora finti messaggi di errore ICMP

# echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses

Non risponde ai ping inviati al broadcast della subnet

# echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

Non accetta pacchetti ICMP di route redirection

# echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
# logger -s "Hard disk full"

Grabbing view 1080p

~#ffmpeg -f x11grab -s 1920x1080 -r 25 -i :0.0 -sameq /tmp/out1.mpg

Disabilita l'auto-open delle finestre al mount

The simplest option is to open a terminal with Ctrl+Alt+T, and type:

gsettings set automount-open false

Turns out, it is. You will need dconf-editor tool, which can be installed by with sudo apt-get install dconf-tools. Run dconf-editor in your terminal. Browse to org -> gnome -> desktop - media-handling. Uncheck automount-open.

Installazione C

~# apt-get install make
~# apt-get install gcc
~# apt-get install make libjpeg-dev libv4l-dev
~# cd /usr/include/linux
~# ln -s ../libv4l1-videodev.h videodev.h

USB Gadget

$ modprobe g_ether
$ ifconfig usb0
$ /etc/modprobe.d/options

Creare una tmpfs

/etc/fstab tmpfs /tmp tmpfs defaults 0 0

Watch dog

Swap su chiavetta

mkswap /dev/sda1 && swapon /dev/sda1

Appunti su Linux Kernel

Appunti su Apache

Abilitazione proxy per dts builder

$ sudo a2enmod proxy_http

Alla fine di /etc/apache2/apache2.conf

ProxyPass /builder
$ sudo apache2ctl restart

Appunti su device tree

Abilitazione DMA su seriali


      usart0: serial@f801c000 {
        pinctrl-0 = <&pinctrl_usart0 &pinctrl_usart0_rts &pinctrl_usart0_cts>;
        status = "okay";
        dmas = <&dma0 2 0x3>,
               <&dma0 2 0x204>;
        dma-names = "tx", "rx";


      usart1: serial@f8020000 {
        pinctrl-0 = <&pinctrl_usart1 &pinctrl_usart1_rts &pinctrl_usart1_cts>;
        status = "okay";
        dmas = <&dma0 2 0x5>,
           <&dma0 2 0x206>;
        dma-names = "tx", "rx";

/dev/ttyS3 (da verificare)

      usart2: serial@f8024000 {
        pinctrl-0 = <&pinctrl_usart2>;
        status = "okay";
        /* Inizio aggiunta */
        dmas = <&dma0 2 0x7>,
           <&dma0 2 0x208>;
        dma-names = "tx", "rx";

In case someone else will need it... This made my Aria ttyS3 use DMA and work fine at speed 460800. (Kernel 3.14.23)

/* /dev/ttyS3 */
      usart2: serial@f8024000 {
        interrupts = <7 IRQ_TYPE_LEVEL_HIGH 5>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_usart2>;
        dmas = <&dma1 1 AT91_DMA_CFG_PER_ID(12)>,
               <&dma1 1 (AT91_DMA_CFG_PER_ID(13) | AT91_DMA_CFG_FIFOCFG_ASAP)>;
        dma-names = "tx", "rx";
        status = "okay";

Customers tips

WiFi su Arietta

Hans Schneider

Hi Sergio,

I spent several hours with my beloved Arietta ;-) and figured out a solution for the problem with multiple WiFi and IP over USB that really works. Will mean that Arietta is to reach over USB IP and over another IP as get on DHCP, eg. at the same time. This is important if Arietta is in an non-WiFi-environment. The problem with the missing internet connection as I described yesterday is solved also with this solution.

Because it's quite confusing now, here again are the complete rows that are inserted into the files.

nano /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo

iface lo inet loopback

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B

pre-up modprobe g_ether
auto usb0
iface usb0 inet static

Eliminare il bash bug


env x='() { :;}; echo vulnerable' bash -c "echo this is a test"


Changing squeeze to wheezy in /etc/apt/sources.list and then running:

apt-get update
apt-get install --only-upgrade bash

Ripristino Unity su Ubuntu

dconf reset -f /org/compiz/
setsid unity

More info...


Inserire codice da GitHub sul sito Acme

Memorizzare in cache la password

Mettere i tag

$ git tag -a v1.01 -m 'Version 1.01'
$ git push origin v1.01

Controllare cosa fa una patch

$ git apply --stat acme.patch

Controllare se funziona una patch

$ git apply --check acme.patch

Applica la patch senza fare il commit:

$ git apply < acme.patch

Applica la patch e fa il commit:

git am --signoff < acme.patch

Tutorial su Git

Importare un branch da un altro repository

git remote add nomedicomodo ../repository
git fetch nomedicomodo
git branch nuovobranch nomedicomodo/branchdaimportare

Eliminare tutti i file unstaged

git checkout -- .

Cancellare un branch

git branch -D branchname

Node js su PC Ubuntu

$ apt-get install nodejs
$ sudo ln -s "$(which nodejs)" /usr/bin/node
$ apt-get install npm
$ npm install dnode

Doc dnode: