11.1 Introduction to the Operating System

11.1.1 History of computers

  1. The first generation of computer (1946~1958) electron tube as the basic electronic devices; Use machine language and assembly language; Mainly used in national defense and scientific calculation; The speed of computation ranges from thousands to tens of thousands of times per second.
  2. The second generation computer (1958~1964) transistor as the main device; Operating systems and algorithmic languages appeared on software; The speed of calculation is tens of thousands to hundreds of thousands of times per second.
  3. The third generation of computers (1964~1971) generally used integrated circuits; Volume reduction; The speed of computation ranges from hundreds of thousands to millions of times per second.
  4. The fourth generation computer (1971~) takes large-scale integrated circuit as the main device; At speeds ranging from millions to hundreds of millions of operations per second.

11.1.2 Operating System Classification

Definition of Operating System Operating System (OS for short) is the System software responsible for supporting the Operating environment of application programs and the Operating environment of users in an electronic computer System. It is also the core and cornerstone of a computer System. Operating system is a set of programs that control and manage computer hardware and software resources, organize computer workflow reasonably, and facilitate user operation. Its responsibilities often include direct supervision of hardware, management of various computing resources such as memory, processor time, and the provision of application-oriented services such as job management. The theory of operating system is an ancient and active branch of computer science, while the design and implementation of operating system is the foundation and core of software industry. Common categories: Mobile phone: Android, IOS Computer: UNIX, LINUX, MacOS, Windows

  1. UNIX UNIX is a powerful multi-user, multi-task operating system that supports a variety of processor architectures and is categorized as a time-sharing operating system. UNIX was first developed by Ken Thompson and Dennis Ritchie at AT&T’s Bell LABS in 1969. Unix-like operating systems refer to traditional Unix and systems similar to traditional Unix. Some are free and some are commercial, but they all have considerable inheritance from the original UNIX, many similarities, and some degree of POSIX compliance. Unix-like systems can run on a wide range of processor architectures and have high utilization on server systems, such as workstations in colleges or engineering applications.
  2. Linux The Linux-based operating system is a multi-user, multi-task operating system introduced in 1991. It is fully compatible with UNIX. Linux was originally developed by Linus Torvalds, a computer science student at the University of Helsinki, Finland, as an operating system kernel program based on UNIX. Linux was designed to be used more effectively on Intel microprocessors. It was later released as the free Software Unix variant under the GNU General Public License at the suggestion of Richard Stallman. Its biggest characteristic is that it is an open source code of the free and open source operating system, its kernel source code can be freely spread. Over the years, the free, open source Linux system has gradually encroaching on previously proprietary software. For example, SGI’s IRIX system has been replaced by the Linux family and the Bell LABS ‘Project 9 and Inferno systems, both designed for decentralized expression environments. Unlike other Unix systems, they choose to come with their own graphical user interface. Project 9 wasn’t popular because it wasn’t free software when it was launched. There are various distributions of Linux, usually GNU/Linux, such as Debian (and its derivative systems Ubuntu, Linux Mint), Fedora, openSUSE, and so on. The Linux distribution has become the mainstream operating system on servers as either a PC operating system or a server operating system.
  3. MacOSX MacOS is an operating system that runs on Apple’s Macintosh family of computers. Mac OS was the first commercially successful graphical user interface. The Macintosh group included Bill Atkinson, Jef Raskin, and Andy Hertzfeld. Mac OS X was first launched in 2001. It consists of two main parts: Darwin, a UniX-like open source environment based on BSD source code and a Mach microcore.
  4. Windows Windows is an operating system successfully developed by Microsoft. Windows is a multi-tasking operating system with a graphical window interface that allows users to perform complex computer operations with the click of a mouse. MicrosoftWindows is a graphical operating system based on ms-dos designed by Microsoft for IBM machines. Windows systems, such as Windows 2000 and Windows XP, are built on the modern Windows NT kernel. The NT kernel is borrowed from systems such as OS/2 and OpenVMS. Windows runs on 32-bit and 64-bit Intel and AMD processors, but earlier versions also run on DEC Alpha, MIPS, and PowerPC architectures. While Windows’ market share declined as interest in open source operating systems increased, some features, such as library services, were available by 2004. WindowsXP was released on October 25, 2001, and service pack 2 was released on August 24, 2004. The latest service pack 3 was released on April 21, 2008. Microsoft’s last operating system, Windows Vista (developed as Longhorn), was released on January 30, 2007. Windows Vista adds many features, especially system security and network management, and features the gorgeous Aero Glass. But overall, its reputation in the global market is not very good. Windows 8 was officially launched by Microsoft in October 2012, with a unique Metro start interface and touch interaction system. At 7:00 PM on October 17, 2013, Windows 8.1 was updated and pushed worldwide through the App Store on Windows. January 22, 2014, Microsoft held an event in San Francisco, the United States, officially released Windows 10 consumer preview version.
  5. IOS iOS is an operating system for handheld devices developed by Apple. IOS, like Apple’s Mac OS X, is based on Darwin and is therefore a commercial UNIX-like operating system. The system was originally called iPhone OS until it was renamed iOS at WWDC on June 7, 2010. As of November 2011, according to the data of Canalys, iOS has occupied 30% of the global smartphone system market share, and 43% of the US market share.
  6. Android Android is an open source operating system based on Linux, which is mainly used for portable devices. The Android operating system was originally developed by Andy Rubin and initially supported mobile phones. It was acquired by Google in 2005 and formed the Open Handset Alliance to develop and improve it, gradually expanding into tablet computers and other areas. In the first quarter of 2011, Android surpassed Symbian in global market share for the first time, becoming the world’s largest. As of November 2012, Android had 76 percent of the global smartphone operating system market, with 90 percent in China.

