Common Linux interview questions (55 questions)

@TOC Strikethrough Format 1. File Management Directory Operation

  1. Create directory: mkdir

The mkdir command can create a new directory. For example, create a directory named "test" in the current directory:

mkdir test
2. Delete directory: rmdir

The rmdir command can delete an empty directory. For example, to delete an empty directory named "test",

rmdir test
If the directory is not empty, you can use the rm -r command to recursively delete the directory and all its subdirectories and files.

rm -r
3. List directory contents: ls

Use lsthe command to list all files and subdirectories in a directory

ls
The ls -l command displays detailed information such as permissions, owner, size, creation date, etc. of files and folders.

ls -l
4. Change directory: cd

Use cdthe command to change the current working directory. For example, to enter a directory named "test"

cd test
5. Copy directory: cp -r

Use cp -rthe command to copy a directory and all its subdirectories and files. For example, to copy a directory named "test" to a directory named "backup"

cp -r test backup
6. Move directory: mv

Use mvcommands to move or rename a directory. For example, to move a directory named "test" to a directory named "backup", you would enter the following command in the terminal: mv test backup. If you want to rename a directory, you can pass the new name of the directory as the second argument to mvthe command.

  1. Find a directory: Use findthe command to find a directory in the file system. For example, to find a directory named "test", enter the following command in the terminal: find / -type d -name test. This will search for a directory named "test" starting from the root directory.

Say more than 10 Linux commands
ls: List all files and folders in the current directory.

When the ls
command is used alone, it will simply list the names of files and folders in the current directory, and will not display detailed information about the files or folders.
ls -l
will display detailed information such as file and folder permissions, owner, size, creation date, etc.
cd: Switch the current working directory.

Example: cd ~/Documents

Explanation: In this example, ~ represents the current user's home directory, that is, the home folder. This command will switch the working directory to the current user's Documents folder.

pwd: Displays the current path.

Example: pwd

Explanation: This command will display the absolute path of the current path on the screen.

mkdir: Create a new directory.

Example: mkdir ~/Documents/NewFolder

Explanation: In this example, this command creates a new folder named "NewFolder" in the current user's Documents folder.

rmdir: delete empty directories.

Example: rmdir ~/Documents/NewFolder

Explanation: This command will delete the folder named "NewFolder" in the current user's Documents folder, but only if the folder is empty. For non-empty folders, use the rm -r command.

touch: Create a new empty file.

Example: touch ~/Documents/NewFile.txt

Explanation: This command will create a new file named "NewFile.txt" in the current user's Documents folder.

cp: Copy files or directories.

示例:cp ~/Documents/OldFile.txt ~/Documents/NewFile.txt

Explanation: This command will copy the file named "OldFile.txt" in the current user's Documents folder to a new file named "NewFile.txt".

mv: Move files or directories.

Example: mv ~/Documents/OldFile.txt ~/Desktop/

Explanation: This command will move the file named "OldFile.txt" from the current user's Documents folder to the desktop.

rm: Delete a file or directory.

Example: rm ~/Documents/OldFile.txt

Explanation: This command will delete the file named "OldFile.txt" from the current user's Documents folder. For folders, use the rm -r command.

cat: View file contents.

Example: cat ~/Documents/OldFile.txt

Explanation: This command will print out the entire contents of the file named "OldFile.txt" in the current user's Documents folder.

more/less: View file contents in pages.

Example: more ~/Documents/OldFile.txt

Explanation: This command can view the file content page by page. The user can press the space bar to view the file content page by page. There is a similar command called less with the same usage.

echo: output text.

Example: echo "Hello World!"

Explanation: This command will print a piece of text to the screen, and the output is Hello World!.

chmod: Modify the permissions of a file or directory.

Example: chmod u+x ~/Documents/OldFile.txt

Explanation: This command will set the execution permissions of the current user on the file named "OldFile.txt" to Allow, and the execution permissions of other users will remain unchanged. Here, "u" means "user", which is the current user, and "+x" means adding execution permissions.

chown: Modify the owner of a file or directory.

示例:chown user:group ~/Documents/OldFile.txt

Explanation: This command will set the owner and user group of the file named "OldFile.txt" to the specified user and user group respectively.

ps: Display current process information.

Example: ps aux

Explanation: This command lists detailed information about all running processes on the system.

In RedHat, what command is generally used to switch from the root user to the userl user
? su - userl
su means switching users (superuser), - means switching to the environment variables of the specified user, maintaining the same environment configuration as the target user. userl is the username of the normal user that needs to be switched to.

How to quickly switch to the home directory of user John.
Use the cd John command to quickly switch to the home directory of user John. Among them, represents the home directory of the current user (that is, the user who uses this command), and John is the user name that needs to enter his home directory.

