• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Run Bash Scripts on Windows 10 Via Git Bash To Launch Linux GUI App

By Abhishek Ghosh August 22, 2018 9:13 pm Updated on August 22, 2018

Run Bash Scripts on Windows 10 Via Git Bash To Launch Linux GUI App

Advertisement

Git Bash Offers Integrity Options With Windows 10 Bash Making it Easy to Work on Both Windows & unix System. In old days, we used Git Bash with MinGW. Indeed, we have 5-7 years old guides on them. This Guide Will Help To Run Bash Scripts on Windows 10 Via Git Bash Almost Like The Way We Use Bash on Mac. We actually can run or update Mac GUI app from MacOS X bash. In the same way, we can launch Notepad or Nano from Windows Git Bash! This is a standalone shell, like PowerShell, Windows 10 Bash will be unaffected following this guide. Installing git on Windows Bash and installing git on windows in this way is different. There will not be any conflict. The environment variables are separate.

Then where is the integration? Git Bash and Windows Ubuntu Bash (wsl) are like two separate machines! We can actually execute command from each another. The output of the below command :

Vim
1
bash -c "uname -a"

will be different on Git Bash and Windows Ubuntu Bash (wsl). Both of them can perform separate SSH. You can SSH from Git Bash to Windows Ubuntu Bash (wsl). It is not big deal, more about Linux server management. Unless your computer is server and port 22 is open to whole earth, slightly loose security setup will allow you to SSH.

Advertisement

---

You asked about where is the integration. SSH to localhost is integration. You’ll find lot of peoples trying to SSH to Windows Ubuntu Bash and failing. They forgot to set root’s password. After setting root password, thing will become somewhat like Mac! root by default not enabled in OS X. Apple’s software engineering part is beautiful. Microsoft’s just ugly.

What is the reason to do so much? Git Bash is allowed by package to open shell anywhere on Windows 10. You need not to fight with registry files, good looking window with True Type fonts.

Run Bash Scripts on Windows 10 Via Git Bash To Launch Linux GUI App

 

How To Run Bash Scripts on Windows 10 Via Git Bash

 

First install Git Bash Windows GUI application :

Vim
1
https://git-scm.com/download/win

Be super careful about installation options. You’ll select everything of UNIX system, including OpenSSL. After Git bash getting installed, open it. Tweak it to make it beautiful looking.

Now our peculiar work will start. Install XServer for Windows (recall we use it on Mac, this helps to run Linux GUI applications via bash) :

Vim
1
https://sourceforge.net/projects/xming/

Now, open Ubuntu Bash. Open sshd_config config file, before that take backup :

Vim
1
2
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup
sudo nano /etc/ssh/sshd_config

and make it like this :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Package generated configuration file
# See the sshd_config(5) manpage for details
 
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation no
 
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024
 
# Logging
SyslogFacility AUTH
LogLevel INFO
 
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
AllowUsers root
StrictModes yes
 
RSAAuthentication no
PubkeyAuthentication no
#AuthorizedKeysFile     %h/.ssh/authorized_keys
 
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
 
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
 
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
 
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes
 
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
 
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
 
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
 
#MaxStartups 10:30:60
#Banner /etc/issue.net
 
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
 
Subsystem sftp /usr/lib/openssh/sftp-server
 
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

Save the file. Now add a password to your Ubuntu Bash by typing :

Vim
1
passwd

Now, restart SSH daemon on Ubuntu Bash :

Vim
1
sudo service ssh --full-restart

After it restarts, SSH from your Git Bash :

Vim
1
ssh root@127.0.0.1

It will ask for password. Enter your password. You’ll login to Windows’ Ubuntu system. You can switch to Git Bash by exit from it by typing exit. Of course, you can make the SSH password-less like server. From Git Bash you can run :

Vim
1
notepad

to launch Windows Notepad. After SSH to Windows’ Ubuntu system, you can run :

Vim
1
2
apt upate
apt upgrade

