WSL Commands and Notes

A collection of commands I find useful for running Windows Subsystem Linux.

Backing Up your Linux on Windows Installation

Windows 10 v1903 includes a built-in WSL export/import command. Specifically, wsl --export, which produces a tar and wsl --import, which imports a previously exported tar. You can then move this file between computers.

You can also specify stdin/stdout with -, which should allow you to directly transfer to another machine and import using a remote shell like ssh.

Starting HTML Hosting Services

Ideally these would start when you first start WSL but so far no solution I have found has worked.

Starting Apache web server:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart

If you run into the problem with not enough upload file size change the following line in /etc/php/7.4/apache2/php.ini. Search for the setting first and change it, otherwise add a new line to the file.

upload_max_filesize = 100M

See also https://phoenixnap.com/kb/fix-the-uploaded-file-exceeds-the-upload-max-filesize-directive-in-php-ini-wordpress.

Starting MySQL server:

sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql restart
sudo /etc/init.d/mysql stop

Featured photo by Sora Shimazaki from Pexels

Leave a Reply