One, linux basics
1. What is linux
Can run on a PC similar to a Unix-style operating system
developed by many programmers through the Internet collaboration
Linux is open source
2. Linux system structure
The linux operating system is composed of a kernel and application programs.
Different manufacturers package various application software and the linux kernel together according to their needs to become a linux release version.
3. Common Linux release versions
RedHat linux
SuSE LINUX
Ubuntu linux
Debian linux
4. Advantages of Linux
Multi-user and multi-task
support multiple platforms,
safe and reliable, stable performance,
rich network function,
good interface,
completely free
...
5. Linux file system type
The file system type used by default in Linux is
EXT4, the third-generation extended file system
SWAP
, and other file system types supported by Linux:
FAT16, FAT32, NTFS,
XFS, JFS
...
6, linux file hierarchy
/bin A command that everyone can use.
Executable file, ls, cd /sbin executable file
/boot boot file, including linux kernel, boot menu and configuration files required for booting (boot boot)
/dev device file, any device and interface device are in file form
/Root root user's home directory
/home common user's home directory
/etc configuration file
/tmp that exists in this directory is a place where general users or programs that are executing temporarily place files
Two, commonly used linux commands
1. File types of linux
file type | effect |
---|---|
- | Ordinary file, similar to Windows Notepad |
d | Directory file, similar to a folder |
c | Character device file, serial port device, sequential read and write, keyboard |
b | Block device file, interface device for storage, random read and write, hard disk |
p | Pipe file for communication between processes |
s | Socket file, usually used for communication on the network. You can start a program to listen to the request of the client, and the client can communicate data through the socket |
l link, link file
2. View the file ls in the directory:
command | effect |
---|---|
ls -l | List in long list =ll |
ls -r | Reverse sequence |
ls -d | View current directory |
ls -ld | Long list lists the details of the current directory |
ls -lh | Display directory or file size in a way that is acceptable to humans |
ls -a | List hidden files, including. And... |
ls -A | List hidden files, excluding. And... |
ls -i | Display file inode number (inode) |
3. Common commands of linux
command | effect |
---|---|
echo | Used to output string or variable extracted value in the terminal |
date | display time |
reboot | Restart the system |
poweroff | Shutdown |
wget | download |
ifconfig | View IP address |
ip addr | View IP address |
uname | Used to view system kernel and system version information |
uptime | Used to view system load information |
free -m | Used to view the current system memory usage information |
who | Used to view the user terminal information currently logged into the host |
last | Used to view the login records of all systems |
history | Display the commands executed in history |
pwd | Display the current working directory of the user, the format is "pwd[option]" |
mkdir | Create catalog file |
rm | Delete Files |
rmdir | Delete empty directories |
cp | Copy files |
mv | Move file or modify file name |
touch | Create normal files |
4. Use of vim editor commands
1. General mode
command | effect |
---|---|
u | Undo current operation |
dd | Delete the current line, = cut |
ctrl+r | Redo the last operation |
yy | Copy the line where the cursor is |
2 yy | Copy the line where the cursor is and the line under the cursor |
p | Paste to the line under the cursor |
P | Paste to the line above the cursor |
cc | Cut |
Number of rows cc | Cut the first few lines of the current line |
X | Delete the content at the cursor position, that is, delete one character backward |
X | Delete one word forward |
w,b | Move the cursor by word |
gg | Jump to the beginning of the document |
dgg | Delete cursor to the beginning of the document |
G | Jump to the beginning of the line at the end of the document |
$ | End of line |
^ | Start of line |
n[enter] | n is a number, the cursor moves down n lines |
h | vim |
j | Move the cursor down (back) line by line |
k | Move the cursor up (forward) line by line |
l | Move the cursor by character to the right |
H | Jump to the top line of the current screen output |
L | Jump to the bottom line of the current screen output |
M | Jump to the middle line of the current screen output |
2. Insert mode
command | effect |
---|---|
i | Insert before the cursor |
a | Insert after the cursor |
O | Insert the line below the cursor |
3. Last line mode
command | effect |
---|---|
:wq | Save and exit |
:q | Exit (you can exit without modifying the content of the file) |
:wq! | Force save and exit |
:q! | Force exit without saving |
: Set no | Show line number |
:set nonu | Do not display line numbers |
: Line number | Jump to the specified line number |
:3,5 d | = Delete 3-5 rows |
: R file name 1 | = Read the content of file 1 to the current file |
: %S/string2/string3 | String 3 replace string 2 |
:%s/1/2/g | = Replace 1 with 2, modify globally |
: W file name 1 | =Save as file name 1 |
/word | Look down for a string of word |
n | Repeat the previous search operation |
N | Reverse the previous search operation |
?word | Look up for a string whose string name is word |
ZZ | If the file has not been changed, then leave, if the file has been changed, then leave after saving |
4. The switch command of linux system
1、重启:
reboot
shutdown -r now
init 6
2、关机
shutdown -h now
poweroff
init 0
5、查看linux系统的各种信息
目的 | 命令 |
---|---|
查看Linux的发行版 | cat /etc/redhat-release |
查看内核 | uname -r |
查看名称 | hostname 或 uname -n |
查看ip | ip a 或 ifconfig |
查看内存 | free -h |
三、linux系统的常见操作
1、重置密码
1>启动界面按e
2>找到linu16,修改ro改为rw,按end到行尾,空格后面 init=/bin/sh
3>按ctrl+x
4>修改密码:echo “redhat” | passwd --stdin root
5> touch /.autorelabel
6>输入:exec /sbin/init