Recommended way of testing if I'm currently running under WSL [duplicate] - windows-subsystem-for-linux

This question already has answers here:
How to check if a program is run in Bash on Ubuntu on Windows and not just plain Ubuntu?
(15 answers)
Closed 5 years ago.
Can a bash script detect if it's running in "Ubuntu on Windows" vs native Ubuntu? If so, how?
I ran env on both machines and didn't see any obvious environmental variable differences. I could test for the existence of the /mnt/c directory, but that is not foolproof because that directory could potentially also be present on native Ubuntu.

It looks like /proc/version in Ubuntu on Windows contains:
Linux version 3.4.0-Microsoft (Microsoft#Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
and my version of Ubuntu has:
Linux version 4.4.0-31-generic (buildd#lgw01-16) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016
This code is working for me to detect which version of Ubuntu the script is running on:
if grep -qi microsoft /proc/version; then
echo "Ubuntu on Windows"
else
echo "native Linux"
fi

Related

virsh console to KVM

When logged in through virsh console on to KVM. hostname is not shown properly in bash prompt. We are using 63 character hostname.
KVM Guest OS: Red Hat Enterprise Linux Server release 7.9 (Maipo)
Host OS: Red Hat Enterprise Linux Server release 7.6 (Maipo)
I don't see above issue when logged in using ssh or virt-manager
hostname i'm using is Nikiabcdefdhijklmnopqrst898hd-uvwxyz-jkkdjkjdsdadjkjkkjdkjsdj90
adding below line in /etc/bashrc resolved the issue.
resize > /dev/null 2>&1
'xterm' rpm provides resize binary.

RabbitMq FreeBsd - Shared object "libdl.so.1" not found, required by "beam.smp"

I just install rabbitmq-3.7.8 on my FreeBsd mashine.
But if I run rabbitmqctl start, then getting error is
Shared object "libdl.so.1" not found, required by "beam.smp"
uname -v
FreeBSD 11.1-RELEASE-p4 #0: Tue Nov 14 06:12:40 UTC 2017
What is that mean?
Thanks for any answer!
You are using 11.1 which is discontinued. I strongly recommended that you upgrade to 11.2.
freebsd-update upgrade -r 11.2-RELEASE
freebsd-update install
reboot
freebsd-update install
Check again your OS version.
uname -r
It should return 11.2-RELEASE
pkg update -f
pkg upgrade -f
All your packages will be reinstalled, then check again if rabbitmqctl starts.
11.1 went End-of-Life slightly less than two months before your post.
If you're not ready to upgrade yet, but have access to a machine running 11.2, you can probably copy /usr/lib/libdl.so.1 from the newer machine into /usr/lib on the older machine, and limp along like that until you're ready to upgrade.

Can ddev work with WSL (Windows Subsystem for Linux)?

As a person working on a Windows machine but enjoying Ubuntu as a working environment I'd like to use ddev in WSL. Is there a way to do that?
2021 Update: DDEV has WSL2 install instructions.
(2018-11-15: Updated for ddev v1.4.0)
It's pretty tweaky, but it can be done. Note that there are no tests or performance results on this, and it's not a supported technique.
Note that WSL actually behaves like linux and uses linux binaries, so you'll use the linux version of ddev.
The biggest problem is that the docker daemon is running under native Windows and WSL has a different filesystem layout, so you have to kind of trick everything on the WSL side to use paths that the Docker daemon will be able to find in native windows.
Start by setting up your WSL/Docker environment as described in this excellent article: https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly#ensure-volume-mounts-work - BUT use DOCKER_HOST=tcp://127.0.0.1:2375 instead of using "localhost" in there.
Install ddev using the Linux instructions.
Make sure all projects are already rm'd with ddev rm -a; projects already running or stopped in native Windows can't be accessed by ddev from WSL-land.
You're probably going to use the web browser on your windows side of the machine, so add the hostname of your project on the Windows side with ddev hostname <yourproject.ddev.local> 127.0.0.1
cd /c/Users//path/to/project (This is a path docker understands.)
ddev start
Visit the project with your browser.
Basically, with this technique you're using paths that the Docker daemon knows how to follow in native windows.
Anyway, it seems to work with a trivial example. Your comments are welcome and we may be able to improve support in the future if people like it.
I have it working (current 1.5.1) inside of WSL. I'm using Docker Toolbox so Docker4Windows may be different.
General setup inside of WSL (I'm using ubuntu)
install docker (apt-get install docker.io)
copy default docker machine certificates to WSL via
cp /mnt/c/Users/[YOUR WINDOWS USER]/.docker/machine/machines/default/*.pem ~/.docker
setup your environment variable inside of WSL (eg. in ~/.bashrc)
export DOCKER_HOST=tcp://192.168.99.100:2376
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=~/.docker
The actual values to use can be determined via docker-machine.exe env from the docker toolbox!
At this point you should get a complete output from docker version (don't forget to restart your shell to actually load the modified environment)
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.4
Git commit: e68fc7a
Built: Fri Oct 19 19:43:14 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:28:38 2018
OS/Arch: linux/amd64
Experimental: false
Containers can't be started yet as the mount of file systems will fail!
With Docker Toolbox the docker server has the host file system available under /c/. But running from WSL the expected path is /mnt/c/
Generating a symlink is sufficient to make it available docker-machine.exe ssh default 'sudo ln -s /c /mnt/c'
This command has to be rerun after reboot or you have to make the changes permanent via the bootlocal.sh mechanism.
Test your mapping with docker run --rm -i -t -v ${PWD}:/mnt ubuntu bash from WSL.
Install docker-compose, depending on your distribution it is outdated and needs to be replaced with a current version.
Enjoy ddev

Apache Mesos on Ubuntu 14.04 32 bit

I am trying to install Apache Mesos from this link : http://mesos.apache.org/gettingstarted/
I did it for first time was stuck on this step :
# Start mesos master (Ensure work directory exists and has proper permissions).
$ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos
The error raised was :
vivek#Pavilion-dv6:~/mesos/build$ ./bin/mesos-master.sh --ip=127.0.0.1 --work_dir = /var/lib/mesos
./bin/mesos-master.sh: line 24: /home/vivek/mesos/build/src/mesos-master: No such file or directory
I have deleted the directory and willing to start again to install but as Homepage says, it works on 64 bit Ubuntu , I have Ubuntu 14.04 32 bit. Should I go on and try again or Should get 64 bit Ubuntu 14.04?
32bit OSes are not officially supported. You may try to build Mesos from sources (and then report the result on the Mesos dev list) or switch to a 64bit OS. Any VM will do.

Installing Solaris Studio 12.2 in Ubuntu

I need help with installing Solaris Studio 12.2 on Ubuntu.
I looked at this question already and it didn't help: Installing Solaris Studio 12.2?
My problem with the solutions provided in that question is that I do not have a script to run when I extract the file I downloaded: SolarisStudio12.2-linux-x86-tar-ML.tar.bz2
To extract it I am just using the Ubuntu GUI, archive manager.
Could this be my problem?
Also I already posted this on askUbuntu: Got no response.
There is no installation script to run with the tarfile distribution. You just extract the archive somewhere and that's it, Solaris Studio is installed and ready to use. You just need to add its bin directory to your PATH.
I'm not familiar with Ubuntu GUI archive manager so here is how I proceed:
$ bunzip2 < SolarisStudio12.2-linux-x86-tar-ML.tar.bz2 | tar xf -
$ PATH=$PWD/SolarisStudio12.2-linux-x86-tar-ML/solstudio12.2/bin cc -V
cc: Sun C 5.11 Linux_i386 2010/08/13
usage: cc [ options ] files. Use 'cc -flags' for details