Edit linux file in windows

Editing files in a Windows Subsystem for Linux development environment

The problem is that Windows apps cannot modify files inside the virtual lxss filesystem. Directly modifying these files is known to cause all sorts of issues.

Therefore, there seem to be only two suboptimal choices when it comes to using WSL for development:

  1. Store the project under lxss ( /home/foo ). The normal toolchain works properly. However, editing is limited to either terminal-based Vim/Emacs or whatever can be run under a janky X server, which is less smooth than native editors running on Windows.
  2. Store the project under the Windows filesystem ( /mnt/c/Users/foo ). Now any Windows-based editor can be used for development. However, the Linux-based toolchain is fragile as it’s not designed to be used on a «network drive», and can cause problems with file watching or databases.

Is there any way to get the best of both worlds here — that is, to be able to edit using a native Windows application, but still have the Linux toolchain work as it normally would on a local drive?

6 Answers 6

Microsoft has recently added comprehensive support for this, and it should be generally available in the April 2019 (19H1) update. Once it’s ready, a 9P server will run in the background whenever a Linux distro is running. The 9P server will be able to handle Linux filesystem metadata, and Windows will be able to treat it as a network drive so it can access it safely. You can read about it at https://blogs.msdn.microsoft.com/commandline/2019/02/15/whats-new-for-wsl-in-windows-10-version-1903/.

With the new feature, you’ll be able to safely access both Windows and Linux filesystem files from Windows, as long as you go through the 9P server. This will be handled natively from within WSL. For example, from the WSL command line you’ll be able to type code /mnt/c/Users/username/src/windows-file.txt to open a Windows file in VS Code, or type code /home/username/src/linux-file.txt to open a Linux file in VS Code.

If you’re not part of the Windows Insider Program, you won’t have access to this yet so you’ll still have to use an older method, such as wslpath.

wslpath will convert between Windows- and Linux-style paths so you can easily open Windows files from the WSL command line. As per https://github.com/Microsoft/WSL/issues/3146#issuecomment-388118689, it will refuse to convert Linux filesystem paths (i.e. %AppData%\lxss), because without 9P it’s unsafe to modify these files from Windows. This means you can’t open /home/username/src/linux-file.txt , but you can use code «$(wslpath -aw /mnt/c/Users/username/src/windows-file.txt)» .

Читайте также:  Linux монтирование от имени пользователя

In the past, there were a number of third-party tools to perform the same conversion but wslpath does it natively— in fact, ls -l /bin/wslpath shows that it’s just a link to /init.

Источник

How do I edit a Linux file in Windows?

Use drag and drop, copy and paste them, or even open them directly in Windows applications to modify them. This also works from the command line, of course. In PowerShell or the Command Prompt, the command cd \\wsl$\Debian\ changes to the root directory of your installed Debian system.

Can you resize Linux partition from Windows?

Do not touch your Windows partition with the Linux resizing tools! Now, right click on the partition you want to change, and choose Shrink or Grow depending on what you want to do. Follow the wizard and you’ll be able to safely resize that partition.

How do I explore a Linux partition from Windows?

Ext2Fsd. Ext2Fsd is a Windows file system driver for the Ext2, Ext3, and Ext4 file systems. It allows Windows to read Linux file systems natively, providing access to the file system via a drive letter that any program can access. You can have Ext2Fsd launch at every boot or only open it when you need it.

How do you edit a partition in Linux?

  1. Unmount the partition:
  2. Run fdisk disk_name.
  3. Check the partition number you wish to delete with the p.
  4. Use the option d to delete a partition.
  5. Use the option n to create a new partition.
  6. Check the partition table to ensure that the partitions are created as required using the p option.

Can I access my Linux files from Windows?

The feature lets users access Linux file systems, such as ext4, that aren’t natively supported by Windows. It also means those who are dual-booting Windows and Linux with different disks can now access Linux files from Windows.

How do I edit a file in Linux?

How to edit files in Linux

  1. Press the ESC key for normal mode.
  2. Press i Key for insert mode.
  3. Press :q! keys to exit from the editor without saving a file.
  4. Press :wq! Keys to save the updated file and exit from the editor.
  5. Press :w test. txt to save the file as test. txt.

Can I resize Ubuntu partition from Windows?

Since Ubuntu and Windows are different operating system platforms, the simplest way to resize Ubuntu partition is that you can resize the Ubuntu partition under Windows if your computer is dual-boot.

