How to Setup Bash on Windows 10 for Developers – Ultimate Setup

Bash for Windows 10 has been out for almost a year now. It has been incredible for a developer like myself to be able to use Bash natively on a Windows machine!

In this article, I’ll show you how I install my main Bash setup for Windows 10.

 

Requirements

  1. Your Windows 10 PC must be running a 64-bit version of Windows 10 Anniversary Update build 14393 or later.
    To find your PC's CPU architecture and Windows version/build number, open Settings>System>About. Look for the System type and OS Build fields.


    In this screenshot, I have a 64-bit operating system, x64-based processor and OS Build, 15063.138, so I fit the requirements.

 

Steps

  1. Install Bash on Windows 10
  2. Install ConEmu for tabs
  3. Must have Bash customizations
  4. Install VcXsrv Windows X Server for opening GUI applications

 

1. Install Bash on Windows 10

In order to run Bash on Windows, you will need to manually:

  1. Turn on Developer Mode
  2. Enable the “Windows Subsystem for Linux (beta)” feature

Open Settings -> Update and Security -> For developers
Select the Developer Mode radio button.

Developer mode is selected.

From Start, search for “Turn Windows features on or off” (type ‘turn’)
Select Windows Subsystem for Linux (Beta)

Windows Subsystem for Linux (Beta) is checked.

Hit OK. Installation will proceed, and afterwards, you will have to restart your computer.

After you restart your computer, you will be able to finish installing Bash on Windows 10.

Search for Microsoft Store.

From the Microsoft Store, find Ubuntu and download and install it.

From Start, search for “bash” (type ‘bash’) or it might already be open.

When you open bash, you will see a command prompt window.

Type "y" to continue.

The real “Bash on Ubuntu on Windows” shortcut will be installed. Bash on Ubuntu on Windows might already be installed through the Microsoft Store.

Now, you can open “Bash on Ubuntu on Windows” whenever you search for “bash”

Try opening Bash.  The first time you install Bash on Windows, you will be prompted to create a UNIX username and password.

After typing in a UNIX user name and UNIX password, you can use Bash the same way that you would use a terminal on Mac and Linux.

The biggest problem though is there are no tabs! Let’s fix the tab issue.

 

2. Install ConEmu for tabs

ConEmu is an amazing program that gives you terminal tabs, allows you to copy and paste the normal way with CTRL-C and CTRL-V, and run any combinations of shells including Command Prompt, Bash, Powershell, and more.

https://conemu.github.io/

Hi the Download button, which will take you to a redirected list of versions of ConEmu. I like to use the Preview version.

Run the executable. Select the x64 bit version of installation.

Hit Next on the next few prompts, which are the intro window, license and agreement, and settings. I leave everything by default.

Now, you are ready to install. Hit Install.

Hit Finish on the next prompt.

From Start, search for “ConEmu” (type ‘ConEmu’)

When ConEmu first starts, you will be brought to the Startup Settings. You have to select the default console that you want to open.

Find and select {Bash::bash} in the Specified named task section.

Now, whenever you open ConEmu, it will open to Bash by default! ConEmu is easy to read and smooth.

I like to pin ConEmu to the taskbar to be able to open bash quickly. Right click ConEmu’s icon and click Pin to taskbar.

To add a new tab on ConEmu, type WIN+W.

To switch to the right tab, type CTRL+Tab.

To switch to the left tab, type CTRL+Shift+Tab.

All ConEmu’s shortcuts are listed: http://conemu.github.io/en/KeyboardShortcuts.html

 

3. Must have Bash customizations

Bash on Windows 10 is great, but it could use a few customizations to make using it with Windows 10 files and programs easier!

First, we will adjust our ~/.bashrc.

nano ~/.bashrc

Use any text editor. On nano, type ALT+/ to go to the end of the file.

These configurations allow easy access to some of my favorite Windows related directories and programs.

I want to be able to change directory to the Windows C: drive easily and access my desktop, so I use aliases.

alias converts the given word into shortcuts.

I also want to be able to use Sublime, which is my go-to GUI text editor, so that I can type subl . and open the current working directory with Sublime.

I am using Sublime 3https://www.sublimetext.com/3

I want to be able to open any folder with File Explorer with open, so that I can open the current working directory with open .

I have a shortcut called linux to open the Ubuntu’s root folder with File Explorer.

