Build Linux environments with virtual machines _win7+virtualbox+ubuntu

Source: Internet
Author: User
Tags create directory

Build Linux development environment with VirtualBox

0. Revision record

"2016-08-20" first edition

1. Software version

Windows:win7/win10

Virtualbox:virtualbox-5.0.24-108355-win

Ubuntu:ubuntu-16.04-desktop-amd64

2. Start installing Ubuntu

STEP1:

Before installation, the virtualization Technology (VTX) option needs to be turned on in the BIOS to enable the installation of a 64-bit Linux operating system and to enable multi-CPU configuration of the virtual machine.

Unlike machines, BIOS configurations are different, and some machines turn on the VTX option by default, without this step. If the VTX is not turned on, it can be opened in the BIOS. "For example: Hp ProDesk boot F10 Security---> System security---> Virtualization Technology"

STEP2:

VirtualBox Click New to create the Ubuntu operating system, as shown in 1:

Figure 1

When creating a virtual hard disk, it is recommended to select vhd,2

Figure 2

STEP3:

Click Start, select the Ubuntu:ubuntu-16.04-desktop-amd64 disc file to start the installation.

3. Network Configuration

3.1 Proxy settings

Generally speaking, if it is a personal computer, it should be able to sisu the net at this time, do not have to do any proxy settings.

If it is the company's computer, in order to secure, many companies use the agent, at this time need to Ubuntu configuration agent can Sisu network, you can first use the intranet to do the test (you can choose the corresponding company's homepage).

If you are using a proxy, set the appropriate agent in the network settings:

Figure 3

3.2 Software Updates

In the terminal (ctrl+alt+t) input apt-get Update, you will find the software update is very slow, this is using Ubuntu foreign sources, we can change to domestic sources, the speed will be much faster, the following methods to choose one.

METHOD1:

Modified:/etc/apt/sources.list

Figure 4

"Http://mirrors.163.com/.help/ubuntu.html"

METHOD2:

You can select a domestic source in the Software Update Center, such as Aliyun

Figure 5

4. Windows SSH Login virtual machine

4.1 Installing the SSH service

Through Xshell, putty and other tools in Windows SSH login to Ubuntu, there can be 2 ways, 4.2 and 4.3 are introduced, recommended to adopt 4.2 way.

Either way, you'll need to install SSH services in Ubuntu. Install OpenSSH.

To install the OPENSSH program:

STEP1 first check if SSH is installed.

dpkg--list|grep SSH

Discover that Ubuntu has already installed the client by default, if not installed, use this command:

#sudo Apt-get Install Openssh-client

STEP2 installing server-side Servers program

#sudo Apt-get Install Openssh-server

STEP3 Restart SSH Service

#sudo/etc/init.d/ssh Restart

To start the SSH service:

#sudo/etc/init.d/ssh Start

To stop the SSH service:

#sudo/etc/init.d/ssh Stop

To restart the SSH service:

#sudo/etc/init.d/ssh Restart

4.2 SSH Login Virtual machine Method 1

The advantage of this method is that the virtual machine is configured to log on with 2 virtual network cards, the benefit of which is that the virtual machine can share the directory with Samba to windows[see 5.2].

4.2.1 NIC Configuration

STEP1: In order to enable Ubuntu Sisu Network, while Windows SSH login to Ubuntu, you need to configure 2 virtual network cards:

VirtualBox---> Management---> Global settings: Add a new virtual network card.

Figure 6

On the Ubuntu Settings page of VirtualBox, select Network, NIC 1 is configured for NAT, Nic 2 is configured as host-only (Figure 7-9) "When configuring the NIC, turn off Ubuntu"

Figure 7

Figure 8

Figure 9

Step 2: Restart Ubuntu, configure NIC 2 (host-only NIC) in Ubuntu

Host-only NIC default settings on Windows side (automatically set when virtual machine is created, without manual setting)

Figure 10

Ubuntu needs to be set manually because the network card address on the Windows side is: 192.168.56.1

So, you need to set the address of Ubuntu Nic 2 to the same network segment, for example: 192.168.56.116

Figure 11

"Note" Sometimes, when this configuration is found, Nic 1 (NAT) will not be able to access the Internet, it is necessary to remove the Host-only network card gateway.

Figure 12

4.2.2 Login Method

Install the SSH login tool such as Xshell and log in to the Ubuntu virtual machine.

When logging in, use Address: 192.168.56.116 (SSH default port is 22)

4.3 SSH Login Virtual machine Method 2

This method does not require 2 virtual network cards, only 1 virtual network cards. This way Ubuntu cannot share folders through Samba with Windows, only by using mount to share folders.

4.3.1 Network card settings

To set up port forwarding for network card 1 (NAT NIC):

Figure 13

4.3.2 Login Method

Login with 127.0.0.1 2222 login virtual machine

5. Sharing folders with Windows

There are 2 ways to share, mount is to share the Windows directory to Ubuntu, Samba is to share the Ubuntu directory to Windows. Some code compiled and installed only in the Ubuntu directory can be successful, the creation of Named Pipes (MKFIFO) can only be in the Ubuntu directory, so the samba mode of the shared directory is necessary. In general, it is recommended to use the Mount method and, in some cases, samba mode.

5.1 Mount mode sharing

STEP1: Installing VirtualBox Enhancements

Figure 14

STEP2: Setting up Shared folders

Figure 15

STEP3: Create directory in Ubuntu, Mount shared folder to created directory.

For example: Create the 10_testseq folder in the/mnt/directory and execute the Mount command

Mount-t vboxsf 10_testseq/mnt/10_testseq/

You can see the Windows shared Folders in Ubuntu F:\10_testSeq

5.2 Samba mode sharing

STEP1: Installing Samba Services

$ sudo apt-get install Samba

STEP2: add configuration in/etc/samba/smb.conf

[Share]

Comment = Ubuntu share

browseable = No

Path =/home/your_user_name

writeable = yes

Guest OK = No

Public = yes
writable = yes

Create mask = 0644

STEP3: Restart Samba service

/etc/init.d/samba restart

To start the Samba server, simply execute the following command:

#sudo/etc/init.d/samba Start

To close the Samba server:

#sudo/etc/init.d/samba Stop

Restart the Samba server:

#sudo/etc/init.d/samba Restart

Step4:ubuntu Open shared directory permissions:

chmod 777/home/your_user_name

Note: Where your_user_name can be any created directory, simply correspond to STEP2.

STEP5: Accessing Shared Folders in Windows

\\192.168.56.116\share

Note: If you visit this directory frequently, you can set a shortcut or add a network location.

6. Software Installation

6.1 Vim Installation

Ubuntu comes with VIM will appear up and down key confusion, need to reinstall VIM

Apt-get Remove Vim-common

Apt-get Install Vim

6.2 Python Pip

Using Python to develop gadgets, you need a lot of Python libraries, Python has a dedicated software management tool PIP, installation Pip as follows:

Apt-get Install Python-pip

Pip Install--upgrade pip

Build Linux environments with virtual machines _win7+virtualbox+ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.