This paper is participating in the30 years of Linux”Topic essay activity
🌲 preface
Why learn Linux commands?
At present, more than 80% or even more systems in enterprises are Linux operating system, so whether it is development or operation and maintenance, it is impossible to work in enterprises without knowledge of Linux. Also, Linux proficiency is part of the job description in many companies.The direction of Linux is also relatively wide, mainly divided intooperations
和 The development of
, subdivide down numerous, basic will be involved, so learn Linux urgent. This article is a summary of common Linux commands I’ve learned over the years! Very full! More detailed! Package learning package meeting!
🏆 Command Summary
🍇 File Management
1️ discount command – display content and property information under the specified working directory
The ls command is an abbreviation of the English word list. As the English word list means, its function is to list the contents of a specified directory and related attribute information.
By default, the ls command lists the contents of the current directory. With parameters, we can do a lot more with LS. As the most basic and frequently used command, it is important to know how to use the ls command, so let’s take a look.
Grammar:
Syntax: ls [option] [file]
Common parameters:
parameter | describe |
---|---|
-a | Display all files and directories (including “. Hidden files at the beginning) |
-l | List file and directory information in long format |
-r | Display files in reverse order (default alphabetical order) |
-t | Sort by last modified time |
-A | Same as -a, but without listing “. (current directory) and “..” (Parent directory) |
-S | Sort by file size |
-R | Recursively lists all subdirectories |
Reference Examples:
List all files (including hidden files) :
ls -a
Copy the code
List file details:
ls -l
Copy the code
List all directories under root (/) :
ls /
Copy the code
List all files in the current working directory whose names start with ‘s’ (excluding folders) :
ls -ltr s*
Copy the code
List all directories and files in /root directory:
ls -lR /root
Copy the code
List all files and directories in the current working directory and sort by file size:
ls -AS
Copy the code
2️ retail command – copy files or directories
The cp command can be understood as the abbreviation of copy. It copies files or directories.
The cp command can copy multiple files to a specific file name or an existing directory, or to a specified directory at the same time.
Grammar:
Syntax: cp [parameter] [file]
Common parameters:
parameter | describe |
---|---|
-f | If the destination file already exists, the original file is overwritten |
-i | If the target file already exists, it will ask whether to overwrite it |
-p | Preserve all attributes of the source file or directory |
-r | Recursively copy files and directories |
-d | When a symbolic link is copied, the target file or directory is also set up as a symbolic link, pointing to the original file or directory connected to the source file or directory |
-l | Hardwire source files instead of copying them |
-s | Make symbolic links to source files instead of copying files |
-b | Back up an existing file target before overwriting it |
-v | The cp command is displayed in detail |
-a | Equivalent to “DPR” option |
Reference Examples:
Copy directory:
cp -R dir1 dir2/
Copy the code
Rename file test1 to test2:
cp -f test1 test2
Copy the code
Copy multiple files:
cp -r file1 file2 file3 dir
Copy the code
Interactively copy all. C files in /home/lucifer to dir:
cp -r /home/lucifer/*.c dir
Copy the code
3️ mkdir command – create a directory
The mkdir command is short for “make directories” and is used to create directories.
📢 Note: By default, if the directory to be created already exists, the system displays a message indicating that the directory already exists and does not continue to be created. Therefore, when creating a directory, ensure that the new directory does not have the same name as the files in the directory. Isn’t the mkdir command powerful enough to create multiple directories at the same time?
Grammar:
Syntax: mkdir [parameter] [directory]
Common parameters:
parameter | describe |
---|---|
-p | Create multilevel directories recursively |
-m | When creating a directory, set the permission of the directory |
-z | Setting the Security Context |
-v | Shows the directory creation process |
Reference Examples:
In the working directory, create a subdirectory named dir:
mkdir dir
Copy the code
Create a subdirectory dir under the /home/lucifer directory and set the file owner to have read, write, and execute permissions.
mkdir -m 700 /home/lucifer/dir
Copy the code
Create subdirectories dir1, dir2, dir3:
mkdir dir1 dir2 dir3
Copy the code
Create a directory recursively:
mkdir -p lucifer/dir
Copy the code
4️ discount command — move or rename files
The mv command is an abbreviation of the word “move”. It does much the same as it does in English: you can move or rename a file.
This is an overused file management command, and we need to pay special attention to the difference between it and copy: mv and CP have different results. The mv command looks like the file “move”, with the file name changed but the number of files not increased. The cp command is used to copy files and the number of files is increased.
Grammar:
Syntax: mv [parameter]
Common parameters:
parameter | describe |
---|---|
-i | If a file with the same name exists, the system asks the user whether to overwrite it |
-f | When overwriting an existing file, no prompt is given |
-b | When a file exists, create a backup of it before overwriting it |
-u | This operation is performed only when the source file is newer than the destination file or the destination file does not exist |
Reference Examples:
Rename file file_1 to file_2:
mv file_1 file_2
Copy the code
Move the file file to the directory dir:
mv file /dir
Copy the code
Move directory dir1 to directory dir2 (if directory dir2 already exists, rename it if it does not) :
mv /dir1 /dir2
Copy the code
Move files from directory dir1 to the current directory:
mv /dir1/* .
Copy the code
5️ PWD command – displays the current path
The PWD command is an acronym for each word in “print working Directory”. Its function is to print the working directory, that is, to display the absolute path of the current working directory.
In practice, we often switch between different directories. To prevent “getting lost”, we can use the PWD command to quickly see the directory path we are currently in.
Grammar:
Syntax: PWD [parameter]
Common parameters:
parameter | describe |
---|---|
-L | Display logical paths |
Reference Examples:
View the current working directory path:
pwd
Copy the code
🍉 Document editing
1️ retail command – display file content on terminal devices
The command “cat” is also easy to remember, because cat means “cat” in English. Does a kitten give you a feeling of being small and cute?
📢 Note: When the file content is large, the text will flash quickly on the screen (scrolling), and users often cannot see the specific content displayed.
Therefore, for longer file contents:
- Press Ctrl+S to stop scrolling;
- Press Ctrl+Q to resume scrolling;
- To terminate the command, press Ctrl+C (Interrupt).
Or for large files, use the more command.
Grammar:
Syntax: cat [parameter] [file]
Common parameters:
parameter | describe |
---|---|
-n | Display number of lines (blank lines are also numbered) |
-s | Display number of lines (multiple blank lines count as one number) |
-b | Display number of lines (blank lines are not numbered) |
-E | The $sign is displayed at the end of each line |
-T | Displays the TAB character as the ^I symbol |
-v | Use ^ and M- references, except for LFD and TAB |
-e | Equivalent to the “-ve” combination |
-t | Equivalent to the “-vt” combination |
-A | Equivalent to the -vet combination |
–help | Display help information |
–version | Display version Information |
Reference Examples:
View the contents of the file:
cat lucifer.log
Copy the code
View the contents of the file and display the line number:
cat -n lucifer.log
Copy the code
View the contents of the file and add the line number to the output of another file:
cat -n lucifer.log > lucifer.txt
Copy the code
Clear the contents of the file:
cat /dev/null > /root/lucifer.txt
Copy the code
Continue writing the contents of the file, ending when EOF is encountered and saving:
cat > lucifer.txt <<EOF Hello, World Linux! EOF
Copy the code
To make an image file of a floppy disk device:
cat /dev/fb0 > fdisk.iso
Copy the code
2️ retail echo command – output string or extract the value of Shell variable
The echo command is used to output the extracted value of a string or variable on a terminal device. This is one of the most common commands in Linux, but the operation is very simple.
The value of a variable is extracted by adding a symbol to it. For example, the value of a variable is extracted by using a symbol, such as PATH, and then the echo command is used to output the value. Alternatively, use the echo command to output a string to the screen to prompt the user.
Grammar:
Echo [parameter] [string]
Common parameters:
parameter | describe |
---|---|
-n | No trailing newline character is printed |
– e “\” | Sound a warning note |
– e “\ b” | Deletes the preceding character |
– e “\ c” | End without a newline character |
– e “\ f” | Newline, the cursor stays at the original coordinate position |
– e “\ n” | Newline, cursor moved to the beginning of the line |
– e “\ r” | Cursor moves to the beginning of the line without newline |
-E | Disallows backslash transfer, as opposed to the -e parameter |
– the version | Viewing version Information |
–help | Viewing Help Information |
Reference Examples:
Print a string:
echo "Hello Lucifer"
Copy the code
Output variable extracted value:
echo $PATH
Copy the code
Escape the content to disallow the $symbol to extract the value of the variable:
echo \$PATH
Copy the code
Import string information into a file with the output redirection:
echo "It is a test" > lucifer
Copy the code
Execute the command with backquotes and print the result to the terminal:
echo `date`
Copy the code
Output content with a newline character:
echo -e "a\nb\nc"
Copy the code
Delete a character from the output. Note that the number 3 is missing:
echo -e "123\b456"
Copy the code
3️ discount command – remove files or directories
The rm command is commonly used to delete one or more files or directories in a directory. It can also delete all files and subdirectories in a directory. For linked files, only the link is deleted, and the original files remain unchanged.
📢 Note: rm is also a dangerous command and should be used with extreme care, especially for beginners, otherwise the entire system will be destroyed by this command (e.g. Rm * -rf under/(root)).
Therefore, before executing rm, it is best to confirm which directory to delete and keep a high level of sanity.
Grammar:
Syntax: rm [parameter] [file]
Common parameters:
parameter | describe |
---|---|
-f | Ignore nonexistent files and no warning message appears |
-i | The system asks the user whether to perform the deletion |
-r/R | Recursive delete |
-v | Display the detailed execution process of the command |
Reference Examples:
Ask and confirm before deleting:
rm -i test.txt.bz2
Copy the code
Delete directly without any prompt:
rm -f test.txt.bz2
Copy the code
Recursively delete a directory and all files in it:
mkdir /data/log
rm -rf /data/log
Copy the code
Delete all files in current directory:
rm -rf *
Copy the code
Clear all files from the system (caution) :
rm -rf /*
Copy the code
4️ retail command – View the contents of the tail of the file
Tail Displays the contents at the end of a file. By default, the last 10 lines of a specified file are displayed on the screen. If more than one file is given, each file displayed is preceded by a filename title. If no file is specified or the file name is -, the standard input is read.
Grammar:
Syntax: tail [parameter]
Common parameters:
parameter | describe |
---|---|
–retry | Always try to open the file, either when the tail command starts or when the file becomes inaccessible later. Use this option in conjunction with the option — follow=name |
– or – bytes = c | Output N (N is an integer) bytes of content at the end of the file |
-f<name/descriptor> | –follow: Displays the latest content appended to the file |
-F | This function is the same when used with the -follow=name and –retry options |
N or — — – line = | The N (N digit) lines at the end of the output file |
–pid=< process number > | When used with the -f option, the tail command automatically exits after the process with the specified process id terminates |
–help | Displays help information for commands |
–version | Displays the version information of the command |
Reference Examples:
Display the last 10 lines of file:
tail file
Copy the code
Display the contents of file from line 20 to the end of the file:
tail +20 file
Copy the code
Display the last 10 characters of file:
tail -c 10 file
Copy the code
Files that keep changing always show the last 10 lines:
tail -f 10 file
Copy the code
Display help information:
tail --help
Copy the code
5️ retail command – delete an empty directory
The rmdir command is used to remove an empty directory. Its full name is remove directory.
Note: the rmdir command can only delete empty directories. To delete a non-empty directory, use the rm command with the “-r” option.
The “-p” parameter of the rmdir command can recursively delete a specified multi-level directory, but each directory must also be empty.
Grammar:
Syntax: rmdir [parameter] [directory name]
Common parameters:
parameter | describe |
---|---|
-p | Delete all parent directories in the specified directory path recursively. If they are not empty, an error is reported |
–ignore-fail-on-non-empty | Ignore error messages caused by command errors when deleting a non-empty directory |
-v | Displays the detailed execution process of commands |
–help | The help information about the command is displayed |
–version | The command version information is displayed |
Reference Examples:
Delete an empty directory:
rmdir dir
Copy the code
Delete the specified directory tree recursively:
rmdir -p dir/dir_1/dir_2
Copy the code
Display the detailed execution process of instructions:
rmdir -v dir
Copy the code
Display the version information of the command:
rmdir --version
Copy the code
🍋 System Management
1️ RPM command – RPM package manager
The RPM command is short for red-hat Package Manager (RPM Package Manager). It is used to manage software packages in Linux. In Linux, almost all software can be installed, uninstalled, and managed through RPM.
In summary, the RPM command contains five basic functions: install, uninstall, upgrade, query, and verify.
Grammar:
RPM [parameter] [package]
Common parameters:
parameter | describe |
---|---|
-a | Example Query all software packages |
– b or – t | Sets the completion stage of the package and specifies the file name for the package file |
-c | Only configuration configuration files are listed. This parameter must be used together with the -l parameter |
-d | Only text files are listed. Use this parameter with the -l parameter |
– or – e erase | Uninstalling software Packages |
-f | Query the software package to which a file or command belongs |
– h or – hash | List the tags when installing the package |
-i | Displays information about software packages |
–install | Installing software Packages |
-l | The file list of the software package is displayed |
-p | Example Query a specified RPM package |
-q | Querying software Packages |
-R | Displays software package dependencies |
-s | Displays the file status. Use this parameter together with the -l parameter |
-u or — the upgrade | Upgrade Software Packages |
-v | The command execution process is displayed |
-vv | Detailed display of command execution process |
Reference Examples:
Direct installation package:
rpm -ivh packge.rpm
Copy the code
Ignore the error and force installation:
rpm --force -ivh package.rpm
Copy the code
List all installed packages:
rpm -qa
Copy the code
Query the installation location of files in RPM packages:
rpm -ql ls
Copy the code
Uninstalling RPM packages:
rpm -e package.rpm
Copy the code
Upgrade package:
rpm -U file.rpm
Copy the code
2️ find command – find and search files
The find command can find a file or directory based on a given path and expression. The find parameter has many options and is powerful with re support. Combined with pipes, it can achieve complex functions and is a command that system administrators and ordinary users must master.
If no parameter is added to find, all files and directories in the current path are searched. If the server load is heavy, do not run the find command during peak hours. Fuzzy search using the find command consumes system resources.
Grammar:
Syntax: find [parameter] [path] [search and search range]
Common parameters:
parameter | describe |
---|---|
-name | Search by name |
-size | Search by size |
-user | Search by property |
-type | Search by type |
-iname | Ignore case |
Reference Examples:
Use the -name parameter to view all configuration files ending in the. Conf file in the /etc directory:
find /etc -name "*.conf
Copy the code
Use the -size parameter to view files larger than 1M in the /etc directory:
find /etc -size +1M
Copy the code
Find all files in the current user’s home directory:
find $HOME -print
Copy the code
List all files and folders in the current directory and subdirectories:
find .
Copy the code
Find the file names ending in.txt in /home:
find /home -name "*.txt"
Copy the code
Ignore case in /var/log to find file names ending in.log:
find /var/log -iname "*.log"
Copy the code
Search for all files that have been accessed for more than 7 days:
find . -type f -atime +7
Copy the code
Search for all files that are accessed for more than 10 minutes:
find . -type f -amin +10
Copy the code
Find files under /home that do not end in.txt:
find /home ! -name "*.txt"
Copy the code
3️ startx command – initialize x-windows
Using the startx command, you can start the X-Window, which calls the initialization program xinit of the X-Window system. To complete the initialization necessary for x-Window to run and start the X-Window system.
Grammar:
Syntax format: startx [parameter]
Common parameters:
parameter | describe |
---|---|
-d | Specifies the display name of the X server that is passed to the client during startup |
-m | When the startup script is not found, start the window manager |
-r | When the startup script is not found, load the resource file |
-w | Mandatory start |
-x | Start an X-Windows session using the startup script |
Reference Examples:
X-windows has been started by default:
startx
Copy the code
Start X-Windows with 16-bit color depth:
startx --depth 16
Copy the code
Forcibly starting x-Windows:
startx -w
Copy the code
4️ disame command – displays system information
The full name of the uname command is Unix name.
Displays system information, such as the host name, kernel version, and hardware architecture.
If no option is specified, the effect is equivalent to executing the “uname -s” command, which displays the name of the system kernel.
Grammar:
Syntax: uname [parameter]
Common parameters:
parameter | describe |
---|---|
-a | Displays all system information |
-m | Displays the computer hardware architecture |
-n | Display host name |
-r | Displays the kernel release number |
-s | Display kernel name |
-v | Display kernel version |
-p | Display the host processor type |
-o | The operating system name is displayed |
-i | Display hardware platform |
Reference Examples:
The system host name, kernel version, and CPU type are displayed.
uname -a
Copy the code
Display only the system host name:
uname -n
Copy the code
Display the kernel version of the current system:
uname -r
Copy the code
Display the current system hardware architecture:
uname -i
Copy the code
5️ vmstat command – Displays virtual memory status
The vmstat command is intended to display the status of Virtual Memory (” Virtual Memory Statistics “), but it can report the overall running status of the system, such as processes, Memory, AND I/O.
Grammar:
Syntax: vmstat [parameter]
Common parameters:
parameter | describe |
---|---|
-a | Display active inside pages |
-f | Displays the total number of processes created after startup |
-m | Display slab information |
-n | Header information is displayed only once |
-s | Displays event counters and memory status in a tabular manner |
-d | Reporting Disk Status |
-p | Displays the status of a specified disk partition |
-S | Unit of output information |
Reference Examples:
Display active inside pages:
vmstat -a
Copy the code
Displays the total number of processes created after startup:
vmstat -f
Copy the code
Display slab information:
vmstat -m
Copy the code
Header information is displayed only once:
vmstat -n
Copy the code
Display event counters and memory state in tabular form:
vmstat -s
Copy the code
Displays the status of the specified hard disk partition:
vmstat -p /dev/sda1
Copy the code
Specifies the interval between status information refreshes to 1 second:
vmstat 1
Copy the code
🍑 Disk Management
1️ df command – displays disk space usage
The full name of the df command is Disk Free. As the name implies, the df command displays the available Disk space in the system. The default unit is KB. You are advised to use the df -h parameter combination to automatically change the unit based on the disk capacity.
This command is commonly used to check the occupied disk space and remaining disk space.
Grammar:
Syntax: df [parameter] [specify file]
Common parameters:
parameter | describe |
---|---|
-a | Display all system files |
-B | < block size > specifies the block size for display |
-h | Display in an easy-to-read manner |
-H | Display in 1000 bytes as conversion units |
-i | Displays index byte information |
-k | Specify a block size of 1KB |
-l | Only local file systems are displayed |
-t | < File system type > displays only file systems of the specified type |
-T | The file system type is displayed |
— -sync | Before obtaining the disk usage information, run sync |
Reference Examples:
Display disk partition usage:
df
Copy the code
Display disk partition usage in an easy-to-read way:
df -h
Copy the code
Displays the disk usage of the partition where the specified file resides:
df /etc/dhcp
Copy the code
The usage of ext4 disks is displayed:
df -t ext4
Copy the code
2️ retail fdisk command – disk partition
The full name of the fdisk command is “Partition table for Linux”, which serves as a disk Partition tool. Hard disk partition is essentially a format of the hard disk, with an image metaphor, partition is like drawing a big box on a piece of white paper, and formatting is like playing a grid in the box.
Grammar:
Syntax: fdisk [parameter]
Common parameters:
parameter | describe |
---|---|
-b | Specify the size of each partition |
-l | Lists the partition table state of the specified peripheral |
-s | Prints the specified partition size to standard output in blocks |
-u | With the “-l” argument list, the number of partitions replaces the number of cylinders to indicate the starting address of each partition |
-v | Display version Information |
Reference Examples:
Query all partitions:
fdisk -l
Copy the code
Select partition disk:
fdisk /dev/sdb
Copy the code
Create an extended partition on the current disk:
fdisk /ext
Copy the code
Speed up partitioning without checking disk surface:
fdisk /actok
Copy the code
Rebuild master boot record:
fdisk /cmbr
Copy the code
3️ discount BLK command – View disk of the system
The LSBLK command, which is called “list block”, lists all available block devices and shows their dependencies, but it does not list RAM disks.
The LSBLK command was included in the util-linux-ng package, now renamed util-linux.
Grammar:
Syntax: LSBLK [parameter]
Common parameters:
parameter | describe |
---|---|
-a | Display all devices |
-b | Displays the device size in bytes |
-d | Do not display slaves or holders |
-D | print discard capabilities |
-e | Rule out equipment |
-f | The file system information is displayed |
-h | Display help information |
-i | use ascii characters only |
-m | Display Permission Information |
-l | Display in list format |
-n | Don’t show title |
-o | Output columns |
-P | The value is displayed in the key= value format |
-r | Display in raw format |
-t | Display topology information |
Reference Examples:
By default, the LSBLK command lists all block devices in a tree:
lsblk
Copy the code
The default option does not list all empty devices:
lsblk -a
Copy the code
Can also be used to list ownership relationships for a particular device, as well as groups and patterns:
lsblk -m
Copy the code
To get a list of SCSI devices, you can only use the -s option, which is used to print dependencies in reverse order:
lsblk -S
Copy the code
For example, you might want to list devices in a list format rather than the default tree format. You can combine two different options to get the desired output:
lsblk -nl
Copy the code
4️ hdparm command – display and setting disk parameters
The hdparm command is used to detect, display, and set the parameters of IDE or SCSI disks.
Grammar:
Syntax: hdparm [parameter]
Common parameters:
parameter | describe |
---|---|
-a | Set the number of blocks to be pre-stored when reading a file |
-f | Writes data from the memory buffer to the disk and clears the buffer |
-g | Display hard disk track, magnetic head, magnetic area and other parameters |
-I | Read hardware specifications information provided by hard disks |
-X | Set the hard drive transfer mode |
Reference Examples:
Display hard drive Settings:
hdparm /dev/sda
Copy the code
Display the number of cylinders, heads, and sectors of the hard disk:
hdparm -g /dev/sda
Copy the code
Evaluate hard disk read efficiency:
hdparm -t /dev/sda
Copy the code
Read the hardware specifications provided by the hard disk directly:
hdparm -X /dev/sda
Copy the code
Put IDE hard disk into sleep mode:
hdparm -Y /dev/sda
Copy the code
5️ vgextend command – extend volume group
The vgextend command is used to dynamically expand an LVM volume group by adding physical volumes to the volume group. Physical volumes in an LVM volume group can be added when a volume group is created using the vgcreate command or added dynamically using the vgextend command.
Grammar:
Syntax format: vgextend [parameter]
Common parameters:
parameter | describe |
---|---|
-d | Debug mode |
-t | Only testing |
Reference Examples:
Add physical volume /dev/sdb1 to volume group vgLinuxprobe:
vgextend vglinuxprobe /dev/sdb1
Copy the code
🍓 File transfer
1️ TFTP command – upload and download files
The TFTP command is used to transfer files. FTP allows users to download and upload files stored on a remote host.
TFTP is a simple text-mode FTP program that uses instructions similar to FTP.
Grammar:
Syntax: TFTP [parameter]
Common parameters:
parameter | describe |
---|---|
connect | Connect to the remote TFTP server |
mode | File transfer mode |
put | Upload a file |
get | The download file |
quit | exit |
verbose | Displays detailed processing information |
trace | Display package path |
status | Display current status information |
binary | Binary transmission mode |
ascii ascii | Transfer mode |
rexmt | Set the timeout period for packet transmission |
timeout | Set the timeout period for retransmission |
help | Help information |
? | Help information |
Reference Examples:
Connecting to the remote server 10.211.55.100:
TFTP 10.211.55.100Copy the code
Remote download file:
tftp> get file
Copy the code
Exit the TFTP:
tftp> quit
Copy the code
2️ retail command – file transfer tool
The curl command is a file transfer tool that uses URL rules to work in the command line of shell terminal. Curl supports uploading and downloading files, so it is a comprehensive transfer tool.
Curl supports HTTP, HTTPS and FTP. It also supports POST, cookies, authentication, downloading files from specified offsets, user agent strings, speed limits, file sizes, and progress bars. Automate web page processing and data retrieval.
Grammar:
[url] curl [url]
Common parameters:
parameter | describe |
---|---|
-O | Write the output to the file, keeping the name of the remote file |
-u | Access is authorized by the user name and password configured on the server |
Reference Examples:
To write downloaded data to a file, you must use the absolute address of the file:
curl https://www.baidu.com /root/lucifer.txt --silent -O
Copy the code
When accessing pages that require authorization, you can use the -u option to provide the user name and password for authorization.
curl -u root https://www.baidu.com/
Copy the code
3️ FSCK command – check and repair the Linux file system
The full name of the FSCK command is filesystem check, which is used to check and repair errors in the Linux filesystem. Before operating a filesystem, back up important data to prevent loss.
The Linux FSCK command is used to check and repair Linux file systems. You can check one or more Linux file systems simultaneously. If the system is powered off or the disk is faulty, run the FSCK command to check the file system.
Grammar:
Syntax: FSCK [parameter] [file system]
Common parameters:
parameter | describe |
---|---|
-a | Automatic file system repair, no questions asked |
-A | Check all file systems listed in the /etc/fstab configuration file |
-N | No instructions are executed, only the actions that are actually executed are listed |
-P | If the -a parameter is used, all file systems are checked at the same time |
-r | Use interactive mode to ask questions when performing fixes so that users can confirm and decide what to do |
-R | If the parameter -a is used, the file system in the/directory is ignored |
-t | Specifies the type of file system to check |
-T | When the FSCK command is executed, no title information is displayed |
-V | Display command execution process |
Reference Examples:
Fix bad partitioned file system:
fsck -t ext3 -r /usr/local
Copy the code
Display the version number of FSCK system installed:
fsck --version
Copy the code
4️ discount command – Displays FTP session information
The ftpwho command is used to display the session information of all FTP login users.
You can run this command to know who the current FTP login users are and what operations they are performing.
Grammar:
Syntax: ftpwho [parameter]
Common parameters:
parameter | describe |
---|---|
-h | Display help information |
-v | Detailed mode, output more information |
Reference Examples:
To query the current user who is logging in to the FTP server:
ftpwho
Copy the code
In detailed mode, query the current user who is logging in to the FTP server.
ftpwho -v
Copy the code
Display help information:
ftpwho -h
Copy the code
5️ LPRM command – Delete the print task in the print queue
The full name of the LPRM command is Remove jobs from the print queue, which is used to delete print jobs from the print queue. Unfinished printer work is placed in the printer store column. This command can be used to cancel work that has not been sent to the printer.
Grammar:
Syntax: LPRM [parameter] [Task number]
Common parameters:
parameter | describe |
---|---|
-E | Enforces encryption when connecting to the print server |
-P | Specifies the target printer to receive the print task |
-U | Specify an optional user name |
Reference Examples:
Remove task 102 from hpPrint printer:
lprm -Phpprint 102
Copy the code
Remove task 101 from the preset printer:
lprm 101
Copy the code
🌽 Network Communication
1️ SSH command – Securely connecting clients
The SSH command is a client connection tool in the OpenSSH suite. It enables secure remote login to and remote management of the server using the SSH encryption protocol.
Grammar:
SSH [parameter] [remote host]
Common parameters:
parameter | describe |
---|---|
– 1 | The SSH protocol version 1 is mandatory |
2 – | The SSH protocol version 2 is mandatory |
4 – | An IPv4 address is mandatory |
– 6 | The IPv6 address is mandatory |
-A | The authentication proxy connection forwarding function is enabled |
-a | Disable the connection forwarding function of the authentication proxy |
– b < IP address > | The IP address specified by the local host is used as the source IP address for the peer connection |
-C | Request compression of all data |
-f < Configuration file > | Specifies the configuration file of the SSH directive. The default configuration file is /etc/ssh/ssh_config. |
-f | The SSH command is executed in the background |
-g | Allows a remote host to connect to a forwarding port on the local host |
-i< identity file > | Specify an identity file (private key file) |
-l< login name > | Specifies the login user name to connect to the remote server |
-N | Do not execute remote commands |
-o < option > | Specify configuration options |
-p < port > | Specifies the port on the remote server |
-q | In silent mode, all warning and diagnostic messages are disabled |
-X | The X11 forwarding function is enabled |
-x | The X11 forwarding function is disabled |
-y | Enable the trusted X11 forwarding function |
Reference Examples:
Log in to the remote server:
SSH 10.211.55.100Copy the code
Connect to remote server as user test:
ssh -l test 10.211.55.100
Copy the code
To view the partition list:
SSH 10.211.55.100 / sbin/fdisk -lCopy the code
Forced SSH version 1:
ssh -1
Copy the code
Enable the authentication proxy connection forwarding function:
ssh -A
Copy the code
2️ netstat command – display network status
The netstat command is used to display various network-related information, such as network connections, routing tables, Interface Statistics, Masquerade connections, and Multicast Memberships.
The output of netstat can be divided into two parts. One is Active Internet Connections, called Active TCP connections, where “recv-q” and “send-q” refer to %0A for receiving and sending queues. These numbers should always be 0. If not, it indicates that the software package is piled up in the queue. This happens only very rarely; The other is Active UNIX Domain Sockets, called Active UNIX Domain Sockets (the same as network sockets, but only for native communication, with twice the performance).
Grammar:
Syntax: netstat [parameter]
Common parameters:
parameter | describe |
---|---|
-a | Displays the sockets of all connections |
-p | Displays the program identifier and program name that is using the Socket |
-u | Displays the connection status of the UDP transport protocol |
-i | The network page information list is displayed |
-n | Use the IP address directly, not the DNS server |
Reference Examples:
Display detailed network status:
netstat -a
Copy the code
Display current household UDP connection status:
netstat -nu
Copy the code
Display UDP port number usage:
netstat -apu
Copy the code
Display network card list:
netstat -i
Copy the code
Display the relationship between multicast groups:
netstat -g
Copy the code
3️ ping command – Test network connectivity between hosts
The ping command is used to test the connectivity between hosts. After the ping command is executed, ICMP is used to send a message requesting a response. If the remote host is running properly, the remote host responds to the message.
It is worth noting, however, that the ping command on Linux is slightly different from the ping command on Windows. In Windows, four requests are sent before the ping command is run. Linux does not terminate automatically. In this case, press CTR+C or use -c to specify the number of requests to be sent in the ping command.
Grammar:
Ping [parameter] [destination host]
Common parameters:
parameter | describe |
---|---|
-d | Use the SO_DEBUG function of the Socket |
-c | Specifies the number of times packets are sent |
-i | Specifies the interval for sending and receiving messages |
-I | Sends packets using the specified network interface |
-l | Sets the packet that is sent before the requested message is sent |
-n | Output only values |
-p | Sets the template style for filled packets |
-q | Command execution process is not displayed |
-R | Recording the Routing Process |
-s | Sets the size of the packet |
-t | Set the TTL value |
-v | Detailed display of command execution process |
Reference Examples:
Check the connectivity with Baidu website:
ping www.baidu.com
Copy the code
Ping4 times:
ping -c 4 www.baidu.com
Copy the code
Set The Times to 4 and the interval to 3 seconds:
ping -c 4 -i 3 www.baidu.com
Copy the code
Use the ping command to obtain the IP address of the specified website:
ping -c 1 baidu.com | grep from | cut -d "" -f 4
Copy the code
4️ dhclient command – dynamically obtain or release IP address
The dhclient command is used to dynamically configure network parameters for a network interface using the Dynamic host configuration protocol (BOOTP).
Grammar:
Dhclient [parameter] [network interface]
Common parameters:
parameter | describe |
---|---|
-p | Specify the port on which the DHCP client listens (default port 86) |
-d | Always run the program in console mode |
-q | In quiet mode, no error message is displayed |
-r | Releasing IP Addresses |
-n | No interface is configured |
-x | To stop the running DHCP client without releasing the current lease, kill the existing DHclient |
-s | Specify the DHCP server before obtaining the IP address |
-w | The operation continues even if no broadcast interface is found |
Reference Examples:
Sends a DHCP request on a specified network interface:
dhclient eth0
Copy the code
Release IP address:
dhclient -r
Copy the code
Get the IP address from the specified server:
Dhclient -s 10.211.55.100Copy the code
Stop dhClient:
dhclient -x
Copy the code
5️ ifconfig command – display or set network equipment
The ifconfig command is called Network interfaces configuring, which is used to configure and display the network parameters of the network interfaces in the Linux kernel. The nic information configured by using the ifconfig command does not exist after the nic is restarted. In order to keep the above configuration information permanently stored in the computer, it is necessary to modify the network card configuration file.
Grammar:
Syntax: ifconfig [parameter]
Common parameters:
parameter | describe |
---|---|
Add the < address > | Example Set the IPv6 IP address of the network device |
Del < address > | Example Delete the IPv6 IP address of the network device |
down | Disable the specified network device |
up | Starts the specified network device |
The IP address | Specify the IP address of the network device |
Reference Examples:
Display network device information:
ifconfig
Copy the code
Enable or disable a specified nic:
ifconfig eth0 down
ifconfig eth0 up
Copy the code
Configure and delete aN IPv6 address for a network adapter:
ifconfig eth0 add 33ffe:3240:800:1005::2/64
ifconfig eth0 del 33ffe:3240:800:1005::2/64
Copy the code
Change the MAC address with ifconfig:
ifconfig eth0 down
ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE
ifconfig eth0 up
ifconfig eth1 hw ether 00:1D:1C:1D:1E
ifconfig eth1 up
Copy the code
Configure the IP address:
Ifconfig eth0 192.168.1.56 ifconfig eth0 192.168.1.56 netmask 255.255.255.0 ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255Copy the code
🍒 Device Management
1️ mount command – file system mount
The mount command is used to mount a file system to a specified loading point. The most common use of this command is to mount the CDROm, so that we can access the data in the Cdrom, because you insert the CD into the CDROm, Linux does not mount automatically, you must use the Linux mount command to do this manually.
Grammar:
Syntax: mount [parameter]
Common parameters:
parameter | describe |
---|---|
-t | Specify the mount type |
-l | The list of loaded file systems is displayed |
-h | Display help information and exit |
-V | Show program version |
-n | Load a file system that is not written to the /etc/mtab file |
-r | Load the file system into read-only mode |
-a | Load all file systems described in the /etc/fstab file |
Reference Examples:
View version:
mount -V
Copy the code
Start all mounts:
mount -a
Copy the code
Mount /dev/cdrom to/MNT:
mount /dev/cdrom /mnt
Copy the code
Mount an NFS file system:
mount -t nfs /123 /mnt
Copy the code
Mount the first partition of the first disk to /etc directory:
mount -t ext4 -o loop,default /dev/sda1 /etc
Copy the code
2️ MAKEDEV command — build the device
MAKEDEV is a script that sets up devices in the /dev directory, through which drivers located in the kernel can be accessed.
The MAKEDEV script creates static device nodes, usually in the /dev directory.
Grammar:
Syntax: MAKEDEV [parameter]
Common parameters:
parameter | describe |
---|---|
-v | Displays every action performed |
-n | No real updates, just to show how it works |
-d | Deleting device Files |
Reference Examples:
Displays each action performed:
./MAKEDEV -v update
Copy the code
Delete a device:
./MAKEDEV -d device
Copy the code
3️ LSPCI command – display information on all PCI buses on the current device
The lspci command is used to display information about all PCI buses and connected PCI devices on the host. Now mainstream devices such as network card storage are using PCI bus
Grammar:
Syntax: lSPCI [parameter]
Common parameters:
parameter | describe |
---|---|
-n | Display PCI vendor and device codes digitally |
-t | Hierarchical relationships of PCI devices are displayed in a tree structure |
-b | Bus-centric view |
-s | Only the device and function block information of the specified bus slot is displayed |
-i | Specifies the PCI number list file, not the default file |
-m | Display PCI device information in a machine-readable manner |
Reference Examples:
Display all PCI bus information of the current host:
lspci
Copy the code
Display hierarchical relationships of PCI devices in tree structure:
lspci -t
Copy the code
4️ discount command – setting the state of three leds on the keyboard
Setleds is a combination of the English phrase “setleds”, which translates into “set LEDS” in Chinese. Using the setleds command, you can set the status of the three LEDS above the keyboard. In Linux, each virtual console has its own Settings.
This is a very magical command, should be able to control the keyboard through the command of the lamp state. So let me learn this command.
Grammar:
Syntax format: setleds [parameter]
Common parameters:
parameter | describe |
---|---|
-F | Set the state of the virtual console |
-D | Change virtual console state and preset state |
-L | Change LED display state directly |
+num/-num | Turn numeric keys on or off |
+caps/-caps | Turn the case key on or off |
+scroll /-scroll | Turn the option key on or off |
Reference Examples:
Control keyboard indicator NUM On and off:
setleds +num
setleds -num
Copy the code
The upper and lower case keys of the keyboard are on or off, and the keyboard indicator is on and off:
setleds +caps
setleds -caps
Copy the code
Control the option key of the keyboard on or off, keyboard indicator light on and off:
setleds +scroll
Copy the code
Combination of the three lights on and off, respectively set as digital light on, upper and lower case light off, option key Scroll light off:
setleds +num -caps -scroll
Copy the code
5️ sensors command — detect server internal temperature and voltage
Sensors command is used to detect the health of the internal cooling system of the server, monitor the motherboard, CPU operating voltage, fan speed, temperature, etc.
Grammar:
1. Sensors
Reference Examples:
Test CPU operating voltage, temperature, etc. :
sensors
Copy the code
🍍 Backup compression
1️ discount zip command – compress files
The ZIP program puts one or more compressed files into a compressed archive along with information about the file (name, path, date, time of last modification, protection, and check information to verify file integrity). You can use a single command to package the entire directory structure into a ZIP archive.
For text files, compression ratios of 2:1 and 3:1 are common. Zip has only one compression method (deflation) and can store files without compression. Zip can also be compressed using BZIP 2 if bZIP 2 support is added, but these entries require a reasonable modern decompression to decompress. When bZIP 2 compression is selected, it replaces deflation with the default method. Zip automatically selects the better two files (deflated or stored, or bzip2 or Store if bzip2 is selected) for each file to be compressed.
Grammar:
Syntax format: zip [parameter] [file]
Common parameters:
parameter | describe |
---|---|
-q | Command execution process is not displayed |
-r | Recursive processing, all files in the specified directory and subdirectories are processed together |
-z | Annotate the compressed file |
-v | Display command execution process or display version information |
-n< tail string > | Does not compress a file with a particular tail-string |
Reference Examples:
Package all files and folders in /home/html/ as html.zip in the current directory:
zip -q -r html.zip /home/html
Copy the code
Delete file a.c from cp. Zip:
zip -dv cp.zip a.c
Copy the code
Mydata: /home: mydata.zip mydata: /home: mydata.zip
zip -r mydata.zip mydata
Copy the code
Zip the ABC folder and 123.txt under /home to abc123.zip:
zip -r abc123.zip abc 123.txt
Copy the code
Package the logs directory as log.zip:
zip -r log.zip ./logs
Copy the code
2️ zipinfo command – View compressed file information
The full name of the zipinfo command is zip Information. This command is used to list information about compressed files. You can run the zipinfo command to obtain details about zip files.
Grammar:
Syntax format: zipinfo [parameter]
Common parameters:
parameter | describe |
---|---|
– 1 | Only file names are listed |
2 – | This parameter has the same effect as the “-1” parameter, but can be used with “-h”, “-t”, and “-z” parameters |
-h | Only file names of compressed files are listed |
-l | This parameter has the same effect as specifying the “-m” parameter, but lists the size of the original file instead of the compression rate of each file |
-m | The effect of this parameter is similar to specifying the “-s” parameter, but it lists the compression rate for each file |
-M | If the information content is more than one screen, the information is listed in a way similar to the MORE command |
-s | List compressed file contents with an effect similar to executing the “ls -l” command |
-t | Only the number of files in the compressed file, file size before and after compression, and compression ratio are listed |
-T | List the date and time of each file in the compressed file in year, month, day, hour, minute, and second order |
-v | Displays detailed information about each file in the compressed file |
-x< Template Style > | Does not list information about eligible files |
-z | If the compressed file contains comments, the comments are displayed |
Reference Examples:
Display compressed file information:
zipinfo file.zip
Copy the code
Displays information about each file in the compressed file:
zipinfo -v file.zip
Copy the code
Display only compressed package size and file number:
zipinfo -h file.zip
Copy the code
Generate a basic, long-form list (rather than a lengthy one) with headings and summary lines:
zipinfo -l file
Copy the code
View the most recently modified files in the archive:
Zipinfo -t file | sort - nr - 7 k | sed 15 qCopy the code
3️ unzip command – Decompress the ZIP file
The unzip command is a decompression tool for. Zip files. The unzip command will list, test, or extract files from zip archives typically located on MS-DOS systems.
The default behavior (i.e., no option) is to extract all files from the specified ZIP archive into the current directory (and subdirectories below). A companion program zip (1L) creates zip archives; Both programs are compatible with PKWARE’s PKZIP and PKUNZIP archive files created for MS-DOS, but in many cases the program options or default behavior are different.
Grammar:
Syntax: unzip [parameter] [file]
Common parameters:
parameter | describe |
---|---|
-l | Displays the files contained in the compressed file |
-v | Displays detailed information at execution time |
-c | Displays the results of the decompression on the screen, converting the characters as appropriate |
-n | Do not overwrite the original file when decompressing |
-j | Does not process the original directory path of the compressed file |
Reference Examples:
Unzip mydata.zip from /home to myDatabak:
unzip mydata.zip -d mydatabak
Copy the code
Unzip the wwwroot. Zip file from /home to /home:
unzip wwwroot.zip
Copy the code
Zip, abc23. Zip, abc34. Zip from /home to /home:
unzip abc\*.zip
Copy the code
View the contents of wwwroot. Zip under /home:
unzip -v wwwroot.zip
Copy the code
Verify that wwwroot. Zip is complete under /home:
unzip -t wwwroot.zip
Copy the code
4️ gzip command – compress and decompress files
The gzip command is commonly used to compress files. Gzip is a widely used compression program. After files are compressed, their names are followed by multiple “.
Gzip is a command used to compress and decompress files in Linux. It is convenient and easy to use. Not only can gzip be used to compress large, lesser-used files to save disk space, it can also be used together with tar to form a popular compressed file format for Linux operating systems. According to statistics, the gzip command has a compression rate of 60% to 70% for text files. Reducing file size has two obvious benefits. One is that it reduces storage space, and the other is that when transferring files over the network, it reduces transfer time.
Grammar:
Syntax format: gzip [parameter]
Common parameters:
parameter | describe |
---|---|
-a | Use ASCII text mode |
-d | Unzip the file |
-f | Forcibly compress files |
-l | This section describes the information about compressed files |
-c | Output compressed files to standard output devices without altering the original files |
-r | Recursive processing, all files and subdirectories under the specified directory are processed together |
-q | No warning message is displayed |
Reference Examples:
Zip each file in the rancher-v2.2.0 directory into a. Gz file:
gzip *
Copy the code
Unzip each compressed file in the above example and list the details:
gzip -dv *
Copy the code
Decompress the directory recursively:
gzip -dr rancher.gz
Copy the code
5️ unarj command – decompress. Arj file
The unarj command is used to decompress. Arj files.
Grammar:
Syntax: unarj [parameter] [.arj compressed file]
Common parameters:
parameter | describe |
---|---|
-e | Unzip the. Arj file |
-l | Displays the files contained in the compressed file |
-t | Check whether the compressed file is correct |
-x | Retain the original path when decompressing |
Reference Examples:
Unzip.arj files:
unarj -e test.arj
Copy the code
Show the files contained in the compressed file:
unarj -l test.arj
Copy the code
Check whether the compressed file is correct:
unarj -t test.arj
Copy the code
Keep the original path when decompressing:
unarj -x test.arj
Copy the code
Unzip the file to the current path:
unarj -ex test.arj
Copy the code
🍌 Other Commands
1️ hash command – Display and clear hash table queries on command run
The hash command displays and clears hash tables that are preferentially queried by the system when commands are run.
When the hash command is executed without specifying an argument or flag, the hash command reports the contents of the list of pathnames to standard output. This report contains the pathnames of commands in the current shell environment found by previous hash command calls. It also contains commands that are invoked and found through the normal command search process.
Grammar:
Syntax: Hash [parameter] [directory]
Common parameters:
parameter | describe |
---|---|
-d | Clear records in a hash table |
-l | Displays the commands in the hash table |
-p < > directive | Adds a command with a full path to the hash table |
-r | Clears records in the hash table |
-t | Displays the full path of the command in the hash table |
Reference Examples:
To display commands in a hash table:
hash -l
Copy the code
Delete command from hash table:
hash -r
Copy the code
Add command to hash table:
hash -p /usr/sbin/adduser myadduser
Copy the code
To clear a record in a hash table:
hash -d
Copy the code
Displays the full path of the commands in the hash table:
hash -t
Copy the code
2️ grep command – a powerful text search tool
Grep is short for “Global Search Regular Expression and print out the line”, which means to search the regular expression thoroughly and print it out. This command can be used in conjunction with regular expressions and is the most widely used command on Linux.
Grep options are used to supplement the search process, and the command pattern is flexible, including variables, strings, and regular expressions. Note that when a pattern contains Spaces, always enclose them in double quotes.
Linux supports three forms of grep. The first is grep, standard and imitation. The second son has many interests. -egrep, which is equivalent to grep -e, supports basic and extended regular expressions. -fgrep, which is equivalent to grep -f, does not support regular expressions and matches the literal meaning of the string.
Grammar:
Syntax: grep [parameter]
Common parameters:
parameter | describe |
---|---|
-i | Ignore case when searching |
-c | Only the number of matching rows is printed |
-l | Only the file names that match are listed, not the specific matching lines |
-n | Lists all matching rows, showing line numbers |
-h | The file name is not displayed when multiple files are queried |
-s | Does not display error messages that do not exist or have no matching text |
-v | Displays all lines that do not contain matching text |
-w | Match the words |
-x | Match the entire line |
-r | Recursive search |
-q | Disable output of any results, exit status indicates whether the search was successful |
-b | Prints the offset, in bytes, of the header of a matching line-spacing file |
-o | Used with -b, prints the offset, in bytes, of the header of the matching data file |
Reference Examples:
Support for multiple file queries and use of wildcards:
grep zwx file_* /etc/hosts
Copy the code
Print the number of matching string lines:
grep -c zwx file_*
Copy the code
List all matching lines and display line numbers:
grep -n zwx file_*
Copy the code
Display all lines that do not contain patterns:
grep -vc zwx file_*
Copy the code
No longer displays file names:
grep -h zwx file_*
Copy the code
List only the filenames that match, not the rows that match:
grep -l zwx file_*
Copy the code
Do not display non-existent or non-matching text messages:
grep -s zwx file1 file_1
grep zwx file1 file_1
Copy the code
Recursive search, not only for the current directory, but also for subdirectories:
grep -r zwx file_2 *
Copy the code
To match the whole word, to interpret it literally, is equivalent to an exact match:
grep zw* file_1
grep -w zw* file_1
Copy the code
Matches the entire line. The entire line in the file is printed only if it matches the pattern:
grep -x zwx file_*
Copy the code
No result is output, exit status indicates the result:
grep -q zwx file_1
echo $?
grep -q zwx file_5
echo $?
grep -q zwx file5
echo $?
Copy the code
Find empty and non-empty lines in a file:
grep -c ^$ file_1
grep -c ^[^$] file_1
Copy the code
Match any or repeated characters with “. Or the “*” symbol to implement:
grep ^z.x file_1
grep ^z* file_6
Copy the code
3️ wait command — one’s orders
The wait command is used to wait for an instruction until it is executed and then returns to the terminal. This command is often used in shell scripting. After the specified command is executed, the next task can be continued. When this instruction waits for a job, the backup number “%” must be added before the job ID.
Grammar:
Syntax: wait [parameter]
Common parameters:
parameter | describe |
---|---|
22 or % 1 | Process ID or job ID |
Reference Examples:
Wait for job 1 to complete and then return:
wait %1
find / -name password
Copy the code
4️ retail BC command – floating point operation
BC, spelled “Binary Calculator”, is a Calculator language that supports interactive execution with arbitrary precision. Bash has built-in support for integer quarts, but it does not support floating-point arithmetic, and BC makes floating-point arithmetic very easy, and integer arithmetic is no longer a problem.
Grammar:
Syntax format: BC [option]
Common parameters:
parameter | describe |
---|---|
-i | Force into interactive mode |
-l | Define the standard math library to use |
-w | Define the standard math library to use |
-q | Print normal GNU BC environment information |
Reference Examples:
Arithmetic operations Advanced operations BC command it can perform floating point operations and some advanced functions:
echo "1.212 * 3" | bc
Copy the code
Set decimal precision (numeric range) :
echo "scale=2; 3/8" | bc
Copy the code
Calculate square and square roots:
echo "10 ^" | bc
echo "sqrt(100)" | bc
Copy the code
5️ history command — display and manipulate history command
The history command is used to display the history commands that a user has executed. You can add or delete the history commands.
If you use Linux commands a lot, using the history command is a great way to increase your productivity.
Grammar:
Syntax: history [parameter] [directory]
Common parameters:
parameter | describe |
---|---|
-a | Appends the history commands of the current shell session to the command history file, which is the configuration file that holds the history commands |
-c | Clear the current history command list |
-d | Deletes a command with a specified sequence number from the history command list |
-n | Read history commands that were not read at the start of this Shell session from the command history file |
-r | Read the command history file into the current Shell history command memory buffer |
-s | Adds the specified command as a separate entry to the command history memory buffer. Delete the last command in the command history memory buffer before performing add |
-w | Writes the contents of the current shell history command memory buffer to the command history file |
Reference Examples:
Display the last 10 commands:
history 10
Copy the code
Write the login command to the history file:
history -w
Copy the code
Read the contents of the command history file into the current shell’s history memory:
history -r
Copy the code
Append the current Shell session history command to the command history file:
history -a
Copy the code
Clear the current history command list:
history -c
Copy the code
This is the end of sharing ~
If you think the article is helpful to you, please like it, favorites it, pay attention to it, comment on it, and support it four times with one button. Your support is the biggest motivation for my creation.
❤️ technical exchange can follow the public number: Lucifer think twice before you do ❤️