11.1.3 Introduction to the Linux System

Linux is an open source and free operating system based on Unix. Due to the stability and security of the system, it almost becomes the best system environment for program code to run. Linux was originally developed by Linus Torvalds and has since spawned hundreds of different Linux systems due to the open source code.

Linux is widely used, not only to run the program code we write for a long time, but also can be installed in a variety of computer hardware devices, such as mobile phones, tablets, routers and so on. In particular, we know that Android applications run on Linux at the very bottom.

11.1.4 Linux classification

  1. Linux according to different market demand, the basic is divided into two directions: 1) the graphical interface version: pay attention to user experience, similar to the Windows operating system, but there is not enough maturity 2) server version: no good interface, is in the console window type the command of the operating system, similar to DOS, we set up the server is the best choice.
  2. Linux is divided into two types according to the degree of its native: 1) Kernel version: the version of the system kernel developed and maintained by the kernel team under Linus’s leadership. 2) Distribution version: the rerelease of the kernel version by some organization or company after secondary development
  3. Different Linux distributions can be divided into n types:

The 11.2 Linux installation

Because Linux is also a system, essentially with our computer Window is no different, so we want to learn Linux first to our computer Window system into Linux system, or in our computer to install dual systems, it sounds not very terrible. In fact, we can install a software in our computer, this software can simulate one or more virtual computer machine, this is the virtual machine virtual machine commonly used have two kinds:

  1. VMware virtual machine software, powerful

VitrualBox virtual machine software of Oracle corporation, free goods

Because VMware usage is high in the market, we install VMware

14.2.1 VMWare introduced

CentOS is a Linux distribution and is used as the main application server system in enterprises. To install CentOS, you need to install the system into VMware virtual machine (VM) software to simulate a Linux computer.

11.2.2 VMWare installation

  1. Click the Vware workstation – full

2. Install

3. The next step

4. Change the installation path

  1. Activate the address

14.2.3 Installing the Linux Operating System (CentOS) on VMWare

  1. Creating a VM

2. Select user-defined configuration

  1. Note: You can select custom and typical here. If you select typical, you do not need to configure below.
  2. Select Workstation 14.x and click “Next”.

4. Select the iso image file of the installation cd-rom (select a path for the image file) and click Next.

5. Set the full name, user name and password (remember the user name and password, they will be used when logging in, and I set them all to Jack)

6. Click “Next”, select the installation path, and click “Next”

7. Specify the disk size. Personally, I’m going to say 100 grams. Just like disks do in our Windows system. Click “Next”.

8. Confirm the VM information and click Finish.

9. Go to the official installation page

10. Choose the recommended ones

11. Select a disk to create for the VM

12. Select the default value

13. This is the vm name in Winodow, do not need to change

14. Click “Finish”

15. Start the VM. It takes time to load the vm for the first time

16. Enter the user name and password on the login page



Linux common commands and use

11.1 Directory Switchover Command

11.1.1 Directory Switchover Command

In Windows, you can switch to any directory by using the GRAPHICAL user interface (GUI) and mouse. In Linux, you must run the CD command to switch to the directory. But before we get to the CD command, it’s important to understand the Linux directory structure

CD usr/ Switch to usr directory CD.. CD/Switch to the system root directory CD ~ Switch to the user home directoryCopy the code

11.2 Directory Operation Commands

11.2.1 Adding a Directory
  • Mkdir Directory name
  • Example: mkdir test under the root directory /, will generate a test query directory under the root directory /

11.2.2 Viewing a Directory
  • Command: ls [-al] Parent directory
  • Example: If you run ls under the root directory /, you can view all the directories and files in the directory

