31-08-2021

This commit is contained in:
2021-08-31 09:29:05 +02:00
parent 7d89fb0224
commit bb890cba15
28 changed files with 1888 additions and 47 deletions

View File

@@ -66,3 +66,73 @@ PUBLIC C:\Users\Public
CommonProgramFiles C:\Program Files\Common Files
```
Afficher le PATH
```powershell
> $env:Path
C:\Program Files\Parallels\Parallels Tools\Applications;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\PowerShell\7\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Users\bruno\AppData\Local\Microsoft\WindowsApps;C:\Users\bruno\AppData\Local\Programs\Microsoft VS Code\bin
```
Ajouter au PATH
```
$addPath = 'C:\Folder\bin'
```
##### which:
`Get-Command <command>`
```powershell
Get-Command wsl
CommandType Name Version Source
----------- ---- ------- ------
Application wsl.exe 10.0.22... C:\WINDOWS\system32\wsl.exe
```
##### Version de Powershell:
`Get-Host`
```powershell
PS C:\Users\bruno> Get-Host
Name : ConsoleHost
Version : 7.1.4
InstanceId : c47454ef-ce56-4af8-b3e0-6b10825d6f8f
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : fr-FR
CurrentUICulture : fr-FR
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
```
`(Get-Host).Version`
```powershell
PS C:\Users\bruno> (Get-Host).Version
Major Minor Build Revision
----- ----- ----- --------
7 1 4 -1
```
`$PSVersionTable.PSVersion`
```powershell
PS C:\Users\bruno> $PSVersionTable.PSVersion
Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
7 1 4
```

View File

@@ -1,5 +1,71 @@
# Trucs
Ouvrir Windows Terminal en 3 panneaux:
```powershell
wt -p "Debian" `; split-pane -p "PowerShell 7" `; split-pane -p "Invite de commandes"
```
Ouvrir en 3 onglets dans Windows Terminal:
```powershell
wt -p "Debian" `; new-tab -p "PowerShell 7" `; new-tab -p "Invite de commandes"
```
Palette de commande:
`Ctrl + Shift + P`
Thèmes:
https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
https://ohmyposh.dev/docs/
#### Ouvrir une nouvelle fenêtre Powershell en administrateur:
1.
```powershell
Start-Process powershell -Verb runAs
```
https://stackoverflow.com/questions/7690994/running-a-command-as-administrator-using-powershell
2.
`Win + Ctrl + Maj + 8`
Si Powershell est en 8e position dans la barre des taches (le 1er étant l'Explorateur).
3.
```powershell
# ouvre une nouvelle fenêtre de Windows Terminal en mode admin.
powershell "Start-Process -Verb RunAs cmd.exe '/c start wt.exe'"
```
4.
[gsudo](https://github.com/gerardog/gsudo)
Installation:
```powershell
choco install gsudo
winget install gsudo
```
```powershell
# Dans PowerShell ou l'invite de commande:
# donne les droits admin à la console courante
gsudo
```
```powershell
@@ -177,3 +243,28 @@ Bash <-> PowerShell:
| | | |
| | | |
#### Réinitialiser Windows Store
1ere solution:
```powershell
PS> PowerShell -ExecutionPolicy Unrestricted $manifest = (Get-AppxPackage Microsoft.WindowsStore).InstallLocation + \AppxManifest.xml ; Add-AppxPackage -DisableDevelopmentMode -Register $manifest
```
2eme solution:
```powershell
PS> sfc /scannow
```
puis reboot (fonctionne W11)
3eme solution:
```powershell
DISM /Online /Cleanup-Image /ScanHealth
```
puis reboot

View File

