Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the suggestions for the use of Linux system?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What are the suggestions for the use of the Linux system? I believe many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Do not modify the system-level configuration file, add a custom configuration file to the system-level configuration directory.

For example, there is usually a configuration directory with the configuration file name .d under the same level directory of the configuration file, which is to prevent configuration conflicts in a multi-user and multi-service environment.

Proc kernel parameter configuration, do not directly modify the configuration file / etc/sysctl.conf, you should name the configuration file (such as 99-app-sysctl.conf) after the business or service name, and then put it in the / etc/sysctl.d directory.

In the same way to configure ulimit, instead of modifying the / etc/security/limits.conf configuration file, you should name the configuration file (such as 99-app-limits.conf) after the business or service name, and then place it in the / etc/security/limits.d/ directory.

In the same way to configure the environment variables for the global Shell, do not modify the / etc/profile or / etc/bashrc file, but should name the configuration file (such as eleme.sh) after the business or separately, and then place it in the / etc/profile.d directory.

Minimum range defines environment variables (Less better than more!)

For example, the environment variables needed to start the program are written in the program startup script.

The environment variables that the user needs are written in the user's ~ / .bashrc.

Need multiple environment variables common to the program, write them in a separate file, and then use the source command to bring them into the program startup script.

If the variable is immutable, decorate it with readonly.

If the variable requires child process or child shell inheritance, decorate it with export.

Cp commands are better than mv commands, and mv commands are better than rm commands.

For example: if you need to put the file in a new location, make sure you need to delete the original file first, and if you don't need to delete it, use the cp command. If you need to delete the original file, use mv to rename it to filename.bak-$ (date% FMI% T). The current system disk is much larger than the amount of space we need, so saving a backup of the original location of a file will help us to recover quickly.

When creating a scheduled task (cron), set a priority (nice) for your scheduled task.

For example, scheduled tasks are all background execution programs, and will compete for resources with other running tasks. If you do not want other tasks on this device to run slowly due to the execution of scheduled tasks, please add nice-n 10 before the command. It runs very fast when there are no other tasks, and it will give up resources when other tasks are running.

When creating a scheduled task (cron), pay attention to the command path problem and use the full path to run the program.

For example, when crontab-e-u USERNAME is used, there is no environment variable setting by default. Please customize PATH and other variables.

When your program cannot be opened, written, or created files and directories, please check its parent directory permissions.

For example: / var/log directory permission root.root 755, if you want your program to log, please create your own / var/log/ program name directory to ensure that the user running the program has write permission.

Please make sure that the input is correct before you enter the command, and confirm that the command is echoed after the execution of the command.

For example, if your network setting command is executed incorrectly, it will directly cause the network to be disconnected, and you will be kicked out of the input box by the fortress machine or frozen. At this time, you should contact the basic operation and maintenance staff as soon as possible. They also have the connection mode of IPMI control card to help you save it.

File names and directories are case-sensitive, please keep all names in lowercase letters

The correct way to empty log files is >. / logfile.log, not rm-rf. / logfile.log

After reading the above, have you mastered the suggestions for the use of the Linux system? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 293

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report