Friday, June 01, 2018

"Windows Subsystem for Linux" (also known as "Bash on Ubuntu on Windows") AKA Windows 10 bash

"Windows Subsystem for Linux" (also known as "Bash on Ubuntu on Windows")

folks try to:
Minimize it - "Oh, it's just Cygwin." (It's actually not, it's the actual Ubuntu elf binaries running on a layer that abstracts the Linux kernel.)
Design it - "So it's a docker container? A VM?" (Again, it's a whole subsystem. It does WAY more than you'd think, and it's FASTer than a VM.)
Here's a simple explanation from Andrew Pardoe  ‎Principal Program Manager, MSVC Compiler and Tools - ‎Microsoft
1. The developer/user uses a bash shell.
2. The bash shell runs on an install of Ubuntu
3. The Ubuntu install runs on a Windows subsystem. This subsystem is designed to support Linux.
It's pretty cool. WSL has, frankly, kept me running Windows because I can run cmd, powershell, OR bash (or zsh or Fish). You can run vim, emacs, tmux, and run Javascript/node.js, Ruby, Python, C/C++, C# & F#, Rust, Go, and more. You can also now run sshd, MySQL, Apache, lighttpd as long as you know that when you close your last console the background services will shut down. Bash on Windows is for developers, not background server apps. And of course, you apt-get your way to glory.
Bash on Windows runs Ubuntu user-mode binaries provided by Canonical. This means the command-line utilities are the same as those that run within a native Ubuntu environment.
Install/Enable the Windows Subsystem for Linux
Enable the "Windows Subsystem for Linux" optional feature and reboot.
Open PowerShell as Administrator and run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
restart
Start bash
Windows Menu type or search bash
-- Beta feature --
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms
Type "y" to continue: y
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: gps
Password: brcm1234
Then, from the bash shell make sure you have build-essential, gdb's server, and openssh's server:
$ sudo apt update
$ sudo apt install -y build-essential
$ sudo apt install -y gdbserver
$ sudo apt install -y openssh-server
Then open up /etc/ssh/sshd_config with vi (or nano) like
sudo nano /etc/ssh/sshd_config
and for simplicity's sake, set PasswordAuthentication to yes. Remember that it's not as big a security issue as you'd think as the SSHD daemon closes when your last console does, and because WSL's subsystem has to play well with Windows, it's privy to the Windows Firewall and all its existing rules, plus we're talking localhost also.
Now generate SSH keys and manually start the service:
$ sudo ssh-keygen -A
$ sudo service ssh start
Connect your build system for Linux to use port 22
username gps
password brcm1234


How connect to your Visual Studio



Getting Started

Visual C++ for Linux Development

Setting up your project for Linux Development

With this workload you can author C++ code for Linux servers, desktops and devices. You can manage your connections to these machines from within VS. VS will automatically copy and remotely build your sources and can launch your application with the debugger. Our project system supports targeting specific architectures, including ARM.

Connecting to Linux

Prerequisites

Today we only support building remotely on the Linux target machine. We are not limited by specific Linux distros but we do have dependencies on the presence of some tools. Specifically, we need openssh-server, g++, gdb and gdbserver. Use your favorite package manager to install them, e.g. on Debian based systems: sudo apt-get install openssh-server g++ gdb gdbserver

First connection

The first time you target a Linux machine you will be prompted for connection information. This is triggered by building the project.
On your Visual Studio go to Tools > Options > Cross Platform > Linux and enter the credential
  • Hostname: IP or hostname of your docker host
  • Port: The port you have pass in the previous command ( 12345 for example)
  • Username: gps
  • Authentication type: password
  • Password: brcm1234

Adding and removing connections

To add a new connection, go to Tools > Options and search for Connection, Connection Manager will be under Cross Platform. From here you can add and remove connections.

To change which connection a project is using go to the project properties general settings and update the Remote Build Machine option.

Project Properties

All of the options necessary to control C++ compilation are exposed on the project properies pages. We'll cover a few specific to how things work for Linux. First under general settings, you will see the remote root is set to ~/projects/ by default and that we are setting the remote project directory to match our project name in that location.

Looking at the General settings for the project, you can see how our output and intermediate directories were configured. Additionally, you’ll see that this project was configured as an application – thus our executable is under bin/x64/Debug/ as ConsoleApplication1.out. Notice that for configuration types we also support static and dynamic libraries.
Add additional library dependencies on the Linker > Input property page.

You can pass additional pre launch commands to the debugger to do things like launch graphical apps on the remote linux machine.


You can also send post build events to control remote behavior, as in this example that exports a gpio pin for use without requiring the executable run as super user.

Console window

The Linux workload has a console window tailored for interacting with your remote executables. This window shows not just the output of your program but can also take input. To activate this window, use the menu Debug, Linux Console.

Now you can attach to gdbserver running inside bash ubuntu on your local Windows 10



=thread-group-added,id="i1"
GNU gdb (GDB) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-mingw32 --target=x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
.
Find the GDB manual and other documentation resources online at:
.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
Loaded 'shared libraries loaded at this time.'. Cannot find or open the symbol file.
Stopped due to shared library event:
  Inferior loaded /lib/x86_64-linux-gnu/libc.so.6
    /lib64/ld-linux-x86-64.so.2
Loaded '/lib/x86_64-linux-gnu/libc.so.6'. Cannot find or open the symbol file.
Loaded '/lib64/ld-linux-x86-64.so.2'. Cannot find or open the symbol file.
Breakpoint 1, main () at /home/gps/projects/ConsoleApplication1/main.cpp:5
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
The program '' has exited with code 0 (0x0).


Monday, January 29, 2018

Windows 10 OS point of view - a lot of good points

well said

https://itvision.altervista.org/why-windows-10-sucks.html

Wednesday, October 18, 2017

PROBLEM FORMATTING USB FLASH DRIVE


Showing unknown size of truncated size

Run CMD.EXE as administrator
Type following commands and hit ENTER key after each command.
· DISKPART starts the DiskPart program
· LIST DISK shows numeral assigned to disks
note the numeral assigned to your usb stick
The numeral 2 will be used in this example
· SELECT DISK 2
· DETAIL DISK the info shown will confirm the correctness of your selection
· CLEAN ALL the entire usb stick will be overwritten with zeros
· CREATE PARTITION PRIMARY create a primary partition on the USB stick
· FORMAT FS=NTFS format the partition
· ACTIVE the partition can contain operating system startup files
· ASSIGN the next available letter is assigned to the USB stick
· EXIT exit from the DISKPART program
· EXIT exit from the command shell

Monday, August 28, 2017

basic linux commands



ls = If you run ls without any additional parameters, the program will list the contents of the current directory in short form.

ls -l = detailed list

ls -a = displays hidden files
cp = Copies sourcefile to targetfile.
cp -r = Copies recursively (includes subdirectories)
mv = Copies sourcefile to targetfile then deletes the original sourcefile.
mv -b = Creates a backup copy of the sourcefile before moving
rm = Removes the specified files from the file system. Directories are not removed by rm unless the option -r is used.
rm -r = Deletes any existing subdirectories
rmdir = Deletes the specified directory, provided it is already empty.
cd = Changes the current directory. cd without any parameters changes to the user’s home directory.
mkdir = Creates a new directory.
cat = The cat command displays the contents of a file, printing the entire contents to the screen without interruption.
cat -n = Numbers the output on the left margin
less = This command can be used to browse the contents of the specified file. Scroll half a screen page up or down with PgUp and PgDn or a full screen page down with Space. Jump to the beginning or end of a file using Home and End. Press Q to exit the program.
grep = The grep command finds a specific searchstring in the specified file(s). If the search string is found, the command displays the line in which the searchstring was found along with the file name.
df = The df (disk free) command, when used without any options, displays information about the total disk space, the disk space currently in use, and the free space on all the mounted drives. If a directory is specified, the information is limited to the drive on which that directory is located.
df -h = shows human readable output of disk usage
du = This command, when executed without any parameters, shows the total disk space occupied by files and subdirectories in the current directory.
du -sh = Shows current folder size
du -sh * = List files/folders with their size in current folder
free = The command free displays information about RAM and swap space usage, showing the total and the used amount in both categories.
free -m = Shows output in human readable format
date = This simple program displays the current system time. If run as root, it can also be used to change the system time. Details about the program are available in date.
top = top provides a quick overview of the currently running processes. Press H to access a page that briefly explains the main options to customize the program.
kill = [You can kill processes which are executed only by you] Unfortunately, sometimes a program cannot be terminated in the normal way. However, in most cases, you should still be able to stop such a runaway program by executing the kill command, specifying the respective process ID (see top and ps).
kill sends a TERM signal that instructs the program to shut itself down. If this does not help, the following parameter can be used:
kill -9 = [You can kill processes which are executed only by you] Sends a KILL signal instead of a TERM signal, with which the process really is annihilated by the operating system. This brings the specific processes to an end in almost all cases.
ping = The ping command is the standard tool for testing the basic functionality of TCP/IP networks. It sends a small data packet to the destination host, requesting an immediate reply. If this works, ping displays a message to that effect, which indicates that the network link is basically functioning.
passwd = Users may change their own passwords at any time using this command. Furthermore, the administrator root can use the command to change the password of any user on the system.
clear = This command cleans up the visible area of the console. It has no options.

Useful options
——————–
mv -f force move by overwriting destination file without prompt
mv -i interactive prompt before overwrite
mv -u update – move when source is newer than destination
mv -v verbose – print source and destination files
man mv/info mv help manual
 


List commands to display the content of a file

head, tail, cat less, more etc

eg.  $ cat file_name.txt

Friday, April 14, 2017

Visual Studio 2017 15.1 April 2017 and Windows 10 version 1703 update _march_2017

Be carreful with Visual Studio Professional 2017 (version 15.1)
Release date 4/4/2017 even if you install the latest version from on top of latest Windows 10 OS from March 2017 which was released before obviously.... Visual Studio will throw at you the most annoying dialog windowd from which you can't copy past the error message and from there you can't open any Xamarin or XAML project

Go figure how stupid you need to be to do such things... Poor team synchronization at Microsoft...
Why can't you check the OS first instead of wasting precious time.....

en_windows_10_enterprise_version_1703_updated_march_2017_x64_dvd_10189290.iso

Get your shit together Microsoft



[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.UniversalCRT.Msu.8 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.2,6.3)'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.UniversalCRT.Msu.81 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.3,6.4)'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Net.4.6.FullRedist as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1.1,6.4)'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.UniversalCRT.Msu.7 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.DiagnosticsHub.KB2882822.Win7 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:05] Marking package WebSocket4NetV2 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:05] Marking package Component.WebSocket as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Net.4.6.1.FullRedist as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1.1,10.0.10241)'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.81SDK.Store.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.81SDK.Store.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.81SDK.Desktop.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.Windows.81SDK.Desktop.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:05] Marking package Microsoft.VisualStudio.OfficeDeveloperTools.WindowsIdentityFoundation.Msu as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '(,6.2)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.UniversalCRT.Msu.8 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.2,6.3)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.UniversalCRT.Msu.81 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.3,6.4)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Net.4.6.FullRedist as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1.1,6.4)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.UniversalCRT.Msu.7 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.DiagnosticsHub.KB2882822.Win7 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:06] Marking package WebSocket4NetV2 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:06] Marking package Component.WebSocket as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Net.4.6.1.FullRedist as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1.1,10.0.10241)'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.81SDK.Store.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.81SDK.Store.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.81SDK.Desktop.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.Windows.81SDK.Desktop.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0031][2017-04-14T14:19:06] Marking package Microsoft.VisualStudio.OfficeDeveloperTools.WindowsIdentityFoundation.Msu as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '(,6.2)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.UniversalCRT.Msu.8 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.2,6.3)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.UniversalCRT.Msu.81 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.3,6.4)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Net.4.6.FullRedist as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1.1,6.4)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.UniversalCRT.Msu.7 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.DiagnosticsHub.KB2882822.Win7 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0050][2017-04-14T14:19:23] Marking package WebSocket4NetV2 as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0050][2017-04-14T14:19:23] Marking package Component.WebSocket as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.2)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Net.4.6.1.FullRedist as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1.1,10.0.10241)'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.81SDK.Store.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.81SDK.Store.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.81SDK.Desktop.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.Windows.81SDK.Desktop.DirectX.Msi as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '[6.1,6.3]'.
[3554:0050][2017-04-14T14:19:23] Marking package Microsoft.VisualStudio.OfficeDeveloperTools.WindowsIdentityFoundation.Msu as not applicable due to reasons: The current OS Version '10.0.15063.0' is not in the supported version range '(,6.2)'.

Thursday, April 06, 2017

Add https to apache on Ubuntu 16


Install

On Ubuntu systems, the Certbot team maintains a PPA. Once you add it to your list of repositories all you'll need to do is apt-get the following packages.
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install python-certbot-apache 

Get Started

Certbot has a fairly solid beta-quality Apache plugin, which is supported on many platforms, and automates both obtaining and installing certs:
$ certbot --apache
If you're feeling more conservative and would like to make the changes to your Apache configuration by hand, you can use the certonly subcommand:
$ certbot --apache certonly
To learn more about how to use Certbot read certbot documentation.

Automating renewal

The Certbot packages on your system come with a cron job that will renew your certificates automatically before they expire. Since Let's Encrypt certificates last for 90 days, it's highly advisable to take advantage of this feature. You can test automatic renewal for your certificates by running this command:
certbot renew --dry-run
More detailed information and options about renewal can be found in the full documentation.