Lastly, I have an alias called reload for reloading the ~/.bashrc to apply any new configurations.

Replace huyle with the username of your computer.

# Custom shortcuts
alias windows="cd /mnt/c"
alias desktop="cd /mnt/c/Users/huyle/Desktop"
alias subl="/mnt/c/Program\ Files/Sublime\ Text\ 3/subl.exe"
alias open="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe /c start -WorkingDirectory C:'\\'Users'\\'huyle'\\'AppData'\\'Local'\\'lxss"
alias linux="open C:/Users/huyle/AppData/Local/lxss"
alias reload="source ~/.bashrc"

These other shortcuts I use to access my favorite directories. I recommend you to add your favorite Windows or Ubuntu directories where you put your development code or work.

# Optional shortcuts
alias repos="cd /mnt/c/Users/huyle/Desktop/Repos"
alias work="cd /mnt/c/Users/huyle/Desktop/Work"
alias youtube="cd /mnt/c/Users/huyle/Desktop/YouTube"

You can save your file with nano by using CTRL+O and then pressing Enter.

Now, we can apply these changes.

source ~/.bashrc

Use the windows alias to easily switch to your Windows files! You can try some of these other aliases!

open .

The open alias does not work with Ubuntu’s directories because of directory translation errors, but by default, at least, I set the alias to open the Ubuntu root directory.

Every now and then, I prefer using Sublime, so it’s very convenient to be able to type subl . in order to open current working directories with Sublime.

Here are some extra utilities that I like to install on Bash. These utilities are optional.

I like to use tmux, which is a terminal multiplexer. It lets you switch easily between several programs in one terminal.

I like tabs, but every now and then, I like everything in one terminal for a bird’s eye view.

I also like to use zip and unzip often to create zip files and extract them.

sudo apt-get install -y tmux zip unzip

Nice! Bash on Windows 10 with tabs and tmux feels so good. Your development is now super-charged!

 

4. Install VcXsrv Windows X Server for opening GUI applications

If you have ever wanted to open GUI applications through SSH connections, this step is for you.

By default, Windows 10 does not come with an X11 server by default. I’ve been using VcXsrv Windows X Server, but Xming also works.

You can download VcXsrv Windows X Server here:

https://sourceforge.net/projects/vcxsrv

Hit the Download green button.

I leave the settings by default.

You can open VcXsrv by searching for “vcx” on Windows 10 search.

I Allow access for VcXsrv Public networks.

Now that we have our X11 server open, we should adjust our ~/.bashrc a little bit to make sure that the DISPLAY value will be correct.

vim ~/.bashrc
# X11 server display value
export DISPLAY=localhost:0.0

Let’s test if our X11 server works! I like to install x11-apps for testing.

x11-apps contains xclock, which is great for testing GUI applications and X11.

sudo apt-get install -y x11-apps

Now, let’s run xclock.

xclock

Last but not least, let’s make sure that X11 will work on top of SSH connections.

mkdir ~/.ssh
vim ~/.ssh/config
Host *
    ForwardAgent yes
    ForwardX11 yes

Now, save the ssh config file and change its permissions correctly.

chmod 600 ~/.ssh/config

Afterwards, you should be able to use -X with ssh in order to enable the forwarding of X11 connections to VcXsrv.

ssh -X [email protected]_address

Great job! Good luck with your development. I’ve been finding this setup very comfortable as a developer!

How to Access Ubuntu Bash Files from Windows

If you installed Bash on Windows 10, and you want to get access to the files that you created on Bash from the Windows side, here’s what you need to do!

  1. Open File Explorer
  2. Click File on the top left, click Change folder and search options
  3. Click on View tab, make sure Show hidden files, folders, and drives is selected, Click OK
  4. Click on the folder directory address box, copy and paste: %localappdata%\lxss or C:\Users\{username}\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu##.##
  5. When you click Enter, you’ll be in the Bash directory (2017): C:\Users\{username}\AppData\Local\lxss
  6. You can access the files through Cygwin or File Explorer in the future

 

1. Open File Explorer.

 

2. Click File on the top left, click Change folder and search options.

 

3. Click on View tab, make sure Show hidden files, folders, and drives is selected, Click OK.

 

4. (2017) Click on the folder directory address box, copy and paste: %localappdata%\lxss

If you’ve downloaded Ubuntu recently in (2018), then the path is different:

A. Go to C:\Users\{username}\AppData\Local\Packages\

