Basic CentOS operation

Source: Internet
Author: User
Tags switches

Linux is a free-to-use and free-to-propagate Unix-like operating system, a POSIX and Unix-based multiuser, multitasking, multi-threaded and multi-CPU operating system. It can run major UNIX tools software, applications, and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the design idea of Unix as the core of network, and is a stable multi-user network operating system.

The Linux operating system was born on October 5, 1991 (This is the first time the official outward announcement). There are many different Linux versions of Linux, but they all use the Linux kernel. Linux can be installed in a variety of computer hardware devices, such as mobile phones, tablets, routers, video game consoles, desktops, mainframes, and supercomputers.
Strictly speaking, the word Linux itself only represents the Linux kernel, but in fact people have become accustomed to using Linux to describe the entire Linux kernel, and use the GNU engineering various tools and databases of the operating system.

The basic idea of Linux has two points: first, everything is a document; second, each software has a definite purpose. The first article in detail is that everything in the system boils down to a file, including commands, hardware and software devices, operating systems, processes, and so on for the operating system kernel, all of which are considered to have their own attributes or types of files. Linux is Unix-based, largely because of the similarity between the two basic ideas.

Linux is a free operating system that can be obtained free of charge through the Internet or other channels, and can be arbitrarily modified by the source code. This is not what other operating systems can do. Because of this, countless programmers from all over the world are involved in the modification and writing of Linux, and programmers can change them according to their own interests and inspirations, which allows Linux to absorb the essence of countless programmers and grow.

Currently, most of the operating systems installed on PCs are Windows systems, so when learning about Linux systems, consider installing a virtual machine on your computer and building a Linux system on a virtual machine.

Here, we use VMware virtual machines as an example to install the CentOS system on VMware virtual machines.

One, VMware installation

VMware is the name of a company born in the United States, and VMware is the global leader in desktop-to-data-center virtualization solutions. Founded in 1998, VMware is headquartered in Palo Alto (Palo Alto), California, USA.

Run two or more windows, DOS, and Linux systems at the same time on a single machine. VMware uses a completely different concept than a "multi-boot" system. A multi-boot system can only run one system at a time, and the machine needs to be restarted when the system switches.

VMware is truly "simultaneous" running, with multiple operating systems on the main system platform, just as the standard Windows application switches. And each operating system you can be virtual partition, configuration without affecting the real hard disk data, through the network card will be a number of virtual machines with a network card connected to a LAN, extremely convenient. The operating system installed on VMware is much lower in performance than the system directly installed on the hard disk, so it is more suitable for learning and testing.

Second, CentOS installation

CentOS (Community Enterprise Operating System, Chinese means: Community Enterprise operating system) is one of the Linux distributions, it comes from Red Hat enterprise Linux is compiled according to the source code released by the open source rules. Because of the same source code, some servers that require a high degree of stability are used with CentOS instead of the commercial version of Red Hat Enterprise Linux. The difference between the two is that CentOS does not contain closed source code software.

CentOS is the product of the source code recompilation of Rhel (Red Hat Enterprise Linux), and it fixes a number of known bugs on the basis of Rhel, and is reliable with respect to other Linux distributions.

CentOS was announced to join Red Hat at the beginning of 2014.
When CentOS joins Red Hat, it does not change:
1. CentOS continues to be free of charge
2. Keep the sponsored content-driven Network center intact
3. Bug, Issue and emergency handling policies unchanged
4. Red Hat Enterprise Linux and the CentOS firewall are still present
The changes are:
1. We are working for Red Hat, not for RHEL
2. Red Hat provides sponsorship for building systems and initial content distribution resources
3. Some development resources, including access to source code, will be easier
4. Avoiding some of the legal issues on Red hat and the original

CentOS, also known as the Community enterprise operating system, is a re-compiled version of the Enterprise Linux distribution leader Red Hat Enterprise Linux (hereafter known as Rhel). Rhel is a Linux distribution used by many enterprises, but if you want to get Redhat service and technical support, users must pay Red hat. CentOS developers use Red Hat Linux's source code to create a Linux that is almost identical to Rhel. But all the trademarks related to Redhat were removed because Redhat did not allow them to do so. CentOS is free and you can use it to build an enterprise-class Linux system environment like Rhel, but you don't have to pay any fees to redhat. Technical support for CentOS is primarily through the community's official mailing lists, forums and chat rooms.

Install CentOS7 on VMware, you can set a password for the root user during installation, and you can add a custom user.

After installing CentOS, you can start CentOS on VMware and choose a user login (such as root or custom user).

In general, the boot process of a Linux system can be broadly divided into 5 phases:

    • Boot of the kernel.
    • Run init.
    • System initialization.
    • Set up the terminal.
    • The user logs on to the system.

We analyze the above startup process.

Kernel boot

When the computer is powered on, it is the BIOS post that starts with the boot device (usually the hard disk) set up in the BIOS.

After the operating system takes over the hardware, it first reads the kernel file in the/boot directory.

Run init

The init process is the starting point for all processes in the system, and you can compare it to the ancestor of all processes in the system, without which any process in the system will not start.

The INIT program first needs to read the configuration file/etc/inittab.

Run Level

Many programs need to boot up. They are called "services" in Windows, and in Linux they are called "daemons" (daemon).

One of the major tasks of the Init process is to run these boot-up programs.