How to hide files in Linux?
Files are generally hidden by adding a . before the file or directory name. For example, if you want to hide a file named example.txt, you can rename it to .example.txt. At this time, the file will be regarded as a hidden file by default and will not be displayed on interfaces such as the file manager.

In the Linux system, the access permission of a file is 755. What does it mean?
In the Linux system, file access permissions are represented by three numbers. Each number represents a set of permissions, namely "owner permissions", "user permissions in the same group" and "other user permissions". Among them, the number of each group of permissions is converted from a three-digit binary number (i.e. rwx), r represents read (read), w represents write (write), and x represents execute (execute). 755 is a common file access permission setting, and its meaning is as follows:

The owner permissions are "read, write, execute", and the corresponding number is 7 (111 in binary).

The user permissions of the same group are "Read, Execute", and the corresponding number is 5 (101 in binary).

Other user permissions are "Read, Execute", and the corresponding number is 5 (101 in binary).

Therefore, 755 means that the owner of the file has read, write, and execute permissions, while users in the same group and other users only have read and execute permissions.

Check the CPU information.
Open the terminal, enter the command cat /proc/cpuinfo, and press Enter to execute.

In the Linux system graphical interface, you can view CPU information through tools such as "System Monitoring".

View the process with the highest CPU usage
top -o %CPU
The "-o" parameter indicates sorting according to the specified field, and "%CPU" indicates sorting according to CPU usage. If you want to sort by other fields (such as memory usage), just replace "%CPU" with the corresponding field.

View the last 50 lines of a file.
You can use the tail command to view the last 50 lines of a file. The command format is as follows:

tail -n 50 filename
where the "-n" parameter indicates the number of lines to be displayed, and "filename" is the path and name of the file.

For example, if you want to view the last 50 lines of the file "example.log" in the current directory, you can execute the following command:

tail -n 50 example.log
After executing this command, the last 50 lines of the file "example.log" will be output to the terminal.

To view the last few lines of a file,
you can use the tail command. The command format is as follows:

tail [option] file name
This command displays the last 10 lines of the file by default. If you want to display other lines, you can specify the required number of lines through the -n option. For example, to display the last 20 lines of the file "example.txt", you can execute the following command:

tail -n 20 example.txt
After executing this command, the terminal will output the last 20 lines of the file "example.txt".

Viewing one page of content
You can use the less command to display one page of content at a time. The less command is a pager, usually used to view file contents. Use the less command to display one page of content at a time, and use the up and down arrows to scroll through the page's content.

The format of using less command is:

less [options] [file]
where options are optional parameters and file is the name of the file to be viewed. If the file parameter is omitted, the less command reads the content from standard input and displays it in pages.

If you want to display one page of content at a time, you can directly enter the less command and add the file name next to it, for example:


After the less example.txt command is executed, the content of the first page of the file will be displayed. Press the space bar to display the content of the next page. Press the up arrow and down arrow to scroll to view the content of the page.

Checking the IP Address
There are many ways to check the IP address in Linux, here are a few common ones:

Use the ifconfig command: This command can display the configuration information of the network interface, including the IP address. Enter the ifconfig command in the terminal and press Enter to view the IP addresses of all network interfaces in the system.

ifconfig
uses the ip command: This command can also display the configuration information of the network interface, including the IP address. Enter the ip addr command in the terminal and press Enter to view the IP addresses of all network interfaces in the system.

ipaddr
uses the hostname command: This command can display the name and IP address of the current host. Enter the hostname -I command in the terminal and press Enter to view the IP address of the current host.

hostname -I
View files
You can use multiple commands and tools to view files in Linux. The following are some common methods:

Use the cat command: This command can display the file contents. Enter the cat [file name] command in the terminal and press Enter to output the file contents to the terminal.

catfile.txt
uses the less command: This command can also display the file content, but compared to the cat command, the less command is more suitable for viewing large files because it can be displayed in pages. Enter the less [file name] command in the terminal and press Enter to view the file using the less tool.

lessfile.txt
In the less interface, you can use the up and down arrow keys to scroll up and down the file content, and press the q key to exit viewing.

Use the head and tail commands: These two commands are used to view the contents of the beginning and end of the file respectively. Enter the head -n [number of lines] [file name] or tail -n [number of lines] [file name] command in the terminal and press Enter to view the first n lines or the last n lines of the file.

head -n 10 file.txt
tail -n 10 file.txt
Dynamically view log files
In Linux, you can use the tail command to view log file updates in real time. The following is the specific command format and parameter explanation:

tail -f log file path
. The -f parameter indicates continuous monitoring of changes in the log file. When new log content is generated, it will be automatically output on the terminal.

For example, to view the latest update records of the /var/log/syslog log file, you can use the following command:

After executing the tail -f /var/log/syslog
command, the latest update record of the syslog log file will be displayed on the terminal in real time. If you want to stop viewing the log file immediately, you can press Ctrl+C to exit.

