Linux series - Linux History, installation, what is bash shell (shell), what can we do, how we use it at ordinary times, shell prompt, shell basic syntax, command completion, command shortcut, History

Posted by articlesocial on Fri, 11 Feb 2022 23:22:54 +0100

Linux features

Openness (open source), multi-user, multi task, good user interface, excellent performance and stability

Multi user and multi task:

Single user: when a user logs in to the computer (operating system), only one user can log in at the same time;

Single task: a task, which allows users to operate the number of tasks at the same time;

Multiple users: multiple users are allowed to log in multiple users at the same time when logging in to the computer (operating system);

Multi task: multiple tasks, allowing users to perform multiple operation tasks at the same time;

Windows belongs to: single user, multitasking.

Linux belongs to: multi-user and multi task.

Linux branch

The Linux we are talking about now actually refers to the distribution version, which is the operating system constructed by using the Linux kernel and various GNU Library files and applications. Introduction to Linux distribution RHEL/Centos/Ubuntu/Suse
In 1993, RedHat compiled the Linux kernel and installed the corresponding software for distribution.
CentOS community enterprise operating system, changed to Redhat, is completely open source.
Ubuntu community maintenance is now mainly engaged in mobile phone system and computer desktop system.

Virtual software installation

Linux virtual machine installation

# Virtualization Technology: kvm, vmware, openstack, docker, k8s
# iaas,paas,saas
# openstack: iaas
# docker: paas
# k8s: container arrangement, container management, containers on different machines

# Next step along the way, after loading (trial, enter the activation code), open

# Network mode: NAT, bridge, host only
	Bridging: the virtual machine and the host computer belong to the same network segment
    NAT: Network address translation,
# Snapshot: it is equivalent to a backup. If something goes wrong in the future, it can be restored to the snapshot state

centos 7.6 installation

# 32-bit and 64 bit operating systems

# DHCP :
DHCP(Dynamic Host Configuration Protocol) is a LAN network protocol. It refers to a period controlled by the server IP Address range. When the client logs in to the server, it can automatically obtain the address assigned by the server IP Address and subnet mask. By default, DHCP As Windows Server A service component of will not be automatically installed by the system, but also needs to be manually installed and configured by the administrator
# dns: domain name address can be converted into ip address
# Host name: production environment, with meaningful address + floor + room number + business
# Swap partition: swap partition
# About partitions
linux The partition structure is tree structure, windows It is a forest structure, so it has C disc D Disk or something, and linux /The partition is the root partition, swap It can be understood as virtual memory, /boot This is a directory, which can be divided into a partition and mounted to/boot You can also use only one directory/Partition, there will be boot Directory, which stores the boot file, kernel and so on

xshell installation and connection

# Restart the network card
systemctl restart network

Introduction and use of bash shell

What is bash shell

Bash Shell is a command interpreter, which is at the outermost layer of the operating system. It is responsible for an interface between the user program and the kernel, translates the commands entered by the user to the operating system, and outputs the processed results to the screen.

Connecting through xshell opens a bash program window. You can only enter commands without clicking the mouse

When we use the remote connection tool to connect to the linux service, the system will open a default shell. We can execute commands on this interface, such as obtaining the current time of the system, creating a user, etc

What can I do

It turns out that the "little by little" on windows is that it can do it

Use Shell to realize most of the management of Linux system, for example:

  1. File management (file creation, move, copy, delete, edit...)
  2. Permission management (different users do not have permission)
  3. User management (create, delete...)
  4. Disk management (Mount)
  5. Network management
  6. Software management

How do we usually use Shell?

1 input command, low efficiency
2 shell script: shell script that executes commands in batches
For example: to create 100 users, it takes 100 times to simply input commands, while Shell script only needs a few lines of commands to complete the creation of 100 users


for i in {1..100}
 useradd test$i
 echo "create test$i"


shell prompt

Explain what each character means

[root@lqz ~]#
# root: current user
# @: meaningless
# lqz: host name
# ~: home directory
# #: indicates super user
[lqz@lqz ~]$ 

Shell basic syntax

It consists of three parts: command options and parameters

#Command option parameters
command [-options] [arguments]

[root@lqz ~]# ls             #command
[root@lqz ~]# ls -a          #Command + option
[root@lqz ~]# ls -a /home/   #Command + option + parameter
ls -a -l
ls -la
ls --all
ls --list
ls -c
ls --color
ls -a /tmp
#Command: the body of the entire shell command
#Option: used to adjust the output effect of the command
    #Guide short format options (single character) with "-", such as "- l"
    #Guide long format options (multiple characters) with "--", such as "-- color"
    #Multiple short format options can be written together with only one "-" boot, such as "- al"
#Parameters: objects operated by the command, such as file, directory name, etc
# Options and parameters can be exchanged. There must be at least one space between commands, options and parameters
# The command must start, and the position of options and parameters can change

Command Completion

When windows is used to find a file with many directory levels, the opening efficiency will be very slow, but if linux is used to find a file with many directory levels, you can quickly complete it by tab

PS: tab key can realize command completion and path completion. In actual production, tab completion is often the most used, because it can reduce the rate of command execution and path error.

# One or two tab s
# After a while, you will find the command you want to use directly
# Twice, list all that may be used

# ifconfig is not available in version 7. Software needs to be installed
yum install net-tools -y

# Yum install bash completion - y completion options
ls - both parties tab All options will be created and prompted

Command shortcuts

Ctrl + a    #The cursor jumps to the beginning of the command line being entered
Ctrl + e    #The cursor jumps to the end of the command line being entered
Ctrl + c    #Terminate the process running in the foreground
Ctrl + d    #In the shell, ctrl-d means to launch the current shell.
Ctrl + z    #Suspend the task and hang it to the background
Ctrl + l    #Clear the screen, which is equivalent to the clear command
Ctrl + k    #Deletes all characters from the cursor to the end of the line
Ctrl + u    #Deletes all characters from the cursor to the beginning of the line
Ctrl + r    #Search history commands, use keywords, and select Tab. Only the nearest one can be found
Ctrl + w    #Forward deletion by word or space
Ctrl + Zuo Youjian #Jump forward and backward by word or space

# Add face before command line "#"The command will not be executed


-w Save command history to history file
-c clear the command history, and the status file will not be deleted
-d delete the nth line of the command history

# History view history command
# ! Number fast execution number line
# ! Quickly execute the latest Yum command using yum

# history -d 70 delete the 70th line of history
# history -c clear all records (connect to other people's server, after the operation, execute it)
# history -w can write the history to the user's home path bash_ In the history file

Topics: Linux