Example: Using ls-a in the root directory /, you can view all files and directories in the directory, including hidden ones

Example: If you run ls -l in the root directory /, you can view the detailed information about all the directories and files in the directory

  • Note: ls-L can be abbreviated to ll
11.2.3 Looking for a Directory
  • Command: find directory parameters (key)
  • Example: Find the directory (file) associated with test under /rootThe find / -name 'test *

  • Note: This is a permission issue. You need to switch to the root directory first

六四事件

// Switch to the root directory su root // Switch to the common user directory su anflyCopy the code
11.2.4 Changing a Directory Name
  • Command: mv directory name New directory name

Note: the mv syntax can rename not only directories but also various files, compressed packages and other operations

11.2.5 Moving a Directory (Cutting)
  • Prerequisite: You must switch to the following directory, otherwise you do not have permission
  • Command: mv directory name New location of the directory
  • Example: under test, cut newTest directory to /usr, usemv newTest usr/

  • Note:
  1. The mv syntax can be used to cut not only directories, but also files and compressed packages
  2. Files are shown in black and folders are shown in blue. When cutting, you must add after the new location/
11.2.6 Copying a Directory
  • Command: cp -r Name of the directory to which the directory is to be copied —–r indicates recursive copy

六四事件

1. The copied directory and target directory must be written to the full path. Otherwise, use the root directory. You can copy anywhereCopy the code
  • For example, to copy newTest under /usr to test under the root directory, run cp -r /usr/newtest test/rm

Note: the cp command can copy not only directories but also files, compressed packages, etc. When copying files and compressed packages, there is no need to write -r recursion

11.2.7 Deleting a Directory

(7) Delete a directory (Delete)

  • Command: rm [-rf] Directory
  • Example: To delete newTest under /usr, run rm -r newTest under /usr

Example: to delete newTest under /test without asking for forced deletion, use rm -rf newTest under /test

Note: Rm can not only delete directories, but also delete other files or compressed packages, in order to enhance your memory, regardless of any directory or file, directly use rm -rf directory/file/compressed package

11.3 File Operation Commands

11.3.1 File Creation
  • Command: touch file name —– Empty file
  • Example: Create an empty file in the test directory touch aaa.txt

11.3.2 Viewing files
  • Command: cat/more/less/tail file
  • Example: Using cat to view the /etc/profile file, only the last screen of content can be displayed
  • For example, you can use more to view the /etc/profile file. To display the percentage, press enter to go to the next line, enter a space to go to the next page, and exit the file with q
  • For example, if less is used to view the /etc/profile file, you can use PgUp and PgDn on the keyboard to scroll up and down the page, and q is used to end the view
  • Example: use tail -10 to view the last 10 lines of /etc/profile, Ctrl+C to end note: The tail -f file command can be used to dynamically monitor a file, such as the tomcat log file. Logs change as the program runs. You can run the tail -f catalina-2016-11-11.log command to monitor file changes
  • Supplementary: the format of the company’s log
11.3.3 Modifying file Content

Three modes: command mode, edit mode, bottom line mode

  1. Command: vim File Example: Run the vim aaa. TXT command to edit the aaa

However, you cannot edit the file at this time because you are in command mode. Click I/A/O on the keyboard to enter the edit mode and edit the file

After the editing is complete, press Esc to return to the command mode. At this time, although the file has been edited, it is not saved. Enter the colon: Enter the bottom line mode, enter wq to write content and exit, that is, save. The input q! Means forcibly exit without saving.

  1. Summary: Vim editor is a powerful component in Linux, is the enhanced version of the VI editor, vim editor commands and shortcuts have many, but here is not a elaboration, we do not need to study very thorough, the use of vim editing and modifying files will use the basic way. Appendix: introduction to Vi Usage and ViM Command Collection
  • How to Use Vim: In actual development, main effect is to modify the configuration file using vim editor vim file — — — — — — — — — — – > > enter the file command mode — — — — — – > press I to enter edit mode — — — — — — — — — — – > edit file > press Esc to enter the bottom line — — — — — > input: wq/q!
11.3.4 Deleting a File

Delete the same directory: memorize the rm -rf file

11.4 File Compression Commands

11.4.1 Packing and Compressing Files

Packaging refers to a large number of files or directories or something into a total file, compression is a large file by some compression algorithm into a small file. In Linux, packages end in.tar, and compressed commands end in.gz. Generally, packaging and compression are done together, and the file name suffix after packaging and compression is generally.tar.gz.

  • Run the tar -zcvf command to package the compressed file name.
