From 73cd251d7b276e3dc5372600a014b9491c5ff154 Mon Sep 17 00:00:00 2001 From: Bruno 21 Date: Sun, 27 Oct 2019 18:43:35 +0100 Subject: [PATCH] Update 27-10-2019 --- docs/Divers/Vagrant/Vagrant.md | 199 ++++++++++++++++++- docs/Divers/Vagrant/creer_une_vagrant_box.md | 28 ++- docs/Divers/debian.md | 118 +++++++++++ docs/Divers/zsh/zsh.md | 46 +++++ docs/MySQL/index.md | 66 ++++++ docs/Synology/opkg/oPKG.md | 4 +- docs/Synology/scripts.md | 8 +- docs/macos/Mail.md | 6 + docs/macos/chflags.md | 58 ++++++ docs/macos/getfileinfo_setfile.md | 62 ++++++ docs/macos/homebrew/brew-cask.md | 29 +++ docs/macos/node/nvm.md | 20 +- docs/macos/webserver/mysql.md | 23 +++ mkdocs.yml | 2 + 14 files changed, 656 insertions(+), 13 deletions(-) create mode 100644 docs/Divers/debian.md create mode 100644 docs/Divers/zsh/zsh.md create mode 100644 docs/macos/Mail.md create mode 100644 docs/macos/chflags.md create mode 100644 docs/macos/getfileinfo_setfile.md diff --git a/docs/Divers/Vagrant/Vagrant.md b/docs/Divers/Vagrant/Vagrant.md index 938b0d0..b11c5ac 100644 --- a/docs/Divers/Vagrant/Vagrant.md +++ b/docs/Divers/Vagrant/Vagrant.md @@ -322,6 +322,199 @@ Connection to 127.0.0.1 closed. +### Installer LAMP: + +```bash +sudo apt-get install apache2 +sudo apt-get install mariadb-server # This will ask for a root password, I leave it blank. +sudo apt-get install php +sudo apt-get install php7.3-mysql +``` + + + +#### Configurer le serveur local: + +Ouvrir le fichier Vagrantfile et dé-commenter les 2 lignes suivantes: + +```bash +config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + +config.vm.network "private_network", ip: "192.168.33.10" +``` + +Quitter la box + +```bash +exit +``` + +et redémarrer + +```bash +$ vagrant reload +$ vagrant ssh +sudo /etc/init.d/apache2 start +``` + +Dans un navigateur, aller à *192.168.33.10* pour voir la page d'accueil d'Apache. + + + +#### Dossiers partagés: + +Créer un dossier *vagrant_site* sur le Mac et y ajouter un fichier *index.php*. + +```php + +``` + +Ouvrir le fichier Vagrantfile et dé-commenter la ligne suivante: + +```bash +config.vm.synced_folder "../data", "/vagrant_data" +``` + +et la modifier comme suit: + +```bash +config.vm.synced_folder "../vagrant_site/", "/var/www/html/" +``` + +- "../vagrant_site/" est le chemin vers le dossier nouvellement crée. +- "/var/www/html/" est le chemin où seront les fichiers dans la VM Vagrant. + +Quitter la box: + +```bash +exit +``` + +et redémarrer: + +```bash +$ vagrant reload +$ vagrant ssh +``` + +Dans un navigateur, recharger *192.168.33.10* pour voir la page 'Hello World'. + + + +#### MySQL: + +Se connecter à la VM et démarrer Mysql: + +```bash +sudo mysql +``` + +```mysql +CREATE USER 'debian'; +GRANT ALL PRIVILEGES ON *.* TO debian;` +quit +``` + +Quitter la VM: + +```bash +exit +``` + +puis + +```bash +$ vagrant ssh-config + +Host default + HostName 127.0.0.1 + User vagrant + Port 2222 + UserKnownHostsFile /dev/null + StrictHostKeyChecking no + PasswordAuthentication no + IdentityFile /Users/bruno/vagrant_boxes/.vagrant/machines/default/virtualbox/private_key + IdentitiesOnly yes + LogLevel FATAL +``` + +Ouvrir Sequel Pro et initier une connexion SSH: + +- Hôte MySQL: 127.0.0.1 +- Utilisateur: debian +- Mot de passe: +- Base: +- Port: +- Hôte SSH: 127.0.0.1 +- Utilisateur SSH: vagrant +- Clé SSH: select /Users/bruno/vagrant_boxes/.vagrant/machines/default/virtualbox/private_key +- Port SSH: 2222 + + + +#### Virtual Host: + +Editer le fichier *hosts* sur le mac: + +```bash +$ sudo nano /etc/hosts +``` + +Ajouter cette ligne à la fin: + +```bash +# Vagrant +192.168.33.10 hello.world +``` + +SSH dans la VM: + +```bash +$ vagrant ssh +``` + +Puis: + +```bash +cd /etc/apache2/sites-available/ +``` + +Créer un nouveau fichier de config: + +```bash +sudo nano hello.world.conf +``` + +Et y ajouter: + +```bash + + ServerAdmin webmaster@localhost + ServerName hello.world + DocumentRoot /var/www/html/ + +``` + +Relancer Apache: + +```bash +sudo a2ensite hello.world.conf +sudo service apache2 reload +``` + +Dans le navigateur, charger la page *hello.wolrd* + + + +### Quitter la box: + +```bash +$ vagrant halt +==> default: Attempting graceful shutdown of VM... +``` + + + ### Supprimer la box: ```bash @@ -333,7 +526,7 @@ $ vagrant destroy ### Supprimer les fichiers: ```bash -$ vagrant box remove (supprime les fichiers) +$ vagrant box remove ``` @@ -400,3 +593,7 @@ $ vagrant reload --provision [How To Provision A LEMP Stack In Vagrant](https://kenfavors.com/code/how-to-provision-a-lemp-stack-in-vagrant/) +[Setting Up a LAMP Server on a Vagrant Machine](https://dev.to/boringbdon/setting-up-a-lamp-server-on-a-vagrant-machine-ppi) + +[SCOTCH BOX 3.5](https://box.scotch.io) + diff --git a/docs/Divers/Vagrant/creer_une_vagrant_box.md b/docs/Divers/Vagrant/creer_une_vagrant_box.md index 4a64145..d714ae7 100644 --- a/docs/Divers/Vagrant/creer_une_vagrant_box.md +++ b/docs/Divers/Vagrant/creer_une_vagrant_box.md @@ -48,7 +48,7 @@ https://www.ceos3c.com/open-source/install-linux-mint-19-virtualbox/ Ajouter: ```bash - add vagrant user + # add vagrant user vagrant ALL=(ALL) NOPASSWD:ALL ``` @@ -57,6 +57,8 @@ https://www.ceos3c.com/open-source/install-linux-mint-19-virtualbox/ - Tester: `sudo pwd` + Pour Debian, voir [ici](../debian.md) + 5. #### Mettre à jour l'OS: ```bash @@ -127,7 +129,7 @@ mkdir ~/vagrant_boxes cd ~/vagrant_boxes ``` -12. #### Créer le paquet (tar.gz et fichiers Vagrantfile , metadata.json +12. #### Créer le paquet (tar.gz et fichiers Vagrantfile , metadata.json ): ```bash $ vagrant package --base Linux\ Mint\ 19\ xfce @@ -137,7 +139,7 @@ $ vagrant package --base Linux\ Mint\ 19\ xfce ==> Linux Mint 19 xfce: Compressing package to: /Users/bruno/vagrant_boxes/package.box ``` -13. #### Tester la box +13. #### Tester la box: ```bash $ vagrant box add mint19-64 package.box @@ -149,6 +151,10 @@ $ vagrant box add mint19-64 package.box +## Vagrant + +#### Initialiser la VM: + ```bash $ vagrant init mint19-64 A `Vagrantfile` has been placed in this directory. You are now @@ -157,6 +163,10 @@ the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. ``` + + +#### Démarrer la VM: + ```bash $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... @@ -171,6 +181,7 @@ information on this option, please refer to the VirtualBox manual: https://www.virtualbox.org/manual/ch04.html#sharedfolders ``` + ```bash This option can be disabled globally with an environment variable: @@ -204,6 +215,8 @@ or on a per folder basis within the Vagrantfile: +#### Se connecter à la VM: + ```bash $ vagrant ssh vagrant@vagrant-VirtualBox:~$ ls @@ -216,3 +229,12 @@ déconnexion Connection to 127.0.0.1 closed. ``` + + +#### Arrêter la VM: + +```bash +$ vagrant halt +==> default: Attempting graceful shutdown of VM... +``` + diff --git a/docs/Divers/debian.md b/docs/Divers/debian.md new file mode 100644 index 0000000..be870d6 --- /dev/null +++ b/docs/Divers/debian.md @@ -0,0 +1,118 @@ +# debian + + + +#### Régler un clavier mac: + +Passer en mode administrateur « root » puis écrire la commande : + +```bash +nano /etc/default/keyboard +``` + +Il faut modifier les deux lignes: + +```markup +XKBVARIANT="latin9" +XKBOPTIONS="” +``` + +par : + +```markup +XKBVARIANT="mac" +XKBOPTIONS="lv3:switch,compose:lwin” +``` + +Sauver puis redémarrer. + + + +#### Installer et configurer sudo: + +Contrairement à Ubuntu, sudo n’est pas installé par défaut sur Debian 10. + +Passer en mode administrateur « root » puis : + +```bash +# apt-get install sudo +``` + + + +##### Ajouter un utilisateur à sudo: + +```bash +sudo nano /etc/sudoers +``` + +puis: + +```bash +# User privilege specification +root ALL=(ALL:ALL) ALL +user ALL=(ALL:ALL) ALL +``` + +Sinon: + +```bash +/usr/sbin/adduser user +``` + + + +##### Ajouter l'utilisateur vagrant à sudo: + +```bash +sudo nano /etc/sudoers +``` + +puis: + +```bash +# User privilege specification +root ALL=(ALL:ALL) ALL +vagrant ALL=(ALL) NOPASSWD:ALL +``` + + + +##### Exécuter la dernière commande avec sudo: + +```bash +$ sudo !! +``` + + + +#### Installer Guest Tools (VirtualBox): + +Passer en mode administrateur « root » puis + +```bash +apt update +apt ugrade +apt install build-essential module-assistant dkms +``` + +Préparer le système à compiler les modules kernel: + +```bash +m-a prepare +``` + +Dans *VirtualBox*, menu *Devices*, cliquer sur *Insert Guest Additions CD image*, puis: + +```bash +mount /dev/cdrom /mnt +cd /mnt +./VBoxLinuxAdditions.run +``` + +Redémarrer la VM: + +```bash +shutdown -r now +``` + diff --git a/docs/Divers/zsh/zsh.md b/docs/Divers/zsh/zsh.md new file mode 100644 index 0000000..ba319e0 --- /dev/null +++ b/docs/Divers/zsh/zsh.md @@ -0,0 +1,46 @@ +# zsh + + + +### [nyae]? + +`n`: **n**o. Ne corrige pas et exécute la commande entrée. + +```bash +[bruno@silverbook/~] $ lx +zsh: correct 'lx' to 'ls' [nyae]? n +zsh: command not found: lx +``` + +`y`: **y**es. Corrige et exécute la modification suggérée par zsh. + +```bash +[bruno@silverbook/~] $ lx +zsh: correct 'lx' to 'ls' [nyae]? y +Applications Movies Sites +Applications (Parallels) Music SynologyDrive +Brewfile Nextcloud backup_list.conf +Cloud OneDrive pCloud Drive +Desktop Parallels path +Documents Pictures plugins.d +Downloads Public project +Dropbox PycharmProjects +Library Shared with me +``` + +`a`: **a**bort. Ne fait rien et affiche un nouveau prompt. + +```bash +$ setfile +zsh: correct 'setfile' to 'SetFile' [nyae]? a +$ +``` + +`e`: **e**dit. Editer la ligne. + +```bash +$ setfile +zsh: correct 'setfile' to 'SetFile' [nyae]? e +$ setfile| +``` + diff --git a/docs/MySQL/index.md b/docs/MySQL/index.md index c6f78cc..98300e9 100644 --- a/docs/MySQL/index.md +++ b/docs/MySQL/index.md @@ -2,6 +2,72 @@ +### Install MariaDB avec Homebrew: + + + +```bash +bruno@SilverBook: ~ $ sudo find / -name mysql +Password: +/usr/local/bin/mysql +/usr/local/include/mysql +/usr/local/etc/init.d/mysql +/usr/local/etc/logrotate.d/mysql +/usr/local/var/mysql +/usr/local/var/mysql/mysql +/usr/local/Cellar/mariadb/10.4.6_1/bin/mysql +/usr/local/Cellar/mariadb/10.4.6_1/include/mysql +/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/server/mysql +/usr/local/Cellar/mariadb/10.4.6_1/include/mysql/mysql +/usr/local/Cellar/mariadb/10.4.6_1/.bottle/etc/init.d/mysql +/usr/local/Cellar/mariadb/10.4.6_1/.bottle/etc/logrotate.d/mysql +/usr/local/Cellar/mariadb/10.4.6_1/share/mysql +/usr/local/share/mysql +``` + + + +#### my.cnf + +```bash +bruno@SilverBook: /usr/local/etc $ ls -la +total 160 +-rw-r--r-- 1 bruno admin 212 4 sep 16:53 my.cnf +drwxr-xr-x 3 bruno admin 96 16 aoû 10:43 my.cnf.d +-rw-r--r-- 1 bruno admin 113 4 sep 16:53 my.cnf.default +``` + +```bash +bruno@SilverBook: /usr/local/etc/my.cnf.d $ l +total 0 +-rw-r--r-- 1 bruno admin 0 16 aoû 10:43 wont_prune.txt +``` + + + +#### Bases + +```bash +bruno@SilverBook: /usr/local/var/mysql $ l +total 245920 +-rw-rw---- 1 bruno admin 6519 15 oct 17:48 SilverBook.local.err +-rw-rw---- 1 bruno admin 5 15 oct 17:48 SilverBook.local.pid +-rw-rw---- 1 bruno admin 24576 15 oct 17:46 aria_log.00000001 +-rw-rw---- 1 bruno admin 52 15 oct 17:46 aria_log_control +-rw-r----- 1 bruno admin 976 15 oct 17:46 ib_buffer_pool +-rw-rw---- 1 bruno admin 50331648 15 oct 17:48 ib_logfile0 +-rw-rw---- 1 bruno admin 50331648 6 aoû 20:18 ib_logfile1 +-rw-rw---- 1 bruno admin 12582912 15 oct 17:46 ibdata1 +-rw-rw---- 1 bruno admin 12582912 15 oct 17:48 ibtmp1 +-rw-rw---- 1 bruno admin 0 6 aoû 20:18 multi-master.info +drwx------ 90 bruno admin 2880 6 aoû 20:18 mysql +drwx------ 3 bruno admin 96 6 aoû 20:18 performance_schema +-rw-rw---- 1 bruno admin 3047 11 aoû 22:49 silverbook-1.home.err +-rw-rw---- 1 bruno admin 30926 15 oct 17:46 silverbook.home.err +``` + + + [Reset Expired root Password for MySQL 5.7 on Mac OS X](Expired-root-Password.md) [mysqlcheck](mysqlcheck.md) diff --git a/docs/Synology/opkg/oPKG.md b/docs/Synology/opkg/oPKG.md index 9eccc47..d53e82d 100644 --- a/docs/Synology/opkg/oPKG.md +++ b/docs/Synology/opkg/oPKG.md @@ -166,7 +166,9 @@ Package nano (2.9.6-1) is installed on root and has the following files: ##### Chercher un paquet: ```bash -bruno@DS916:~ $ sudo opkg search ??? +bruno@DS916:~ $ sudo opkg search '*php*' + +bruno@DS916:~ $ sudo opkg find '*php*' ``` ##### Afficher les infos sur un paquet: diff --git a/docs/Synology/scripts.md b/docs/Synology/scripts.md index 89a7487..cf35cb5 100644 --- a/docs/Synology/scripts.md +++ b/docs/Synology/scripts.md @@ -1,10 +1,4 @@ -# FFmpeg - - - -[:fa-link: Doc](http://ffmpeg.org/ffmpeg.html#Options) - -[:fa-link: Encode AAC](https://trac.ffmpeg.org/wiki/Encode/AAC) +# Scripts diff --git a/docs/macos/Mail.md b/docs/macos/Mail.md new file mode 100644 index 0000000..d25c0ab --- /dev/null +++ b/docs/macos/Mail.md @@ -0,0 +1,6 @@ +# Récupérer les BAL *Sur mon Mac* dans OSX Mail + + + +https://grayjetmedia.com/2016/04/01/recovering-lost-on-my-mac-local-mailboxes-after-os-x-10-11-el-capitan-upgrade/ + diff --git a/docs/macos/chflags.md b/docs/macos/chflags.md new file mode 100644 index 0000000..734522d --- /dev/null +++ b/docs/macos/chflags.md @@ -0,0 +1,58 @@ + + + + +# chflags + + + +Changer les flags d'un fichier ou d'un dossier. + + + +Voir les flags dans macOS (**ls -lO**): + +```bash +silverbook-1:~ enzo$ ls -lO +total 0 +drwx------+ 3 enzo staff - 96 12 aoû 22:28 Desktop +drwx------+ 3 enzo staff - 96 12 aoû 22:28 Documents +drwx------+ 3 enzo staff - 96 12 aoû 22:28 Downloads +drwx------@ 56 enzo staff hidden 1792 17 aoû 08:07 Library +drwx------+ 3 enzo staff - 96 12 aoû 22:28 Movies +drwx------+ 3 enzo staff - 96 12 aoû 22:28 Music +drwx------+ 3 enzo staff - 96 12 aoû 22:28 Pictures +drwxr-xr-x+ 4 enzo staff - 128 12 aoû 22:28 Public +``` + +Par défaut, le dossier Bibliothèque de l'utilisateur est caché. + +Si aucun flag n'est pis, un tiret est affiché. + + + +Les différents flags sont: + +- arch, archived (super-user only) +- opaque (owner or super-user only) +- nodump (owner or super-user only) +- sappnd,sappend (super-user only) +- schg, schange, simmutable (super-user only) +- uappnd, uappend (owner or super-user only) +- uchg, uchange, uimmutable (owner or super-user only) +- hidden + + + +Pour supprimer un flag, il faut le régler à l'opposé: + +```bash +$ sudo chflags dump /usr/bin/local/oty.sh +``` + +Comme pour chmod, l'option -R permet la récursivité. + +```bash +$ chflags -R nohidden ~/Desktop +``` + diff --git a/docs/macos/getfileinfo_setfile.md b/docs/macos/getfileinfo_setfile.md new file mode 100644 index 0000000..49954b9 --- /dev/null +++ b/docs/macos/getfileinfo_setfile.md @@ -0,0 +1,62 @@ +# GetFileInfo - SetFile + + + + + +### GetFileInfo + +#### Attributs (-a): + + Minuscule = 0, Majuscule = 1 + + A Alias file + B Bundle + C Custom icon* + D Desktop* + E Hidden extension* + I Inited* + M Shared (can run multiple times) + N No INIT resources + L Locked + S System (name locked) + T Stationery + V Invisible* + Z Busy* + + Les items marqués avec un astérisque (*) sont autorisés avc les dossiers. + + + Après une clean install de Mojave, mon dossier utilisateur n'apparassait pas dans le Finder (/Users/). +```bash +silverbook:Users enzo$ GetFileInfo bruno/ +directory: "/Users/bruno" +attributes: aVbstclinmedz +created: 08/03/2019 17:59:52 +modified: 08/12/2019 23:03:17 +``` + +Je crée un 2nd utilisateur qui lui apparait bien. + +```bash +silverbook:Users enzo$ GetFileInfo enzo/ +directory: "/Users/enzo" +attributes: avbstclinmedz +created: 08/12/2019 22:28:15 +modified: 08/12/2019 23:06:58 +``` + +Dans le 1er cas, l'attribut V (majuscule) est mis sur invisible. + +Dans le 2nd cas, l'attribut v (minuscule) est correctement mis sur visible. + + + +### SetFile + +Pour remettre visible mon dossier utilisateur: + +```bash +silverbook:Users bruno$ SetFile -a v bruno/ +``` + diff --git a/docs/macos/homebrew/brew-cask.md b/docs/macos/homebrew/brew-cask.md index 609890b..a3de491 100644 --- a/docs/macos/homebrew/brew-cask.md +++ b/docs/macos/homebrew/brew-cask.md @@ -249,6 +249,35 @@ Already downloaded: /Users/bruno/Library/Caches/Homebrew/downloads/1916f7da74b03 +### Error: undefined method `match?' for nil:NilClass + +```bash +Casks upgrade. +==> Satisfying dependencies +==> Downloading https://download.docker.com/mac/stable/37877/Docker.dmg +Already downloaded: /Users/bruno/Library/Caches/Homebrew/downloads/b3bb59c37763f69c59847ec95b1e097d3500ace49f5d25eb9acfd4f4eee215f5--Docker.dmg +==> Verifying SHA-256 checksum for Cask 'docker'. +==> Uninstalling Cask docker +==> Removing launchctl service com.docker.helper +Password: +==> Removing launchctl service com.docker.vmnetd +Error: undefined method `match?' for nil:NilClass +Follow the instructions here: + https://github.com/Homebrew/homebrew-cask#reporting-bugs +``` + +Supprimer l'application Docker manuellement, puis la réinstaller. + +```bash + $ rm -rvf "$(brew --prefix)/Caskroom/docker" + + $ brew cask install docker +``` + + + + + ### Réinstaller une ancienne version de VirtualBox (6.0.6 au lieu de 6.0.8): Désinstaller la version actuelle: diff --git a/docs/macos/node/nvm.md b/docs/macos/node/nvm.md index 196d011..68bde1b 100644 --- a/docs/macos/node/nvm.md +++ b/docs/macos/node/nvm.md @@ -61,7 +61,7 @@ export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm" -### Utilisation +### Utilisation: Installer NodeJS. @@ -155,3 +155,21 @@ Now using node v10.15.0 (npm v6.4.1) $ nvm reinstall-packages 8 ``` + + +### Erreur: + +```bash +# A l'ouverture d'une fenêtre bash + +N/A: version "N/A -> N/A" is not yet installed. + +You need to run "nvm install N/A" to install it before using it. +``` + +Entrer: + +```bash +$ nvm alias default 12 +``` + diff --git a/docs/macos/webserver/mysql.md b/docs/macos/webserver/mysql.md index 5f83711..5a015a6 100644 --- a/docs/macos/webserver/mysql.md +++ b/docs/macos/webserver/mysql.md @@ -597,3 +597,26 @@ mysql.db OK mysql.event OK ``` + + +#### BASH : exécuter une requête MySql et exploiter le résultat + +```bash +$ echo "SHOW DATABASES;" | mysql -h localhost -u root -ppassword +Database +information_schema +mysql +performance_schema +wordpress +zenphoto +``` + +[exécuter une requête MySql et exploiter le résultat](https://www.quennec.fr/trucs-astuces/systèmes/gnulinux/utilisation/bash-exécuter-une-requête-mysql-et-exploiter-le-résultat) + + + +#### Créer un utilisateur avec les permissions lecture seule pour le backup des bases. + +```mysql +GRANT SELECT, LOCK TABLES ON *.* TO 'MYBACKUPUSER'@'%' IDENTIFIED BY 'MYPASSWORD'; +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 9469285..f7e7f1b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -127,6 +127,7 @@ nav: - Index: Raspberry/index.md - apt-get: Raspberry/apt-get.md - aptitude: Raspberry/aptitude.md + - Backup SD: Raspberry/backup_sd.md - Boot et clone: Raspberry/boot.md - Backup: Raspberry/backup.md - Hardware: Raspberry/hardware.md @@ -172,6 +173,7 @@ nav: - Session de travail avec git: Divers/git/git-session.md - go: Divers/go.md - Markdown: Divers/markdown.md + - Nextcloud: Divers/nextcloud.md - Plex: Divers/plex.md - Vagrant: - Installation: Divers/Vagrant/Vagrant.md