


Summary of commonly used commands in Linux systems
Command format: command - option parameters, for example: ls -la /usr; when there are multiple options, they can be written together.
ifconfig: View the IP information of the current machine
service network restart: Restart the network service
service iptables status: View the current machine firewall status
hostname XX: View or modify the host name
pwd: View Full path of the current file
ls -l or ll or ls: View the contents of the current directory
cat File name: Indicates viewing the content of the file (small file)
more File name: Indicates viewing the content of the file (large file ), use spaces to turn pages, press Enter to display the next line, q (or ctrl+c) to exit
mkdir: Create a folder
mkdir -p d3/d4/d5: Recursively create a folder
touch : Create a file
head -number [file name]: View the first number of lines of the file
tail -number [file name]: View the last number of lines of the file
mv 1 Function to modify the file name: mv [ Source file name] [New file name]
2 Move file location: mv [Source file name] [New file location + New file name]
Command: chmod
Syntax: chmod [{ugo }{+-=}{rwx}] [File or directory]
chmod [mode=421] [File directory]
Description: Change the permissions of the file or directory
Form: chmod g+w filename
Form: chmod 761 filename
Problem example: Create a new directory with a new file below it. Try to use an ordinary user to delete the new file in the new directory.
1 Try to modify: Set the read and write permissions of the new file to 777, and delete the file
2 Try to modify: Set the read and write permissions of the new directory to 777, and delete the file
rwx permissions:
r: Can perform read operations such as catch and more.
w: Modify the content of the file and other write operations, but it does not mean that you can delete the file.
x: Perform operations on files.
rwx permissions of the directory:
r: Readable operation, you can list the contents of the directory, such as the ls command.
w: Indicates the permission to create or delete files in the directory.
x: Indicates that you can enter this directory (basically all directories will have rx permissions).
So: the permission to delete a file is to have the write permission of the directory where your current file is located.
Command: chown
Syntax: chown user file
Description: Change the owner of the file
Example: chown newuser t1.sh
useradd username Add user
passwd username is User set password
Command: chgrp
Syntax: chgrp group file
Description: Change the group to which the file belongs
Example: chgrp adm t1.sh
View system default permissions: umask -S (umask view permission mask value 022, use 777-022 to get the real permissions)
Command: find
Syntax: find [search range path] -name [file name] (search based on file name)
find [search range path] -size [(+-) file size] (search based on file size, greater than + and less than -)
find [search range path] -user (owner of the file)
find [time search] [in days]
[in days] 1 ctime, atime, mtime
[in minutes] 2 cmin, amin, mmin
. . . . .
Description: Find any file or directory (all)
find [Time search] [in days]
Days: ctime, atime, mtime
Minutes: cmin, amin, mmin
c means: change means changing file attributes (such as owner, group, permission change).
a means: access means that it has been accessed (such as viewed, etc.).
m means: modify means changing the content.
Add in front of the time: - means inside, + means outside
Find the applied connector:
-a (meaning and, logical AND)
-o (or means logical or)
find search: search based on file type:
-type
where: f represents a binary file, l represents a soft link file, d represents a directory
Find connection execution symbol:
find ... -exec [execution command] {} \;
Note: "{}" represents the result of the find command, and "\" represents the escape character
find ... -exec [Execute command] {} \;
find ... -ok [Execute command] {} \;
The difference between ok and exec is that ok means asking for confirmation.
find -inum [i node label] Find files based on i node. In the Linux system, all files have a unique identifier, which is convenient for the Linux kernel to call. This is the i node
command: locate
Syntax: locate [file name]
Description: Find files according to the index inside the Linux database (updatedb command, you can manually update the updatedb database, generally used in conjunction with locate)
Note: The search speed of locate Very fast, much faster than find. The reason is that locate searches for the index value of the file database built by the Linux system, so it is very fast. However, sometimes newly created files cannot be found using the locate command. The reason is that the file The index is not immediately updated to the Linux system file database.
Command: man
Syntax: man [command or configuration file],
Description: Help command, very useful, you can get help documentation for the command, how to use it, etc.
Command: whatis
Syntax: whatis [command]
Description: View the description of the command.
Command: --help
Syntax: [Command] --help
Description: View command option usage.
Command: gzip
Syntax: gzip [file name]
Description: The original file is not retained during compression, and only files can be compressed but not directories
Command: gunzip
Syntax: gunzip [compressed file]
Description: Decompress the file without retaining the source file
Command: tar
Syntax: tar [zcvf] [zxvf] [package file name .tar.gz] [Source file]
-c Generate tar package file (required)
-x Generate decompressed file (required)
-v Display detailed information
-f Specify Compressed file name
-z Pack and compress simultaneously
Description: The suffix name .tar.gz generated by the packaging directory, or decompression
Add -C in the final configuration to indicate the path where the file will be stored after decompression
The file command can view the type of any file
Command: zip
Syntax: zip option [-r] [Compressed file name] [Source file]
Description: The format of zip is windows and linux A common format that can compress files and directories. The option -r is required when compressing directories.
Command: unzip
Syntax: unzip [decompressed file]
Description: Decompress
Add -d in the final configuration to indicate the path where the file will be stored after decompression
ping
(Note: There are many reasons why ping cannot reach the other party's network, and you need to investigate in detail step by step)
(1) First, ping the loopback address 127.0.0.1 to check whether the network protocol of your own machine is correct
( 2) Ping the local IP again to see if your local network is correct
(3) Then check the other party’s network settings, firewall, plug-ins, etc.
(4) If you find that there are lost packets in the packet loss rate, It may be caused by the network or network cable
(5) Ping configuration option ping -c 6 192.168.80.100 (meaning it will be disconnected after pinging 6 times)
(6) Ping configuration option ping -s 60000 (maximum 65507)
View network card information: ifconfig
Shutdown: shutdown -h now
Restart: reboot
ctrl + l Clear the screen.
ctrl + c Exit the application.
Tab key, information completion.
Filtering: grep, you can filter the specified content and then output it.
Pipeline:
Transmit the output of one command to another command as the input of another command. Pipes can connect N commands.
ls -l /etc | more (indicates that the output of ls -l /etc is used as the input of the more command, that is, the content browsed by the more command is the output of the previous command)
ls -l /etc | grep init (indicates that the output results of ls -l /etc are filtered and displayed as the results of init)
ls -l /etc | grep init | wc -l (the last number of statistics displayed)
Logical AND (&&)
Form: ls && pwd (If the first command is executed successfully, the second command will be executed)
Logical OR (||)
Form: ls || pwd (If the first command is executed successfully, the second one will not be executed. If the first command fails, the second one will be executed)
Input and output redirection:
Shell is predefined for each process 3 file descriptors (0,1,2)
0 (stdin) standard input 1 (stdout) standard output 2 (stderr) standard error output
Output redirection: is to display the output results to a On the file (> indicates output redirection)
File information description:
drwxr-xr-x. 2 root root 6 Nov 5 2016 etc
d: Start with d, indicates directory, indicates folder
-: starts with -, indicates ordinary binary file
l: starts with l, indicates soft link file (link)
r: read permission, w: write write permissions, The permissions of r-x (group) and the permissions of others r-x (others)
After entering the text editing, you need to press a or i or o to edit the text
Exit the text editing operation The sequence is: first press the ESC key, then press SHIFT + :, enter wq to save and exit, enter q! to not save and force exit
Linux file description
1. File rwx
2, hard connection number
3, owner
4, group to which it belongs
5, file size (not precise)
6, file creation or modification time
7, The name of the file
export JAVA_HOME=/usr/software/JDK/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
1. Close firewall:
systemctl stop firewalld.service #Stop firewall
systemctl disable firewalld.service #Disable firewall startup
firewall-cmd --state #View the default firewall status (displayed after closing) notrunning, running will be displayed after turning it on)
2. iptables firewall (iptables has been installed here, configure it below)
vi/etc/sysconfig/iptables #Edit firewall configuration file
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT[0:0]
:OUTPUT ACCEPT[0:0]
-A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -jACCEPT
-A INPUT -i lo -jACCEPT
-A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state -- state NEW -m tcp --dport 80 -jACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
-A INPUT -j REJECT--reject- with icmp-host-prohibited
-A FORWARD -jREJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #Save and exit
Note: 80 and 8080 are used here Take port as an example. The *** part is generally added above or below the "-A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT" line. Remember not to add it to the last line, otherwise the firewall will not work after restarting. Take effect.
systemctlrestart iptables.service #Finally restart the firewall to make the configuration take effect
systemctlenable iptables.service #Set the firewall to start at boot
The above is the detailed content of Summary of commonly used commands in Linux systems. For more information, please follow other related articles on the PHP Chinese website!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
