当前位置:网站首页>Difference between service and systemctl / method of modifying path / a command to view IP address, gateway and DNS server
Difference between service and systemctl / method of modifying path / a command to view IP address, gateway and DNS server
2022-07-21 16:18:00 【Everything is lovely 33】
One .service and systemctl The difference between
Linux Two ways of service management :service and systemctl
service The order is actually to /etc/init.d Under the table of contents , To execute relevant procedures ,init.d The directory contains many start and stop scripts for various services of the system . When Linux Startup time , Will look for service scripts in these directories , And according to the script run level Determine the different boot levels .
This method has two disadvantages :
- First, it takes a long time to start .init Process is serial start , Only the previous process started , To start the next process .
- Second, the startup script is complex .init The process just executes the startup script , Whatever else . Scripts need to deal with all kinds of situations themselves , This tends to make scripts very long
Systemd It was born to solve the above problems . Its design goal is , Provide a complete set of solutions for system startup and management . according to Linux practice , Letter d It's the daemons (daemon) Abbreviation . Systemd The meaning of the name , It's about guarding the whole system . Used Systemd, There's no need to use init 了 .Systemd To replace the initd, Become the first process of the system (PID be equal to 1), Other processes are its children .
[[email protected] system]# pwd
/usr/lib/systemd/system
systemctl Can manage /usr/lib/systemd/system All in this directory are marked with .service The end of the service , for example Network.service,nginx.service
Essentially systemctl Or execute an executable file to manage that service , It's just convenient , adopt systemctl To manage , We don't need to find that file to execute
[[email protected] system]# cat NetworkManager.service
ExecStart=/usr/sbin/NetworkManager --no-daemon # for example systemctl start NetworkManager Is to /usr/sbin/NetworkManager To execute that file
Two . modify PATH Method of environment variable
1. The method of temporary modification
export PATH= Variable path :$PATH Or directly PATH= Variable path :$PATH
2. Permanent modification
modify /root/.bashrc In the document PATH Variable
3. Permanent modification
modify /etc/profile file , add to PATH=/sc:$PATH, Just add in the first line . Effective for all users , We all know the installation path of your program
3、 ... and . Write a script , Realize that you can view at the same time through one command IP Address 、 gateway 、DNS The server , And it is set to be used directly wherever you enter this command
[[email protected] shell-test]# pwd
/lianxi/shell-test
[[email protected] shell-test]# cat ip.sh
#!/bin/bash
# get IP Address
ip=`ip add|awk -F' ' 'NR==9 {print $2}'`
# Get gateway
route=`ip route|awk 'NR==1 {print $3}'`
# get DNS The server
dns=`cat /etc/resolv.conf|awk 'NR==3 {print $2}'`
echo "IP The address is :"$ip,"GATEWAY by :"$route,"DNS The server is :"$dns
[[email protected] shell-test]# bash ip.sh
IP The address is :192.168.2.43/24,GATEWAY by :192.168.2.1,DNS The server is :114.114.114.114
The above simple function has been realized , But only in /lianxi/shell-test This specified location implements , Other locations cannot be achieved . Next we add aliases and modify PATH Variable , Achieve input at any position in the system ipa This command can get the above effect
[[email protected] shell-test]# vim /root/.bashrc
[[email protected] shell-test]# cat /root/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ipa=`bash /lianxi/shell-test/ip.sh` # Set an alias for the script just now , Input ipa You can get the same effect
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=/lianxi/shell-test/:/usr/local/sclilin99/sbin:/lianxi: # modify path Variable , Add the path where your script is located
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[[email protected] shell-test]# ipa
IP The address is :192.168.2.43/24,GATEWAY by :192.168.2.1,DNS The server is :114.114.114.114
[[email protected] shell-test]# cd ~
[[email protected] ~]# ipa # Now the above functions can be realized in any position
IP The address is :192.168.2.43/24,GATEWAY by :192.168.2.1,DNS The server is :114.114.114.114
边栏推荐
- How can traditional retail enterprises promote consumption cycle and share purchase mode to enable the development of physical enterprises?
- Is there any risk in opening a mobile stock account? Is it safe?
- 每日一題-LeetCode1260-二維網格遷移-數組-映射
- 设置 当前样式dimstyle
- 2022 eye care lamp exhibition, traditional Chinese medicine eye conditioning exhibition, Shandong eye health exhibition, China eye Expo
- 2022 Shandong vision prevention and control conference, China eye care products exhibition, Jinan myopia correction equipment exhibition
- In the future, a new way of tourism, VR traveling without leaving home, embracing poetry and distance
- Esp8266 nodemcu - connect WiFi using WiFi manager Library
- Projection & local illumination
- [stc15 controls ws2812 RGB color lamp cascade]
猜你喜欢
At present, pytest, the hottest testing framework, is a magical explanation
Wechat vaccine appointment applet graduation design (5) assignment book of applet completion work
深度解析:链动2+1模式是如何玩转招商引流的
C | | structure consortium enumeration type
Change dimension style text fill color
Algorithm summary] 20 questions to complete bat interview - binary tree
传统零售企业如何促进消费循环、分享购模式赋能实体企业发展?
Wechat vaccine appointment applet graduation design of applet completion works (1) development outline
Esp8266 nodemcu -- use u8g2 library to light OLED
Dama Chapter 11 (data warehouse and business intelligence)
随机推荐
Xqlla2.3.2 parsing query
深度解析:链动2+1模式是如何玩转招商引流的
L'ipaylinks, un service d'intégration des paiements transfrontaliers, a remporté le prix 3A Asia de l'actif!
DTOS帝拓思的3D引擎將取代遊戲引擎巨獸,實現國產化替代
Amazon cloud technology training and Certification Course in August is wonderful and can't be missed!
十大券商开户有没有风险的?安全靠谱吗?
Using go TCP to realize simple online group chat function
i2c adapter驅動
Training of head and neck segmentation networks with shape prior on small datasets
[JS] mouse follow
Okaleido tiger NFT is about to log in to binance NFT platform, and the future market continues to be optimistic
專注跨境支付一體化服務 iPayLinks榮獲《財資》(The Asset)3A亞洲獎!
Source code, complement and fixed-point number operation
Wechat vaccine appointment applet graduation design (5) assignment book of applet completion work
致测试/开发程序员:爱生活,不加班,苦逼的程序员......
One Oracle statement to update or add
deadlock
[example] input text in the input box to output the typewriter effect
How can traditional retail enterprises promote consumption cycle and share purchase mode to enable the development of physical enterprises?
设置 当前样式dimstyle