- Linux Terminal Introduction
- Shell prompt
- Bash Shell Basic Syntax
- use of BASIC commands:ls, pwd, CD
- View System and BIOS Hardware Time
- How Linux gets Help
- Linux shutdown command: Shutdow, INIT, etc.
- Linux 7 Boot levels
- Create a quick and easy snapshot of your experimental environment
- Set up the server to automatically power on after the call
Linux Terminal Introduction
TTY Console terminal pts Virtual Terminal
Tty1-tty6
The first entry is the graphical surface:tty1 is the graphical interface.
the graphical interface switches to Character Interface Terminal: ctrl+shift+alt+f2-6
to switch characters to the graphical interface: Alt+f1
PTS Virtual Terminal
Ctrl+shift+t
Alt+1
Zoom in:Ctrl+Shift+ +
Zoom Out:Ctrl +-
pts (pseudo-terminal slave) pseudo terminal : after connecting via the SSH related tool, the terminal is shown as: Pts
Shell prompt:
[email protected] ~]#
[user @ host name current directory name] prompt root # Normal User: $
Bash Shell Basic Syntax
Summary Linux command input rule:
How to enter a command:
Command [Options] ([parameters]) [Value of options] ([value of parameter])
Space as a split
common Options (parameters):-H--help; Features: Options look like:-Letters OR--add words
Basic command:
ls Command
function: See what files are in the current directory
syntax:ls directory, if you do not add a directory to view the current directory
Parameters:
-L display the shortcut in the detailed information system #ll
-A Show hidden files
-D View directory (without viewing the contents)
-H Enhanced Readability
Early Linux is a bit by bit.
Cases:
[Email protected] ~]# ls-l/etc/passwd
-rw-r--r--1 root root 1753 Jan 20:45/etc/passwd
[Email protected] ~]# LS/ETC/PASSWD
/etc/passwd
[Email protected] ~]# ls-d/etc/
/etc/
[Email protected] ~]# ls-dl/etc/
Drwxr-xr-x. 20:45/etc/Root 12288 Jan
[Email protected] ~]# ls-l/etc/passwd
-rw-r--r--1 root root 1753 Jan 20:45/etc/passwd
[Email protected] ~]# LS-LH/ETC/PASSWD
-rw-r--r--1 root root 1.8K Jan 20:45/etc/passwd
Example: viewing hidden files,
Ls-a
. Current directory
.. Parent directory (upper directory, parent directory)
Pwd
Function: View current directory
syntax:pwd has no parameters
Cases:
Pwd
[Email protected] ~]# ll-d/etc/
Drwxr-xr-x. 20:45/etc/Root 12288 Jan
Cd
Role: Switch Directories
Syntax:CD directory Name
Cases:
#cd back to the user's own home directory
#cd ~ Go back to the user's own home directory
#cd-Go back to the previous directory
# cd/etc////sysconfig/ the same as Cd/etc/sysconfig .
cd/etc/ the Same as cd/etc .
View System and BIOS hardware time: Refers to the BIOS time
[Email protected] sysconfig]# Hwclock
Wed 08:58:11 PM CST-0.942319 seconds
How Linux gets Help
method 1: Add parameter-H or--help
[email protected] ~]# shutdown --help
[Email protected] ~]# fdisk-h
[email protected] ~]# Mans Find
Shutdown command:
shutdown , Init , reboot
Shutdown
Function: Shutdown, restart, timer shutdown
Syntax: shutdown [Options]
The following options are available:
-R = Restart the computer
- h = off Machine
-H time = timer off
-C-= Cancel the pre-timer shutdown or Ctrl + C
Cases:
shutdown-h +10 #10分钟后关机
If you want to use the command at a specific time when the timer is turned off:
Shutdown-h 10:01
immediate shutdown: shutdown-h now
Shutdow-r usage is the same as shutdown-h.
Shutdown-r now restart
shutdown-r +10 # Restart after 10 minutes
shutdown-r 22:22 # Restart after 22:22
Init Command
Role: Switching the system operating level
syntax:init 0-6
Cases:
Init 0 command is used to immediately switch the system run level to 0 , that is, shut down the machine;
Init 6 command to switch the system run level to 6 , that is, restart.
Linux 7 Boot levels:
0 System shutdown mode, the system default operation level cannot be set to 0, otherwise it will not start normally, the machine shuts down.
1 single-user mode, root privilege, for system maintenance, prohibit remote login, like Safe mode login under Windows.
2 Multi-user mode, no NFS network support.
3 full multi-user text mode with NFS, login to console command line mode.
4 The system is unused, reserved for general use, and in some special cases it can be used to do something. For example, you can switch to this mode to do some setup when your laptop's battery is running out.
5 graphical mode, after landing into the graphical GUI mode, X window System.
6 Restart mode, the default run level cannot be set to 6, otherwise it will not start normally. Running the init 6 machine will restart.
RunLevel
Function: View the current level of operation
Syntax:runlevel
- Create a quick and easy snapshot of your experimental environment
Configure a good static IP address, close iptables firewall, turn off SELinux
[[Email protected] ~]# Setup
[[email protected] ~]#/etc/init.d/networkmanager stop
Stopping NetworkManager daemon: [FAILED]
[Email protected] ~]# Chkconfig NetworkManager off
[Email protected] ~]#/etc/init.d/network restart
[email protected] ~]# cat!$
Cat/etc/selinux/config
# This file controls the state of the SELinux on the system.
# selinux= can take one of these three values:
# Enforcing-selinux security policy is enforced.
# Permissive-selinux Prints warnings instead of enforcing.
# disabled-no SELinux policy is loaded.
Selinux=disabled
#SELINUX =enforcing
# selinuxtype= can take one of these the values:
# targeted-targeted processes is protected,
# Mls-multi level Security protection.
selinuxtype=targeted
[Email protected] ~]# iptables-f
[Email protected] ~]#/etc/init.d/iptables Save
iptables:saving firewall rules to/etc/sysconfig/iptables:[OK]
- Set up the server to automatically power on after the call
Linux Basic file Management
What this section says:
- Linux system directory structure
- relative /absolute path
- Create /copy/delete files
- RM-RF/accident
- View File Contents
- Recovery Linux files that have been deleted
Linux system directory structure
Inverted tree-type structure
/ commonly referred to as the root partition. All files and directories begin with this. Only The root user has write access to this directory.
The---/etc configuration file contains the configuration files for all applications and also contains scripts to start and close a particular program, for example,
/etc/passwd , /etc/init.d/network and so on.
---/boot stores the files that the Linux system needs to load when it starts. (usually saved in another disk partition) Kernel, grub and other files are stored here.
---/home general user all data stored in this directory
---/var is an extensible directory that contains very often variable files. For example,/var/log (System log),/var/lib (Pack documentation),
---/root all data for the administrator. Root User's home directory
---/tmp temporary file storage location
---/usr usr represents the Unix software source
---/bin command This directory contains a binary executable file.
---/sbin system commands, the commands in this directory are intended primarily for system administrators to use for system maintenance. For example, Iptables, reboot, Fdisk, and so on.
/MNT-mount the directory mount point, which the system administrator can use to temporarily mount the file system.
---/dev contains device files. In Linux, everything is considered a file. Terminal devices, USB, disks, and so on are all considered files, such as/DEV/SDA.
absolute path /relative path:
cd/etc/sysconfig/network-scripts/
Relative path:
[Email protected] ~]# cd/etc
[Email protected] etc]# CD sysconfig/network-scripts/
. Represents the current directory
.. Indicates a parent directory
Create /view/copy/delete files and folders
Creating files and folders
Touch
Function: Often used to create empty files
syntax: Touch file name
[email protected]/]# Touch a.txt
[[email protected]/]# ls a.txt
A.txt
Mkdir
Role: Create a directory
syntax:mkdir directory Name
Example: mkdir/tmp/test
-P is created along with the parent directory
#mkdir/path/to/dirname
#mkdir-P
/a/b/c/d
Example 1:
[Email protected] ~]# mkdir-p/A/B/C/D
[[Email protected] ~]# CD !$ #!$ represents the last parameter of the previous command
cd/a/b/c/d
[Email protected] d]# CD. /.. /
[Email protected] b]# pwd
/a/b
To view file methods:
Cat
Function: View the contents of a file
syntax:cat file name
Cases:
cat/etc/passwd
More View file names
Cases:
more/etc/passwd
Q exit
Less view file names
Q exit
Use the cursor keys to page UP
The difference between more and less in Linux
MORE: Does not support back, but almost no need to add parameters, the space bar is the page down, the ENTER key is down the line, in the case of no need to back the situation is convenient.
Less: Supports rollover, either up (PageUp button) or down (pagedown button). , the SPACEBAR is a page down, and the ENTER key is a downward-turning line
Head starts at the first line, viewing the file, showing the first 10 rows by default
-N numbers show how many rows
Cases:
head/etc/passwd
Head-n 3/etc/passwd
Tail starting from the first line, viewing the file, showing the last 10 rows by default
-N shows how many rows
-F Dynamic Display data (not closed) often used to view logs
[Email protected] tmp]# tail-f/var/log/messages
[Email protected] ~]# service network restart
See who modified the /etc/resolv.conf the DNS server address in the .
To copy a file:
Cp
Role: Copying files
Syntax:CP source File Destination file
[Email protected] ~]# cp/etc/passwd/tmp/
[Email protected] ~]# LS/TMP/PASSWD
/tmp/passwd
Copy directory:
[Email protected] ~]# cp/etc//tmp/
cp:omitting (Ignore) directory '/etc/'
-R contains subdirectories and files.
[Email protected] ~]# cp-r/etc//tmp/
CTRL + C
Interaction:
Touch/tmp/test11
Mkdir/tmp/test11 #这个命令还可以创建成功吗?
Note: Files and filenames are different in the same directory.
Delete files and folders
RM
Action: Delete a file or directory
syntax: rm-rf file or directory name
[Email protected] ~]# rm-rf/tmp/test
[Email protected] ~]# rm-rf/tmp/test11
-R Recursive Delete (can delete things in directory and directory)
-F forcibly removed
Rename:
MV
Role: Renaming
syntax:MV Source: File or directory name destination: file or directory name
[Email protected] ~]# mkdir Yanhuo
[Email protected] ~]# MV Yanhuo Xiaoli
[[email protected] ~]# ls Yanhuo
Working experience: Use the Delete command carefully, use the MV command frequently
Linux Basic command and file management