What commands are commonly used to view logs, and what are the main contents checked?
In Linux systems, common commands for viewing logs include tail, cat, less, etc.

tail: You can view the log file being updated in real time, often used to monitor the log information generated when the system is running;

cat: can display the contents of the entire log file, suitable for viewing smaller log files;

less: View the contents of the log file by page, and also supports search and jump operations in the file.

When viewing logs, you mainly need to pay attention to the following:

Error messages and abnormal events: This information can help us quickly discover problems in the system and handle them in a timely manner.

The operating status of the system: including system startup and shutdown time, usage of resources such as CPU, memory, and network, etc., can help us understand the performance of the system and optimize the system configuration in a timely manner.

Application log information: Record the running process of the application, including access logs, debugging logs, business exceptions, etc., which can help us diagnose application problems and improve the stability and reliability of the application.

Checking the system hard disk space
To check the Linux system hard disk space, you can use the df command. This command can display the disk space usage of the file system, including used space, free space, file system type, etc.

The command format is:

df [options][file system]
Commonly used options include:

-h: Display disk space in human-readable form;

-T: Display file system type;

-x: Exclude specified file system types.

For example, to view the disk space usage of all file systems of the current system, you can execute the following command:

The df -h
command will output the disk space usage information of each file system.

Check a certain port number
Use the netstat command or the lsof command to check whether a certain port is occupied on the Linux system.

The format for using the netstat command is:

netstat -anp | grep port number
Among them, -a means to display all connected and listening ports, -n means to output in numerical form, -p means to display the process information occupying the port, and the grep command filters out the data containing the specified port number. OK

For example, to check whether there is a process listening on port 80 in the system, you can use the following command:

After executing the command netstat -anp | grep 80
, if the output result is empty, it means that the system does not have a process listening to port 80; otherwise, the output result will contain information about the process occupying the port.

Use the lsof command to check whether a port is occupied. The command format is as follows:

lsof -i :port number
For example, to check whether there is a process listening on port 80 in the system, you can use the following command:

After executing the command lsof -i :80
, if the output result is empty, it means that there is no process in the system listening to port 80. Otherwise, the output results will display the process information occupying the port.

View all ports listening on the current machine
You can use the following command to view all ports listening on the current machine:

netstat -tlnp
Among them, -t means to display the connection status of the TCP protocol, -l means to display the connection in the listening state, -n means not to display the domain name and service name, and -p means to display the PID and program name.

View the process ID
Use the ps command to view the process ID (PID) of a process on the Linux system. The ps command is a commonly used process viewing tool that can list the current user's process list or the list of all system processes.

The format of using ps command is:

ps -ef | grep process name
Among them, -e means to list all processes, -f means to display process details, and the grep command is used to filter out lines containing the specified process name.

For example, to view the process number of a process named "nginx", you can use the following command:

After ps -ef | grep nginx
executes the command, the output will include process information with the process name "nginx", and the second column is the process number of the process.

If you know the name or keyword of the process you want to find, you can also directly use the pgrep command to find the process number of the process. The command format is:

pgrep process name
For example, to find the process number of a process with the process name "nginx", you can use the following command:

After pgrep nginx
executes the command, the output result will include the process number of the process name "nginx".

Checking network faults
The tracert command can be used to check the steps or routes taken by the network when connecting to the site. If there is a network fault, you can use this command to check the location of the problem. Therefore, the tracert command can be used to detect and troubleshoot network problems.

How to filter the file content containing "ERROR"?
You can use the grep command to filter out lines containing specific strings in the file content. The grep command is a powerful text search tool that can find text lines containing a specified string in a file or standard input, and output the matching lines.

To filter lines containing "ERROR" in file content in Linux, you can use the following command:

grep "ERROR" filename
where filename is the file name to be filtered. After executing the command, the grep command will look for text lines containing "ERROR" in the filename file and output their contents.

If you want to ignore case, you can add the -i parameter, for example:

grep -i "error" filename
The above command will find lines of text containing "error" or "ERROR" in the filename file.

What parameters are used in the ps command to display the processes of all users?
In the Linux ps command, use the parameter "-e" or "-A" to display the processes of all users. Among them, the "-e" parameter is used to display all processes, and the "-A" parameter is equivalent to the "-e" parameter. Therefore, running the following command will list the processes of all users:

ps -e
or

ps -A
How to query the tomcat process and kill it.
Use the ps command to query the process ID (PID) and other information of the Tomcat process. The following commands can be used:

ps -ef | grep tomcat
This command will list all Tomcat related processes and their details.

Find the PID of the Tomcat process you want to end.

Use the kill command to shut down the process. The following commands can be used:

kill [PID]
where [PID] is the PID of the Tomcat process to be shut down.

