SAO operation
(curl wttr.in/hangzhou? lang=zh)
Basic command record
The centos7.x environment uses /usr/share/doc
The installation package is required to run the following commandyum install redhat-lsb
[root@iZbp1g4ytp0whqz29e5dyfZ data]# lsb_release -aLSB Version: : the core - 4.1 - amd64: core - 4.1 - noarch: CXX - 4.1 - amd64: CXX - 4.1 - noarch: desktop - 4.1 - amd64: desktop - 4.1 - noarch: languages - 4.1 - amd64: la Nguages-4.1-noarch: Print-4.1-AMD64: Print-4.1-Noarch Distributor ID: CentOS Description: CentOS Linux release 8.3.2011 release: 8.3.2011 Codename: n/aCopy the code
help
date --helpQuick helpman dateManual Operation Instructions
Yum [option] [parameter] Install software group, system-wide update
Yum not only provides automatic online upgrades, it can also be used for queries, installation of software groups, overall version upgrades, and more
optionThe main parameters include:
- -y: When yum asks a user for comment, it actively answers yes without typing
[Work items queried]: Due to different conditions of use, there are a number of selected items, including:
installSpecify the name of the software to be installedupdateThe act of upgrading as a whole: it is also possible to upgrade only one piece of softwareremoveTo delete a software, follow the software namesearchSearch for software or key keywordslistList all software names and versions currently managed by YUM, somewhat similar to RPM-QAinfoSame as above, but somewhat similar to RPM -qaicleanDownload file is in/var/cache/yum, can use the clean to remove it (items to remove from be packages | headersmetadataI cache, etc.)
The work item part of the query can also have the installation of the entire group software, as follows:
grouplistList all available software groups, such as Development Tools and the likegroupinfoFollowed by group name, you can know all software names contained in the groupgroupinstallThis works! Can install a whole group of software groups, quite good!groupremoveExample Delete a software group
Yum instance
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# yum search nginx
Last metadata expiration check: 0:49:57 ago on Wed 07 Jul 2021 04:52:54 PM CST.
========================================================================================================= Name Exactly Matched: nginx ==========================================================================================================
nginx.x86_64 : A high performance web server and reverse proxy server
======================================================================================================== Name & Summary Matched: nginx =========================================================================================================
collectd-nginx.x86_64 : Nginx plugin for collectd
...
Copy the code
lsView files and directories by yourselfls --help
cpReplicate on their own
Cp [-adfilprsu] source file destination file-a=-drThe commonly used-dCopy link does not copy the file itself-rA recursive copy-iCovering the tip-pTime of the user who has permission to back up commonly copied filescp -ai /data /data/test
rmDelete your own use caution
-fIgnore files that do not exist-iAsking whether the operation is performed-rRecursive deleterm -rf /
mvmobile
mv [-fiu] source destination-fDirect coverage coercion-iAsked to cover-uNewer
dateDisplays the date and time
date +%Y/%m/%dFormatting date
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# date
Thu Jun 24 09:21:43 CST 2021
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# date +%Y/%m/%d
2021/06/24
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# date +%H/%M
09/46
Copy the code
localeDisplays the supported language families
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# localeLANG= en_us.utf-8 // language LC_CTYPE="en_US.UTF-8"// Information output LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"/ / time LC_COLLATE ="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"LC_ALL= // Updated values of all data synchronizationCopy the code
LANG=en_US.utf8Set the language
LANG is related only to the output information. To change other different information, you need to update LC_ALL simultaneously
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# LANG=en_US.utf8
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# export LC_ALL=en_US.utf8
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# locale
LANG=en_US.utf8
LC_ALL=en_US.utf8
Copy the code
calAccording to the calendar
CAL [month] [year]
cal 2021Look at 2021cal 6 2021See June 2021
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# cal
June 2021
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# cal 6 2021
June 2021
Su Mo Tu We Th Fr Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# cal 20212021 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 1 2 3 4 5 6 3 4 5 6 7 8 8 9 7 8 9 10 11 12 13 10 11 12 13 14 15 16 14 15 16 17 18 19 20 14 15 16 17 18 19 20 17 18 19 20 17 18 19 20 17 18 19 20 17 18 19 20 17 18 19 20 21 22 23 21 22 23 24 25 26 27 21 22 23 24 25 26 27 24 25 26 27 28 29 30 28 28 29 30 31 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 1 2 3 4 5 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 18 19 20 21 22 23 24 16 17 18 19 20 21 22 21 22 23 24 25 26 25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 30 31 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 3 4 5 6 7 1 2 3 4 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11 11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18 18 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 25 26 27 28 29 30 31 29 30 31 26 27 28 29 30 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 1 2 3 4 3 4 5 6 7 8 9 7 8 9 10 11 12 13 5 6 7 8 9 10 11 10 11 12 13 14 15 16 14 15 16 17 18 19 20 12 13 14 15 16 17 18 17 18 19 20 21 22 23 21 22 23 24 25 26 27 19 20 21 22 23 24 25 24 25 26 27 28 29 30 28 29 30 26 27 28 28 29 and 30 and 31Copy the code
bcThe calculator
+ - * /^index%remainderscale=3Specify decimal placesA third = >. 333quitexit
[root@iZbp1g4ytp0whqz29e5dyfZ dev]# bcCopyright 1991-1994, 1997, 1998, 2000, 2004, 2006, 2008, 2012-2017 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For detailstype `warranty'. 2+5 7 *8 64Copy the code
man dateparsing
man manYou can view the details directlyDATE(1)1 indicates the commands or executable files that can be operated by ordinary users. See Table 1 belowNAMEThe command nameSYNOPSISBasic usageDESCRIPTIONDetailed instructionsENVIRONMENTEnvironmental parameters
othermanrelated
man -f manDocumentation related to MAN- abbreviations
whatisCommand or file dependencymandb
- abbreviations
man 1 manDescription file of 1man 7 manDescription file for 7man -k manInclude keywords- abbreviations
aproposCommand or file dependencymandb
- abbreviations
Table 1
| Code name | On behalf of the content |
|---|---|
| 1 | Commands or executable files that users can operate in the shell environment |
| 2 | System kernel can call the function and tools |
| 3 | Common functions (functions) and libraries (libraries), mostly C(liBC) |
| 4 | Description of device files, usually under /dev |
| 5 | Configuration file or some file format |
| 6 | The game |
| 7 | Conventions and protocols, such as file systems, network protocols, ASCII descriptions |
| 8 | Management commands available to the system administrator |
| 9 | Kernel-related files |
DATE(1) User Commands DATE(1)
NAME
date - print or set the system date and time
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION
Display the current time in the given FORMAT, or set the system date.
Mandatory arguments to long options are mandatory for short options too.
EXAMPLES
...
Copy the code
info page
Web page data displayed in command line mode, /usr/share/info
info info
Next: Standalone Info, Up: (dir) Standalone GNU Info ******************** This document describes a stand-alone information reader that you can use to read information documents. If you are not familiar with an information reader, you can start by typing'H'Represents a list of base key bindings. You can read through the rest by typing <SPC> and <DEL> (or <Space> and <Backspace>) to see the manual moving forward and backward in it. * Menu: * Stand-alone Info:: What is Info? * Invoking Info:: Options you can pass on thecommand line.
* Cursor Commands:: Commands which move the cursor within a node.
* Scrolling Commands:: Commands for reading the text within a node.
* Node Commands:: Commands for selecting a new node.
* Searching Commands:: Commands for searching an Info file.
* Index Commands:: Commands for looking up in indices.
* Xref Commands:: Commands for selecting cross-references.
* Window Commands:: Commands which manipulate multiple windows.
* Printing Nodes:: How to printout the contents of a node. * Miscellaneous Commands:: A few commands that defy categorization. * Variables:: How to change the default behavior of Info. * Colors and Styles:: Customize the colors used by Info. * Custom Key Bindings:: How to define your own key-to-command bindings. * Index:: Global Index. * Menu: * Independent information :: What is information? * Call Info:: options that you can pass on the command line. * Cursor command :: Command to move the cursor within a node. * Scroll command :: command used to read text inside a node. * Node command :: Command used to select a new node. * Search command :: Command used to search information files. * Index command :: command used to look up in an index. * External reference commands :: commands used to select cross-references. * Window commands :: Commands that manipulate multiple Windows. * Print node :: How to print out the contents of a node. * Miscellaneous commands: Some commands that cannot be classified. * Variables :: How to change the default behavior of information. * Colors and styles :: Customize the colors used for messages. * Custom key bindings :: How to define your own key to command bindings. * Index :: global index.Copy the code
Shut down the
syncSynchronize data to some human disks- Only the root account can update data in the entire system. An individual account can update only its own data
shutdownTo turn it offShotdown [-KRHC] [Time] [warning message]-kDon’t turn it off, just send a warning messageShutdown -k now 'Shutdown'-rAfter stopping the system service, restart it (common)shutdown -r nowShutdown -r +30 'System will restart in 30 minutes'-hPower off after shutting down system service (often used)shutdown -h 20:22-cCancel the shotdown command in progressShutdown -h 10 '10 minutes after shutdown 'Shutdown scheduled for Thu 2021-06-24 14:08:01 CST, use 'shutdown -c' to cancel.- If no operating system is added, the system will be shut down in one minute
reboot/halt/poweroffRestart thesync; sync; sync; reboothaltThe system stop screen may retain stop informationpoweroffSystem shutdown screen blank
Systemctl [the halt/poweroff/reboot/suspend (sleep)]systemctl rebootrestart
File permissions
/etc/passwdSystem account
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
...
Copy the code
/etc/shadowPersonal password
/etc/groupGroup name
-File /dDirectory attribute
| permissions | link | The owner | User groups | The file size | Modification date | The file name |
|---|---|---|---|---|---|---|
| -rw——- | 1 | root | root | 2342 | The 2021-06-21 09:23:18. 555835553 + 0800 | .bash_history |
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# ls -al --full-timeTotal 32 DR-xr-x --. 6 root root 202 2021-06-21 09:23:18.555835553 + 0800. dr-xr-xr-x. 18 root root 256 2021-06-17 16:31:20. 732426568 + 0800.. -rw------- 1 root root 2342 2021-06-24 13:09:28.756957281 + 0800. bash_history -rw-r--r--. 1 root root 18 2019-05-11 23:33:50.000000000 + 0800.bash_logout-rw-r --r-- 1 root root 176 2019-05-11 23:33:50.000000000 + 0800.bash_profile -rw-r--r--. 1 root root 176 2019-05-11 23:33:50.000000000 + 0800. bashrc DRWX ------ 3 root root 17 2021-04-20 Cache -rw-r--r-- 1 root root 100 2019-05-11 23:33:50.000000000 + 0800. CSHRC drwxr-xr-x 2 root Root 45 2021-06-17 16:31:27.522526144 + 0800. NVM drwxr-xr-x 2 root root 22 2021-04-20 12:11:58.322875714 + 0800. PIP -rw-r--r-- 1 root root 206 2021-05-27 18:04:06.972567392 + 0800. pydistutils. CFG DRWX ------ 2 root root 29 2021-04-20 12 18:16.779957288 + 0800. ssh-rw-r --r-- 1 root root 129 2019-05-11 23:33:50.000000000 + 0800. TCSHRC -rw------- 1 root Root 1510 2021-06-21 09:23:18.555835553 + 0800.viminfoCopy the code
explain-rw-r--r--.
1The file type-On behalf of the filedOn behalf of the directorylLink to the filebPeripheral devicescSerial ports such as mouse and keyboard
A 234 - bitFile owner rightsA 567 - bitUser Group PermissionsA 890 - bitOther accounts that are not my own and do not have the permission to join this user grouprforreadreadwforwritewritexforexecuteperform- If no permission is displayed
-
Modify file properties and permission user group owner
chgrpModifying a User Groupchgrp [-R] dirname/filename-RMake recursive changes to both files and folders in the directorychgrp users test.txt- See below for examples
code1chgrp users user.txt
chownModify ownerChown [-r] Name of the account dirname/filenameChown [-r] Account name: user group name dirname/filename- See below for examples
code2chown bin user.txt
chmodModify file permissions- Number type modification permission
r:4 w:2 x:1chmod [-R] xyz dirname/filenam- See below for examples
code3chmod 777 user.txt
- Permission to modify symbol types
-
u:user g:group o:other a:all -
Code4 chmod u= RWX,go=rx user.txt
-
+: Join -: Remove =: Set -
See code5 chmod a+w user.txt for an example
-
code5chmod a-x user.txt
-
- Number type modification permission
code1
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
-rw-r--r-- 1 root root 0 Jun 24 16:00 user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chgrp users user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
-rw-r--r-- 1 root users 0 Jun 24 16:00 user.txt
Copy the code
code2
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chown bin user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
-rw-r--r-- 1 bin users 0 Jun 24 16:00 user.txt
Copy the code
code3
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chmod 777 user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
-rwxrwxrwx 1 bin users 0 Jun 24 16:00 user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]#
Copy the code
code4
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chmod u=rwx,go=rx user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
-rwxr-xr-x 1 bin users 0 Jun 24 16:00 user.txt
Copy the code
code5
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chmod a+w user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
-rwxrwxrwx 1 bin users 0 Jun 24 16:00 user.txt
Copy the code
Complete example of file permissions
[root@iZbp1g4ytp0whqz29e5dyfZ data]# mkdir testing
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
drwxr-xr-x 2 root root 6 Jun 24 16:47 testing
-rwxrwxrwx 1 bin users 0 Jun 24 16:00 user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chmod 744 testing/
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ll
total 0
drwxr--r-- 2 root root 6 Jun 24 16:47 testing
-rwxrwxrwx 1 bin users 0 Jun 24 16:00 user.txt
[root@iZbp1g4ytp0whqz29e5dyfZ data]# touch testing/testing
[root@iZbp1g4ytp0whqz29e5dyfZ data]# chmod 600 testing/testing
[root@iZbp1g4ytp0whqz29e5dyfZ data]# ls -ald testing/ testing/testing
drwxr--r-- 2 root root 21 Jun 24 16:49 testing/
-rw------- 1 root root 0 Jun 24 16:49 testing/testing
Copy the code
File and directory management
Directory based
.This layer directory.Represents the directory at the previous level-Represents the previous working directory~Represents the home directory of the current user~accountRepresents the user home directory of the secondary accountcdSwitch directorypwdShow current directorypwd -PDisplay the real path instead of the link
mkdirCreate a new directoryMkdir [-mp] Specifies the directory name- -m Sets file permissions
- -p Creates a directory recursively
mkdir test1/test2/test3An error is reported by adding -pmkdir -m 711 test2Specify permissions and create folders
rmdirDelete an empty directoryRmdir -p Directory nameRecursive deletels -ld test*Viewing the Number of directories
Execute the file path variable
Add a variable PATH = “${PATH} : / root/NVM/versions/node/v14.15.0 / bin:”
[root@iZbp1g4ytp0whqz29e5dyfZ data]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
Copy the code
Change the PATH
export PATH=/usr/local/mongodb/bin:$PATH
| Change the method | Effective method | Valid term | User limits |
|---|---|---|---|
| Modify in terminal | Effective immediately | The current terminal window | The current user |
| Modify bashrc. | source ~/.bashrc/ heavy into |
permanent | Only for the current user |
| Modify the profile | System Restartsource /etc/profile/ heavy into |
permanent | All users |
| To modify the environment | System restart | permanent | All users |
Modify the PATH on the terminal
Enter the export PATH = / root/NVM/versions/node/v14.15.0 / bin: $PATH export PATH = / root/NVM/versions/node/v14.15.0 / bin/node: $PATHCopy the code
Modify bashrc.
Vim ~/.bashrc adds the following to the last line:exportPATH = / root/NVM/versions/node/v14.15.0 / bin:$PATH
Copy the code
Modify the profile
vim /etc/profile
/exportPATH // Find the row to set PATH to addexport PATH=/usr/local/mongodb/bin:$PATH
Copy the code
Modify the environment file
Vim/etc/environment in PATH ="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"Add: / usr /local/mongodb/bin
Copy the code
Common environment variables
PATHDetermines which directories the shell will look for commands or programsHOMECurrent user home directoryHISTSIZEHistorical record numberLOGNAMEThe login name of the current userHOSTNAMEIndicates the name of the hostSHELLShell type of the current userLANGUGELanguage-specific environment variables that can be modified for multiple languagesMAILThe mail directory of the current userPS1The basic prompt, # for root and $for ordinary users
Cat /more/less View file contents
catStarting from the first line of display directly viewing the contents of a file can be used- cat [-AbEnTv]
- [Fixed] an integration option equivalent to -vet that lists special characters instead of whitespace.
- -b Displays the line numbers only for non-blank lines. Blank lines are not marked with line numbers.
- -e displays the trailing newline character $;
- -n prints the travel number, which also has the line number along with the blank line, unlike the -b option;
- -t displays the [TAB] key as ^I;
- -v: lists some special characters that cannot be seen.
- cat -n /etc/issue
tacFrom the last – line displayed, you can see that TAC is written backwards for cat.Nl - BNW fileWhen displayed, print the line number.moreDisplay file contents page by page.lessSimilar to more, but better than more, it can scroll forward. Head only looks at the first few lines.tail [-n number]Just look at the last few lines.- -n 10 represents several lines
- -f Continuously refreshes the contents of subsequent files
- tail -n 20 /var/log/message
- tail -f 20 /var/log/message
odRead file contents in binary mode.
Take 11-20 lines head – n 20 / etc/man_db. Conf | tail -n 10
Take 11-20 lines and line number cat – n/etc/man_db. Conf | head – n 20 | tail -n 10
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# cat -n /etc/man_db.conf | head -n 20 | tail -n 10
11 # -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
12 # MANDATORY_MANPATH manpath_element
13 # MANPATH_MAP path_element manpath_element
14 # MANDB_MAP global_manpath [relative_catpath]
15 # -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
16 # every automatically generated MANPATH includes these fields
17 #
18
#MANDATORY_MANPATH /usr/src/pvm3/man
19 #
20 MANDATORY_MANPATH /usr/man
Copy the code
Default file permission umask [-s]
File hiding attribute chattr [+-=] [ASacdistu] File or directory
- Chattr [+-=] [ASacdistu] File or directory
- Lsattr [-ADR] File or directory
File special permission: SUID SGID SBIT
Too many. I just need to read the message
Observe the file type: file
[admin@jw-test ~]$ file ~/.bashrc
/home/admin/.bashrc: ASCII text
Copy the code
Command and file lookup
Which [-a] command finds the execution file
[admin@jw-test ~]$ which -a node
/usr/bin/node
[admin@jw-test ~]$ which node
/usr/bin/node
[admin@jw-test ~]$ which ifconfig
/usr/sbin/ifconfig
[admin@jw-test ~]$ which which
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
/usr/bin/alias
/usr/bin/which
[admin@jw-test ~]$ which history // history/usr/bin/is not found because it is the bash built-in commandwhich: no history in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/admin/.local/bin:/home/admin/bin)
Copy the code
File finds whereis [-nmsu] file or directory
[admin@jw-test ~]$ whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
[admin@jw-test ~]$ whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz
Copy the code
locate [-iclSr] keyword
[admin@jw-test ~]$ locate nginx.conf
/etc/nginx/nginx.conf
/etc/nginx/nginx.conf.default
Copy the code
Update your own database once a day
find [PATH] [option] [action]
- Atime n: files read in the last n days
- Cmin n: the value has been modified in the last n minutes
- Cnewer file: newer files than file
- Ctime n: indicates the file that was modified in the last n days
- mtime [num+-]
+ 4Five days ago4 -Less than or equal to 4 days44 to 5 that day
- .
Simple operation of the file system
Df [-ahikhtm] [Directory or file name] lists the total disk usage of the file system
Df command parameter Function: Check the disk space usage of the file system. You can use this command to obtain information such as how much space is occupied and how much space is left.
- -a: Lists all file systems, including system-specific file systems such as /proc.
- -k: Displays each file system in KBytes.
- -m: Displays file systems in the capacity of MBytes.
- -h: displays itself in easy-to-read formats such as GBytes, MBytes, and KBytes.
- -h: replaces M=1024K with M=1000K.
- -t: displays the filesystem type and the filesystem name (for example, ext3) of the partition.
- -i: indicates the number of inodes instead of disk capacity
[admin@jw-test /]$df List all file systems in the system! Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 7768864 0 7768864 0% /dev tmpfs 7779208 0 7779208 0% /dev/shm tmpfs 7779208 1264 7777944 1% /run tmpfs 7779208 0 7779208 0% /sys/fs/cgroup /dev/vda1 103080204 74690584 23969392 76% / tmpfs 1555844 0 1555844 0% /run/user/0 tmpfs 1555844 0 1555844 0% /run/user/1000 [admin@jw-test /]$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.5g 0 7.5g 0% /dev TMPFS 7.5g 0 7.5g 0% /dev/ SHM TMPFS 7.5g 1.3m 7.5g 1% /run TMPFS 7.5g 0 7.5g 0% /sys/fs/cgroup /dev/vda1 99G 72G 23G 76% / TMPFS 1.5g 0 1.5g 0% /run/user/0 TMPFS 1.5g 0 1.5g 0% /run/user/1000 [admin@jw-test /]$df -at List all special file formats and names in the system. Filesystem Type 1K-blocks Used Available Use% Mounted on sysfs sysfs 0 0 0 - /sys proc proc 0 0 0 - /proc devtmpfs devtmpfs 7768864 0 7768864 0% /dev securityfs securityfs 0 0 0 - /sys/kernel/security tmpfs tmpfs 7779208 0 7779208 0% /dev/shm devpts devpts 0 0 0 - /dev/pts tmpfs tmpfs 7779208 1264 7777944 1% /run tmpfs tmpfs 7779208 0 7779208 0% /sys/fs/cgroup cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd pstore pstore 0 0 0 - /sys/fs/pstore cgroup cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct cgroup cgroup 0 0 0 - /sys/fs/cgroup/hugetlb cgroup cgroup 0 0 0 - /sys/fs/cgroup/pids cgroup cgroup 0 0 0 - /sys/fs/cgroup/blkio cgroup cgroup 0 0 0 - /sys/fs/cgroup/perf_event cgroup cgroup 0 0 0 - /sys/fs/cgroup/memory cgroup cgroup 0 0 0 - /sys/fs/cgroup/freezer cgroup cgroup 0 0 0 - /sys/fs/cgroup/devices cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpuset configfs configfs 0 0 0 - /sys/kernel/config /dev/vda1 ext4 103080204 74690852 23969124 76% / systemd-1 - - - - - /proc/sys/fs/binfmt_misc mqueue mqueue 0 0 0 - /dev/mqueue hugetlbfs hugetlbfs 0 0 0 - /dev/hugepages debugfs debugfs 0 0 0 - /sys/kernel/debug tmpfs tmpfs 1555844 0 1555844 0% /run/user/0 tmpfs tmpfs 1555844 0 1555844 0% /run/user/1000 sunrpc rpc_pipefs 0 0 0 - /var/lib/nfs/rpc_pipefs nfsd nfsd 0 0 0 - /proc/fs/nfsd binfmt_misc binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc [admin@jw-test /]$ df -h /home/ Filesystem Size Used Avail Use% Mounted on /dev/vda1 99G 72G 23G 76% /Copy the code
Du: Checks the disk space usage
Fdisk: used for disk partitions
It’s been modified in the last 24 hours
Jw - test ~] [admin @ $find / - mtime 0 / TMP/TMP/tomcat - the docbase. 3093306490971783601.9107 / TMP/yum_save_tx. 2021-06-29. 15-07. BLToON. Yumtx/TMP/SSH - hGNomDUh7i/TMP/SSH - hGNomDUh7i/agent. 13153Copy the code
Compare the old and new files
[admin@jw-test ~]$ find /data/nodesh/ypt-admin-nuxt/ypt-admin-nuxt-v2.zip /data/nodesh/cloud_platform_admin/cloud_platform_admin.zip
/data/nodesh/ypt-admin-nuxt/ypt-admin-nuxt-v2.zip
/data/nodesh/cloud_platform_admin/cloud_platform_admin.zip
Copy the code
chown admin:admin -R ./cloud_platform_admin/
Copy the code
Touch [-acdmt] Creates a file
An impure text fileod
- – t type
- A is printed as the default character
- C The output is in ASCII characters
- D a decimal
- F floating point number
- O octal
- X hexadecimal
[admin@jw-test data]$ od -t c /usr/bin/passwd
0000000 177 E L F 002 001 001 \0 \0 \0 \0 \0 \0 \0 \0 \0
Copy the code
In js ‘2’ > ’11’ // true, liunx can be used to view the ASCII values of ‘2’ greater than ’11’
[admin@jw-test. Pm2]$node Welcome to node.js v16.4.0.type".help" for more information.
> '1'>'11'
false
> '2'>'11'
true
>
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
>
[admin@jw-test .pm2]$ echo '2' | od -t oCc
0000000 062 012
2 \n
0000002
[admin@jw-test .pm2]$ echo '11' | od -t oCc
0000000 061 061 012
1 1 \n
0000003
Copy the code
The sample
Copy files to other users
- Copy the file
cp ~/.bashrc ~admin/bashrc - Modify the permissions
chowm admin:admin ~admin/bashrc
Create a directory for admin account management, other people can not modifydrwxr-xr-x
- Create a directory:
mkdir /data/admin - Modify attributes:
chown -R admin:admin /data/admin - Modify permission:
chmod -R 755 /data/admin
Netstat View local and network connection backdoors
- netstat
[rn]Routing related - netstat
[antulpc]Parameters related to the network interface
List the routing table status
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 1.1.1.253 0.0.0.0 UG 0 0 0 eth0
1.1.1.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
Copy the code
Lists all current network connections
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# netstat -anActive Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN TCP 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN TCP 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN... unix 3 [ ] STREAM CONNECTED 21941 /run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 21839 unix 2 [ ] DGRAM 19596 unix 2 [ ] STREAM CONNECTED 10886707 unix 2 [ ] STREAM CONNECTED 10886752 unix 3 [ ] STREAM CONNECTED 226275 Active Bluetooth connections (servers and established) Proto Destination Source State PSM DCID SCID IMTU OMTU Security Proto Destination Source State ChannelCopy the code
Lists the network services that have been started
[root@iZbp1g4ytp0whqz29e5dyfZ ~]# netstat -tulnpActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 33822/nginx: Master TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 694897/ SSHD TCP 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 39208/ SRC /redis-ser tcp6 0 0 :::80 :::* LISTEN 33822/nginx: master tcp6 0 0 :::33060 :::* LISTEN 31374/mysqld tcp6 0 0 :::3306 :::* LISTEN 31374/mysqld tcp6 0 0 :::6379 :::* LISTEN 39208/ SRC /redis-ser UDP 0 0 127.0.0.1:323 0.0.0.0:* 694929/chronyd UDP6 0 0: :1:323 ::* 694929/chronydCopy the code
Which file is used to set the mapping between the service name and port Number?
/etc/services
Text interface downloader Wget
- Wget [option]
vim /etc/wgetrcSet the agent
SSH Text interface to connect to the server
- /etc/init.d/ SSHD restart
- netstat -tlnp | grep ssh
- Log in to the remote host using SSH [email protected] -p 22
- To be continued
SFTP Simulates file transfer through FTP
- SFTP [email protected]
Examples of operation
Upload /etc/hosts on the local PC to the admin directory as user admin and copy. Bashrc to the/TMP directory on the local PC
SFTP > SFTP [email protected] // Log in to SFTP > put /etc/hosts // Upload SFTP > get. Bashrc // Download SFTP >exit/ / exitCopy the code
SCP files are directly copied remotely
- SCP [-pr] [-l rate] file [account @] Host: directory name // Upload
- SCP [-pr] [-l rate] [account @] Host :file Directory name // Download
Other temporary
[root@iZbp1he26e8gmdfzc9162rZ logs]# ps -ef | grep 9452
root 9452 24517 0 11:03 ? 00:00:00 node /data/nodesh/ypt-public-nuxt-express/src/index.js
root 10145 22214 0 11:04 pts/4 00:00:00 grep --color=auto 9452
// PID 9452
[root@iZbp1he26e8gmdfzc9162rZ logs]# ps -x | grep 94529452? Ssl 0:00 node /data/nodesh/ypt-public-nuxt-express/src/index.js // PID 10938 [root@iZbp1he26e8gmdfzc9162rZ logs]# netstat -anp | grep 3000
tcp6 0 0 :::3000 :::* LISTEN 10938/node /data/no
// PID 10938
[root@iZbp1he26e8gmdfzc9162rZ logs]# ps aux | grep nodeRoot 10938 0.4 0.1 632944 27568? Ssl 11:06 0:00 node /data/nodesh/ypt-public-nuxt-express/ SRC /index.js root 11577 0.0 0.0 112808 968 PTS /4 S+ 11:07 0:00 Grep --color=auto node root 12378 0.1 0.1 625304 22632? Ssl 10:17 0:03 node /data/nodesh/ypt-admin-nuxt/start.js root 12390 0.1 0.1 625092 22580? Ssl 10:17 0:04 node /data/nodesh/ypt-admin-nuxt-2/start.js root 12455 0.0 0.6 994372 105772? Sl 10:17 0:02 node /data/nodesh/ypt-admin-nuxt/node_modules/. Bin /nuxt start root 12462 0.0 0.5 966500 80468? Sl 10:17 0:02 node /data/nodesh/ypt-admin-nuxt-2/node_modules/.bin/nuxt start [root@iZbp1he26e8gmdfzc9162rZ logs]# ps aux | grep pm2Admin 1452 0.0 0.2 910340 34560? Ssl May26 6:21 PM2 v4.5.6: God Daemon (/home/admin/.pm2) root 3949 0.0 0.2 840644 42532? Ssl May06 0:19 PM2 v4.5.6: God Daemon (/root/.pm2) root 5954 0.0 0.1 632736 28248? Ssl 10:33 0:00 PM2 v4.5.6: God Daemon (/root/.pm2) dev 9070 0.0 0.2 828044 36464? Ssl 2020 12:55 PM2 V4.4.1: God Daemon (/home/dev/.pm2) root 11976 0.0 0.0 112812 968 PTS /4 S+ 11:08 0:00 grep --color=auto pm2 root 24517 0.0 0.2 910804 40004? Ssl May26 17:32 PM2 v4.5.6: God Daemon (/root/.pm2) dev 26431 4.9 13.8 2976332 2222308? Ssl May06 3529:07 PM2 v4.5.6: God Daemon (/home/dev/.pm2)Copy the code
To be continued
The article is constantly updated as I progress