Appunti su Linux

Monitorare gli interrupt in arrivo

# watch --n 1 -d cat /proc/interrupts

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 tanzilli@acmesystems.it "ls /var/www/new-acme-website"

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"

Ricerche metodo Montefusco

egrep 'get_property.*non-removable' *.c

Watch

$ 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

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

Disattivare un account

$ sudo passwd -l username

Per riattivarlo:

$ sudo passwd -u username

Grabbing view 1080p

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

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 192.168.10.1
$ /etc/modprobe.d/options

Creare una tmpfs

/etc/fstab tmpfs /tmp tmpfs defaults 0 0

Watch dog

http://lxr.linux.no/linux+v2.6.38/Documentation/watchdog/ http://coleman.jandasoft.biz/?p=25

Swap su chiavetta

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

Appunti su Apache

Abilitazione proxy per dts builder

$ sudo a2enmod proxy_http

Alla fine di /etc/apache2/apache2.conf

ProxyPass /builder http://terzo.acmesystems.it
$ sudo apache2ctl restart

Customers tips

WiFi su Arietta

Hans Schneider hans.schneider@gmx.ch

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 192.168.10.10 and over another IP as get on DHCP, eg. 192.168.1.71 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
address 192.168.10.10
netmask 255.255.255.0
gateway 192.168.10.20

Eliminare il bash bug

VerificaTest

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

Aggiornamento

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...

Git

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:

https://www.npmjs.com/package/dnode

Create a swapfile on-the-fly

dd if=/dev/zero of=swapfile bs=1M count=128
mkswap swapfile
swapon swapfile

Check a file and make an action

#!/bin/sh 
while true; do
  inotifywait -e modify /var/www/html/out.png
  # Do something *after* a write occurs, e.g. copy the file
  /usr/bin/fbi -T 1 -noverbose /var/www/html/out.png
done

Driver relations

find /sys/bus/*/drivers/* -maxdepth 1 -lname '*devices*' -ls

Create an image from a microSD

sudo dd bs=1M if=/dev/sdb of=arietta_webcam.img count=1680 

WebCam to Display

mplayer -fps 15 -tv driver=v4l2:width=320:height=240:device=/dev/video0 -vf scale tv:// 

Appunti ssh