B. Start looking for folder with the Ubuntu version (example): CanonicalGroupLimited.Ubuntu18.04

C. Your final destination will be in the LocalState\rootfs folder:

 

5. When you click Enter, you’ll be in the Bash directory: C:\Users\{username}\AppData\Local\lxss

 

6. You can access the files through Cygwin or File Explorer in the future!

How to Create Shared Folder on VirtualBox – Windows and Ubuntu

I have a Windows 10 laptop, and I am running VirtualBox. One of my virtual machines has Ubuntu 14.04 64 bit operating system. Now, I want to be able to share folders from my Ubuntu to Windows 10 and vice versa. I’m assuming that you have installed the Ubuntu virtual machine already and ready to set up the shared folder.

Step 1) Make a folder to be shared on your Windows 10 host operating system.

I’ll create a folder called shared on my Windows 10 Desktop.

create-shared-folder

I’ll put a bunch of stuff inside the shared folder to be used by the Ubuntu virtual machine.

a-bunch-of-stuff-in-shared-folder

 

Step 2) Make sure that you have an empty optical drive for your virtual machine.

empty-optical-drive

 

Step 3) Boot your Ubuntu virtual machine. Go to Devices tab and click Insert Guest Additions CD image…

insert-guest-additions-cd-image

 

Step 4) Open up a terminal and install the Guest Additions CD.

We make a directory to mount the Guest Additions CD. The Guest Additions CD contains a file system type that we need to use.

sudo mkdir /media/cdrom

Now, we can mount the Guest Additions CD to the /media/cdrom folder.

sudo mount /dev/cdrom /media/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only

We should install necessary packages if they have not already been installed.

sudo apt-get install make gcc linux-headers-$(uname -r)

Now, we can install and run the Guest Additions CD.

sudo /media/cdrom/VBoxLinuxAdditions.run

 

Step 5) Click on the Devices tab and click Shared Folder Settings… and integrate the Windows 10 shared folder.

shared-folder-settings

Hit the add shared folder button.

hit-the-add-folder-button

Click on the Folder Path list and find your shared folder on Windows 10. I checked off Read-only, Auto-mount, and Make Permanent. Hit OK.

find-shared-folder-in-shared-folder-settings

 

Step 6) Create a shared folder on Ubuntu virtual machine and mount the shared folder.

You make a directory on the Ubuntu virtual machine that will act as Ubuntu’s shared folder.

mkdir ~/shared-windows10

We mount the shared folder on Windows 10 to the ~/shared-windows10 folder.

sudo mount -t vboxsf shared ~/shared-windows10

shared was the name of the Windows 10 shared folder, and I called the Ubuntu shared folder, ~/shared-windows10, to differentiate between the two.

 

Step 7) Change directory into the shared folder and see all the shared files.

cd ~/shared-windows10
ls

shared-windows10-folder-content

Huzzah! The shared folder is great for transferring files from Windows 10 to the Ubuntu virtual machine and vice versa.

I set the shared folder to Read-only, but you can uncheck the box in the Shared Folder Settings…

How to Get Multiple Terminals on Ubuntu Server

Let’s say that you want multiple terminals on an Ubuntu server. If you have ever used the Ubuntu server version of the OS, you should know that it is maneuvered only through the terminal. We had a situation where we didn’t have access to the Internet, so we couldn’t install something like tmux for multi-tasking, and we thought screen was hard to use.

We needed multiple terminals, so that we could run multiple commands at the same time!

If you are using a keyboard and monitor with Ubuntu server, it so happens that you can use ALT + F1ALT + F6 to spawn new terminals to do your work. The keyboard shortcuts switch you to a new terminal window. You can have 6 of these terminals, which are basically the equivalent of terminal tabs on Ubuntu with the GUI.

In my case, I was using Ubuntu 14.04, but it should work with the other versions as well.

ubuntu-1404-server

ALT + F2 to spawn terminal #2 and so on

How to Download Packages and Dependencies from Different Architectures on Ubuntu

Let’s say that I have a computer that I installed Ubuntu 14.04 x86-64 also known as amd64. I want to download a package, but I want to download the package and its dependencies from a different architecture instead of amd64. In this scenario, I want to download a package from arm64 architecture.

Enable Another Architecture to Download

First, we will add a new architecture to be able to select when installing or downloading any package. Instead of arm64, you can substitute any architecture abbreviated name in the following command.

