wiki:HowTo

Acceuil

How to ?

flat files search

find . -type f -print | xargs grep "some string"

camera

usefull tools

apt-get install uv4l-utils

display

ffplay /dev/video0

recording

ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 output.mkv

fetch mysql information

/usr/sbin/mysqld --help --verbose

force svn commit outdated

svn up --accept mine-full

removing broken package

sudo apt-get purge "^pakage_name-.*"
sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get clean

or via

mv /var/lib/dpkg/info/PACKAGE.* /tmp/
dpkg --remove --force-remove-reinstreq PACKAGE

Setting up a network interfaces bridge

**source debian**

ip addr show
ip link show wlan1

eth0 : interface to existing network

apt-get -y install bridge-utils 
brctl addif br0 wlan1 eth0

in /etc/network/interfaces

iface eth0 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports wlan1 eth0

install new fonts

see: google fonts

manually

Download the appropriate .ttf or otf files and placing them into /usr/local/share/fonts (system-wide), ~/.local/share/fonts (user-specific) or ~/.fonts (user-specific). These files should have the permission 644 (-rw-r--r--), otherwise they may not be usable

for OTF fonts use target : /usr/share/fonts/opentype

update font cache

fc-list – lists fonts

fc-match -s helvetica – show an ordered list of fonts matching a certain name or pattern

fc-cache -fv – rebuilds cached list of fonts (in ~/.config/fontconfig, older caches may also be in ~/.fontconfig)

find openssl location

openssl version -d

raspberry unwanted reboot


NOT TESTED


due to current draw lake the PI self reboot. To reduce cpu load edit /etc/rsyslog.conf and comment out following lines

# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
daemon.*;mail.*;\
        news.err;\
        *.=debug;*.=info;\
        *.=notice;*.=warn       |/dev/xconsole

raspberry cpu config

vcgencmd get_config int

raspberry cpu performance

to avoid cpu frequency scaling (defaults to power-save)

sudo nano /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
performance

remove broken packages

mkdir /tmp/package-name
sudo mv /var/lib/dpkg/info/package-name.* /tmp/package-name
sudo dpkg --remove --force-remove-reinstreq package-name

Raspbian images

archives

Check I2C device address

sudo i2cdetect -y 1

Dump Sqlite3

database

sqlite3 mydb.sqlite
.output db_dump.sql
.dump
.exit

table

sqlite3 mydb.sqlite
.output table_dump.sql
.dump table_name
.exit

execute sql script

.read table_dump.sql

rename table

alter table MyOldTable rename to MyNewTable 

SSH key

sudo -i
mkdir -p /etc/ssh/private
export ROOT_KEY=/etc/ssh/private/emmanuel.brunet
sudo openssl genrsa -out ${ROOT_KEY}.key 2048 
sudo openssl req -new -x509 -key  ${ROOT_KEY}.key -out  ${ROOT_KEY}.crt -sha256

format SD Card

sudo mkdosfs /dev/sdbx -F32

add debian backports

gpg --keyserver pgpkeys.mit.edu --recv-key 8B48AD6246925553
gpg -a --export 8B48AD6246925553 | sudo apt-key add -
gpg --keyserver pgpkeys.mit.edu --recv-key 7638D0442B90D010
gpg -a --export 7638D0442B90D010 | sudo apt-key add -
echo deb http://ftp.debian.org/debian jessie-backports main contrib non-free >> /etc/apt/sources.list

library dependencies

list the executable lib dependencies

ldd $(which ffmpeg)

library path

les fichier .conf contenant les chemins d'accès sont placés dans /etc/ld.so.conf.d

puis

ldconfig

remout fstab entries

set / in read only mode. usefull for fsck actions

sudo mount -o remount ro /

return in write mode

sudo mount -o remount rw /

Save gnome sessions

version : debian 8 / gnome 3

gsettings set org.gnome.SessionManager auto-save-session true

DHCP leases

on debian 7.1 located at

/var/lib/dhcp/

Nginx debug

running the http server in foreground mode

sudo nginx -g "daemon off;"

Check QT version

qmake --version

Extend /tmp partition

overlap the current /tmp file system with a new device

all process using /tmp (db servers, http servers, and so on ...) won't be able to find their working files. so stop them (mysql, postgres, apache, nginx , tuxedo, MqSeries? , kafka .. and so on)

creating a 2G° device

sudo dd if=/dev/zero of=/usr/tmp-disk bs=2M count=1024
sudo mke2fs -j /usr/temp-disk

mount file system on the new device ovet the current /tmp one

sudo mount -t ext3 -o rw,noexec,nosuid,loop /usr/tmp-disk /tmp