After waiting for a while, run the ps command again to ensure that the Tomcat process has ended successfully.

The meaning of the command kill9.
The command kill -9 means to forcefully terminate a process. By executing this command, you can send a SIGKILL signal to a specific PID process to directly end the process without going through the normal shutdown process.

Using this command may cause data corruption or resource leakage in some processes, so it is recommended to use the kill -9 command only when necessary and perform necessary backup and data protection at the same time.

It should be noted that if the process cannot be ended by normal methods, only use the kill -9 command to force a stop. Consider using this command only if the target process is unresponsive or cannot be terminated by other means.

Find the haha.txt file in the current user directory.
You can use the find command in Linux to find the file in the current user directory. The specific command is as follows:

find~ -name "haha.txt"
where the symbol "~" represents the current user directory, and the -name parameter is used to specify the file name to be searched. The above command means to find the file named "haha.txt" in the current user directory. .

How to search and display all lines starting
with " " in a file. You can use the grep command in the Linux system to search for all lines starting with " " in the file. The specific command is as follows:

grep "^*" filename
where ^ means matching the beginning of the line, * is the string to be found, and filename is the file name to be searched.

After executing this command, the system will search for all lines starting with "*" in the specified file and output these lines to the terminal. If you want to save the search results to a file, you can change the command to:

grep "^*" filename > result.txt
The command to pack and compress a folder into .tar.gz, and the command to decompress and unpack .tar.gz. The
command to pack a folder into .tar.gz is as follows:

tar -zcvf filename.tar.gz foldername
Among them, -z means to use gzip compression, -c means to create a new archive file, -v means to display detailed process information, and -f means to specify the compressed file name. filename.tar.gz is the name of the compressed file you want to generate, and foldername is the name of the folder you want to compress.

The command to decompress a .tar.gz compressed package is as follows:

tar -zxvf filename.tar.gz
Among them, -x means to extract the file, -z means to use gzip to decompress, -v means to display detailed process information, and -f means to specify the file name to be operated.

This command will extract the folder and its contents in the current directory. If you want to extract the files to a specified directory, you can add the target path at the end of the command.

If the Xshell tool wants to upload or download files from the server, what packages can be installed on the server?
The Xshell tool can upload or download files from the server by using the SFTP protocol. Therefore, the OpenSSH package needs to be installed on the server to support the SFTP protocol.

On Linux systems, OpenSSH can be installed with the following command:

sudo apt-getupdate
sudo apt-get install openssh-server
On Windows systems, you need to download and install OpenSSH from the official website.

Take the first five lines of /etc/passwd as an example to extract the user name?
Taking the first five lines of /etc/passwd as an example, the format is as follows:

root❌0:0:root:/root:/bin/bashdaemon❌1:1:daemon:/usr/sbin:/usr/sbin/nologinbin❌2:2:bin:/bin:/usr/sbin/nologinsys❌ 3:3:sys:/dev:/usr/sbin/nologinsync❌4:65534:sync:/bin:/bin/sync You
can see that the username is the string before the first colon (:) of each line . Therefore, the username can be extracted using the cut command. The specific commands are as follows:

cat /etc/passwd | cut -d: -f1 | head -n 5
Among them, cut -d: -f1 means to use colon as the separator to extract the first column (that is, the user name), and head -n 5 means to display only the first column The result of the five elements.

After running the above command, the output result is:

What is the difference between root
daemon
bin
sys
sync
grep and find in Linux?
grep: used to find a specified string in a file and output the line containing the string. The syntax is as follows:

grep [options] pattern [file…]
Among them, pattern is the string to be found, and file is the file to be found. If no file is specified, the default is to read from standard input. The grep command supports many options, such as -i (ignore case), -v (display lines that do not contain the matching string), -n (display the line number of the matching line), etc.

find: Used to find files or directories that meet the conditions in the specified directory and perform the specified operation. The syntax is as follows:

find [path][expression]
where path is the directory to be found, and the default is the current directory. expression is an expression consisting of various options and test conditions. Common options include -name (match by file name), -type (match by type), -exec (execute command), etc.

As you can see, the main difference between grep and find is that they work on different objects. grep works on the file content to find the specified string in the file; while find works on the file system to find files or directories that meet the conditions.

What are the uses of grep?
Find a string in a single file:

grep pattern filename
pattern is the pattern to be searched, which can be an ordinary string or a regular expression.

filename is the file name to be searched.

Find strings in multiple files

grep pattern file1 file2...
You can specify multiple file names at the same time, which means searching for the specified pattern in these files.

Find files in a directory recursively

grep pattern -r directory
directory is the directory that needs to be searched recursively, which can be a relative path or an absolute path.

Ignore case when finding strings:

grep -i pattern filename
uses the -i option to ignore case and treat lowercase and uppercase letters as the same characters.

Display the line number of matching lines:

