Google Drive folder with Bash Windows - linux

I have installed WSL (Windows Subsystem for Linux) and it works perfectly. I like opening bash with CMD or PowerShell typing "bash" because it keeps the same folder.
For example:
PS C:\Users> bash
root#X /mnt/c/Users #
I also use Google Drive (backup and sync).
The folder is in C:/Users/X/Google Drive.
The problem is that when I use "my trick" in that folder it doesn't work. It leads me to bash ~ instead of the real location.
Firstly I thought that It was caused by the spaces from "Google \Drive" but no. All folder work fine (even with spaces)
To sum up, I can't start in that folder or under it. However I can cd there, but you know... not convenient.
Sorry my english in advance, and thank you for your answers :)

I'm a little confused about your question but will do my best to be helpful. It seems that you are attempting to run bash in a Windows environment? I know little of Windows, but work and play in Unix daily.
Once you're using your terminal like a unix terminal, Bash WILL struggle with Google Drive. I use GD as well, and the whitespace is the bane of my existance. However, for simple command-line navigation, something like "cd ~/Google\ Drive" will change your directory to the GD dir. This can be applied to other scenarios as well.. variably.
If you are trying to go to the location in the code you posted, in bash, this would be the appropriate syntax:
cd /mnt/c/Users
This may not apply to Windows, but on a Unix machine, you can get to your personal user directory in appbreviated fashion using "~":
cd ~/
Hope this helps.

work-around: https://github.com/Microsoft/WSL/issues/2999#issuecomment-455835951
Here is a way to mount GFS in WSL based on https://superuser.com/questions/1353169/getting-sshfs-working-on-wsl-or-finding-an-alternative The trick is to use https://www.nsoftware.com/sftp/netdrive/ to ssh to GFS from Windows and relay it as a filesystem that can be mounted under WSL.
Install OpenSSH Server under Win10
Win10 Settings -> Apps -> Manage optional features -> Add feature -> OpenSSH Server
restart if necessary
open Services -> OpenSSH -> Properties -> Startup Type -> Automatic (delayed)
Install and run SFTPNetDrive, right click on icon in hidden icons -> Main window (or maybe already open) -> Profile -> new profile ( server: localhost, user: * pwd:* Drive Letter: F (or another) Advanced -> ( Protocol -> uncheck compression; Specified folder: G:\ ) )
in Bash (wsl): sudo mkdir /mnt/f; sudo mount -t drvfs F: /mnt/f
I'm not sure how stable it is, but I was able to open files in WSL.

Related

Where does '~' expand to when mounted in docker with windows subsystem for linux?

I have a docker container I wrote that sets up AWS profiles for me. In Linux it works great, on WSL it partially works.
When I run the container I am mounting the ~/.aws directory, checking if the profiles exist and if they don't exist I create them. If they do exist I don't do anything.
In Linux I can run this container and then continue to use aws-cli with no problems.
In Windows subsystem for Linux - when I run the container the first time around, it will create the profiles for me. If I choose to run the container again it sees that the profiles already exist so it does nothing. This tells me the file exists somewhere but I cant use aws-cli because the file doesn't exist at ~/.aws.
So my question is where is ~/.aws in WSL when mounted to a docker container? I've attempted to do a find on the entire filesystem in WSL and that returns nothing. I've also tried changing the mount path to /root/.aws and I run into the same conditions.
EDIT:
I still don't know the answer to my question above. But if anyone comes across this question I did find a work around.
I've updated Docker Desktop to allow mounting the entire c:/ drive. Then I just changed my docker run command to mount c:/.aws instead of ~/.aws, so my command looks like -v c:/.aws:/root/.aws. After that I added this environment variable in WSL export AWS_SHARED_CREDENTIALS_FILE="/mnt/c/.aws/credentials" and now aws cli picks up on my profile changes.
The shell always expands ~ to the value of the HOME environment variable. If that environment variable is not set, then it expands to nothing. If you want to find where ~/.aws is located, then you can write something like echo ~/.aws and the shell will expand it for you.
The only exception is that ~user expands to the home directory of the user user; the HOME environment variable is not consulted there.
You have to remember that in your setup the docker engine (docker for windows) is installed on windows, it is inside the windows environment that the docker command is 'launched'. So when you say use ~/.aws it looks in the windows file system for this location.
In windows ~ is a valid directory name (try mkdir ~ from a cmd prompt) so when you say map ~/.aws I'm unsure what actually gets created. maybe try searching your c drive for a folder called ~. There is no ~ shortcut in windows for the home folder, and if there was which home would it be? the home of the logged in windows user? or the home inside WSL?
To make this work in WSL you need to pass ~/.aws to wslpath like this:
➜ echo $(wslpath ~/.aws)
/mnt/c/home/damo/.aws
But this location is the path according to WSL not windows you need to do it twice with the -w flag the second time
➜ echo $(wslpath -w $(wslpath ~/.aws))
C:\home\damo\.aws
which would make your final docker command look like this:
docker run -it -v $(wslpath -w $(wslpath ~/.aws)):/root/.aws awsprofileprocessor:latest
With this you will now be telling docker for windows the windows path to put the mount
Please let me know if this works for you, I'm interested in how it turns out.

