项目作者: sulpub

项目描述 :
Linux command
高级语言:
项目地址: git://github.com/sulpub/linux_informations.git
创建时间: 2019-03-23T09:44:06Z
项目社区:https://github.com/sulpub/linux_informations

开源协议:

下载


Linux bandeau

Linux_cmd_informations

Information on Linux command

File actions

  1. ls -als // list all files
  2. mkdir titi // make directory "titi"
  3. rmdir -rf titi // remove all file on the "titi" directory
  4. cd // Go to your home directory
  5. cd // Go to the upper directory

update linux with root profile

  1. sudo apt-get update //update all the package on your distribution
  2. sudo atp-get upgrade //upgrade all package installed on your distribution
  3. sudo apt-get install gimp //exemple to install gimp software for example you can replace gimp by other software....
  4. sudo apt-get remove gimp //remove gimp software for example. You can replace gimp by other software for removing....
  5. sudo apt-get install libffi6=3.2.1-6 //specify a version of the librairy

network information

  1. iwconfig //see status of wireless card.
  2. ifconfig //see adress ip of each network card.
  3. sudo iwlist scan //scan les connexion wifi
  4. //arret demmarage carte wifi
  5. sudo ifconfig wlp5s0 up //connexion de la carte wlp5s0
  6. sudo ifconfig wlp5s0 down //deconnexion de la carte wlp5s0

network configuration example

  1. sudo nano /etc/network/interfaces //edit the network conf file.
  2. config example
  3. STATIC
  4. iface wlp5s0 inet static
  5. address 192.168.1.10
  6. netmask 255.255.255.0
  7. gateway 192.168.1.254
  8. wpa-psk "replace by your wpa password securit"
  9. wpa-driver wext
  10. wpa-key-mgmt WPA-PSK
  11. wpa-proto WPA2
  12. wpa-ssid "replace by your SSID"
  13. auto wlp5s0
  14. DYNAMIC
  15. iface wlp5s0 inet dhcp
  16. auto wlp5s0
  17. After saving file run these commands :
  18. sudo service networking force-reload
  19. sudo service networking restart
  20. sudo iwconfig //for controlling if your connexion was OK

dns configuration

  1. sudo nano /etc/resolv.conf
  2. add dns as well :
  3. nameserver 212.27.40.240

Main Issues for my specifics problems

ISSUE 1 disconnect wifi card intel PRO wireless 3945ABG on LUBUNTU

  1. sudo rmmod iwl3945 //Software disconnect the wifi board
  2. sudo modprobe iwl3945 //Software reconnect the wifi board

ISSUE 2 connect on windows remote desktop

  1. install rdesktop
  2. sudo apt-get install rdesktop
  3. Run rdesktop with rdp to IP.IP.IP.IP adress with screen size 1440x900 with 16bits color and sound stay on the distant computer.
  4. rdesktop -r sound:remote -k fr -g 1440x900 -a 16 IP.IP.IP.IP
  5. rdesktop -k fr -a 8 IP.IP.IP.IP //color 8bit full screen keyboard FR

ISSUE 3 ssh connexion

  1. ssh user@IP.IP.IP.IP //run ssh connexion with user "user" at adress IP.IP.IP.IP
  2. ssh -X user@IP.IP.IP.IP //run ssh with server X.

