Linux Learning-1 initial Linux 20180407

Source: Internet
Author: User
Tags ssh

some simple things to know:


    • Linux is the operating system

    • Like Windows, you can do exactly the same thing, but it's relatively stable. More than 80% servers in the world are Linux

    • Andriod system is Linux, in fact, Mac system is UNIX



Linux Origins:

    • Unix------>minx----->linus Torvalds developed the Linux kernel in 1991

    • GNU (GNU is not UNIX) a PLAN this to fight Unix that can better than Unix but after use to publish their own source code and can not be used for commercial


Linux distributions

    • Debian 1993-ubuntu 2004

    • Slackware 1993-suse 1994

    • RedHat 1994-centos 2003

    • Redhat-redflag 1999

    • Redhat Fedora Community Edition RHEL 2002 Business Edition

CentOS is an improvement on the basis of redhat, but it is not so good after-sales maintenance as compared to the commercial version.


Installing CentOS on a virtual machine

    • Normal Next step

    • There are three types of network adapters, the understanding of NAT is understood as the VM is as a router to assign IP to the virtual machine to achieve Internet access, and the VM and Windows is the main system is independent of each other, the network segment is not the same. Bridging is the connection between a physical machine and a virtual machine, which is the same network segment. This way, if the physical machine changes the network environment, the virtual machine will not be. Only hosts are communicating with hosts only. NAT is the network that shares the host.

    • Use a custom installation when disk is installed | LVM is a way of lossless data expansion in the future, virtual disk into a large disk, can be expanded and reduced capacity |

    • Select a standard partition and then partition and Mount | The mount point can be simply understood as the drive letter a name


Specifically, the allocation of mount points

    • /boot is a startup related directory does not require too much space hundreds of trillion enough

    • Swap is the swap partition, the virtual memory in Windows is the swap partition, the purpose is the memory is not enough when the physical space to store memory when the temporary place things but the speed certainly no memory fast | Usually according to the memory of twice times set. If the memory is greater than 4G, put 8 g enough

    • The rest is for the root---this is the practice of aming teacher, I was the home and so on to carry out the mount. But not big deal

    • The disk expression is sda1 SDA refers to a disk, if there are two disks will have SDB SDA1 is the first directory and so on


Graphical interface By default is the user login (before the physical machine directly installed problems, not adding users but root and unable to log on) so minimize the installation, no graphical interface is not related.


Configure IP

The goal is to remotely connect to a better operating system, and also to simulate a real-world scenario

Therefore, you need to configure a static IP


Dhclient command is to automatically obtain an IP command, before this command is not seen in the IP, only after the implementation of the IP and other information appears. So you need to execute this command first.


The dhclient command uses Dynamic Host Configuration Protocol to dynamically configure network parameters for network interfaces.

Dhclient-r #释放 ipdhclient #获取IP

IP add


“of LinuxIPCommands andifconfigsimilar, but the former is more powerful and is designed to replace the latter. With the IP command, you can easily perform some network administration tasks with just one command. Ifconfig is a command that has been deprecated in net-tools and has not been maintained for many years. Many of the enhanced commands are available in the Iproute2 suite, which is one of the IP commands. The search Result


Depending on VM virtual network settings, you can see that the subnet address is 192.168.202.0


The gateway is the equivalent of a router, because the restart, will be assigned an IP address, so need to fix down the IP address is how much

Static IP

The next step is to find the configuration file for the NIC. All documents!


Because of the need to configure static IP so also to configure the subnet mask, DNS, gateway, etc., and need to onboot change to Yes boot use

One of the errors here is that DNS1 should be set to 119.29.29.29, which is the cause of the error.


Systemctl Restart Service

Systemctl Restart Network.service

Systemctl is a systemd tool that is primarily responsible for controlling SYSTEMD systems and service managers.


But I found that after the configuration is not able to surf the internet, that is, ping things, how the whole?

--------------------the wrong line

At this point, you can tell the virtual machine to be bridged to see if it fits the features of the bridge.

Bridge Connection

Bridge network refers to the local physical network card and virtual network card through the VMnet0 Virtual Switch Bridge, physical network card and virtual network card in the topology map on the same status, then the physical network card and virtual network card is equivalent to the same network segment, Virtual switch is equivalent to a real network switch, Therefore, the IP address of the two network card should also be set to the same network segment.

So when we want to use a virtual machine on the LAN, to provide services to other local area network PCs, such as FTP, provide SSH, provide HTTP services, then choose the bridge mode.

For example, there is a router in the university dormitory, the dormitory four people connect this router, the router's Wanip ignore, this IP is dynamically obtained, and Lanip default is 192.168.1.1, subnet mask is 255.255.255.0. While the other four people are automatically acquiring IP, assume that the IP of four people is:

a:192.168.1.100/255.255.255.0, b:192.168.1.101/255.255.255.0, c:192.168.1.102/255.255.255.0, D:192.168.1.103/ 255.255.255.0

Then the IP address of the virtual machine can be set 192.168.1.2-192.168.1.99,192.168.1.104-192.168.1.254 (except for the network address of all 0 and all 1, and then the IP address of ABCD four person)

Then the IP address of the virtual machine can be set to 192.168.1.98/255.255.255.0, set the IP address, ABCD These four people can access the virtual machine through the 192.168.1.98, if the virtual machine needs Sisu Network, then also need to configure the virtual machine routing address, is 192.168.1.1, so that the virtual machine can sisu network, but, the internet we generally go through the domain name to access the external network, so we also need to set up a virtual machine Set up a DNS server, we can simply point to the DNS server address configured as Google's DNS server: 8.8.8.8, the virtual machine will be able to surf the Internet.

The search Result


That is, the IP of the virtual machine should be the same as the bridge, and the machine is within a network segment.



After the test, there is nothing really.

Restart the network service by resetting the static IP as it was originally set up above. Just ping it again. Now it's static IP.



What is Yum? Installing the Software


VMware snapshot, which is equivalent to Windows Backup

How?

Right click on the virtual machine, select snapshot, Notes good.



The next step is to install putty and Xshell

There's nothing to say


In the next step is to use, remember to save the session down. By contrast, Xshell will be more flexible and more functional. In particular, a few windows can be opened according to the needs of the arrangement, very convenient.



The next step is to set the key


Client private key

Server Public Key

As long as the pairing is successful, it can be authenticated


Putty

Click Puttygen

Generate the public key, the public key is a long string of strings, save well. The private key also needs to be saved natively.


Next, create a directory in Linux

Mkdir/root/.ssh


Change permissions

chmod 700/root/.ssh


Create a file, paste the public key in

Vi/root/.ssh/authorized_keys


Save exit


Shutting down the firewall

Setenforce 0


Then quit landing.


The next is on the putty side, which is the client setting. Load into the session, and then go to ssh to find auth to import the private key on the computer to save. In connection with the host, everything is done.

Because you previously added a password to the private key pairing, you need to enter a password. In other words, if someone gets this file, they need a password to log in. It's kind of interesting.

You can configure another client to log on to another computer.


Next, we use Xshell to connect to Linux.


The principle is the same, just the step difference.



Go in from the new place.



Copy the public key because it needs to be used in the host.


Log in to the host, open the key file under/root/.ssh, and another line (already exists is the public key of putty production)

When landing, you need to change the password login to a key login

When connecting again, select the public key pair and then you can log in directly.



Single-User mode


Forgot root password?

1. Single-user mode

2. Rescue mode

Single-user mode requires first restart of Linux (reboot, init 6, Shutdown-r now can be restarted)

E-edit


Then press CTRL x to enter emergency/Safe mode

In fact has not entered the original system, a bit like in the BIOS, need to enter the/sysroot, which is the real directory of the system. This time you need to use Chroot to enter the system, you can use passwd root to change the password

chroot/sysroot/after passwd root

If it is garbled, lang=en define the language.

A very important step in the next.

Touch/.autorelabel only exists to log into the system.

It will take a long time, just fine.




The different levels of CentOS 7 are actually the same as CENTOS6.


Rescue mode-What if the grub password is forgotten? Set Grub Password http://ask.apelearn.com/question/14743

First, enter the BIOS to change the CD to the first boot.

Then read the disc-rescue



Cloning a virtual machine

What if you need more than one machine but don't want to reinstall it?

Turn off the virtual machine first. Then click on the virtual machine to manage, clone, link to clone can, otherwise too big.

When done, modify the IP address, the UUID is deleted, save


How do I change the host name?

Hostnamectl set-hostname XXX


Then use the tool to connect, because it is copied, so the key also exists.




Interconnection of two Linux machines


SSH IP can be a regular SSH [email protected]

W View current Load

SSH default Port 22

If not 22, you need to specify the port number ssh-p port [email protected]

What if I need a key? Ssh-keygen production key Pair

It produces the private key and the public key, and if the other machine is the host, it needs to put the public key on the other machine. Don't forget to place the path.

More simple just put the public key into the host file, the private key is already configured on this machine, the connection can be.

To turn off the firewall, enforce







Summary command:


Dhclient Automatically assign IP

IP Addr View IP information

Systemctl Restart Network.service Restart Network Service

Setenforce 0 shutting down the firewall

Linux Learning-1 initial Linux 20180407

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.