Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of CentOS Terminal types and their conversion modes

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the example analysis of CentOS terminal types and mutual conversion methods, the article is very detailed, has a certain reference value, interested friends must read it!

The terminals in the Linux system are basically in the / dev directory, which can be divided into text command line mode and graphical interface mode. The graphical interface in the Windows system is in the system kernel space, while the graphical interface in the Linux system is called as an application, so the graphical interface in the windows system is boot-on, while the graphical interface in the Linux system can be booted and not started, because it is equivalent to an application running on the Linux system.

Startup items can be changed in CentOS and RedHat by modifying the id:3:initdefault in the / etc/inittab file. If id is 3, text command terminal mode is started, and changing 3 to 5 starts graphical interface (that is, Xwindow) mode by default. Inittab is a non-executable text file that is called by the init initialization process after Linux finishes booting the kernel. It is a configuration file. The format of id in the file is: id:run-level:action:process, items are separated by colons, and some parts can be empty. The inittab file in my Centos6 system has only the first three items, and process is empty. The id identifier is unique and cannot be repeated in the configuration file. Run-level specifies the system run level, and when you view the file through vi / etc/inittab, you can see the explanation shown in the following figure:

It is divided into seven levels (0,6):

0-halt, that is, shutdown, so the shutdown can also be executed through the init 0 instruction, but this is a direct shutdown, will not be prompted, it is recommended that multi-users do not use this.

1-single user mode. Only the system administrator can enter the single-user mode, where the administrator can process files that cannot be changed in the presence of logged-in users. The number 1 can also be replaced by s.

2-Multi-user text command line mode that does not have network file system functionality. I use it less.

3-Multi-user text command line mode with network file system functionality. Is the most commonly used mode of operation and the default mode for most servers.

4-keep it.

5-with the network function of Xwindow mode, beginners can set it to the default mode, the system initialization directly into the graphical interface, the operation is more convenient, suitable for beginners, but for commonly used Linux users, this is not a good choice, or should use 3 mode.

6-close all running processes and restart the system.

Action is the action of execution, and initdefault is the level of execution that the system enters after startup, and the line does not need to specify process.

If the mode starts in text command line mode with run-level 3, you can instruct the startx command to switch to 5 Xwindow mode after logging in, and use startx -: 1 to open the second Xwindow. In Xwindow mode, you can return to the command line mode via Ctrl+Alt+ (F1~F6). F1~F6 represents six consoles. Startx can only be used when xwindow has not been started, if you have already started xwindow, and then return to the command line mode, if you also want to return to the already started xwindow, you can not use startx, you need to use Ctrl+Alt+F7/F8, which represents two xwindow consoles. Switching between command line consoles can be done through Alt+Fn, for example, from command line console 1 to console 5, Alt+F5 can be performed. These commands can be executed normally on a real machine, but if you are on a Linux system in a VM virtual machine, there will be problems because Ctrl+Alt has been used as a shortcut key by VM, so there will be conflicts. At this time, you can switch through Ctrl+Alt+Shift+Fn, if this does not work, you can press and hold Ctrl+Alt, then press the Spacekey, then release the Spacekey, and then press the Fn key to complete the switch. I have experimented with the Centos6 system of my VM virtual machine and can switch normally.

In the Linux system, / dev/ttyn represents the console terminal, that is, the text command line terminal mentioned above, which can be switched with each other through Alt+Fn. When logging in to the console, you are using tty1, and you can use the who command to see that a user has logged in to tty1:

At this point, open a text console terminal and log in, tty2 will be used, and so on, tty can generally support 6, and tty1~tty6. Tty0 represents the virtual terminal currently in use, and the information generated by the system is sent to this terminal, which is equivalent to an alias for the terminal currently in use, for example, if tty3 is currently being used, tty0 represents tty3. Only root users can write to / dev/tty0. For example, a test message can be sent to the currently used terminal through ech0 "test" > / dev/tty0, but if it is not root, the user will prompt permission denied.

There are also three pts terminals in the figure above. On my machine, pts/0 and pts/2 are two xwindow consoles, and pts/1 is a Xshell terminal logged in through SSH. At this point, the following message appears when viewed through ls / dev/pts:

Pts is the implementation method of pty, which is used with ptmx to realize pty, and pty is a virtual terminal, that is, a pseudo terminal. Pty is a pair of logical end devices, that is, master and slave devices, and the operation on master is reflected on the slave. They are not directly related to the actual physical equipment. If a program treats ptyp3 (master device) as a serial port device, its read / write operations to that port will be reflected in another ttyp3 (slave device) corresponding to the logical terminal device. Ttyp3 is the logical device used by another program to read and write.

There is also a terminal under Linux called serial port terminal, namely / dev/ttySn. These terminals are terminal devices connected by computer serial ports, corresponding to COM1~COMn under DOS system. For example, executing echo test > / dev/ttyS1 sends the word test to the device connected to the ttyS1 port.

Finally, you can clear all processes on the xxx console by executing the skill-9 xxx. For example, skill-9 / dev/pts/0 clears all processes on the first xwindow console.

The above is all the contents of the article "sample Analysis of CentOS Terminal types and their conversion methods". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report