Outils pour utilisateurs

Outils du site


blog

Téléphone portable Android connexion PC sous GNU/Linux

Notes adb

Voir :

Préreq :

  • le mode debug USB doit être activé
  • le debug doit être autorisé. Si pas le cas passez en “Photo transfer (PTP) mode”

Install

apt-get install android-tools-adb

Autre outils ?

apt-cache search android-tools
android-tools-adb - Android Debug Bridge CLI tool
android-tools-fsutils - Android ext4 utilities with sparse support
android-tools-fastboot - outil en ligne de commande pour le protocole Fastboot d'Android
Connexion
adb start-server
adb devices
lsusb
Bus 002 Device 005: ID 0e8d:201d MediaTek Inc

~/.android/adb_usb.ini

# 0xidVendorHere
0x0e8d

ou

export ADB_VENDOR_KEYS=0x0e8d

Redémarrage d'adb pour le prise en compte de la modif

adb start-server
adb kill-server

Copie

adb push plop.txt /sdcard/
App
Dépôts alternatifs

Voir aussi :

Install de F-Droid un dépôt de Logiciel Libre

wget https://f-droid.org/FDroid.apk
adb install FDroid.apk

Mise à jour

adb install -r cartes-gps-navigation-osmand.apk

Liste des applis installées

adb shell 'pm list packages -f'

Exemple sauvegarde

#adb backup -apk -shared -all -f backup.ab
adb backup '-apk -shared -all -f backup.ab'

Tar du fichier de sauvegarde

tail -n +5 backup.ab | pigz -d -z  > backup.tar
dd if=backup.ab bs=24 skip=1 | pigz -d -z  > backup.tar

Notes fastboot

Voir :

Prerequisites:

  • unlocked bootloader
  • adb and fastboot installed on your computer
adb reboot bootloader
#fastboot flash recovery twrp-2.8.x.x-xxx.img
fastboot flash system <ROM file here>
fastboot reboot

Source : https://www.thecustomdroid.com/how-to-unlock-bootloader-on-huawei-devices/

adb reboot bootloader
fastboot devices
fastboot oem unlock 2155388422526005
fastboot getvar unlocked
fastboot reboot

Source : https://www.kingoapp.com/root-tutorials/how-to-unlock-bootloader-android-device.htm

apt-get install android-tools-fastboot
 
fastboot devices
fastboot oem unlock
 
# Après confirmation sur le téléphone : 
fastboot reboot

Recovery Fastboot https://www.androidpit.com/forum/731450/wiko-sunny-how-to-get-twrp-recovery-installed

fastboot devices
fastboot oem unlock
 
fastboot flash recovery recovery.img
 
fastbook
fastboot oem unlock
< waiting for device >

Partage de fichier - montage lecteur

Partage MTP (Transfère de fichiers)
apt-get install mtp-tools jmtpfs mtpfs

avec interface graphique

apt-get install gmtp
mkdir ~/mnt/mtp/
jmtpfs ~/mnt/mtp/
rsync -ax /media/cdrom/ mnt/mtp/Carte\ SD/plop/
fusermount ~/mnt/mtp/
Partage PTP (Transfère de photos)

Pb

$ adb install cartes-gps-navigation-osmand.apk 
4529 KB/s (18980364 bytes in 4.092s)
        pkg: /data/local/tmp/cartes-gps-navigation-osmand.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]

$ adb install -r cartes-gps-navigation-osmand.apk 
4861 KB/s (18980364 bytes in 3.812s)
        pkg: /data/local/tmp/cartes-gps-navigation-osmand.apk
 Success

Autres

Logs

adb logcat | grep $(adb shell ps | grep org.smssecure.smssecure | cut -c10-15)
logcat -C -b crash,system,main 'bash:S logcat:S mali_winsys:S *:I'

Droits appli

adb shell pm grant uk.co.richyhbm.monochromatic android.permission.WRITE_SECURE_SETTINGS

root access
https://f-droid.org/wiki/page/Should_I_root_my_device%3F

debian
https://www.debian-fr.org/t/debian-kit-debian-en-parallele-dandroid-sans-chroot/59967

Sécurité Sources inconnues Autoriser l'installation d'application issue de sources inconnues

wget http://download.clockworkmod.com/superuser/superuser.zip
 
mkdir plop
cd plop
unzip ../superuser.zip
 
adb kill-server
$ adb root
adbd cannot run as root in production builds
Note root wiko

SuperSU TWRP ( Team Win Recovery Project)

wipe dalvik/cache

Changer son IMEI ? https://play.google.com/store/apps/details?id=com.cryptotel.chamelephon

adb shell getprop ro.build.version.release
adb shell getprop | grep ro.build.version.release

Autres

Désinstaller une application système