ISSUE 4 test network bandwith

  1. nc -lk 2112 >/dev/null //run on the remote computer 10.10.10.1
  2. dd if=/dev/zero bs=16000 count=625 | nc -v 10.10.10.1 2112 //transfert 10MB to the remote computer and evaluate the bandwith.
  3. Response example on the local computer :
  4. Connection to 10.10.10.1 2112 port [tcp/*] succeeded!
  5. 625+0 enregistrements lus
  6. 625+0 enregistrements écrits
  7. 10000000 bytes (10 MB, 9,5 MiB) copied, 4,08256 s, 2,4 MB/s

ISSUE 5 : Hard drive informations

  1. sudo blkid //To know informations concerning hard drive.
  2. sudo hdparm -C /dev/sda //See the hard drive status
  3. sudo hdparm -y /dev/sda //Put the hard drive sda in standby mode
  4. sudo hdparm -S 1 /dev/sda //le chiffre 1 correspond au temps par multiples de 5 secondes.
  5. sudo hdparm -S 120 /dev/sda1 //put the disk in standby mode after 120*5s=10 minutes
  6. sudo hdparm -I /dev/sda | grep level //To verify if the hard drive support low power management. If the disk support low power you will see 254 by default.

ISSUE 6 : Delete shell history

  1. Delete specific line
  2. history -d 505 // delete ligne 505 in the istory command
  3. or edit the local bash history
  4. nano ~/.bash_history

ISSUE 7 : Audio configuration with USB-AUDIO

  1. List of USB device :
  2. lsusb
  3. List aof audio device :
  4. aplay -l
  5. Edit /etc/asound.conf
  6. Modify as well :
  7. pcm.!default {
  8. type hw
  9. card 0
  10. device 0
  11. }
  12. ctl.!default {
  13. type hw
  14. card 0
  15. device 0
  16. }
  17. Nota : if the local file ~/.asoundrc exist, it have more priority.

ISSUE 8 : Change the icon of the login on Lubuntu under XFCE

  1. Place an icon in PNG format on the home directory of the user.
  2. Rename it to .face
  3. That's all.

ISSUE 9 : Change Welcome message Shell linux

Edit the file /etc/motd

  1. sudo nano /etc/motd

You can use this link to form special text message :http://www.patorjk.com/software/taag

After modify your motd (Message Of The Day) file when you log in ssh with your terminal, the new text message appears.

ISSUE 10 : Find big file on the system

You can use this command for file up to 500Mo

  1. sudo find /PATH/ -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

ISSUE 11 : How To Create a New User and Grant Permissions in MySQL

Run MYSQL : sudo mysql

  1. // add user
  2. mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
  3. // add grand permission
  4. mysql> GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
  5. // relaod privilege
  6. mysql> FLUSH PRIVILEGES;

link : https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

ISSUE 12 : Intempestive wifi disconnexion

For resolve this problem, it is necessary to disconnect the power save of the wifi connexion.

It is important to do this manipulation for each wifi network.

  1. cd /etc/NetworkManager/system-connections/
  2. ls
  3. sudo nano your_wifi_network
  4. Add "powersave=2" on the wifi section, save the file and reboot the system

To see if the configuration was ok run : iwconfig and watch if you see “Power Management:off”

linux_informations

List of linux commands use the wiki for informations

list of the 10 lines at the end the auth.log file

tail -n 10 /var/log/auth.log

If auth.log is empty, you can restart the log service.

  1. sudo /etc/init.d/rsyslog restart

List end line of open session

last -n 1

Serveur Email at home

List of command for installing email server at home.

Install the package bind9-host

sudo apt-get install bind9-host

for testing
host -t MX

  1. Example :
  2. host -t MX google.com
  3. google.com mail is handled by 10 aspmx.l.google.com.
  4. google.com mail is handled by 40 alt3.aspmx.l.google.com.
  5. google.com mail is handled by 50 alt4.aspmx.l.google.com.
  6. google.com mail is handled by 30 alt2.aspmx.l.google.com.
  7. google.com mail is handled by 20 alt1.aspmx.l.google.com.

Empty file

For erasing the content of a file, you can send this command :

  1. echo > filename.txt

with this command it is not necessary to delete file and recreate it.

How to know the directory size

  1. du -h // for list size directory
  2. du -sh /etc //total size of etc directroy

OpenVPN configuration

Lien IONOS.FR : https://www.ionos.fr/digitalguide/serveur/configuration/installer-un-serveur-vpn-via-raspberry-pi-et-openvpn/

Installation PYTHON

Choix version python 3 : exemple 3.9.1 defaut

  1. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 0
  2. sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.9 1

Choix python 3 au lieu de python 2 :

//controle version

  1. python --version

//desactivation python 2

  1. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 0

//activation python 3

  1. sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1

//controle version

  1. python --version

YOLO V5 notes

install package debian

  1. sudo dpkg -i package_name.debconda activate yolov5

YOLO INFERENCE

  1. cd yolov5
  2. python detect_mqtt_nowifi.py --line-thickness 1 --conf-thres 0.85 --iou-thres 0.4 --img 640 480 --nosave --weights ./w
  3. eights/20230309_best_orin_50eph_new_light.pt --source 0

YOLO TRAIN

Note : sur le portable la carte graphique a 4G de mémoire si on utilise des modele large il faut reduire le batch size.

  1. conda activate yolov5
  2. cd yolov5
  3. python train.py --img 640 --batch 16 --epochs 100 --data data/poste_intelligent_order.yaml --weights yolov5l.pt
  4. python train.py --hyp hyp.no-augmentation.yaml
  5. python train.py --img 640 --epochs 3 --data coco128.yaml --weights yolov5s.pt
  6. //high resolution
  7. python train.py --img 1280 --epochs 3 --batch-size 2 --data ./datasets/bat18650.yaml --hyp ./dataset/hyp.no-augmentatio
  8. n.yaml --weights yolov5m6.pt
  9. python train.py --img 1280 --epochs 500 --batch-size 1 --data ./datasets/bat18650_3.yaml --hyp ./datasets/hyp.no-augmen
  10. tation.yaml --weights yolov5l6.pt

Make icone launchable

https://icon.kitchen/
https://askubuntu.com/questions/141229/how-to-add-a-shell-script-to-launcher-as-shortcut
https://linuxconfig.org/how-to-create-desktop-shortcut-launcher-on-ubuntu-20-04-focal-fossa-linux

Protocol :
Create *.desktop file, location depends on if it is for personal use or all users. If these directories do not exist, create them.

For personal use , ~/.local/share/applications
gedit ~/.local/share/applications/name.desktop
For all users, /usr/local/share/applications/ (or /usr/share/applications/ depending upon your system).
sudo -i gedit /usr/share/applications/name.desktop

Paste below text

[Desktop Entry]
Type=Application
Terminal=true
Name=unmount-mount
Icon=/path/to/icon/icon.svg
Exec=/path/to/file/mount-unmount.sh

edit Icon= and Exec= and Name=
Also Terminal=True/false determines whether the terminal opens a window and displays output or runs in the background
Put this in unity panel by dragging it from files manager

YOLO MARK

yolo mark


./yolo_mark x64/Release/data/img x64/Release/data/train.txt x64/Release/data/obj.names

astuce yolomark
<- prev_img
-> next_img
c - clear_marks
n - one_object_per_img
0-9 - obj_id
m - show coords
ESC - exit”,

w - line width
k - hide obj_name
p - copy previous
o - track objects
r - delete selected
R-mouse - move box”

h - disable help”
h - show help”

YOLO notes

Capture image with webcam

  1. place object in position_1
  2. define name_1 of the lot of picture
  3. take a lot of picture (30-50 picture) with varing light, move behind your objet to modify the aspect.
  4. Do the step 1 to 3 a lot of time depending of the quantity you want.

Run yolo inference

  1. run the yolo inference with the pictures you catch
  2. Activate the text output

Run yolo mark

For finalize the annotation of your dataset

  1. Put all the picture and txt fil in the same directory
  2. Configure yolo_mark to see the annotated pictures
  3. Make correction of the annotated errors and use copy to reproduce all the bounding box on the lot of your picture
  4. Save all your job by pressing ESC touch

rehenforce your model

GESTION SWAP UBUNTU

Pour augmenter la taille du swap sous Ubuntu, voici les étapes à suivre :

1. Vérification de l’espace swap actuel

D’abord, vérifiez la taille actuelle de votre partition ou fichier de swap avec la commande suivante :

  1. swapon --show

Vous pouvez aussi vérifier l’espace total avec :

  1. free -h

2. Désactiver le swap existant (si vous travaillez avec un fichier swap)

Avant de modifier ou de créer un nouveau fichier de swap, désactivez le swap actuel :

  1. sudo swapoff -a

3. Créer un nouveau fichier de swap

Supposons que vous souhaitiez créer un nouveau fichier de swap de 4 Go. Voici comment le faire :

  1. sudo fallocate -l 4G /swapfile

Si fallocate n’est pas disponible, utilisez dd :

  1. sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

4. Ajuster les permissions du fichier swap

Assurez-vous que seuls les utilisateurs root peuvent lire et écrire dans le fichier :

  1. sudo chmod 600 /swapfile

5. Configurer le fichier swap

Formatez le fichier en tant qu’espace swap avec la commande suivante :

  1. sudo mkswap /swapfile

6. Activer le swap

Pour activer le nouveau fichier swap :

  1. sudo swapon /swapfile

7. Vérification

Vérifiez si le swap est bien actif et s’il a la taille désirée :

  1. swapon --show
  2. free -h

8. Rendre le swap permanent

Pour rendre le changement persistant après redémarrage, ajoutez cette ligne au fichier /etc/fstab :

  1. echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Bonus : Ajuster le swappiness

Vous pouvez ajuster l’utilisation du swap par le système en modifiant le paramètre swappiness (0 signifie presque jamais utiliser le swap, 100 signifie l’utiliser agressivement) :

  1. sudo sysctl vm.swappiness=10

Pour le rendre persistant, ajoutez cette ligne à /etc/sysctl.conf :

  1. vm.swappiness=10

Ces étapes permettent d’augmenter ou de redimensionner le swap sous Ubuntu selon vos besoins.
1- Prepare your data with this new annotated picture
2- Run the inference with the first model generated with synthetic images.

Redimensionner carte SD (exemple jeston nano 32Go -> 64Go)

Etape 1 : Identifier la partition à redimensionner

Ouvrez un terminal et tapez :

  1. lsblk

Notez le nom de votre partition principale (par exemple, /dev/mmcblk0p1).

Étape 2 : Utiliser fdisk pour supprimer et recréer la partition

⚠️ Attention : Assurez-vous d’avoir une sauvegarde de vos données importantes avant de continuer, car toute erreur peut rendre le système inutilisable.

Lancez fdisk :

  1. sudo fdisk /dev/mmcblk0

Une fois dans fdisk, suivez les étapes suivantes pour supprimer et recréer la partition sans perdre de données.

  • Tapez p pour afficher les partitions actuelles. Notez le numéro de partition (généralement 1) et le secteur de début de la partition principale (Start).
  • Tapez d pour supprimer la partition principale (généralement 1).
  • Tapez n pour créer une nouvelle partition :
    • Choisissez le même numéro de partition (généralement 1).
    • Entrez le secteur de début original que vous avez noté précédemment pour ne pas modifier les données existantes.
    • Laissez le secteur de fin par défaut pour utiliser tout l’espace disponible.
  • Tapez w pour écrire les modifications et quitter fdisk.

Redémarrez votre Jetson Nano :

  1. sudo reboot

Étape 3 : Redimensionner le système de fichiers

Une fois redémarré, utilisez resize2fs pour redimensionner le système de fichiers afin qu’il occupe toute la partition :

  1. sudo resize2fs /dev/mmcblk0p1

Étape 4 : Vérifier la taille

Utilisez df -h pour vérifier que la partition principale utilise maintenant toute la carte SD :

  1. df -h