Shell is the system's user interface, a user interface to interact with the kernel. It receives a command input by a user and put it into the kernel to perform.
Shell is actually a command interpreter that interprets a command input by a user and send them to the core. Moreover, Shell has its own programming language used
Editing commands, which allows the user to program a command shell composed. Shell programming languages have many features common programming languages, such as it has
Branched cyclic structure and control structure, in this programming language Shell program having the same effect with other applications.
We can use SHELL to achieve most of the management of Linux systems such as:
-
Document Management
-
User Management
-
authority management
-
Disk Management
-
Software Management
-
Network management
…
Shell of two ways:
Enter the command inefficient for a small amount of work
Shell Script for high efficiency to complete complex, repetitive work
Summary:
bash shell prompt
shell syntax
bash properties
Linux help
A, bash shell prompt:
===================
[root@tianyun ~]# echo $PS1
[\u@\h \W]$
[root@tianyun ~]# date
October 24, 2019 09:38:54 CST Wednesday
[root@tianyun ~]# whoami
root
[root@tianyun ~]# useradd jack
[root@tianyun ~]# passwd jack
Changing password for user jack.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
Two, shell syntax
=====================
Command options parameters
[root@tianyun ~]# ls
[root@tianyun ~]# ls -a
[root@tianyun ~]# ls -a /home
The entire body shell command: Command
Options: trim command will affect the behavior usually // -, -
Parameters: Object command role
Three, bash basic characteristics
- Autocomplete
ls /etc/sysconfig/network-scripts/
ls /etc/sysconfig/network-scripts/ifcfg-eth0
cat /etc/sysconfig/network-scripts/ifcfg-eth0
systemctl restart crond.service
date -s 12:30
- hot key
^ C terminate the program running in the foreground // ping 10.18.40.100
^ D equivalent exit exit
^ L clear screen
^ A foremost end of the command line cursor to the editing commands //
^ E move the cursor to the command line of the back-end editing commands //
^ U // delete all the characters before the cursor editing commands
^ K delete the cursor all the characters after // editing commands
^ R Search command history, use keyword
Alt +. References on the last parameter of a command, equivalent to! $
ESC. References on the last parameter of a command, equivalent to! $
ls /etc/sysconfig/network-scripts/ifcfg-eth0
cat ESC .
- Command history
history
a. cursor down key
. B ^ R // search-history (Enter a keyword of a command: must be continuous)
c.! 220 // execute command history command in Article 220
! // search string in recent history commands that begin with a character xxxx commands, such as! Ser
! $ // references on the last parameter of a command
Example 1:
[root@instructor ~]# ls /root /home
[root@instructor ~]# cd !$
cd /home
Example 2:
[root@instructor ~]# ls /root /home
[root@instructor ~]# touch !$/file1
touch /home/file1
Example 3:
[root@instructor ~]# systemctl restart crond
[root@instructor ~]# ls
[root@instructor ~]# date
[Root @ instructor ~] #! His
After speaking one week
- Command aliases
[Root @ tianyun ~] # alias tianyun = 'cat / etc / sysconfig / network-scripts / ifcfg-eth0' // alias (temporary, this effect only in the Shell)
[Root @ tianyun ~] # unalias tianyun // cancel the alias tianyun
[Root @ tianyun ~] # alias // Display the current alias
ll=‘ls -l --color=tty’
[root@tianyun ~]# ll
[root@tianyun ~]# /bin/ls
[root@tianyun ~]# /bin/ls --color
[Root @ tianyun ~] # type -a ls // Check command type
ls is aliased to `ls --color=auto’
ls is /usr/bin/ls
ls is /bin/ls
[root@tianyun ~]# /bin/ls
[root@tianyun ~]# /usr/bin/ls
[Root @ tianyun ~] # ls // alias priority
[Root @ tianyun ~] # \ ls // skip alias
[Root @ tianyun ~] # cp -rf / etc / tmp // first time
[Root @ tianyun ~] # cp -rf / etc / tmp // Second
[root@tianyun ~]# \cp -rf /etc /tmp
[root@tianyun ~]# type -a cp
cp is aliased to ‘cp -i’
cp is /usr/bin/cp
cp is /bin/cp
Permanent Alias:
/ Etc / bashrc shell configuration file one
[Root @ tianyun ~] # gedit / etc / bashrc // add the following lines
alias tianyun=‘cat /etc/sysconfig/network-scripts/ifcfg-eth0’
Four, Linux help
- Command --help
ls --help
Usage: ls [option] ... [file] ...
Common options for ls
-a all, see all the files in the directory, including hidden files
-l long list display
-h human displayed in a user-friendly way
-d lists only the directory name, does not list other content
-t Sort by modification time
-S sort by file Size
-r reverse order reverse
inode number (index number) -i display files
date --help
Usage: date [OPTION]… [+FORMAT]
or: date [-u|–utc|–universal] [MMDDhhmm[[CC]YY][.ss]]
date
date +%H
date +%F
date 0214080019
date 0214080019.30
date -s 12:00
[root@tianyun ~]# touch date +%F
_file.txt
[root@tianyun ~]# ls
2017-07-24_file.txt
Two kinds of time:
Hardware time, i.e. the motherboard BIOS time
The system time, Linux system time
- the name of the man page (for command help, the configuration file for help, help for the function)
[root@tianyun ~]# man man
MANUAL SECTIONS
The standard sections of the manual include:
1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Special Files
5 File Formats and Conventions
6 Games you. In the.
7 Miscellanea
8 System Administration tools and Deamons
Help command: Chapter 1, Section 8
Help function: Chapter 2, Section 3
File format: Chapter 5
Generally chapter number is not required to use, for example:
I ls
man useradd
man setfacl (/EXAMPLES)
Tip 1: Query by chapter
/ Usr / bin / passwd command to modify user password
/ Etc / passwd file contains user configuration information
man -f passwd passwd lists all the chapters in the manual
Help man 1 passwd passwd command
Help man 5 passwd user profile
Tip 2: Search all sections