Windows sublinux - get windows path where linux was called

is it possible to get the directory path from Windows where for example "debian" was executed?
For example I open my projects with Visual Code and execute the NodsJs/npm projects from Windows WSL Debian. So it would be nice if "debian" is called from inside the Visual Code console that my linux subsystem auomatically joins the Windows directory from where I am coming.
Yes I am already using symlinks but then I have to create a symlink for each project. An automatically solution would be much more comfortable.
I googled and haven't found something regarding this. Would be great if someone can tell me if this is possible or not.
I was not sure what you meant but apparently there's a debian.exe that lands in the users home dir.
You can just use the wsl.exe to get the behavior that you described.
i.e. wsl.exe -d "Debian"
Which looks like this on the shell
PS C:\Users\PeterT> cd C:\DEV
PS C:\DEV> wsl.exe -d "Debian"
petert#debian:/mnt/c/DEV$

how to run non-installed(portable) application using linux terminal

I'm new to Linux and i use Kali Linux. I downloaded the eclipse ide. Every time, when i need to run it, i should navigate to eclipse folder and run the eclipse file. there are other softwares like pycharm have the same issue.
If there's any method to run these programs just typing "eclipse" or "pycharm" on terminal (like firefox, atom) it's very helpful. If anyone know how to do it please let me know. I already searched a solution for this problem and i couldn't find any solution.
-Thanks (sorry for my English)
Modify your ~/.bashrc and add the PATH of your application(you use PATH rather then CONFIG_PATH)
export PATH=$PATH:/path/to_directory_containing_program
export CONFIG_PATH=/my_path_to_PROGRAM/PROGRAM/config/
Another solution is Create a shorcut in your desktop
Go to cd /usr/local/bin (or cd /usr/bin) and do:
sudo ln -s /path/to/eclipse where eclipse is the binary that you are used to launch.
/usr/local/bin and /usr/bin directories should already be in your PATH, so you don't need to modify ~/.bashrc.

How to create files and folder in Atom using the command line?

I was watching a speedy workflow tutorial about Atom text editor, and saw how the guy uses Linu commands like ls (to check the files in the directory), touch (to create files eg. style.css) and mkdir (to create folders). Now in my Atom editor I am able to open the command line using the following command.
CTRL + SHIFT + T
Now in my command line the default windows command line opens up, I am able to create folder using mkdir, but the commands touch and ls don't work, which makes me wonder weather Atom has its own command line?
See the SCREENSHOT to see how this guy is creating folders, files and using the ls command.
So my question is, how do I create files in Atom? How do I get the touch command to work?
It looks like the tutorial is using the Term2 package for opening a shell within the editor (http://code.tutsplus.com/courses/speedy-workflows-with-atom/lessons/term2). Since you seem to be able to open a terminal using the described screenshot, you seem to have the Term2 package installed - so far so good.
This package opens a standard command window within the editor. The tutorial seems to be using Linux or Mac OS X as the operating system. If you're running Windows, you will only have the Windows CMD interpreter available.
Windows does not natively support the touch command (but it has a mkdir command). There is a unxtools project that provides some of the common Gnu tools. If you install that, you should be able to run touch from the Windows command shell as well. More details can be found here.

Xampp on linux mint

im trying to install xampp on "new" linux mint machine.
However im quite a noob to linux since i havnt used it for that long.
When i try to run the file that ive download from the following page:
Xampp download
i get the following error two errors:
Could not display "/home/marc/Downloads/xampp-linux-x64-1.8.3-0-installer.run".
and if i click yes
Installing mime type handlers isn't supported
To search and install software which can open certain file types you have to install app-install-data.
can anyone tell me what the problem is and how i might fix it?
you need to execute the file (e.g. open a terminal, navigate to your Downloads folder and run bash xampp-linux-x64-1.8.3-0-installer.run (possibly it might need to be run otherwise, but thats my best guess)).
alternatively you might be presented to run/execute the file (instead of displaying it). if so, choose this option.
on the other hand, you might consider installing apache/php/mysql via your package manager.
what you can do is that you can use the chmod +x /your folder location/.run file that you want to install
after that you can run following command
./and your .run file name
example:-
in my case :- User#user~$su root
it will ask for password so give it
User#user~chmod +x /Downloads/xampp-linux-x64-1.8.3-0-installer.run
User#user~./xampp-linux-x64-1.8.3-0-installer.run

Resources