grep -n pattern filename
uses the -n option to display the line number of the matching line to facilitate quick location.

Show unmatched lines:

grep -v pattern filename
Use the -v option to display lines that do not contain a matching pattern.

Count the number of matching lines:

grep -c pattern filename
uses the -c option to output the number of matched lines.

Match whole words:

grep -w pattern filename
Use the -w option to match the entire word rather than part of the pattern.

Creating and deleting multi-level directories
There are two ways to create multi-level directories using Linux commands:

Use the mkdir -p command

mkdir -p dir1/dir2/dir3
Note: The above command will create a directory named dir1 in the current directory, create a subdirectory named dir2 in it, and finally create a directory named dir3 in dir2.

Use the method of creating directories level by level

mkdir dir1 && cd dir1 && mkdir dir2 && cd dir2 && mkdir dir3
Note: The above command uses multiple && connectors to connect multiple commands together. First create a directory named dir1 in the current directory, then switch to the dir1 directory and create a subdirectory named dir2 in it. Then enter the dir2 directory and create a directory named dir3 in it.

There are also two ways to delete multi-level directories using Linux commands:

Use the rm -r command

rm -r dir1
Description: The above command will recursively delete the directory named dir1 and all subdirectories and files in it. It should be noted that this command will not prompt the user to confirm the operation and will be deleted directly once executed.

Use the rmdir command

rmdir dir1/dir2/dir3
Description: The above command will delete the directory named dir3, then execute the rmdir... command in it to delete the dir2 directory, and then execute the rmdir... command in it to delete the dir1 directory. It should be noted that this command can only delete empty directories. If there are files or subdirectories in the directory, you cannot use this command to delete them directly.

How to delete a non-empty subdirectory /tmp
In Linux, you can use the rm command to delete the directory. If you want to delete a non-empty subdirectory, you need to add the -r parameter to recursively delete all files and subdirectories in it.

The specific operations are as follows:

rm -r /tmp/your_directory
In the above command, your_directory is the name of the non-empty subdirectory to be deleted, and /tmp/ is the parent directory where the subdirectory is located.

How to know how much space is left in the current directory?
The du command can display the disk usage of a specified directory or file, including the total disk space occupied by the file or directory and the space of its subdirectories.

To know the space usage of the current directory, you can enter the following command in the terminal:

du -sh.
Among them, the -s parameter means that only the space size of the current directory is counted, and the -h parameter can display the output results in a human-readable format for easy viewing. The last . indicates the current directory and can also be replaced with the specified directory.

After executing the above command, the terminal will display the total space size of the current directory in KB, MB or GB. For example:

43M.
The above output results indicate that a total of 43 MB of disk space is occupied in the current directory.

How to change the permission settings of a file?
In Linux, you can use the chmod command to change permission settings for a file or directory. The chmod command can modify the access permissions (read, write, execute) of a file or directory, and allow users, user groups, and other users to have different permissions.

To change the permission settings of a file, you can enter the following command in the terminal:

chmod file
, mode is the permission setting parameter, which can be represented by numbers or symbols, and file is the name of the file whose permissions are to be changed.

When using numbers to represent permissions, the mode parameter consists of three digits, each of which can take a value of 0-7, representing the permissions of the user, user group and other users respectively. Among them, 0 means no permission, 1 means execution permission, 2 means write permission, 3 means write and execute permission, 4 means read permission, 5 means read and execute permission, 6 means read and write permission, 7 means read, write and execute. permissions. For example, chmod 755 file.txt means to set the permissions of the file file.txt to -rwxr-xr-x, that is, the user has read, write, and execute permissions, and the user group and other users have read and execute permissions.

When using symbols to represent permissions, the mode parameter consists of multiple symbols, including:

u: Indicates the user's permissions.

g: Indicates the permissions of the user group.

o: Indicates the permissions of other users.

a: Indicates the permissions of all users.

+: Indicates increasing permissions.

-: Indicates canceling permission.

=: Indicates setting permissions.

For example, chmod u+w file.txt means to add write permission to the user permissions of file file.txt.

It should be noted that when changing the permissions of a file or directory, you need to have sufficient permissions, otherwise a Permission denied error will be prompted.

How does Linux define all tasks that will be run at a specific time in the future?
In Linux, you can use the at command to execute a task at a specific time in the future. To define a task to run at a specific time, follow these steps:

Use the at command to create a new task, the syntax is as follows:

at

Enter the command or script to be executed at the task prompt at>. Everything added after the task prompt will run at the specified time. For example, to run the /path/to/my/script.sh script file at 8 a.m. tomorrow, enter the following command:

at8am tomorrow
at>/path/to/my/script.sh
at>
The first line of command hands the session to at and sets the task to run at 8 am tomorrow; the second line of command enters the content of the script to be run; the last line of command indicates End input.