Z: calls the gzip command to compress the file c: packages the file V: displays the running process f: specifies the file nameCopy the code
  • Example: Package and compress all files in /test. The compressed package name is xxx.tar.gz tar -zcvf xxx.tar.gz aaa.txt bbb. TXT ccc. TXT or tar -zcvf xxx.tar.gz /test/*

11.4.2 Decompressing a Package (Key)
  • Command: tar [-xvf] To compress a file
  • Gz in /test to the current directory: tar -xvf xxx.tar.gz

  • For example, decompress xxx.tar.gz in /test to the root directory /usr: tar -xvf xxx.tar.gz -c /usr——C specifies the location for decompression

11.5 Other Commands

11.5.1 Displaying the Current Location
  • Command: the PWD

11.5.2 Search Commands
  • Command: grep string file to be searched
  • Example: Search for lines in /usr/sudu.conf that contain the string to

  • Example: search the /usr/sudu.conf file for lines containing the string to to be highlighted
11.5.3 Pipe Commands
  • Command: | will be the output of the previous command as the input of the directory
  • Example: View all processes in the current system that contain the system stringps -ef |grep system

11.5.4 Viewing Processes
  • Command: ps -ef
  • Example: View the processes running in the current system

11.5.5 Killing a Process
  • Command: kill -9 Pid of the process

11.5.6 Network communication commands
  • Run the ifconfig command to view the nic information in the current system

Run the ping command to check the connection to a certain machine

11.5.7 Viewing Port Usage in the Current System

Netstat, the an, and usually | grep used together

11.6 Linux Permission Commands

11.6.1 Linux Permission Commands

Permission is an important concept in Linux. Every file or directory has permission. You can run the ls -l command to view the permission of a file or directory in a directory

  • Example: ls -l in a directory

The information for the content of the first example is explained as follows:

The string has 10 bits and can be read in four sections.

  • The first paragraph (the first bit) indicates a directory or a file. – indicates a file, and d indicates a directory.
  • The second paragraph (2-4 bits, a total of three strings) indicates the permission of the User who owns the file – the limit of ownership (User);
  • The third paragraph (5-7 digits, a total of three strings) indicates the user Group to which the file belongs.
  • The fourth paragraph (digits 8-10, a total of three strings) indicates the permissions that other users have on it – other;

Note: we use a 3-bit base 8 for file permissions. R (read) is identified by 4, w(write) by 2, and x(excute) by 1. (3) The three-digit order of each segment is immutable. If there is no corresponding permission, use -rwxrw-r as shown in the figure above — can be represented by the octal number 764.

Case study:

六四事件

-rwxrwxrwx
Copy the code

Convert it to an octal number, 777, which indicates that this is a file with development permission for all.

11.6.2 Command for modifying the Permission on a file/directory: chmod

  • For example, the owner has all permissions, the group to which the owner belongs has read and write permissions, and other users have only read permissions chmod u= RWX,g=rw,o=r aaa.txt

The above example can also be represented numerically:

chmod 764 aaa.txt

11.7 Free Viewing memory Information

11.7.1 Free Viewing memory Information

The free directive displays memory usage, including physical memory, virtual swap file memory, shared memory segments, and buffers used by the system core

The df df -h command displays statistics on file system disk usage on the Linux operating system

11.8 Top Viewing Resource Information (CPU)

11.8.1 Top Viewing Resource Information (CPU)

Shutdown command reboot Restarts the operating system. Shutdown -h now Shuts down the operating system immediately. Now is 0

Linux command directory operation CD usr/ Switch to the usr directory CD.. CD/Switch to the system root directory mkdir Directory name Create a directory ls directory name Query all directories and files under the directory ls [-a] directory name Query all directories and files under the directory, including hidden files ls [-l] directory name Find / -name Directory name Search for directories (files) under /root mv directory name New directory name Modify directory name mv directory name New directory location Cut cp -r directory name Target directory location Copy to rm Run the touch file name command to create an empty file. Cat /more/less/tail File View the file content. Tail -f File Dynamic/real-time view files (logs) Vi /vim file Modify the contents of the file rm -rf file Forcibly delete the file File package tar -zcvf file name tar File to be packaged Decompress the file tar -xvf file name tar Expansion: decompress the file to a fixed location tar -xvf file name tar -xvf file name - C specify the location of the extract query the current location PWD view process ps - ef | grep process name (tomcat/mysql) kill processes kill 9 pid view port netstat - an | grep port number (3306). Ping The external IP address Ping the internal IP address Ping the internal IP address Command chmod 777 File authorization Check the CPU top Check the disk information df -h Check the memory information Free run the shutdown -h now command to shutdown the operating system immediately. Now is 0. Shutdown -h 10:23 shutdown -h +10 the operating system automatically shuts down after 10 minutesCopy the code