Читайте также:  Linux 64 bit distributions

How do I shrink a Linux partition in Windows?

  1. Load your Ubuntu live CD.
  2. Launch Gparted.
  3. Select the Ubuntu partition (it will be having ext4 File system).
  4. Shrink/Resize it.
  5. You will have unallocated space now.
  6. Push this unallocated space such that, it is right adjacent to Windows partition.

How do I remove a Linux partition in Windows 10?

Step One: Delete Your Linux Partitions Start by booting into Windows. Press the Windows key, type “diskmgmt. msc“ into the Start menu search box, and then press Enter to launch the Disk Management app. In the Disk Management app, locate the Linux partitions, right-click them, and delete them.

How do I delete a partition in Linux?

Delete a Partition in Linux

  1. Step 1: List Partition Scheme. Before deleting a partition, run the following command to list the partition scheme.
  2. Step 2: Select the Disk.
  3. Step 3: Delete Partitions.
  4. Step 4: Verify Partition Deletion.
  5. Step 5: Save Changes and Quit.

Can I access Ubuntu files from Windows?

Linux environments you install from the Store (like Ubuntu and openSUSE) keep their files in a hidden folder. You can also access your Windows files from the Bash shell. Update: Starting with Windows 10’s May 2019 Update, there’s now an official, safe way to access your Linux files from Windows applications.

How can I change the size of my Linux partition?

How can I access my Linux partition in Windows?

How to access Linux ext4 partition and data on Windows?

Is there a way to extend the Ubuntu partition?

Источник

Editing text files in WSL with Notepad++

I use WSL (Windows Subsystem for Linux) with Debian, which provides a simple cmd interface. I’d like to open files in Notepad++, which is installed on the Windows side of this PC. is this possible? if not, suggest an editor more robust and accessible than Nano.

I don’t understand what you are asking. I see what that you want to exit files, and that you like notepad++. I just don’t grok what the question is.

There is a snap for notepad++, however I could not get it to work. I was not really trying, I was installing kotlin at the time, and thought it would be nice to have notepad++. I think there are some dependencies, that are not managed by snap. However the native one should work, you probably need a wrapper script, to launch it. Last time I did this I used cygpath to convert the filenames from Unix to MS-Windows.

Читайте также:  Network manager linux команды

5 Answers 5

You can edit files on the Windows side ( C:\xxx ) and access them from Debian ( /mnt/c/xxx ), that’s no problem. You can even start Notepad++ from bash which opens in Windows as usual, but as you can’t edit any linux files that doesn’t make any sense.

So in order to edit files of your linux filesystem you will have to copy them to a shared windows directory /mnt/c/whatever first, edit them there and copy them back afterwards.

Another possibility would be to install samba on linux and mount your work-directories in Windows. The other way around accessing a Windows share using smbclient is also possible, but no fun using commandline linux, already tried that. You are faster copying your files.

Источник

Use Windows VScode to edit Linux files.

VScode is one of the best code editors with lots of add-on packages. Although you can install VScode in linux and use X windows to edit in linux, most people run VScode in Windows and would like to edit Linux files from Windows within VScode. There is a simple way to do this using the Mobax terminal https://mobaxterm.mobatek.net/ .

First download ad install Mobaxterm and make sure you can login to linux using ssh with Mobax terminal.

Once logged in to ssh terminal on the left it will show a directory of your files in home directory. Right click on any file and click Open With->Select Visual Studio Code (make sure you had already installed VScode in windows).

The linux file will open in VScode editor. Now if you make any change and save the file in VScode it will pop-up a Mobax prompt asking if you would like to save the file to remote server. Click yes and the changed file is saved in linux. So it feels like you are working directly in Linux.

You can even run Python code in VScode in the linux file. Just right-click on the File in VScode and click Open in Terminal. It will open a terminal session in VScode and the file will be in a directory and you can run it with python in windows. So now you can use python editor as well:

PS C:\Users\userid\Documents\MobaXterm\slash\RemoteFiles\135498_12_1> python mypythonscript.py

Set specific python interpreter in VSCODE

Setting your interpreter is pretty easy, you got a few ways to do it (taken from VS code documentation):

a) Open the Command Pallete (Ctrl/Cmd + Shift + P) and type “Python: Select Interpreter”, select the command and it should present you a list of available interpreters (the ones Python extension has detected)

Источник

Оцените статью
Adblock
detector