Use the atq command to list all currently pending tasks and confirm that the tasks have been added successfully.

Close the terminal and wait for the specified time to arrive, and the task will be automatically executed.

It should be noted that the availability of the at command depends on whether the atd service is installed and enabled on the system. If the service is not installed on the system, you need to install and start the service first. For example, in Ubuntu, you can use the following command:

sudo apt-get install at
sudo systemctl start atd
In bash, what is the role of the export command?
In the bash shell, the role of the export command is to set or display environment variables. When executing a program in the shell, the shell will provide a set of environment variables. The export command can add, modify, or delete environment variables for subsequent use of the program.

There is a backup program mybackup that needs to be run at 1 pm and 8 pm from Monday to Friday. Which crontab item can be used to complete this task? You can use the following crontab
expression to complete this task:

0 13,20 * * 1-5 /path/to/mybackup
This crontab expression indicates that the /path/to/mybackup command is executed at 1 pm and 8 pm from Monday to Friday. The specific explanation is as follows:

0 represents minutes, indicating that the task is executed at the 0th minute of every hour;

13,20 represents the hour, indicating that the task is performed at 1 pm and 8 pm every day;

  • Indicates date, indicates any date;

  • Indicates month, indicates any month;

1-5 indicates the day of the week, indicating that the task will be performed from Monday to Friday.

How to unmount a mounted file system from the current system
To unmount a mounted file system, you need to use the umount command. Here is the basic syntax:

umount [options] file system path
where options include:

-f: Force unmount, even if the file system is busy, it will be unmounted;

-l: Delay uninstallation until the file system is no longer in use.

To unmount a mounted file system, follow these steps:

Determine the file system path to be unmounted, such as /mnt/mydata;

Enter the command umount /mnt/mydata in the terminal to unmount the /mnt/mydata file system.

How to mount all files defined in /ect/fstab
In Linux system, to mount all file systems defined in /etc/fstab, you can use the mount -a command. The meaning of the -a option is to mount all files in /etc/ File systems listed in the fstab file that are defined but not currently mounted.

This command can be executed automatically when the system starts, or manually after modifying the /etc/fstab file to make the new file system entries take effect.

How to copy f1.txt to f2.txt
In Linux, you can use the cp command to copy one file to another. Enter the following command in the terminal to copy f1.txt to f2.txt:

cp f1.txt f2.txt
Among them, cp is the name of the copy command, f1.txt is the name of the source file to be copied, and f2.txt is the name of the target file after copying.

ps: If the target file f2.txt with the same name already exists in the current directory, you will be prompted whether to overwrite the file. If you want to force overwriting, you can add the -f option, that is, cp -f f1.txt f2.txt.

What symbol should be added at the end of a line to indicate that it is not over and will continue
on the next line? Adding a backslash symbol (\) at the end of a line indicates that it is not over and will continue on the next line. This technique is called line continuation or line folding, and is common in programming languages, shell scripts, etc.

For example, in a shell script, you can use line continuation to divide a long command into multiple lines to improve the readability of the code. Examples are as follows:

echo "This is a relatively long command and needs to be divided into
multiple lines to be completely displayed in the terminal."
In this example, we use the backslash symbol to split a long string into two lines, but these two lines of string It is actually a complete command and will be processed as a single line when executed.

In which file should the variable settings for all users be placed?
In Linux, variable settings for all users can be placed in the /etc/profile or /etc/environment file. These two files have different functions:

/etc/profile file: It is the global shell configuration file of the system. It will be read when the user logs in, set environment variables, execute system-level scripts, etc. If you want to set environment variables for all users, you can add the corresponding statements to the /etc/profile file.

/etc/environment file: It is a system-wide environment variable configuration file. It contains all system-wide environment variable settings. These settings will be read when the system starts and will take effect in all processes. If you want to set a global environment variable for all users, you can add the variable name and value to the /etc/environment file.

What do script files usually start with in Linux systems?
In Linux systems, script files generally start with #!/bin/bash or #!/usr/bin/env bash. The statement at the beginning of this line is called a shebang or sha-bang, and it tells the system which interpreter the script should be executed with.

Script files starting with #!/bin/bash will be executed using the Bash interpreter, while script files starting with #!/usr/bin/env bash will search for a program named bash in the system's $PATH, and Use it to execute script files.

What is the name of the software that provides TCL/IP packet filtering function in Linux?
In Linux, the software that provides TCP/IP packet filtering function is called iptables. It is a kernel-based software that can monitor and filter IP packets transmitted in the network, and can implement network flow control on the server to enhance network security and stability.

What is the command to exit without saving in vi?
In vi, to exit the file without saving the changes, you can use the :q! command. This command will force quit vi and discard all previous modifications.

The specific steps are as follows:

Enter the vi editor interface.

Press the Esc key to make sure you are in command mode.