Install Google earth on debian 8

Need to setup the multi-arch debian functionnality to allow i386 (32bits) programs to execute

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libfontconfig1:i386 libx11-6:i386 libxrender1:i386 libxext6:i386 libgl1-mesa-glx:i386 libglu1-mesa:i386 libglib2.0-0:i386 libsm6:i386
sudo apt-get -f install
sudo dpkg -i googleearth_6.0.3.2197+1.2.0-1_amd64.deb

note:

fine name is subject to changes, just type

ls

and check the your file name to apply corresponding fix

for information

dpkg --print-architecture
dpkg --print-foreign-architectures
less /var/lib/dpkg/arch
apt-get purge ".*:<arch>" and then sudo dpkg --remove-architecture <arch>

Setup flashplayer for debian

apt-get install pepperflashplugin-nonfree
update-pepperflashplugin-nonfree --install

to check the current version

update-pepperflashplugin-nonfree --status

Set up Nautilus extract tool

sudo apt-get install nautilus-actions

change php5-fpm listener

changing listener address

edit : /etc/php5/fpm/pool.d/www.conf

restarting service :

with systemD

sudo systemctl restart php5-fpm.service

old style

sudo service php5-fpm restart

Install locales

uncomment desired locales to load extras

sudo nano /etc/locale.gen
sudo locale.gen

and configure

sudo dpkg-reconfigure locales

Display open IP ports

sudo netstat -tlnp

Find and delete files

ex : remove recusively GIMP files

find . -regex ".*\.xcf" -exec rm -f {} \;

Replace invalid space character in file name

find . -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;

Clean DHCP leases

delete file dhclient.leases

sudo rm /var/lib/dhcp/dhclient.leases

Read encrypted DVD's

need to install the DVD library

On debian 7.1 (not tested)

sudo apt-get install libdvdcss2

On Ubuntu 14.04

sudo apt-get install libdvdread4
sudo sh /usr/share/doc/libdvdread4/install-css.sh

SSH SSL key

check ssh key list

ls -al ~/.ssh

generate a new ssh key

ssh-keygen -t rsa -C "emmanuel.brunet@open-si.org"
Enter file in which to save the key (/home/you/.ssh/id_rsa)

start the SSL agent

eval "$(ssh-agent -s)"
# Agent pid 75566

Add the new SSH key in the list

ssh-add ~/.ssh/id_rsa

Java 8 installer from PPA repository

Register

sudo -i
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java8-installer

Create python3 virtual env

for python3.4.2

Install the virtualenv module

pip3 install --user virtualenv 

add the virtualenv command directory to the path in ~/.bashrc

PATH=$PATH:~./local/bin

to create a virtual environment

virtualenv /path/to/project

you can specify the python interpreter

virtualenv -p /usr/local/bin/python3.4m python3.4

To enter the environment

source /path/to/project/bin/activate

Manage subversion / svn unversionned files

Adds

 svn status | grep ? | awk '{print $2}' | xargs svn add

Deletes

svn status | grep ! | awk '{print $2}' | xargs svn delete

to unlock files

svn status | grep L | awk '{print $2}' | xargs svn --force unlock

Building the volley.jar Android library

Assuming that the android / ant executables are in your path note:

Android-16 version is 4.1.x

git clone https://android.googlesource.com/platform/frameworks/volley
cd volley
android update project -p . --target android-16 --subprojects
ant jar

development path :

~/AndroidStudioProjects/Assistant?/app/src/main

the volley.jar file is located in volley/bin directory

just copy it to your libs android project directory

If the library is not recognized, try :

In android studio :

  • Project Structure > Modules > Dependencies > Add Files

Browse to the location of jar file and select it

  • in the build.graddle file check that this line is present
dependencies {
...
    compile files('libs/volley.jar')
...
}

Nautilus using del key

Run dconf-editor, and open: Applications/System Tools/dconf Editor

select

  • org -> gnome -> desktop -> interface

Enable "can-change-accels".

Open nautilus, select any file/directory, then click "Edit" from menubar, and hover on "Move to Trash" menuitem. While hovering, click twice on the delete key. The accel should change from "cntrl+del" to "del".

Installing OpenJDK

sudo apt-get install openjdk-7-jdk

Selecting the java runtime

sudo update-alternatives --config java

To add a new JRE

sudo update-alternatives --verbose --install /usr/bin/java java /usr/lib/jvm/newjre/bin/java numeric sequence (1045)

Fix missing item in Eclipse

svn status | grep "^\!" | awk '{print $2}' | xargs svn rm

if newly add but missing

svn status | grep "^\?" | awk '{print $2}' | xargs svn add

