preface
For those of you who are migrating to Windows on your MAC, the lack of a Linux available environment on your Windows environment is often annoying. This series of articles focuses on the pitfalls I’ve stepped into in building a comfortable Linux environment.
So let’s see what it looks like
- After the COMPUTER is powered on, the VM automatically starts in the background without manual operation or GUI
- It takes up less memory, and a small hose works
- With the UTools initiator, you can use simple commands to quickly turn on, off, and restart a VM
bootTo turn it offrestart
- Xshell automatic connection, cool terminal
- Support command highlighting, command TAB prompt, history command one-key completion (instead of Ctrl+R), more beautiful skills can see a water friend
- After startup, the host code directory, tools directory, download directory will be automatically mounted to our specified directory
Why virtual machines
In fact, many students need to use Docker for Linux. Docker Desktop is also available on Windows platform, which is easy to install and out of the box. Why do they need to use virtual machines?
The main reason is that the current computer memory is only 8G, docker Desktop and Hyper-V after starting, directly take up more than 1G of memory. Development usually requires the browser, IDE, documentation, etc., to be open at the same time. Too many open things get jammed and crash easily.
Running Docker on centos for vmware WorkStations usually requires very little memory. As you can see, the virtual machine I started took up very little memory after running a mysql and Redis.
Without further ado, let’s get right to the installation
Install and configure the VM
Download vmware Workstation and centos by yourself
Create and install a VM
It is best to name virtual machinesUsing EnglishAnd the path had better beEnglish. If it is In Chinese, there will be coding problems in the process of setting up the virtual machine background self-start, and it will be troublesome to toss and turn back and forth. It is better to use Chinese directly. Click start, and install centos, installation process omitted, always the next step is good, fool installation.
Configure the network
Choose Edit -> Virtual Web EditorClick Change SettingsSelect NAT mode and click NAT SettingsRemember these three addressesStart the VM and log in to the system
vi /etc/sysconfig/network-scripts/ifcfg-ens33
Copy the code
Perform the following steps to change the IP address and add the IP addressAfter the modification is complete and saved, reset the network
systemctl restart network
Copy the code
Then you can test your Internet connection
Run the vmrun command to start and stop a VM
Find the installation directory for vmware Workstation, which usually has an execution file called vmRun. Vmware Workstation uses this command to start virtual machines.You can test virtual machine startup by executing commands from the CMD command line
#On the instructions
"D:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws start "D:\tools\centos\CentOS.vmx" nogui
#Shutdown instructions
"D:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws stop "D:\tools\centos\CentOS.vmx" nogui
#Restart the instruction
"D:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws stop "D:\tools\centos\CentOS.vmx" nogui
"D:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe" -T ws start "D:\tools\centos\CentOS.vmx" nogui
Copy the code
The first parameter"D:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe"
Indicates the absolute path of VMRun"D:\tools\centos\CentOS.vmx"
Indicates the installation path of your VMnogui
Boot in the background without a GRAPHICAL user interface (GUI). After a few seconds, you can connect through terminal tools such as Xshell.If the command instart
Switch tostop
It indicates shutdown.We put these two commands, respectively into two BAT files, and click execute, you can directly switch the virtual machine through the command.However, using the mouse to click the script, or typing this long command is very troublesome. With quick startup tools like UTools and WOx, you can go directly to the script and start and shut it down
Set the VM to start automatically upon vm startup
MSC -> User Configuration -> Windows Settings -> Double click script (Login/Logout) -> Double click Login or Logout to add them respectivelyIn this case, the system automatically starts the VM before each startup and stops the VM after logging out.
Install the vmware tools
Vmware Tools can be used to set shared folders. Choose VM > Install vmware Tools
- First mount the installer
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
Copy the code
See… Mounting Mounting Success Indicates mounting success.
- Unpack the vmware tools
CD/MNT /cdrom ls -al tar -zxvf vmwareTools-10.2.0-7259539.tar. gz -c/TMPCopy the code
- Execute setup
cd /tmp/vmware-tools-distrib/
./vmware-install.pl
Copy the code
Theoretically, only one should be returned at the very beginningy
If you confirm, the rest can be entered.If the following error occurs
The path "" is not valid.
What is the location of the directory of C header files that match your running
kernel?
Copy the code
You can use commands to update the kernel and then restart the machine
yum update kernel
Copy the code
Setting a Shared Directory
The most important purpose of installing vmware Tools is to set up file sharing between host and virtual machine. Click OK to enter the VM and enter the commandvmware-hgfsclient
You can see that the three directories we set up are already in placeBut the files inside are not currently accessible, so first we create a few directories where we want to mount these shared files. Let’s say I want to mount all of these directories to /root/host
#Create a directory
mkdir -p /root/host/workspace
mkdir -p /root/host/tools
mkdir -p /root/host/download
#Run the mount command
/usr/bin/vmhgfs-fuse .host:/workspace /root/host/workspace -o subtype=vmhgfs-fuse,allow_other
/usr/bin/vmhgfs-fuse .host:/tools /root/host/tools -o subtype=vmhgfs-fuse,allow_other
/usr/bin/vmhgfs-fuse .host:/download /root/host/download -o subtype=vmhgfs-fuse,allow_other
Copy the code
Then check the /root/host directory. The three directories are properly mounted.
Set directory mounting to start automatically upon startup
This mode of directory mounting usually disappears after the machine restarts. We need to set up a startup automatic execution script so that the virtual machine can automatically mount these three directories to the directory we specified after each startup. Scripting:
#! /bin/bash
/usr/bin/vmhgfs-fuse .host:/workspace /root/host/workspace -o subtype=vmhgfs-fuse,allow_other
/usr/bin/vmhgfs-fuse .host:/tools /root/host/tools -o subtype=vmhgfs-fuse,allow_other
/usr/bin/vmhgfs-fuse .host:/download /root/host/download -o subtype=vmhgfs-fuse,allow_other
Copy the code
Give execute permission to the script
chmod +x mount.sh
Copy the code
Add this script to the startup startup
#The default permissions for this file are lowered in centos7, so execute permissions are given first
chmod +x /etc/rc.d/rc.local
#Modify the file and put the mount script at the end
vi /etc/rc.d/rc.local
Copy the code
Restart to see that the directory is automatically mounted.
Terminal Settings
In the past, item2+ OH_MY_zsh and various plug-ins were very convenient on MAC, but Item is not available on Windows platform, XShell is also an excellent terminal management software, in addition to the possibility of no Ctrl+C/Ctrl+V, not so convenient, as long as you get used to it, it is also good.
Same as saying nothing, just do it
Install the ZSH
Using the commandcat /etc/shells
Check which shells are currently installed; generally, ZSH is not
After the installation, run the CHSH -s /bin/zsh command to switch shells
Echo $SHELL = /bin/ ZSH; echo $SHELL = /bin/ ZSH
Reboot to enter the ZSH world
Install OH My ZSH and related plug-ins
# yum Install Git # Yum Install Git # Yum Install Git
After installing Git, use the following code to install OH my ZSH
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Copy the code
If the following figure is displayed, the installation is successful
__ __ ____ / / _ ____ ____ ____ ____ _____ _____ / / __ / __ / __ \ / __ ` __ \ / / / / / _ / / ___ / __ / / / _ / / / / / / / / / / / / __ / / / / _ (__) / / / \ ____ _ / _ / _ / / __ / / _ \ __, / / ___ / _____ there comes / __ / / __ / / /... is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. p.s. Follow us at https://twitter.com/ohmyzsh. p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.Copy the code
You can modify the theme by using vi ~/.zshrc
#The theme I'm using is Agnoster, and there are other themes that you can choose if you like
ZSH_THEME="agnoster"
Copy the code
So far the cool terminal installation is complete, more cool skills we must play than I slip, not to show the ugly.