Enter the :q! command, including the colon: and the exclamation mark!.

Press the Enter key to exit the vi editor and discard previous modifications.

It should be noted that this command cannot restore previous modifications, and once executed, it cannot be undone, so please confirm whether you need to save the modifications before using it.

In Linux, what command is used to detect basic network connections?
In Linux, you can use the ping command to detect basic network connections. The ping command sends an ICMP echo request to the specified IP address or domain name and waits for a response. If the target host responds correctly, the network connection is normal; otherwise, there may be a network failure or the target host is unreachable.

The specific command format to detect network connections is:

ping <IP address or domain name>
For example, to check the network connection with Baidu, you can enter the following command:

When pinging www.baidu.com
, please note that ICMP requests may be prohibited in some network environments, and the ping command may not be available in this case. In addition, the ping command can set some parameters, such as setting the packet sending interval, setting the number of sent packets, etc. You can view the help document through the man ping command to learn more.

For the Apache server, which user provides the default values ​​for a child process.
For the Apache server, the user that provides the default values ​​for a child process is the user to which the server process belongs (usually the httpd user).

The Apache HTTP server is essentially a multi-process server. The main process receives connection requests from clients and creates child processes to handle these requests. By default, newly created child processes inherit the effective user ID and group ID of the main process and use these IDs to run programs. Therefore, if the main process runs as a privileged user (such as root), then all child processes will also have the same permissions and may be a security risk.

In order to avoid this security risk, you can usually modify the User and Group directives in the Apache configuration file to specify the user and group running the server process, thereby reducing the level of permissions occupied by the server process. For example, setting these directives to a non-privileged user, such as the httpd user, can enhance server security.

Which is the main configuration file of apache?
The main configuration file of apache is the httpd.conf file. This file is usually located in the installation directory of the Apache server. You can configure various parameters of the server by editing this file, including listening IP address and port number, virtual host configuration, user permission settings, etc.

What is the command to install compiled code through Makefile?
If you want to install the compiled code to a specified location, you can define the install target in the Makefile and write the installation command in it. Before installation, you need to compile and generate target files and executable files, and package them into a release package. In the Makefile, you can use the tar tool to package and use the install command to install to the specified location.

For example, under Linux, you can use the following command to package a file:

tar -czvf my_project.tar.gz my_project
Then, add an install target to the Makefile as follows:

install:
mkdir -p /usr/local/my_project
tar -xzvf my_project.tar.gz -C /usr/local/my_project
Execute the make install command to install the compiled code into the /usr/local/my_project directory.

The command netstat -a stopped for a long time without responding. What could be the problem?
The function of the command netstat -a is to list all network connections (including TCP, UDP protocols, etc.), as well as related status, port number and other information. If the netstat -a command hangs for a long time without responding, it may be because there are a lot of connections and network traffic on the system, causing the command to take a long time to complete. In addition, if the system performance is poor or there is a network failure, the execution of the netstat -a command may also become slow or unresponsive.

What is the protocol used by ping?
The protocol used by the ping command is the ICMP (Internet Control Message Protocol) protocol. ICMP is a sub-protocol in the TCP/IP protocol suite. It is mainly used to transmit control messages between network devices, such as determining whether the host is reachable, calculating network delay, etc. Since ICMP is a connectionless-oriented protocol, the host's reachability and network status can be detected directly through ICMP messages without establishing a TCP or UDP connection. When executing the ping command, the ICMP protocol is used to send a detection message to the target host, and the network connection and delay are determined by the response of the target host.

In TCP/IP, which protocol is used for automatic IP allocation?
In the TCP/IP protocol suite, the DHCP (Dynamic Host Configuration Protocol) protocol is used for automatic IP allocation. DHCP is a connectionless-oriented protocol that supports the automatic assignment of network configuration information such as IP addresses, subnet masks, gateways, and DNS servers to client devices. When a new device joins the network, it can initiate a request to the DHCP server to automatically obtain available IP addresses and other network configuration information. Using DHCP can simplify network management and improve network stability and scalability.
——————————————
Copyright statement: This article is an original article by CSDN blogger “Qingwei Qingwei” and follows the CC 4.0 BY-SA copyright agreement. Please attach a link to the original source for reprinting and this Statement.
Original link: https://blog.csdn.net/m0_71986704/article/details/130062372

Welcome to the Markdown editor

Hello! This is the welcome page displayed when you use the Markdown editor for the first time . If you want to learn how to use the Markdown editor, you can read this article carefully to learn about the basic syntax of Markdown.

new changes