Convert .mov / .mp4 to .avi for windows

ffmpeg -i input.mov -vcodec msmpeg4v2 -acodec pcm_u8 -q:v 0 -f avi output.avi
ffmpeg -i input.mp4 -vcodec msmpeg4v2 -acodec pcm_u8 -q:v 0 output.avi

Cups printer management

sudo usermod -a -G lpadmin user_account

in an internet browser reach address

http://localhost:631

Adding new fonts to ImageMagik or GIMP

Based on FontConfig system

List all known fonts

convert -list font

to add new fonts either add them in the system font path or in your .fonts personal directory (see .fonts.conf)

Resize image with nautilus

sudo apt-get install nautilus-image-manipulator nautilus-image-converter

List program locks on a TCP port

$ lsof -i tcp:873

List package dependencies

$ apt-cache depends package-name

Edit GNOME properties

$ dconf-editor

Example : to activate the del key on Nautilus :

  • org -> gnome -> desktop -> interface
  • Enable "can-change-accels"
  • Open nautilus, select any file/directory
  • click "Edit" from menubar, and hover on "Move to Trash" menuitem. click on your delete key.

Create Java DEB package from tar

$ sudo apt-get install java-package
$ make-jpkg /path/to/java-download-archive.tar.gz

a .deb file is created and can be install with

$ sudo dpkg -i package-name.deb
$ sudo ldconfig

Sync filesystems

$ sudo sync

File: coreutils.info, Node: sync invocation, Next: truncate invocation, Prev: stat invocation, Up: Disk usage

sync: Synchronize data on disk with memory

Copy System Image on SD Card

$ sudo umount /mnt/mount-dir
$ sudo dd bs=4M if=kernel-image.img of=/dev/sdb

Attention : procédure longue sans indicateur de progression : attendre.

Créer une image à partie de la carte

$ sudo dd if=/dev/sdb of=kernel-image.img

Mount External System for Cross Compile

$ sudo mkdir /mnt/kernel-rootfs
$ sudo mount -o loop,offset=62914560 kernel-image.img /mnt/kernel-rootfs

Pour déterminer l'offset : start (122880) * sector size (512bytes) = 62914560

$ sudo fdisk -lu kernel-image.img

Disk raspberry-working-image.img: 15.7 GB, 15720251392 bytes
255 heads, 63 sectors/track, 1911 cylinders, total 30703616 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000981cb

                      Device Boot      Start         End      Blocks   Id  System
raspberry-working-image.img1            8192      122879       57344    c  W95 FAT32 (LBA)
raspberry-working-image.img2          122880    30703615    15290368   83  Linux

Change Java Virtual machine

sudo update-alternatives --config java

Identifier le driver d'une carte réseau

lspci -nnk | grep -iA2 net
02:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller [10ec:8136] (rev 02)
	Subsystem: Hewlett-Packard Company Device [103c:143c]
	Kernel driver in use: r8169
03:00.0 Network controller [0280]: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller [14e4:4727] (rev 01)
	Subsystem: Hewlett-Packard Company Device [103c:145c]
	Kernel driver in use: wl

Specific locations :

  • /lib/modules/3.2.0-4-amd64/kernel/net/wireless
  • /lib/firmware
  • /etc/modprobe.d/blacklist.conf

Vérifier l'état d'une carte wifi

Wifi Debian : lire les problèmes de disponibilités de drivers wifi libres.

$ sudo apt-get install rfkill
$ rfkill list
0: hp-wifi: Wireless LAN
	Soft blocked: yes
	Hard blocked: yes

Pour débloquer la carte wifi utiliser une des commandes suivantes :

sudo rfkill unblock wifi
sudo rfkill unblock all
sudo rfkill unblock wlan

Pour lister les réseaux wifi connus

iwlist scan

Specific locations

  • /var/lib/NetworkManager/NetworkManager.state

Inspecter des packages

Permet de rechercher des fichiers dans des packages non installés.

sudo apt-get install apt-file

Boot with filesystem in read only mode

In recovery mode at boot time to allow file update type

$ mount -o remount,rx /

Compile Qt5 Android

./configure -xplatform android-g++ -nomake tests -nomake examples -android-ndk ~/build/qt5-android/android-ndk-r8e -android-sdk ~/build/qt5-android/android-sdk-linux -android-ndk-host linux-x86_64 -android-toolchain-version 4.8 -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -no-warnings-are-errors -prefix /opt/Qt

Change locales

$ sudo dpkg-reconfigure locales

Acceuil?

Emmanuel Brunet - 2014-2017

Last modified 13 months ago Last modified on 10/17/2018 05:28:43 PM