Where Windows ubuntu Stores the Linux Files (ok)
https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/
Last updated
https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/
Last updated
CHRIS HOFFMAN @chrisbhoffman UPDATED JUNE 26, 2019, 2:36PM EDT
Linux environments you install from the Store (like Ubuntu and openSUSE) keep their files in a hidden folder. You can access this folder to back up and view files. 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.
Microsoft strongly warns against adding or modifying Linux files with Windows software. This could cause metadata problems or file corruption, and may force you to uninstall and reinstall your Linux distribution to fix it. However, you can still view and back up your Linux files using Windows software, and that won’t cause any problems.
In other words, treat the Linux folder as if it were read-only from within Windows. Don’t use any Windows tool, including graphical apps or command line tools, to modify them. Don’t create new files within these folders using Windows tools, either.
If you do want to work with a file from both the Linux and Windows environments, you should create it in your Windows file system. For example, if you have a folder at C:\project in Windows, you could also access it at /mnt/c/project in the Linux environment. Because it’s stored on the Windows file system and is accessed under /mnt/c, it’s safe to modify the file with either Windows or Linux tools.
Your Linux file system is stored in a hidden folder for a reason, as Microsoft doesn’t want you tampering with it. But, if you need to view or back up some files, you’ll find them stored in a hidden folder. To access it, open File Explorer and plug the following address into the address bar:
(This takes you to C:\Users\NAME\AppData\Local\Packages
. You can also show hidden folders in File Explorer and navigate here manually, if you prefer.
In this folder, double-click the folder for the Linux distribution whose files you want to view:
Ubuntu: CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
openSUSE Leap 42: 46932SUSE.openSUSELeap42.2_022rs5jcyhyac
SUSE Linux Enterprise Server 12: 46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac
The names of these folders may change slightly in the future. Just look for a folder named after the Linux distribution.
In the Linux distribution’s folder, double-click the “LocalState” folder, and then double-click the “rootfs” folder to see its files.
In other words, the files are stored at:
Note: In older versions of Windows 10, these files were stored under C:\Users\Name\AppData\Local\lxss. This changed starting with the Fall Creators Update.
To view the files stored in your home folder, double-click the “home” folder, and then double-click your UNIX username.
Remember, don’t modify any of these files or add files to these folders from File Explorer!
The Windows Subsystem for Linux makes your full Windows system drive available so you can work with the same files in both environments. However, the Bash environment doesn’t just dump you in your C:\ drive. Instead, it places you in your UNIX account’s home directory within the Linux environment’s file system.
Your Windows system drive and other connected drives are exposed in the /mnt/ directory there, where other drives are traditionally made available in the Linux directory structure. Specifically, you’ll find the C: drive at the following location in the Bash environment:
To change to this directory with the cd
command, just type:
If you have a D: drive, you’ll find it located at /mnt/d, and so on.
For example, to access a file stored at C:\Users\Chris\Downloads\File.txt, you’d use the path /mnt/c/Users/Chris/Downloads/File.txt in the Bash environment. And yes, it’s case-sensitive, so you need “Downloads” and not “downloads.”
RELATED: How to Mount Removable Drives and Network Locations in the Windows Subsystem for Linux
You can also mount external drives and network locations to access more files from within the Linux environment.
Note that, when accessing Windows system files, your Bash shell environment has the permissions it was launched with. If you launched it normally from the shortcut, it will have the same file access permissions your Windows user account does.
For example, if you want to access a system folder your user account doesn’t have permission to access, you’d need to right-click the Bash shell shortcut and select “Run as Administrator” to launch the Bash shell with Windows Administrator privileges.
This works just like the Command Prompt, which needs to be launched as Administrator if you need write access to Administrator-only files, or write access to system files. You can’t just use sudo
in the Bash environment.READ NEXT