@@ -2,6 +2,8 @@
[Docs](https://github.com/microsoft/terminal/tree/master/doc/user-docs)
https://docs.microsoft.com/en-us/windows/terminal/get-started
### Installation:

77
docs/Windows/winget.md Normal file
View File

@@ -0,0 +1,77 @@
# winget
https://github.com/microsoft/winget-cli
https://docs.microsoft.com/en-us/windows/package-manager/?WT.mc_id=thomasmaurer-blog-thmaure
#### Installation:
Nécessite un compte <u>Windows Insider</u>.
Sur le Microsoft Store, installer **App Installer** (Programme d'installation d'application)
La commande **winget** est dispo dans l<u>'Invite de commande</u> ou dans <u>Powershell</u>.
#### Utilisation:
##### Rechercher un paquet:
`winget shearch <paquet>`
```powershell
PS> winget search etcher
Nom ID Version
----------------------------------------------
balenaEtcher Balena.Etcher 1.5.121
UCF Ahlyab.UdemyCouponFetcher 1
```
##### Information sur un paquet:
`winget show <paquet>`
```powershell
PS> winget show etcher
Trouvé balenaEtcher [Balena.Etcher]
Version: 1.5.121
Publisher: Balena Inc.
Author: Balena Inc.
Moniker: etcher
Description: Etcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more.
Homepage: https://www.balena.io/etcher
License: Apache License 2.0
License Url: https://raw.githubusercontent.com/balena-io/etcher/v1.5.121/LICENSE
```
##### Installer un paquet:
`winget install <paquet>`
```powershell
PS> winget install balenaEtcher
Trouvé balenaEtcher [Balena.Etcher]
La licence dutilisation de cette application vous est octroyée par son propriétaire.
Microsoft nest pas responsable des paquets tiers et naccorde pas de licences à ceux-ci.
Downloading https://github.com/balena-io/etcher/releases/download/v1.5.121/balenaEtcher-Setup-1.5.121.exe
140 MB / 140 MB
Le code de hachage de linstallation a été vérifié avec succès
Démarrage du package dinstallation... Merci de patienter.
Installé correctement
```
##### Mettre-à-jour un paquet:
`winget upgrade <paquet>`
`winget upgrade --all`
`winget list <paquet>`
##### Désinstaller un paquet:
`winget uninstall <paquet>`

View File

@@ -2,7 +2,7 @@
### WSL 2 (installation)
### WSL (installation)
Nécessite au minimum la build 2004 (une <u>insider build</u> au 31/03/2020)
Aller à Fonctionnalités de Windows:
@@ -19,11 +19,23 @@ Pour voir, si elle est active, aller dans le Gestionnaire de taches -> onglet Pe
Pour Parallels Desktop, aller dans Configuration -> Matériel -> CPU et mémoire -> Paramètres avancés, et cocher <u>Activer la virtualisation imbriquée</u>.
Aller sur le Microsoft Store et installer une distrib Linux.
Mettre-à-jour le [composant noyau](https://docs.microsoft.com/en-us/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package):
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_arm64.msi
Dans PowerShell:
```powershell
wsl --set-default-version 1
```
Aller sur le Microsoft Store et installer une distrib Linux (Debian).
```bash
$ cat /etc/debian_version
10.3
11.0 # bullseye
```
Dans l'<u>invite de commande</u>:
@@ -41,7 +53,7 @@ Distributions du sous-système Windows pour Linux :
Debian (par défaut)
```
Les distros sont visibles en tapant `\\wsl$` dans la barre de l'explorer.
Les distros sont visibles en tapant \\wsl$ dans la barre de l'explorer.
Même en quittant la distro (`$ exit`), elle y reste dispo.
#### Quitter une distro:
@@ -80,7 +92,7 @@ wsl --set-default-version 2
#### Pour démarrer la distro:
```bash
```powershell
wsl --distribution Debian
@@ -93,6 +105,61 @@ NAME STATE VERSION
#### Liste des distributions:
```powershell
# Prêtes à l'utilisation:
wsl -l
wsl --list
Distributions du sous-système Windows pour Linux :
Debian (par défaut)
Ubuntu
# Toutes les distributions:
wsl --list --all
Distributions du sous-système Windows pour Linux :
Debian (par défaut)
Ubuntu
# En cours d'utilisation:
wsl --list --running
Distributions du sous-système Windows pour Linux :
Debian (par défaut)
```
#### Distribution par défaut:
Celle qui répond aux commandes `wsl`
```powershell
wsl -s Debian
wsl --setdefault Debian
```
Pour utiliser une distribution spécifique, sans la mettre par défaut:
```powershell
wsl -d Ubuntu
wsl --distribution Ubuntu
```
#### Désactiver une distribution:
Elle n'apparait plus dans `wsl --list`:
```
wsl --unregister Debian
```
Retourner dans le Microsoft Store pour la réinstaller.
@@ -124,8 +191,26 @@ https://docs.microsoft.com/en-us/windows/wsl/wsl-config#set-wsl-launch-settings
#### Fichier de config `/etc/wsl.conf`:
Il est lu au chargement de la distro.
#### Fichier de configuration globale `C:\Users\<yourUserName>\.wslconfig`:
Les options s'appliquent à toutes les distros (WSL2)
https://docs.microsoft.com/en-us/windows/wsl/wsl-config
#### Installer une GUI:
```
sudo apt-get update
```
Installer xfce4:
```bash
@@ -153,10 +238,16 @@ Trouver l'adresse IP de la distrib WSL
```bash
ifconfig | grep inet (ip addr | grep inet)
Les IP de ipconfig.exe ne sont pas les bonnes.
#Les IP de ipconfig.exe ne sont pas les bonnes.
```
```bash
hostname -i
127.0.1.1
```
Ouvrir une session xRDP
> mstsc.exe
> puis fournir l'adresse IP
@@ -164,6 +255,12 @@ Ouvrir une session xRDP
mstsc.exe 127.0.0.1:3390
```
Si erreur *failed to execute child process "dbus-launch"*:
```bash
sudo apt-get install dbus-x11
```
Ajouter un alias au .zshrc
```bash
@@ -178,6 +275,12 @@ https://korben.info/linux-wsl-gui-interface-graphique-windows-10.html
```bash
sudo apt install python3 python3-pip ipython3
```
#### Navigation dans les dossiers/fichiers:
Dans WSL:

View File

@@ -158,12 +158,55 @@ $ chmod 600 ~/.ssh/*
#### Installer keychain dans wsl:
#### Créer le ssh-agent:
```bash
$ eval $(ssh-agent -s)
Agent pid 3551
```
#### Ajouter la clé ssh au ssh-agent:
```bash
$ ssh-add
Enter passphrase for /home/bruno/.ssh/id_rsa:
Identity added: /home/bruno/.ssh/id_rsa
```
####
#### ~~Installer keychain dans wsl:~~
```bash
$ sudo apt install keychain
```
et ajouter au `.zshrc`:
```bash
# on peut mettre toutes les clés que l'on veut attacher à la keychain
eval `keychain --eval --agents ssh ~/.ssh/id_rsa`
```
A la première ouverture du terminal, keychain demande la passphrase.
Pour les sessions suivantes, keychain indique que des clés sont chargées.
Liste des clés:
```bash
$ keychain --list
3072 SHA256:V/qyypJ2NVwfvQ8l8P/JBZcNC515j66MKG9HTAuDnX0 bruno@BRUNOPESENT79AA (RSA)
```
Décharger les clés en mémoire:
```bash
$ keychain --clear
```
#### Copier la clé sur le serveur:
@@ -184,6 +227,25 @@ scp -P42666 C:\Users\bruno\.ssh\id_rsa.pub bruno@clicclac.synology.me:~/.ssh/aut
#### Ne plus demander la passphrase ssh:
#### 1.
```powershell
# By default the ssh-agent service is disabled. Allow it to be manually started for the next step to work.
# Make sure you're running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Manual
# Start the service
Start-Service ssh-agent
# This should return a status of Running
Get-Service ssh-agent
# Now load your key files into ssh-agent
ssh-add ~\.ssh\id_rsa
```
#### 2.
https://medium.com/@glsorre/windows-subsystem-for-linux-never-prompt-your-ssh-passphrase-again-353db7c931ab
<u>Installer CredentialManager:</u>
@@ -285,6 +347,24 @@ compinit
#### Pipe vers le presse-passier Windows:
Ajouter dans le .zshrc:
```bash
alias clip="clip.exe"
```
puis dans le shell:
```bash
grep alias .zshrc | clip
```
et coller (Ctrl+V) dans Notepad.
### Fin
```bash
@@ -296,5 +376,11 @@ $ uname --release
https://opticos.github.io/openinwsl/
https://opticos.github.io/gwsl/
https://github.com/sirredbeard/Awesome-WSL
https://devblogs.microsoft.com/commandline/access-linux-filesystems-in-windows-and-wsl-2/