We have made some functional expansion and syntax support for the Markdown editor. In addition to the standard Markdown editor functions, we have added the following new features to help you use it to write blogs:

  1. The new interface design will bring a new writing experience;
  2. Set your favorite code highlighting style in the creation center, and Markdown will display the code piece in the selected highlighting style ;
  3. Added image drag and drop function, you can drag local images directly to the editing area for direct display;
  4. Brand new KaTeX mathematical formula syntax;
  5. Added mermaid syntax 1 function that supports Gantt charts ;
  6. Added the function of editing Markdown articles on multiple screens;
  7. Added functions such as focus writing mode, preview mode, concise writing mode, left and right area synchronized wheel settings, etc. The function button is located between the editing area and the preview area;
  8. Checklist functionality added .

Function shortcut keys

Undo: Ctrl/Command+ Z
Redo: Ctrl/Command+ Y
Bold: Ctrl/Command+ B
Italic: Ctrl/Command+ I
Title: Ctrl/Command+ Shift+ H
Unordered list: Ctrl/Command+ Shift+ U
Ordered list: Ctrl/Command+ Shift+ O
Checklist: + +Insert code Ctrl/Command: Shift+ C
+ Ctrl/CommandInsert Shiftlink K
: Ctrl/Command+ Shift+ L
Insert picture: Ctrl/Command+ Shift+ G
Find: Ctrl/Command+ F
Replace: Ctrl/Command+G

Properly create titles to help create a table of contents

Enter it directly once #and press it, spaceand a level 1 title will be generated.
After entering it twice #and pressing it space, a level 2 title will be generated.
By analogy, we support level 6 titles. TOCHelps to generate a perfect table of contents using syntax.

How to change the style of text

Emphasis on text Emphasis on text

bold text bold text

mark text

Delete text

quoted text

H 2 O is a liquid.

The result of 2 10 operation is 1024.

Insert links and images

Link: link .

picture:Alt

Pictures with dimensions:Alt

Centered image:Alt

Centered and sized image:Alt

Of course, in order to make it more convenient for users, we have added the image drag and drop function.

How to insert a beautiful piece of code

Go to the blog settings page and choose a code fragment highlighting style you like. The same highlighting style is shown below 代码片.

// An highlighted block
var foo = 'bar';

Generate a list that works for you

  • project
    • project
      • project
  1. Project 1
  2. Project 2
  3. Project 3
  • Scheduled Tasks
  • mission accomplished

Create a form

A simple table is created like this:

project Value
computer $1600
cell phone $12
catheter $1

Set content to center, left, or right

Use :---------:center
. Use :----------left.
Use ----------:right.

first row The second column third column
The first column of text is centered The second column of text is on the right The third column of text is on the left

SmartyPants

SmartyPants converts ASCII punctuation characters into "smart" typographic punctuation HTML entities. For example:

TYPE ASCII HTML
Single backticks 'Isn't this fun?' ‘Isn’t this fun?’
Quotes "Isn't this fun?" “Isn’t this fun?”
Dashes -- is en-dash, --- is em-dash – is en-dash, — is em-dash

Create a custom list

Markdown
Text-to- HTML conversion tool
Authors
John
Luke

How to create a footnote

A text with footnotes. 2

Comments are also essential

Markdown converts text to HTML .

KaTeX math formula

You can render LaTeX mathematical expressions using KaTeX :

Gamma infrastructure ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb NC ( n )=(n1)!nN is the integral via Euler

Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t   . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. C ( z )=0tz 1 etdt.

You can find more information about LaTeX mathematical expressions here .

New Gantt chart function to enrich your articles

2014-01-07 2014-01-09 2014-01-11 2014-01-13 2014-01-15 2014-01-17 2014-01-19 2014-01-21 已完成 进行中 计划一 计划二 现有任务 Adding GANTT diagram functionality to mermaid
  • Regarding Gantt chart syntax, please refer here ,

UML diagram

UML diagrams can be used for rendering. Mermaid . For example, a sequence diagram generated below:

张三 李四 王五 你好!李四, 最近怎么样? 你最近怎么样,王五? 我很好,谢谢! 我很好,谢谢! 李四想了很长时间, 文字太长了 不适合放在一行. 打量着王五... 很好... 王五, 你怎么样? 张三 李四 王五

This will produce a flowchart. :

链接
长方形
圆角长方形
菱形
  • Regarding Mermaid syntax, refer here ,

FLowchart flowchart

We will still support flowchart flow charts:

Created with Raphaël 2.3.0 开始 我的操作 确认? 结束 yes no
  • Regarding Flowchart flowchart syntax, refer here .

Export and import

Export

If you want to try using this editor, you can edit whatever you want in this article. When you finish writing an article, find the article export in the upper toolbar and generate a .md file or .html file for local saving.

import

If you want to load a .md file you have written, you can select the import function on the upper toolbar to import the file with the corresponding extension and
continue your creation.


  1. mermaid syntax description↩︎

  2. Explanation of footnote↩︎

Guess you like

Origin blog.csdn.net/l453521934/article/details/131321943