Now, your integration of bash script from Windows GUI has two options. One is via Git Bash and another is via Git Bash on Ubuntu Bash. Ordinary things you can run on Git Bash, but complex stuffs which has package on Windows System will need to run on Ubuntu Bash.

Git Bash can use a .bash_profile file can be used to store settings between sessions. To edit this file, start Git Bash and type:

Vim
1
notepad ~/.bash_profile

It is typically C:\Users\user\.bash_profile on Windows system. From that file, you can add missing fonts, icons etc for Ubuntu Bash powered with ZSH.

We can associate shending scripts on Windows system. Create a blank script.sh file on Windows with Notepad and right-click on it, choose Open with from the right click context menu. Click More apps and navigate to C:\Program Files\Git\bin\sh.exe. Enable Always use this app to open .sh files and click OK.
Now, navigate to Control Panel > System > Advanced > Environment Variables. You’ll get a list of file extensions separated by ;. Modify it to look like :

Vim
1
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.SH

Now we can run from Windows utilities like command prompt :

Vim
1
sh script

In order to run command on your Ubuntu Bash, you have to modify the script.sh file like running command on server.

To run GNU/Linux GUI applications, you need to install them on Windows Ubuntu Bash. Like vim-gtk :

Vim
1
sudo apt-get install vim-gtk

Then run with command like :

Vim
1
DISPLAY=:0 gvim

If you create such bash scripts to “launch programs”, you can run them from Windows GUI.

 

Conclusion

 

This way is complex but will give you more granular control. You can select which system your bash script will run. It is not practical to allow any unknown bash script to directly get executed on Ubuntu Bash. That Git Bash serving many purposes. Needless to say, it is avoiding various registry tweaks to add “open bash here” on right click context menu. Mac is actually nicely integrated with scripting. It is not that Apple’s engineers are exceptionally knowledgeable but Apple, at least in the past did serious works to integrate which we see as “Apple Scripts”.

Tagged With git bash app , windows 10 run command in git bash , git bash run script , git bash windows 10 , git bash run exe , gitbash run , git bash script , git bash start sh , git bash for windows 10 , git bash launch js file

This Article Has Been Shared 706 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Run Bash Scripts on Windows 10 Via Git Bash To Launch Linux GUI App

  • Will you use cracked Windows 7?

    Know why using a cracked version of Microsoft Windows 7 is dangerous

  • Which one to buy:Factory installed (OEM) or Retail (Box pack) Windows 7

    This article demystifies the terms: OEM Windows 7 and Retail Windows 7 and it is a good guide to help the new customers to decide which one to buy: OEM Windows 7 or Retail Windows 7

  • What are keyloggers, trojans and Backdoors?

    Here is a small article explaining the terms Keyloggers, Trojans and Backdoors to an average Microsoft Windows user.

  • Using Apple Magic Mouse in Windows 7, Windows 8

    Using Apple Magic Mouse in Windows 7, Windows 8 with all functions needs some drivers specific for 32 bit or 64 bit version of Windows 7, Windows 8.

  • Should You Install iTunes for Windows?

    Should You Install iTunes for Windows as Music Player to Test Drive? iTunes is a Typical Mac and iPhone Application For the Music Lovers as Default Music Player.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (22.1K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Ways To Make Sure Your Online Course Outshine Others July 3, 2022
  • Will Smart Factories Become the New Assembly Line? July 2, 2022
  • The Cost of Doing Business as a Handyman July 1, 2022
  • Samsung Galaxy S22 Ultra: Long Term Review June 30, 2022
  • How to Make the Most of Your S Pen (S22 Ultra) June 29, 2022

About This Article

Cite this article as: Abhishek Ghosh, "Run Bash Scripts on Windows 10 Via Git Bash To Launch Linux GUI App," in The Customize Windows, August 22, 2018, July 4, 2022, https://thecustomizewindows.com/2018/08/run-bash-scripts-on-windows-10-via-git-bash-to-launch-linux-gui-app/.

Source:The Customize Windows, JiMA.in

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Privacy Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2022 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy