Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use WSL like an Linux expert

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to use WSL like an Linux expert". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to use WSL like an Linux expert".

Keep your Linux system up to date

In fact, when you run Ubuntu or openSUSE through WSL, the underlying Linux kernel is not running. However, you must keep your distribution up-to-date to protect your system from any new known vulnerabilities. Since there are only two free community distributions in the Windows App Store, the tutorial will cover only the following two: openSUSE and Ubuntu.

Update your Ubuntu system:

# sudo apt-get update# sudo apt-get dist-upgrade

Run the update for openSUSE:

# zypper up

You can also use the dup command to upgrade openSUSE to a * version. However, before running the system upgrade, use the previous command to run the update.

# zypper dup

Note: openSUSE defaults to root user. If you want to perform any non-administrator tasks, please switch to a non-privileged user. You can learn how to create users on openSUSE in this article.

Manage local files

If you want to use excellent Linux command-line tools to manage local files, you can easily do so using WSL. Unfortunately, WSL doesn't support things like lsblk or mount to mount local drives. However, you can cd to disk C and manage files:

/ mnt/c/Users/swapnil/Music

I am now in the Music directory of disk C.

To install other drives, partitions, and external USB drives, you need to create a mount point, and then mount the drive.

Open File Explorer and check the mount point of the drive. Suppose it is mounted as S:\ in Windows.

In the Ubuntu/openSUSE terminal, create a mount point for the drive.

Sudo mkdir / mnt/s

Now mount the drive:

Mount-f drvfs S: / mnt/s

After mounting, you can now access the drive from the distribution. Keep in mind that distributions running in WSL mode will see what Windows can see. Therefore, you cannot mount an ext4 drive that cannot be natively mounted on Windows.

Now you can use all these magical Linux commands here. Do you want to copy or move files from one folder to another? Simply run the cp or mv command.

Cp / source-folder/source-file.txt / destination-folder/cp / music/classical/Beethoven/symphony-2.mp3 / plex-media/music/classical/

If you want to move folders or large files, I would recommend rsync instead of the cp command:

Rsync-avzP / music/classical/Beethoven/symphonies/ / plex-media/music/classical/

Yeah!

To create a new directory in the Windows drive, simply use the mkdir command.

Do you want to set up a cron job at some point to automate the task? Continue to use crontab-e to create a cron job. It's very simple.

You can also mount network / remote folders in Linux so that you can use better tools to manage them. All my drives are plugged into raspberry pies or servers, so I just need ssh to get into the machine and manage the hard drive. Transferring files between the local computer and the remote system can be done again using the rsync command.

WSL is no longer a beta, and it will continue to get more new features. The two features I'm excited about are the lsblk command and the dd command, which allow me to natively manage my drive and create bootable Linux drives in Windows. If you are new to the Linux command line, the previous tutorial will help you get started with some of the most basic commands.

The above is all the contents of the article "how to use WSL like an Linux expert". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report