adb shell pm uninstall -k --user 0 foundation.e.mail
2025/03/24 15:06

Téléchargement

Source : https://www.debian.org/CD/http-ftp/#stable

Veuillez utiliser à la place un outil qui permet la reprise des téléchargements interrompus.

  • Sous UNIX et GNU/Linux, vous pouvez utiliser aria2, wget ou curl ou HTTPie
wget -c URL

ou

curl -C - -L -O URL

Remplacer URL par l'adresse HTTP ou HTTPS

Vous pouvez aussi consulter une comparaison de gestionnaires de téléchargement pour vous aider à choisir un programme qui vous convient.

2025/03/24 15:06

Tcp cluster nonlocal bind

/etc/sysctl.conf

net.ipv4.ip_nonlocal_bind = 1
2025/03/24 15:06

Créer une archive tar depuis un find grâce à cpio

Présentation

cpio est à la fois le nom d'une commande et d'un format d'archivage. Voir manuel http://www.gnu.org/software/cpio/manual/cpio.html

La commande cpio prend aussi en charge d'autre format que cpio, comme par exemple le format ustar.

Tar avec cpio

Utilisez l'option '-depth' à find.

find . -depth | cpio -ov --format=ustar |pigz > archive.tar.gz
 
# Équivalent ?
find . -depth | xargs tar czf archive.tar.gz
find . -exec tar rvf archive.tar "{}" \;

'-depth' pas nécessaire si votre find ne retourne pas de répertoire. Comme avec l'option '-type f' par exemple

find . -type f |cpio -ov --format=ustar |pigz > archive.tar.gz

Si vous avez des noms de fichiers avec des espaces et des caractères bizarres

find . -depth -print0 |cpio -0 -ov --format=ustar |pigz > archive.tar.gz

Il est également possible de créer un tarball depuis un find (ou un ls) avec Pax qui est à privilégier. Cependant contrairement à pax, cpio est livré par défaut dans la plupart des distributions.

Voir Pax

Limitation

Le format d'archive défini par la norme POSIX.1-1988 appelé ustar est très portable. Mais en revanche, il est assez limité.

  • Taille max de l'archive : 8GB
  • Taille max nom de fichier : 256 caractères grand max (souvent moins)
  • Taille max nom lien symbolique : 100 caractères

Voir détails http://www.gnu.org/software/tar/manual/html_section/tar_68.html

Exemple en pratique

Autre CPIO

find . -mount -print | cpio -pdm /mnt/newhost-disk

Autre

Avec Tar

tar -cvf allfiles.tar -T mylist.txt
2025/03/24 15:06

Taille fichiers sur disque du ls sparse

Voir : https://wiki.archlinux.org/index.php/Sparse_file

Voir aussi reflink :

Sparse, fichiers à trous

Voir du dh “ls -s” fallocate truncate

Notes :

du -sh /var/lib/libvirt/images/dic01-disk0
2,0G    /var/lib/libvirt/images/dic01-disk0

ls -lh /var/lib/libvirt/images/dic01-disk0
-rw-r--r-- 1 qemu qemu 120G 20 juin  14:53 /var/lib/libvirt/images/dic01-disk0
$ ls -lsh
total 22G
 16K drwx------ 2 root root  16K août   9 10:42 lost+found
7,7G -rw-r--r-- 1 jibe jibe 120G août   9 11:18 VM152-SUPPMSM-V-clone.img
 14G -rw-r--r-- 1 jibe jibe  14G févr. 24 09:15 VM152-SUPPMSM-V-clone.qcow2
$ du -h VM152-SUPPMSM-V-clone.*
7,7G    VM152-SUPPMSM-V-clone.img
14G     VM152-SUPPMSM-V-clone.qcow2

Unsparse

cp --sparse=never VM152-SUPPMSM-V-clone.raw VM152-SUPPMSM-V-clone_copy.raw
 
#Ou
truncate -c -s $(( 1024 * 1024 + 1024 * $(ls -s VM152-SUPPMSM-V-clone.raw |awk '{print $1}') )) VM152-SUPPMSM-V-clone.raw
NOTES

Source : https://softwarebakery.com/shrinking-images-on-linux

fdisk -l myimage.img
Disk myimage.img: 6144 MB, 6144000000 bytes, 12000000 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: 0x000ea37d

      Device Boot      Start         End      Blocks   Id  System
myimage.img1            2048     9181183     4589568    b  W95 FAT32

Note two things in the output:

  • The partition ends on block 9181183 (shown under End)
  • The block-size is 512 bytes (shown as sectors of 1 * 512)
truncate --size=$[(9181183+1)*512] myimage.img

Autres

rsync

rsync : Voir l'option --sparse

-S, --sparse                traite les fichiers à trous efficacement
cp

cp --sparse=always et --sparse=never

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki