This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
other:win10wsl [2020/08/23 22:18] jypeter [Upgrading ubuntu] |
other:win10wsl [2021/02/24 14:44] (current) jypeter [WSL] |
||
---|---|---|---|
Line 75: | Line 75: | ||
There are several ways to open a default terminal: | There are several ways to open a default terminal: | ||
- | * select //Ubuntu// from the ''Start'' menu | + | * Select //Ubuntu// from the ''Start'' menu |
- | * click on the //Ubuntu// icon on the task bar | + | * Click on the //Ubuntu// icon on the task bar |
* if you don't have a //Ubuntu// icon on the task bar yet: right-click on the //Ubuntu// icon (in the ''Start'' menu) -> More -> Pin to the task bar | * if you don't have a //Ubuntu// icon on the task bar yet: right-click on the //Ubuntu// icon (in the ''Start'' menu) -> More -> Pin to the task bar | ||
* to open more terminals: right-click on the //Ubuntu// icon on the task bar -> Ubuntu | * to open more terminals: right-click on the //Ubuntu// icon on the task bar -> Ubuntu | ||
- | * type ''ubuntu''+<Enter> or ''wsl''+''<Enter>'' in the (Cortana) Search field on the task bar | + | * Type ''ubuntu''+<Enter> or ''wsl''+''<Enter>'' in the (Cortana) Search field on the task bar |
== Copy/paste in the default terminal == | == Copy/paste in the default terminal == | ||
Line 92: | Line 92: | ||
=== The WSLtty terminal === | === The WSLtty terminal === | ||
- | <note tip>This is the recommended (by JYP) option for now</note> | + | <note tip> |
+ | * This is the recommended (by JYP) option for now | ||
+ | |||
+ | * If you can't open a terminal after Windows upgrades from WSL to WSL v2, get and install the latest version of WSLtty ! | ||
+ | </note> | ||
[[https://github.com/mintty/wsltty|WSLtty]] allows you to use the efficient //Mintty// as a terminal for WSL. **You do not need to have an //X server// running to use it!** | [[https://github.com/mintty/wsltty|WSLtty]] allows you to use the efficient //Mintty// as a terminal for WSL. **You do not need to have an //X server// running to use it!** | ||
* Download and execute the latest [[https://github.com/mintty/wsltty/releases|64bit installer]] (the most recent ''wsltty-*-install-x86_64.exe'' file) | * Download and execute the latest [[https://github.com/mintty/wsltty/releases|64bit installer]] (the most recent ''wsltty-*-install-x86_64.exe'' file) | ||
- | * You will then have different ways to start a terminal: | + | * After installing, you will get several ways to open a terminal: |
- | * //WSL terminal// shorcut on the desktop | + | * Double-click on the ''WSL terminal'' icon on the desktop |
- | * //Ubuntu terminal// and //WSL Terminal// in the ''Start'' menu | + | * ''U''=>''Ubuntu terminal'' and ''W''=>''WSL Terminal'' in the ''Start'' menu |
- | * Open a terminal and right-click in it to discover/use the options | + | * There is also a ''W''=>''WSLtty'' folder, than you don't really need |
- | * More options with CTRL+right-click | + | * Open a terminal and right-click in it to check the available options |
+ | * You can access even more options with CTRL+right-click | ||
* You can cycle between the open WSLtty terminals with CTRL+Tab and Shift+CTRL+Tab | * You can cycle between the open WSLtty terminals with CTRL+Tab and Shift+CTRL+Tab | ||
* [[https://github.com/mintty/mintty/wiki|Technical stuff]] (on the Mintty wiki) | * [[https://github.com/mintty/mintty/wiki|Technical stuff]] (on the Mintty wiki) | ||
Line 107: | Line 112: | ||
=== The new Windows Terminal === | === The new Windows Terminal === | ||
- | Microsoft is working on a powerful replacement of the old ''cmd'' terminal, but it still needs to be improved ([[https://devblogs.microsoft.com/commandline/windows-terminal-preview-v0-8-release/|Windows Terminal Preview v0.8 Release]]) | + | Microsoft is working on a powerful replacement of the old ''cmd'' terminal! Check [[https://github.com/microsoft/terminal|Windows Terminal, Console and Command-Line @ github]] |
- | You can install it from the Microsoft Store: search //Windows Terminal (Preview)// | + | Note: the //Windows Terminal// looks really promising, but will be nice when there is a GUI for editing the options (rather the editing a //json// file with a text editor...) and a way to select //xterm-style// copy-pasting. See [[https://github.com/microsoft/terminal/issues/7646|Feature request: add xterm-style select/copy/paste options]] |
- | [[https://github.com/microsoft/terminal|Windows terminal @ github]] | + | * [[https://aka.ms/terminal|Getting the Windows Terminal from the Microsoft Store]] |
+ | * [[https://docs.microsoft.com/en-us/windows/terminal/|Documentation]] | ||
=== Terminals started from Linux === | === Terminals started from Linux === | ||
Line 392: | Line 398: | ||
===== Updating WSL and ubuntu ===== | ===== Updating WSL and ubuntu ===== | ||
- | <note tip>You don't have to worry about this if you have just installed WSL+Ubuntu!</note> | + | <note tip>You don't have to worry about the //Upgrade// section if you have just installed WSL+Ubuntu, because you are already using the latest Ubuntu stable release!</note> |
==== WSL ==== | ==== WSL ==== | ||
- | WSL is automatically updated when Windows 10 is updated | + | **Nothing to do!** WSL is automatically updated, provided you have **enabled** the [[other:win10maintain#updating_microsoft_office|Get updates for other Microsoft products]] option |
[[https://docs.microsoft.com/en-us/windows/wsl/wsl-config#managing-multiple-linux-distributions| WSL command line options]] | [[https://docs.microsoft.com/en-us/windows/wsl/wsl-config#managing-multiple-linux-distributions| WSL command line options]] | ||
Line 709: | Line 715: | ||
It is not possible to **stop or reboot WSL** like a regular Linux computer | It is not possible to **stop or reboot WSL** like a regular Linux computer | ||
* ''shutdown -r now'' will generate an error message | * ''shutdown -r now'' will generate an error message | ||
- | * WSL keeps on running even when all the terminals are closed | + | * WSL keeps on running even when all the Linux terminals are closed |
- | Shutting down or rebooting the Windows computer will of course stop WSL but it's useful to be able to only stop/restart WSL in order to: | + | Shutting down or rebooting the Windows computer will of course stop WSL but it's useful to be able to just stop/restart WSL in order to: |
* force WSL to **recognize new disk drives** and make them available as ''/mnt/<new_drive_letter'' | * force WSL to **recognize new disk drives** and make them available as ''/mnt/<new_drive_letter'' | ||
* force WSL to recognize drives that were still encrypted when the first WSL terminal was opened | * force WSL to recognize drives that were still encrypted when the first WSL terminal was opened | ||
- | WSL can be stopped the following way. Warning: all the opened terminals and running processes will be terminated! | + | WSL can be stopped the following way. Warning: all the open terminals and running processes will be terminated! |
* from a Windows terminal (''cmd'', ''PowerShell'', ... no need to run as administrator): | * from a Windows terminal (''cmd'', ''PowerShell'', ... no need to run as administrator): | ||
- | * Get the name of the installed (and running) Linux: **''wsl %%--%%list %%--%%all''** | + | * Get the name of the installed (and running) Linux: **''wsl %%--%%list %%--%%verbose''** |
- | * Stop this instance of Linux (e.g. if it is named //Ubuntu//): **''wsl %%--%%terminate Ubuntu''** | + | * Stop //this instance// of Linux (e.g. if it is named //Ubuntu//): **''wsl %%--%%terminate Ubuntu''** |
+ | * or Stop //all// the currently running Linux distributions: **''wsl %%--%%shutdown''** | ||
- | Alternative (and less convenient) ways: | ||
- | * from the //Services// tab of the Task manager or the //Services// program (launch ''services.msc'') | ||
- | * Right-click on the ''LxssManager'' service and select //Restart// | ||
- | * from a //Powershell// in admin mode (right-click on the Windows //Start// button) | ||
- | * Type ''Get-Service LxssManager | Restart-Service'' | ||
- | |||
- | Source: google ''wsl lxssmanager'' ([[https://www.how2shout.com/how-to/how-to-reboot-wsl-windows-subsystem-linux-in-windows-10.html|most usable answer]]) | ||
==== Creating a backup of the Linux running in WSL ==== | ==== Creating a backup of the Linux running in WSL ==== | ||
There are several types of WSL related directories that you may want to back up: | There are several types of WSL related directories that you may want to back up: | ||
- | * <wrap hi>Your Linux //home// directory</wrap> (''/home/<your_login>''), or some specific sub-directories of the //Ubuntu// running in WSL (sub-directories of ''/''): all these files are located in a [[other:win10wsl#location_of_the_files|hidden sub-directory of you Windows directory]], and the best way to save them is probably to **create a tar file from Linux**, and put this tar file in a specific Windows folder | + | |
+ | * <wrap hi>Your Linux //home// directory</wrap> (''/home/<your_login>''), or some specific sub-directories of the //Ubuntu// running in WSL (sub-directories of ''/''): all these files are located in a [[other:win10wsl#location_of_the_files|hidden sub-directory of you Windows directory]], and the best way to save them is probably to **create a tar file from Linux**, and put this tar file in a specific Windows //WSL backup folder// (we will use below the directory ''/mnt/c/Scratch/<your_login>'' or ''c:\Scratch\<your_login>'') | ||
* <code bash>$ cd /home | * <code bash>$ cd /home | ||
- | # $ du -sh <your_login> | + | |
$ du -sh $USER | $ du -sh $USER | ||
232K <your_login> | 232K <your_login> | ||
- | # $ tar cfz /mnt/c/Scratch/<your_login>/<your_login>_home_<some_date>.tgz <your_login> | + | |
- | # We assume below that there is an existing /mnt/c/Scratch/$USER/ directory | + | # We assume below that there is an existing /mnt/c/Scratch/<your_login>/ directory |
- | # It's a WINDOWS directory C:\Scracth\$USER | + | # It's a WINDOWS directory C:\Scratch\<your_login> |
$ tar cfz /mnt/c/Scratch/$USER/${USER}_home_`date +%y%m%d_%H%M`.tgz $USER | $ tar cfz /mnt/c/Scratch/$USER/${USER}_home_`date +%y%m%d_%H%M`.tgz $USER | ||
- | </code> | + | |
+ | # Check the size of the new (and existing old) backup(s) | ||
+ | $ ls -ltr /mnt/c/Scratch/$USER/${USER}_*.tgz | ||
+ | 81K Jan 21 2020 /mnt/c/Scratch/<your_login>/<your_login>_home_200121.tgz | ||
+ | 93K Aug 22 2020 /mnt/c/Scratch/<your_login>/<your_login>_home_200822_1151.tgz | ||
+ | 95K Feb 24 12:09 /mnt/c/Scratch/<your_login>/<your_login>_home_210224_1209.tgz</code> | ||
* <wrap hi>Regular Windows folders</wrap> where you store data used by WSL: you can use ''tar'' in a Linux terminal, as above, or use any usual way of backing up Windows files (drag and drop, some specific [[other:win10apps#backup_software|backup software]]) | * <wrap hi>Regular Windows folders</wrap> where you store data used by WSL: you can use ''tar'' in a Linux terminal, as above, or use any usual way of backing up Windows files (drag and drop, some specific [[other:win10apps#backup_software|backup software]]) | ||
+ | |||
* <wrap hi>The **full** Linux/Ubuntu installation</wrap> running in WSL (based on [[https://docs.microsoft.com/en-us/windows/wsl/faq#how-can-i-back-up-my-wsl-distros-or-move-them-from-one-drive-to-another|How can I back up my WSL distros?]]). The following steps will save the full installation in a tar file, that can be used later for restoring the full installation (//restoration// not tested yet) | * <wrap hi>The **full** Linux/Ubuntu installation</wrap> running in WSL (based on [[https://docs.microsoft.com/en-us/windows/wsl/faq#how-can-i-back-up-my-wsl-distros-or-move-them-from-one-drive-to-another|How can I back up my WSL distros?]]). The following steps will save the full installation in a tar file, that can be used later for restoring the full installation (//restoration// not tested yet) | ||
- | * Open a Windows terminal (preferably a //PowerShell// if you need easy copy/paste) | + | * Open a **Windows terminal** (preferably a //PowerShell// if you need easy copy/paste)\\ The //Windows// terminal is where you will type the ''wsl'' commands shown below |
- | * Determine the name of the current Linux installation used in WSL | + | * Determine the name of the current Linux installation used in WSL (and see if it is running, and using //WSL 1// or //WSL 2//) |
* <code>> wsl --list --all | * <code>> wsl --list --all | ||
- | Distributions du sous-système Windows pour Linux : | + | Distributions du sous-système Windows pour Linux : |
- | Ubuntu (par défaut)</code> | + | Ubuntu (par défaut) |
+ | |||
+ | > wsl --list --verbose | ||
+ | NAME STATE VERSION | ||
+ | * Ubuntu Running 1</code> | ||
* [[other:win10wsl#rebooting_wsl|Stop WSL+Linux]] | * [[other:win10wsl#rebooting_wsl|Stop WSL+Linux]] | ||
- | * Export the current Linux to a tar file:\\ ''wsl %%--%%export Ubuntu C:\Scratch\<your_login>\<your_login>_ubuntu-<ubuntu_version>-full_<some_date>.tar'' | + | * <code>> wsl --list --verbose |
- | * You can optionally open a new terminal (this will start again WSL+Ubuntu) to get some information about the created file (size and number of saved files/directories), and compress it to save some space | + | NAME STATE VERSION |
+ | * Ubuntu Running 1 | ||
+ | |||
+ | > wsl --shutdown | ||
+ | |||
+ | > wsl --list --verbose | ||
+ | NAME STATE VERSION | ||
+ | * Ubuntu Stopped 1</code> | ||
+ | * Export the current Linux to a //tar// file: | ||
+ | * <code> > wsl --export Ubuntu C:\Scratch\<your_login>\<your_login>_ubuntu-<ubuntu_version>-full_<some_date>.tar</code> | ||
+ | * You can optionally open a new terminal (this will start again WSL+Ubuntu) to get some information about the created file (size and number of saved files/directories), and compress it in order to save some disk space | ||
* <code>$ cd /mnt/c/Scratch/<your_login> | * <code>$ cd /mnt/c/Scratch/<your_login> | ||
- | $ ls -lh <your_login>_ubuntu-full_200514.tar | + | |
- | 2.6G May 14 16:29 <your_login>_ubuntu-full_200514.tar | + | $ ls -ltrh *ubuntu*tar* |
- | $ tar tvf <your_login>_ubuntu-full_200514.tar | wc -l | + | 976M Jan 21 2020 <your_login>_200121.tar.gz |
- | 105600 | + | 2.8G Aug 22 2020 <your_login>-16.04-full_200822.tar |
- | $ gzip <your_login>_ubuntu-full_200514.tar | + | 3.4G Feb 24 14:06 <your_login>-20-04-1-full_210224.tar |
- | $ ls -lh <your_login>_ubuntu-full_200514.tar.gz | + | |
- | 976M May 14 16:29 | + | # Determine the number of files/directories in the backup |
+ | $ tar tvf <your_login>-20-04-1-full_210224.tar | wc -l | ||
+ | 112711 | ||
+ | |||
+ | $ gzip *ubuntu*.tar | ||
+ | |||
+ | $ ls -ltrh *ubuntu*tar* | ||
+ | 976M Jan 21 2020 <your_login>_200121.tar.gz | ||
+ | 1.2G Aug 22 2020 <your_login>-16.04-full_200822.tar.gz | ||
+ | 1.8G Feb 24 14:06 <your_login>-20-04-1-full_210224.tar.gz | ||
</code> | </code> | ||