How to Access Your Ubuntu Bash Files in Windows (and Your Windows System Drive in Bash)

Origin: https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/

By Chris Hoffman on July 6th, 2016

Windows 10’s “Bash on Ubuntu on Windows” environment contains a few different components. The first time you run the bash.exe program, it will download and install an entire Ubuntu user space environment. You can access these files in File Explorer or other Windows programs, if you know where to look.

You can also access your Windows system drive–and any other drives on your computer–from within the Ubuntu Bash shell. This allows you to work with your normal Windows files using Linux command-line utilities.

Where the Ubuntu Bash Shell Files Are Stored in Windows

Note that each Windows user account that uses Bash will have its own separate Bash environment and files under its own user directory.

To access these files, you’ll first need to show hidden folders in File Explorer. Open a File Explorer window and click View > Options > Change Folder and Search Options.

In the Folder Options window that appears, select View > Show Hidden Files, Folders, and Drives.

Navigate to the following directory to find these folders:

C:\Users\USERNAME\AppData\Local\lxss

The Ubuntu system files are stored at:

C:\Users\USERNAME\AppData\Local\Lxss\rootfs

Your Ubuntu user account’s home folder is stored at:

C:\Users\USERNAME\AppData\Local\Lxss\home\USERNAME

The root account’s home folder is stored at:

C:\Users\USERNAME\AppData\Local\Lxss\root

Where Your Windows System Drive Appears in Bash

The Ubuntu Bash shell environment 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 /, or the root directory you’d have on Linux. If you perform an ls command to view the contents of the directory, you’ll just see the Ubuntu directories that provide the Linux environment.

Your Windows system drive and other connected drives are exposed in the /mnt/ directory here, where other drives are traditionally made available in the Linux directory structure. Specifically, you’ll find the C: drive at the following in the Bash environment:

/mnt/c

To change to this directory with the “cd” command, run the following command:

cd /mnt/c

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 need to use the path /mnt/c/Users/Chris/Downloads/File.txt in the Bash 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 the C:\Users\Administrator folder, 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.

How can I change the date modified/created of a file?

[From]: http://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file

Easiest way – accessed modified will be the same:

touch -a -m t 201512180130.09 fileName.ext

Where:

-a = accessed
-m = modified
t  = timestamp - use [[CC]YY]MMDDhhmm[.ss] time format

If you wish to use NOW just drop the t and the timestamp

To verify they are all the same: stat fileName.ext

See: touch man

shareimprove this answer

What does “&” at the end of a linux command mean?

http://stackoverflow.com/questions/13338870/what-does-at-the-end-of-a-linux-command-mean

The & makes the command run in the background.

From man bash:

If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0.

shareimprove this answer