sudo dpkg --add-architecture arm64

Update sources.list

To get access to arm64 packages, we need to add additional sources to our sources.list where apt-get finds its packages.

sudo vi /etc/apt/sources.list

Add the following URLs to the file. Note that I am using Ubuntu 14.04, which is code named: trusty. You will use a different code name at the end of the URLs if you have a different version of Ubuntu.

# source urls for arm64
deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ trusty universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates universe
deb http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates multiverse

We need to update our sources list with the new URLs so that we can download packages for arm64.

sudo apt-get update

How to Download Ubuntu Packages and Dependencies Locally

Afterwards, we should make a directory to store the packages that we want to download.

mkdir arm64-packages

Now, we download the package inside that directory. For instance, let’s say that we wanted to download vim and not install it. To download arm64 architecture packages, you have to place :arm64 after the package name. If you don’t put the architecture name after the package, then the default architecture in my case amd64 will be downloaded.

Where vim:arm64 is, you can replace with the name of any package available through apt-get followed by :arm64.

cd arm64-packages
for i in $(apt-cache depends vim:arm64 | grep -E 'Depends|Recommends|Suggests' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/); do sudo apt-get download $i 2>>no32.txt; done

Any errors will be outputted inside no32.txt. If you ls, then you should see all of the deb packages and dependencies for arm64.

ls
libacl1_2.2.52-1_arm64.deb
libc6_2.19-0ubuntu6.9_arm64.deb
libgpm2_1.20.4-6.1_arm64.deb
libpython2.7_2.7.6-8ubuntu0.2_arm64.deb
libselinux1_2.2.2-1ubuntu0.1_arm64.deb
libtinfo5_5.9+20140118-1ubuntu1_arm64.deb
no32.txt
vim-common_2%3a7.4.052-1ubuntu3_arm64.deb

How to Download Packages and Dependencies Locally on Ubuntu

I want to download a package and all of its dependencies that I would typically use apt-get to install on Ubuntu. How do I download a package and its dependencies locally on Ubuntu? I am using Ubuntu 14.04 and Ubuntu 16.04 for this tutorial.

How to Download Ubuntu Packages and Dependencies Locally

We require Internet access to download the packages locally. First, we should always update our package sources.

sudo apt-get update

Afterwards, we should make a directory to store the packages that we want to download.

mkdir packages

Now, we download the package inside that directory. For instance, let’s say that we wanted to download vim and not install it. Where vim is, you can replace with the name of any package available through apt-get.

cd packages
for i in $(apt-cache depends vim | grep -E 'Depends|Recommends|Suggests' | cut -d ':' -f 2,3 | sed -e s/'<'/''/ -e s/'>'/''/); do sudo apt-get download $i 2>>no32.txt; done

Any errors will be outputted inside no32.txt. If you ls, then you should see all of the deb packages and dependencies.

ls
libacl1_2.2.52-1_amd64.deb
libc6_2.19-0ubuntu6.9_amd64.deb
libgpm2_1.20.4-6.1_amd64.deb
libpython2.7_2.7.6-8ubuntu0.2_amd64.deb
libselinux1_2.2.2-1ubuntu0.1_amd64.deb
libtinfo5_5.9+20140118-1ubuntu1_amd64.deb
no32.txt
vim-common_2%3a7.4.052-1ubuntu3_amd64.deb
vim-doc_2%3a7.4.052-1ubuntu3_all.deb
vim-runtime_2%3a7.4.052-1ubuntu3_all.deb
vim-scripts_20130814ubuntu1_all.deb

How to Install .deb Files

sudo dpkg -i *

Errors are processed in no32.txt.

How to SSH to Another Computer with Ethernet Cable – Local Area Network

Let’s say that we wanted to connect an Ethernet cable from Ethernet port of one computer to Ethernet port of another computer. I want to be able to SSH into the other machine from my computer given that I know the other machine’s password or have an authenticated SSH key.

ethernet-to-ethernet

You can also SSH to a series of machines if you have a switch with all the other machines connected to that switch through Ethernet cables. The switch is basically a hub point where all the machines can connect their Ethernet cables to and be able to access every other machine on the local area network.

ethernet-cables-to-a-switch

Let’s talk about how to SSH from 1 computer to another computer when the Ethernet cable from port to port of the two computers. One of the computers is my Windows 10 laptop. The other computer is an Ubuntu 16.04 server.

 

