I have made a python script in WSL using VSCode. I want to call this script from another python script that is running in Windows.
My plan was to use os.system() to command line into wsl and start the script from it's directory, however when I go into windows terminal to try to start it manually, I can't access any of my directories.
The path I am attempting to access from terminal is \wsl.localhost\Ubuntu\home\ben\apps and root user can't access it either.
Windows terminal:
(base) PS C:\Users\benja> wsl
ben#DESKTOP:/mnt/c/Users/benja$ cd ~
ben#DESKTOP:~$ ls
ben#DESKTOP:~$ ls -a
. .. .bash_history .bash_logout .bashrc .profile
ben#DESKTOP:~$ cd ..
ben#DESKTOP:/home$ ls
ben
ben#DESKTOP:/home$ cd /ben
-bash: cd: /ben: No such file or directory
ben#DESKTOP:/home$ cd ..
ben#DESKTOP:/$ ls
bin boot dev etc home init lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
ben#DESKTOP:/$ cd ..
ben#DESKTOP:/$ cd /home/ben/apps
You're accessing /ben aka root_directory/ben
try: ~/apps or cd ben
WSL has both Ubuntu and Debian. apps is in Ubuntu, however my WSL was defaulting to Debian. That is why the directories were empty.
Related
From Windows, I can access the file systems of all the WSL containers from under \\wsl$.
And from inside a WSL container, I can access the windows C:\ drive as /mnt/c.
But how can I access another container's drive from inside a WSL container?
I'm trying to access \\wsl$\othercontainer\some\file from inside a WSL container.
wslpath can normally convert Windows file paths to paths accessible from WSL:
WSL2#~» wslpath 'C:\Windows\System32\drivers\etc\hosts'
/mnt/c/Windows/System32/drivers/etc/hosts
But it doesn't work for:
WSL2#~» wslpath '\\wsl$\othercontainer\some\file'
wslpath: \\wsl$\othercontainer\some\file
WSL2#~» echo $?
1
And of course:
WSL2#~» ls -l '\\wsl$\othercontainer\some\file'
ls: cannot access '\\wsl$\othercontainer\some\file': No such file or directory
This answer provided the answer:
sudo mkdir /mnt/othercontainer
sudo mount -t drvfs '\\wsl$\othercontainer' /mnt/othercontainer
ls -l /mnt/othercontainer/some/file
NOTE: It looks like symbolic links aren't supported. When one is encountered, we get an error like:
$ ls -l /mnt/othercontainer/bin
ls: cannot read symbolic link '/mnt/othercontainer/bin': Function not implemented
lrwxrwxrwx 1 root root 7 Apr 23 2020 /mnt/othercontainer/bin
When I open the Ubuntu windows store app and the bash command line (if I am not wrong?) comes up it's working directory is /home/username . I want to run a script which on my Windows is located in D:\University... . Can I do this and if so how?
I have only tried cd D:\ but I get " -bash: cd: D:: No such file or directory". I don't have any experience so far with Linux so I don't know if Ubuntu on Windows can only run in its own location or it can access all the files on my PC.
you can use mnt to access your drives.
root#user-pc: cd /mnt/d/your_destination_directory;
Is it possible to create user-privilleged directories from Windows to WSL directly?
I can create a folder from Windows, but it won't be the same as mkdir in WSL. For example, using Windows Explorer I create a new folder A
But, coming back to WSL, I can't cd A:
-bash: cd: A: Permission denied
Unless I do chmod 0761 * eventually. Isn't there a way to do that automatically?
So currently I have Busybox installed on an embedded kernel in its /system/bin/ folder and can call manually to the VI editor by typing busybox vi and vi will be executed. HOWEVER, I want to create a symbolic link to busybox vi by just typing vi file.txt instead of busybox vi file.txt so I won't have to type busybox every time. How to do this? I already tried this:
Installing Busybox
If the Busybox executable is renamed to one of the commands it supports, it will act as that command automatically:
ln -s busybox pwd
./pwdfrom
...from Busybox's website but still doesn't work, all it says is on my terminal for which command is:
127|root#nitrogen6x:/system/bin # ln -s busbox which
root#nitrogen6x:/system/bin # which ls
/system/bin/sh: which: not found
127|root#nitrogen6x:/system/bin # ls -la which lrwxrwxrwx root root 1970-01-03 18:15 which -> busbox
any ideas what I'm doing wrong? My $PATH is: /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
I figured out how to get this to work
HERE'S HOW:
So I went to root directory:
cd /
Then I remounted the /system/ directory:
mount -o rw,remount /system
Then I went into the binary folder where busybox was located:
cd /system/bin/
Then I used the link command for the busybox binary I wanted:
ln -s busybox lsusb (remember you must be in /system/bin directory already)
For Already Linked Files:
For already linked files like ls, remove the linked file and replace with Busybox binary instead (I know it sounds crazy but you can always go back to system's binary utilities):
sudo rm /system/bin/ls
ln -s busybox ls (remember you must be in /system/bin directory already)
You should get something like this when you do ls -l ls:
lrwxrwxrwx 1 0 0 7 Jan 4 21:53 ls -> busybox
One point to consider is that you have to be on the same file system.
For example if you are trying to create a symbolic link from one mounted file system to a file on another file system then that's an issue.
If your / and /usr are not on the same mounted file system as there might be the case for embedded systems, then you cannot create a symbolic link /usr/bin/which to point to /bin/busybox.
One possible solution is to put a copy of busybox binary in /urs/bin and create link to that.
I have xmpp server (openfire_3.9.3) that is running on my ubuntu Ubuntu 14.04.1 LTS.
I have installed openfire by following given steps
1. $ sudo tar -zxvf openfire_x_x_x.tar.gz
2. $ sudo mv openfire /opt
then I moved to openfire bin directory to start openfire as
$ cd /opt/openfire/bin
$ sudo ./openfire start
then during setup through admin console always I am getting the given error
Home not found. Define system property "openfireHome" or create and add the openfire_init.xml file to the classpath
where I need to set openfireHome ? or how can i fixed it out ?
Well it seems your user account might have permissions issue. Can't you keep openfire in your home and try to run it from there and share results?
For me, it's a permissions issue.
I'm using server(Openfire 4.7.0, build e020f58) on my local computer (macOS Monterey 12.1 (21C52)).
My SOLUTION is:
sudo chmod -R 777 /usr/local/openfire