However, different applications need to start different programs, such as when serving as a server, the need to start Apache, as a desktop is not required.

Linux allows different start-up programs to be assigned for different occasions, which is called "RunLevel" (runlevel). That is, at startup, depending on the runlevel, determine which programs to run.

The Linux system has 7 runlevel (runlevel):

    • RunLevel 0: System down state, system default RunLevel cannot be set to 0, otherwise it will not start normally
    • RunLevel 1: Single User working status, root privilege, for system maintenance, remote login Forbidden
    • RunLevel 2: Multi-User State (no NFS)
    • RunLevel 3: Full multiuser State (with NFS), enter console command line mode after login
    • Run Level 4: System not used, reserved
    • Run level 5:x11 console, login to GUI mode
    • RunLevel 6: The system shuts down gracefully and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally
initialization of the system

There is a line in the init configuration file: Si::sysinit:/etc/rc.d/rc.sysinit It calls execution/etc/rc.d/rc.sysinit, and Rc.sysinit is a bash shell script, It is mainly to do some system initialization work, Rc.sysinit is each run level must first run the important script.

Its main tasks are: Activating the swap partition, checking the disk, loading the hardware modules, and some other priorities that need to be performed.

The actual RC startup scripts are actually placed in the/etc/rc.d/init.d/directory.

set up terminal

After the RC finishes executing, return to init. At this point the basic system environment has been set up, various daemons have been started.

Init then opens 6 terminals so that the user can log on to the system.

The following 6 lines in Inittab define 6 terminals:

1:2345:Respawn:/sbin/Mingetty tty12:2345:Respawn:/sbin/mingetty tty23:2345:< Span class= "PLN" >respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty45:2345:respawn:/sbin/ mingetty tty56:2345:< Span class= "PLN" >respawn:/sbin/mingetty tty6    

From the above can be seen in the 2, 3, 4, 5 of the operating level will be respawn to run the Mingetty program, mingetty program can open terminal, set mode.

At the same time it will display a text login interface, which is the login interface we often see, in this login screen will prompt the user to enter a user name, and the user input user will be passed as a parameter to the login program to verify the identity of the user.

User Login System

In general, there are three ways users sign in:

    • (1) Command line login
    • (2) SSH login
    • (3) Graphical interface login

For graphical users with a run level of 5, their login is via a graphical login interface. After successful login, you can go directly to KDE, Gnome and other window manager.

This article is mainly about the text mode of login: When we see the Mingetty login interface, we can enter the user name and password to log into the system.

Linux Account Verification Program is Login,login will receive mingetty from the user name parameters.

Login then parses the username: If the user name is not root and there is a/etc/nologin file, login will output the contents of the Nologin file and then exit.

This is typically used for system maintenance to prevent non-root users from logging on. Only the terminal registered in/etc/securetty allows the root user to log on, and if the file does not exist, the root user can log on at any terminal.

The/etc/usertty file is used to make additional access restrictions to the user, and there are no additional restrictions if the file does not exist.

How to switch between graphic mode and text mode

Linux presets provide six command window terminals let's log in.

By default we are logged in the first window, that is, Tty1, the six windows are Tty1,tty2 ... tty6, you can press CTRL + ALT + F1 ~ F6 to toggle them.

If you have a graphical interface installed, by default it is entered into the graphical interface, you can press CTRL + ALT + F1 ~ F6 to enter one of the command window interfaces.

When you go to the Command window interface and then return to the graphical interface just press CTRL + ALT + F7 to come back.

If you are using a VMware virtual machine, the shortcut keys for the command window switch are ALT + Space + f1~f6. If you are in the graphical interface, press ALT + Shift + Ctrl + F1~F6 to switch to the command window.

After logging into the system, you can open the Command Line Terminal window and enter the command "Cat/etc/os-release" in it, then the terminal window will display the version information of the CentOS system:

The next step is to work with CentOS.

Three, CentOS7 basic operation

Four, vim operation

V. Supplementary

How do I shut down Linux?

Most of the Linux domain is used on the server, and there are few shutdown operations. After all, running a service on the server is endless, unless in exceptional circumstances, the last resort will be turned off.

The correct shutdown process is: sync > Shutdown > Reboot > Halt

The shutdown instruction is: shutdown, you can look at the help document with man shutdown.

For example, you can run the following command to shut down:

Sync synchronizes the data from memory to the hard disk. Shutdown shutdown instructions, you can look at the help documentation for man shutdown. For example, you can run the following command to shut down: shutdown–h ' This server would shutdown after the mins ' This command tells you that the computer will shut down after 10 minutes and will be displayed in the login user's current screen. Shutdown–h now immediately shuts down Shutdown–h 20:25 the system shuts down at 20:25 today, Shutdown–h +10 10 minutes after shutting down the machine shutdown–r the system immediately restarts Shutdown–r +10 system restarts after 10 minutes Reb Oot is the restart, equivalent to the Shutdown–r nowhalt shutdown system, equivalent to Shutdown–h now and Poweroff

In conclusion, whether it is rebooting the system or shutting down the system, first run the Sync command to write the data in memory to disk.

The command to shut down has shutdown–h now halt Poweroff and init 0 , and the command to restart the system has shutdown–r now reboot init 6.

Basic CentOS operation

Related Article

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.