当前位置:网站首页>Common operating commands of Linux
Common operating commands of Linux
2022-07-07 08:53:00 【Please Sit Down】
Command is often used
Log off users :logout or exit
restart :reboot or shutdown -r now
To turn it off :halt or shutdown -h now
see liunx Kernel version :uname
-r: Display the release number
-a: View all information
-man: Displays the type of machine used
-i: Displays the required hardware platform
-v: Display the operating system version number
-n: Check the network node host name
Check the disk space size and remaining space size of the file system :df
How long has the display system been running :uptime
View the current system memory usage :free
Exit open document :esc : q
Inquire about CPU Detailed hardware information :cat /pros/cpuinf
Dynamically display the data of the current process :top
View login log information :last
View the logged-in user information :w [ user name ]
Display monthly calendar or annual calendar :cal
cal 09 2020: see 2020 year 9 Calendar of the month
Display or set the current date and time :date
Display all user names of users currently logged in to the system :who
Show that I am currently logged in to the system user terminal :who am i
Count the number of lines in a given file 、 Number of words and characters :wc [-lw] [-c] file name
l: The statistical number of rows
w: Count characters
c: Count the number of bytes
Clear the screen :clear
View all history commands :history | more
Execute the commands in the historical command list :! n(n Is the number in the historical command list )
> and >> :“>” Means to write the input information directly ,“>>” It means that the output information is written into
ls > t.txt : Enter the current information into t.txt In file
Switch 6 Virtual terminals
Ctrl+Alt+F1: Graphical interface terminal
Ctrl+Alt+F2~F6:5 Virtual terminals
Common directory
/: root directory , At the top of the file system
/bin: Store common commands , Ordinary users can also perform
/lib: Library file storage directory
/dev: Store equipment files
/etc: Store most configuration files and subdirectories of the system
/tmp: Storage of temporary documents
/boot: Store contents and guide system program files
/usr: The directory where the system stores programs
/home: The default storage location of the home directory of ordinary users
/lost+found:EXT2 or EXT3 File system , Fragmented files caused by unexpected system crash or accidental shutdown
/opt: Can choose , Store some software packages or third-party applications
/root: System administrator home directory
/mnt: Used to temporarily mount file systems , Provide default mount points for some devices
/proc: Virtual file system , The files in this directory are images in memory
/sbin: Save the system administrator or root User's command file
/var: Usually save content that changes frequently , Such as system logs and mail files
Common shortcut key
Tab: Automatic completion
Ctrl+U: Clear the current position to the first character of the line
Ctrl+K: Clear the current position to the end of the line
Ctrl+L: Clear the screen
Ctrl+C: To terminate the execution of an order
Ctrl+D: Save and exit
pageup: The previous page
pagedown: The next page
Ctrl+U: Cut the contents in front of the cursor
Ctrl+Y: Paste
Ctrl+E: Move the cursor to the end of the line
Ctrl+A: Move cursor to the beginning of line
ALT+F: Jump to the next space
ALT+B: Jump back to the last space
ALT+Backspace: Delete the previous word
Ctrl+W: Cut the word after the cursor
Shift+Insert: Paste text into the terminal
1、 Directory switching command
cd Toggle directory
cd . Current working directory
cd .. Parent directory
cd - Previous working directory
cd ~ User home directory
pwd Display the current directory
su user name : Switch to different users (exit Exit current user )
ls [ Options ] [ Directory name ]: View information in the directory
ls -a List all files in the directory , Include implied documents
ls -l List file details ( Abbreviation :ll)
ls -h And '-l' Together , Easy to read format output file size
ls -m Compact the list of files separated by commas
ls -R Recursively display the files in each subdirectory of the specified directory
ls -i Display the inode number of the file in the first column of the output
ls --help Display help information
Catalog color :
Blue : Catalog ( Folder )
gray : Ordinary documents
green : Executable file
Red : Compressed files
sky blue : Link to the file
2、 Document management order
mkdir [ Options ] Directory name : Create directory
mkdir -m Set the permission mode when creating a directory
mkdir -p Create each directory specified in the directory structure , Create a directory if it doesn't exist , If the directory already exists, it will not be overwritten
mkdir -v or --verbose: Every time you create a new directory, the message
mkdir -help Display help information
Example :
mkdir Catalog + file name 1 Catalog + file name 2
mkdir -p xx/yy/zz Create multiple folders in succession
mkdir -m 766 xxx give xxx Folder 766 jurisdiction
touch file name : Create a new blank text file
cp [ Options ] Source file Target file : Copy directories or files
-a: Keep links 、 File attribute , When copying directories, you can recursively copy directories
-f: If the target file or directory already exists , Then cover it , No hint (force)
-i: If the target file or directory already exists , Then prompt the user , You can use letters y confirm , The other letters are denial
-r: duplicate catalog , Copy the files and subdirectories under the source directory to the target directory
Example :
cp -r xx yy/ : Copy xx Folder path yy Under the folder
cp -a xx yy/ : Keep the original properties
mv [ Options ] Source file Target file : Move or rename directories or files
Example :
mv /xx/1.txt /yy/2.txt : Move xx Under the folder 1.txt To yy Folder and rename it 2.txt
rm [ Options ] Target file : Delete file
-f: If the target file or directory already exists , Then cover it with swallows , No hint (force)
Example :
rm 1.txt: Delete 1.txt file
rm -r xx: Delete xx Folder and prompt
rm -rf xx: Delete xx Folder does not prompt
rm -rf xx yy dd: Delete xx yy dds Folder does not prompt
rmdir [ Options ] Directory name : Delete empty directory , And you must delete it in the parent directory
-p Delete the specified tree
-v --verbose Output diagnostic information during directory deletion
--help Display command help
find Find the path to the directory Search for conditional options Setting of search conditions : It is used to find the files that meet the conditions under the relative path
-name: Find the file by filename
-user: Find files by user name
-type: Find files by file type
-size: Find files by file size
-atime: Find the file by its last access date ( Company : God )
-mtime: Find the file by the last modification date of the file ( Company : God )
-newer: Find files that are newer than the specified file
-amin: Find files that have been accessed within a specified time ( Company : minute )
-cmin: Find files that have been changed within a specified time ( Venerable position : minute )
-perm: Find files that match the specified permission values
Example :
find / -name xxx: Look in the root directory xxx The file of
info command : Find an overview of specific commands
man command : Find an overview of specific commands
3、 File permissions
There are three kinds of users with access rights :
File owner (Owner): Owner of file
When the user (Group): Users in the same group that the file belongs to
Other users (Others): Other users who can access the file
Representation of access to files or directories :
r( read ): Allow reading of file contents or column directories
w( Write ): Allows you to modify the contents of a file or create 、 Delete file
x( Can be executed or found ): Allow the execution of files or allow the use of cd Command to enter the directory
-( No authority ): It is not allowed to read the file 、 Modification and implementation
for example :
file type File owner When the user Other users
d rwx r-x r--
Binary representation 111 101 100
Octal representation 7 5 4
Modify file permissions :
① Modify permissions in alphabetical form :
chomd [ Options ] Pattern [, Pattern ] file name
User object :
u:user Represent user , The owner of a file or directory
g:group Represents the same group of users , That is, it has the same group as the file group ID All users of
o:others Means other users
a:all It means all the above users
Operation symbol :
+: Add a permission
-: Cancel a permission
=: Give the given permission and cancel all other permissions
Operating authority :
r: Can be read
w: Can write
x: Executable
for example :
chmod u+x,g+w,o-r file1 to file1 Add executable permissions to the file owner , Add writable permissions to users in the same group , Other users cancel the read permission
chmod a=rw file2 to file2 All users of the file are granted read and write permission
② Modify permissions in digital form :
chmod Octal mode file name
for example :
chomd 664 file1 (110 110 100) to file1 The owner of the file grants read and write permission , Users in the same group are granted read and write permission , Other users give readable permission
chomd 700 file2 (111 000 000) to file2 The owner of the file grants readable, writable and executable permissions , Users in the same group are not authorized , Other users are not authorized
4、vi Editor
vi file name -》 Enter command mode
vi + file name Open the file and stop the cursor at the beginning of the last line
vi + n file name Open the file, and the cursor stops at n Line beginning
vi - r file name Files recovered after the system crashed
vi + / word file name Find... From the file “ word ” First occurrence , The cursor stops at the beginning of the line changing
In command mode, press "a(append)、i(insert)、o" Enter input mode , Press... In input mode and last line mode "esc" Enter command mode , In command mode, press ":" Enter last line mode
Cursor movement :( Command line mode )
On Next Left Right : ↑ ↓ ← →
Turn the previous page : Page Down or Ctrl+F
Turn the next page : Page Up or Ctrl+B
Jump to the top of the line : Home or "^" or "0"
Jump to end of line : End or "$"
Move right # Characters : #→
Move left # Characters : #←
Jump to the beginning of the line of the file : 1G or gg
Jump to the last line of the file : G
Jump to file No # That's ok : #G
Show line numbers in the editor : :set nu
Cancel the line number in the editor : :set nonu
Copy 、 Paste 、 Delete 、 Move :( Command line mode )
Delete a single character at the cursor : x or Del
Delete the current cursor line : dd
Delete... From the cursor # Row content : #dd
Delete all characters from the current cursor to the first line : d^
Delete all characters from the current cursor to the end of the line : d$
Copy the entire contents of the current line to the clipboard : yy
Copy from cursor # Row content : #yy
Copy # To # Line to the current cursor position : :#,# co .
Copy # To # Row to # Where the line is : :#,# co #
After pasting the contents of the buffer to the cursor position :p
Move # To # Line text to # That's ok : :#,# m #
Move # To # Line text to filename In file : :#,# w filename
Move # To # Line text is appended to filename In file ::#,# w >> filename
File content search :( Last row mode )
Find the string in the file from top to bottom "word": /word
Find the string in the file from bottom to top "word": ?word
Locate the next matching found string : n
Locate the last matching searched string : N
Undo editor :
Press once to cancel the most recent operation , Press multiple times to restore : u
Used to cancel all current edits : U
Save files and exit vi Editor :( Command line mode )
Save the file : :w or :w /root/newfile( Save as other file )
sign out : :q( Unmodified exit ) or :q!( Forced exit )
Save file and exit ::wq
File content replacement :( Command line mode )
The first string found in the current row "old" Replace with "new": :s /old/new
All strings found in the current line "old" Replace with "new": :s /old/new/g
In the line number "#,#" Replace all strings in scope "old" by "new": :#,# s/old/new/g
Replace all strings throughout the file "old" by "new": :% s/old/new/g
Prompt the user to confirm for each replacement action : :s /old/new/c
5、 see file
more file name : Browse all contents of the file ( Space page 、 Enter displays line by line , Exit automatically after display )
less file name : Browse all contents of the file ( Will not exit after display ,:q sign out )
cat [ Options ] file name
-n Number the number of output lines
-b Number the number of non blank lines output
-s When encountering more than two consecutive blank lines , Replace with a blank line
head [ Options ] file name : Look at the first few lines of the file ( Before default 10 That's ok )
-# See the former # That's ok
tail [ Options ] file name : Look at the last few lines of the file ( After default 10 That's ok )
-# Check out the last # That's ok
grep keyword Find the range : Find the matching string , Output all the contents of the line where the matching string is located
example :grep student /etc/passd lookup student In the file /etc/passd Position in
(1) Check the status of open ports
Query open ports netstat -anp
Query whether the specified port is open firewall-cmd --query-port=666/tcp
Tips yes, Open for indication ;no Indicates not on .
(2) View firewall status
View firewall status systemctl status firewalld
Turn on the firewall systemctl start firewalld
Turn off firewall systemctl stop firewalld
Turn on the firewall service firewalld start
If you can't open it
First use :systemctl unmask firewalld.service
then :systemctl start firewalld.service
(3) Foreign development port
Check whether the port you want to open is open :
firewall-cmd --query-port=6379/tcp
Add the specified port to be opened :
firewall-cmd --add-port=123/tcp --permanent
Overload into the added port :
firewall-cmd --reload
Query whether the specified port is opened successfully :
firewall-cmd --query-port=123/tcp
Remove the specified port :
firewall-cmd --permanent --remove-port=123/tcp
边栏推荐
- 調用華為遊戲多媒體服務的創建引擎接口返回錯誤碼1002,錯誤信息:the params is error
- Several methods of calculating the average value of two numbers
- LeetCode 715. Range module
- Nanjing commercial housing sales enabled electronic contracts, and Junzi sign assisted in the online signing and filing of housing transactions
- NCS Chengdu New Electric interview Experience
- 面试题:高速PCB一般布局、布线原则
- 模拟卷Leetcode【普通】1705. 吃苹果的最大数目
- 南京商品房买卖启用电子合同,君子签助力房屋交易在线网签备案
- ncs成都新电面试经验
- Compilation and linking of programs
猜你喜欢
Routing information protocol rip
2022-06-30 Unity核心8——模型导入
let const
2022-07-06 Unity核心9——3D动画
Recommended by Alibaba P8, the test coverage tool - Jacobo is very practical
Analysis of using jsonp cross domain vulnerability and XSS vulnerability in honeypot
数字三角形模型 AcWing 275. 传纸条
ncs成都新电面试经验
Rapid integration of authentication services - harmonyos platform
Category of IP address
随机推荐
Greenplum 6.x build_ install
测试人一定要会的技能:selenium的三种等待方式解读,清晰明了
使用Typora编辑markdown上传CSDN时图片大小调整麻烦问题
channel. Detailed explanation of queuedeclare parameters
Novice entry SCM must understand those things
Greenplum6.x常用语句
oracle一次性说清楚,多种分隔符的一个字段拆分多行,再多行多列多种分隔符拆多行,最终处理超亿亿。。亿级别数据量
Mountaineering team (DFS)
测试踩坑 - 当已有接口(或数据库表中)新增字段时,都需要注意哪些测试点?
路由信息协议——RIP
Greenplum 6.x common statements
Pointer advanced, string function
模拟卷Leetcode【普通】1706. 球会落何处
opencv 将16位图像数据转为8位、8转16
Greenplum6.x重新初始化
数据分析方法论与前人经验总结2【笔记干货】
Isomorphic C language
LeetCode 715. Range module
systemd
Redis summary