Step 1) Start the SSH server on the Ubuntu 16.04 computer.

First, we make sure that we have the OpenSSH server installed. We will require Internet access for this step.

sudo apt-get install openssh-server

Now, we restart the SSH server to be sure that it is working properly.

sudo service ssh restart
ssh stop/waiting
ssh start/running, process 3878

Step 2) Connect Ethernet cable from the Ethernet port of Windows 10 computer to the Ethernet port of the Ubuntu 16.04 computer.

Step 3) Set a static IP address on the Ubuntu 16.04 computer.

If both machines are connected to the Internet on the same router through Wi-Fi, then you will not need to create a static IP address. For more information about setting static IP addresses on Ubuntu, go here.

sudo vi /etc/network/interfaces

Look for an interface that begins with eth. The interface is typically named eth0.

auto eth0
iface eth0 inet static
address 18.125.5.100
netmask 255.255.255.0
gateway 18.125.5.1

Now, you save the file and restart the interface.

sudo ifdown eth0 && sudo ifup eth0

Step 4) Set a static IP address on the Windows 10 computer.

We need to have an IP address on the same IP space as the Ubuntu 16.06 computer. On Windows 10, you will right click the Internet icon on your task bar and click on Open Network and Sharing Center.

change-adapter-settings

On the right side bar, click Change adapter settings. Right click on Ethernet and click Properties. Click on Internet Protocol Version 4. Click Properties.

ethernet-properties-windows-10

Check off Use the following IP address and fill out IP address and Subnet mask. Note that you cannot use an IP address that is already used by the other machine.

internal-network-access-set-local-ip-on-machine

I will set the Windows 10 computer with the IP address 18.125.5.251 and the subnet mask of 255.255.255.0. Default gateway is optional. Use the following DNS server addresses is optional. I set 8.8.8.8 to point to Google’s Public DNS server. I check off Validate settings upon exit and hit OK.

After the validation, your computer should have the new static IP address. If you do not have Wi-Fi, you will not have Internet access at the moment since you set a static IP address that is likely not valid by your DHCP server, but you will be able to SSH into the Ubuntu 16.04 computer.

Step 5) SSH from Windows 10 terminal to the Ubuntu 16.04 computer.

For the Windows 10 terminal, you can use something like Cygwin to SSH into the Ubuntu 16.04 computer. Cygwin is program that allows Windows to use UNIX.  First, we ping the Ubuntu 16.04 machine to see if we have network connectivity.

ping 18.125.5.100

Eureka! Now, we can SSH into the Ubuntu 16.04 computer with its username.

ssh [email protected]

Enter your password, and you will have access to your Ubuntu 16.04 computer from your Windows 10 computer using the local area network and direct Ethernet cable.

How to Set Static IP on Ubuntu

To set the static IP address on Ubuntu, we want to first determine what network interfaces we currently have. These network interfaces represent the Infiniband or Ethernet ports on your computer. You will typically have an interface called eth0 or eth1 that allows you to connect to the Internet.

Note, setting the static IP will allow you to connect to the Internet as long as the IP address is valid according to your DHCP server. If you set any static IP address randomly and refresh the interface, you will not be able to connect to the Internet. However, the static IP address should still work on the internal network. I would recommend doing the following steps directly on the computer instead of through SSH.

ubuntu-static-ip

To find out what interfaces you have, you can first check for interfaces that contain eth.

ifconfig -a | grep eth

You can also use the following command to see all your interfaces:

cat /proc/net/dev

Here, we have an eth0 interface that we can set a static IP. If we don’t see any interfaces after running the above commands, then we will have to check the interfaces configuration file.

sudo vim /etc/network/interfaces

You will see something like this:

auth lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto lo refers to the loopback for connections to oneself. We want to change the eth0 interface or whatever named interface you have. Note, the interface may have a different name.

We want to give the eth0 interface a static IP address.

auto eth0
iface eth0 inet static
address 168.122.196.180
netmask 255.255.255.0
gateway 168.122.196.1
dns-nameservers 8.8.8.8 8.8.8.4

Now, we save the file, and we can restart the network.

sudo ifdown eth0 && sudo ifup eth0

We can check if eth0 has the new static IP address.

ifconfig | grep eth0

You should see the new eth0 interface information after running the above command.

14 Steps to Create a Website with Amazon Web Services EC2 instance – Ubuntu

