Linux System Overview

Computer architecture

  • Computer consists of Computer hardware and Computer Software. Computer Software can be divided into system Software and application Software. System Software is the operating system and the foundation of other Software.

  • At present, the mainstream operating system has: Windows series, Unix series, Linux series, Android series, IOS series,…

Overview of the Linux system

  • Linux was born in 1991. It was designed and developed by Linus Torvalds as a hobby during his college years because he was not satisfied with the MINIX operating system used in his teaching.
  • Linux is a unix-like operating System based on Posix(PortableOperating System Interface) standard and multi-user, multi-task, multi-thread operating System.
  • Linux runs major Unix tools, applications, and network protocols on both 32-bit and 64-bit hardware.

Major releases

  • Redhat: by far the largest Linux publisher, fully functional and stable, was acquired by IBM in October 2018 for $34 billion.
  • Ubuntu: the best Linux desktop version, with a very user-friendly interface, powerful software source support.
  • CentOS is a clone of RHEL and can be regarded as the free Redhat operating system.

CentOS System Installation

Vmware download and installation

  • Download it at www.vmware.com/cn.html

Download and install CentOS system

  • Download it at www.centos.org/

The directory structure

Frame structure

Directory,

Directory name Function is introduced
/bin Binarie: Stores binary executable files (such as the bin directory of Tomcat)
/sbin Super binaries: Stores binary files accessible only to root users
/boot The system startup core directory stores the system startup program file. For example, check the size of the startup file
/dev Devices: Stores hardware device files
/etc Etcetera: System configuration files
/home Home directory, each user has a “home”, the user’s starting directory, create users to follow the creation of the corresponding home directory
/lib Library: System resource file class library
/proc Memory mapping directory for viewing system hardware information
/var This is a variable. For deploying the project
/tmp Temporary: Stores temporary files
/root The home directory of superuser root
/usr Unix shared resouce: stores Unix shared system resources

Common commands

The concept of the Shell

  • Shell, commonly known as Shell, is a software that provides a user interface, called a command interpreter.
  • It is mainly responsible for receiving the user input command, and then calling the corresponding application program, and finally output the results of the program to the user.

Format of a command

  • Command [- option] [parameter]
  • The command is case-sensitive. Options and parameters are optional and separated by Spaces.

Detailed explanation of common commands

View files/directories in a directory

The command Functional description
ls List displays files
Ls -l or ll List-list Displays detailed information
ls -a List-all Displays all files (including hidden files)
ls -al List -all Two combinations in the list
Ls directory name See what’s in the directory

Directory to switch

The command Functional description
cd .. Upper level directory
cd dirname Enter the directory
CD or CD ~ Go directly to the user’s home directory
cd / Return to the system root directory
  • The concepts of relative and absolute paths.

View the full path

The command Functional description
pwd View the location of the current directory

Viewing the Current User

The command Functional description
whoami View the name of the current user

User switching

The command Functional description
su Switch from a common user to the root user
su root Switch to user root
Su user name Switch to a common user
exit Return to original user
  • It is best to use su with exit, otherwise multiple su commands will result in user “stacking”.

Manage users

The command Functional description
useradd xxx Create a user
passwd xxx Set the password for the created user
userdel Delete user

View the directory where the command resides

The command Functional description
Which command View information about the path where the specified command resides

File operations

The command Functional description
touch fileName Create a file named fileName
touch dir/fileName Create a file named fileName in the dir directory
Echo content > fileName Write content overwrite to a file, or create if the file does not exist
Echo content >> fileName Append the contents to the file
cat fileName Print file contents to terminal
more fileName View each line of a file in a split screen
less fileName View all parts of a file
head -n fileName View the first n lines of the file
tail -n fileName View n lines at the end of the file
wc fileName View the number of lines in the file

Directory operations

The command Functional description
The mkdir directory name Creating a normal folder
Mkdir -p directory/directory/directory Create multilevel parent folders recursively
mv dir1 dir2 Move dir1 to dir2
mv dir1/dir2 ./ Move dir2 from dir1 to the current directory
mv dir1 name Rename dir1 to name
cp dir1 name Copy dir1 as name
cp -r dir1 dir2 The -r (recursive) parameter needs to be set to ignore the directory level
The rm files Delete the file
The rm -r directory Recursively delete directories (regardless of directory hierarchy)
Rm -rf File/directory -r force(forcibly) Deletes files or directories

Find operations

The command Functional description
Find / -name passwd[full name] Find the passwd file
The find. / – name “p *” Find files with “P”
find ./ -type f Find all files
The grep content fileName Finds the specified contents from the specified file

Rights management

The command Functional description
Chmod Specifies the name of the permission file or directory This command is used to manage permissions on specified files. R read :4 W Write :2 x execute :1

Process management

The command Functional description
ps View the process in the current terminal window
ps -aux View all processes in the system
ps -ef Viewing the Process List
Kill the process, Kills the specified process
Kill -9 Indicates the process ID Forces the specified process to be killed

Other commands

The command Functional description
ifconfig View information such as the IP address of the current system
Tar ZCVF File name of the compressed file.tar.gz Path 1 Path 2… Implement the packaging of a group of files or folders
Tar ZXVF File name of the compressed file.tar Implement decompression and package decompression
Man [Section ID] Name of a command/function Query the specified command or function

Use the VI tool

The basic concept

  • Vi and vim are text editors on the command line of the Linux operating system. The format is vi file name or vim file name.

Three models

use

Edit command in command mode

I: insert before current position A: insert after current position O: insert under current lineCopy the code

Delete command in command line mode

X deletes one character dw deletes the current word 3dw deletes three words DD deletes the current line 5dd deletes five linesCopy the code

Modify command in command line mode

R replaces a character CW replaces a word cc replaces a line C replaces the cursor to the end of the lineCopy the code

Copy commands in command line mode

Yw Copy word YY Copy line (or Y) DD Cut line P Paste u under current line Undo CTRL + R Cancel UndoCopy the code

Bottom line mode command

:w saving :w newfile saving to a newfile :wq saving to exit Vi(or ZZ, or :x) :q! Forcibly exit without saving :1,2 CO3 Copy line 1, line 2 after line 3 :4,5 MO6 Move line 4, line 5 after line 6 :% S/source string/destination string :%s/source string/destination string /g replace all in each lineCopy the code

Pay attention to use

  • Use the vimtutor command to practice the vi command.
  • The. Vimrc file in the user’s home directory can realize the simple setting of VI.