Setting up an Amazon Web Services EC2 instance for the first time can be a pain in the ass. It’s time for an easy tutorial on how to get a website set up on an AWS EC2 Ubuntu instance.

Step 1:

Go to http://aws.amazon.com. Sign up for an Amazon Web Services account if you don’t already have an account. Sign into your account if you have one.

signin
Sign up for an AWS account or Sign in.

 

Step 2:

Click on EC2 Virtual Servers in the Cloud on the left side of the management console.

ec2
Go to EC2.

 

Step 3:

Click on the Launch Instance button to create a new EC2 virtual server.

Click the Launch Instance blue button.

 

Step 4:

Choose an Amazon Machine Image. You can select from a number of free tier eligible instances, which include a variety of different linux distributions and a windows server. We will be selecting Ubuntu Server 14.04 LTS (HVM).

Select the free tier eligible Ubuntu Server.

 

Step 5:

Through Steps 2-5 on the EC2 instance setup, you can click the gray Next button at the bottom right of your browser.

 

Step 6:

On the Configure Security Group step, you want to Create a new security group for future websites. Input a Security group name in the box and a description in the other box. Add two additional rules. Add rule Type HTTP. Add rule Type Custom TCP Rule. For the Custom TCP rule, input port range 8080 in the box. By adding these two rules, we can see our website online. HTTP is the default website port connection. Port 8080 for the Custom TCP rule is the common alternative port.

Configure Security Group. Add HTTP rule and a Custom TCP rule with port range 8080.

 

Step 7:

Click the blue button at the bottom right to Review and Launch the instance.

 

Step 8:

A Select an existing key pair or create a new key pair prompt box will pop up. Leave the create a new key pair as it is. Write a name for the key pair. Download key pair. This key pair will be used to ssh (get access) to the AWS EC2 instance.

Save the key pair after naming it.

 

Step 9:

For Mac or any Linux distribution, you can open any terminal. For Windows, you must use a program like Cygwin or Putty in order to use SSH. Open up a terminal that can use SSH on your computer. Maneuver to your pem file. ls is to list the contents of the directory. cd is to switch directories/folders.

cd ~ (I change directory to the home folder for my user)
ls (I list the contents of this directory where I saved my pem file)
cygwin
cd – change directory. ls – list contents.

 

Step 10:

To SSH or get access to your Amazon EC2 instance, you must change permissions of the pem (key) file. Amazon likes to secure the instance, so you need specific, secure permissions on the pem (key) file.

ls -l (lists the name and permissions of all files in the directory).
chown :Users website.pem (gives the file ownership to the Users group (for Windows, you have to do this)).
chmod 600 website.pem (allows only the owner of the file to read and write that file (Amazon requires this type of permission for the key to be used)).
permissions
Give the correct permissions to the pem (key) file.

 

Step 11:

Now, you can SSH into the EC2 instance. You first need the public DNS or IP of the EC2 instance. Go back to the EC2 Management Console. Click on Running Instances or Instances on the left sidebar to be brought to the EC2 instance dashboard. By now, your instance state should be running. Click on the instance. At the bottom of your browser, you can see the description of this instance. At the right, you can see a public DNS. Copy the public DNS.

Copy the Public DNS.

 

Step 12:

Once you have the public DNS, you can SSH onto the instance. Go back to your terminal. The command is:

ssh -i website.pem [email protected]

We SSH onto the instance as the user ubuntu. ubuntu is the default user. The flag -i is to use the key file. Type yes for the fingerprint prompt.

ec2successfullogin
ssh with the key file as ubuntu on the Ubuntu instance.

 

Step 13:

Let’s set up an Apache web server so that our EC2 instance is viewable online. We must first install apache2. For Ubuntu, you type the following command:

sudo apt-get install apache2 (apt-get install is used to install packages on ubuntu. apache2 is a web server that allows our web files to be seen through the browser. sudo is running the command as the super user or basically the administrator.)
Type Y and enter to continue.
installapache2
Install apache2 by using sudo apt-get install apache2.

 

Step 14:

Copy the Public DNS to any web browser and go to the web address. You’ll see that your EC2 instance is now viewable on the web. Hurray!

ec2instanceisup
Copy and paste the Public DNS to a browser, and you can see that the page is up and running with the default success page.

 

Your website is now up and running with the default success page for newly installed apache2 web server Amazon Web Service instances. Enjoy!