国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

service和systemctl的區(qū)別/修改PATH的方法/一條命令查看IP地址和網(wǎng)關(guān)以及DNS服務(wù)器

這篇具有很好參考價(jià)值的文章主要介紹了service和systemctl的區(qū)別/修改PATH的方法/一條命令查看IP地址和網(wǎng)關(guān)以及DNS服務(wù)器。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一.service和systemctl的區(qū)別

Linux服務(wù)管理的兩種方式:service 和 systemctl

service命令其實(shí)是去/etc/init.d目錄下,去執(zhí)行相關(guān)程序,init.d目錄包含許多系統(tǒng)各種服務(wù)的啟動(dòng)和停止腳本。當(dāng)Linux啟動(dòng)時(shí),會(huì)尋找這些目錄中的服務(wù)腳本,并根據(jù)腳本的run level確定不同的啟動(dòng)級(jí)別。

這種方法有兩個(gè)缺點(diǎn):

  • 一是啟動(dòng)時(shí)間長(zhǎng)。init 進(jìn)程是串行啟動(dòng),只有前一個(gè)進(jìn)程啟動(dòng)完,才會(huì)啟動(dòng)下一個(gè)進(jìn)程。
  • 二是啟動(dòng)腳本復(fù)雜。init 進(jìn)程只是執(zhí)行啟動(dòng)腳本,不管其他事情。腳本需要自己處理各種情況,這往往使得腳本變得很長(zhǎng)

Systemd 就是為了解決上面問題而誕生的。它的設(shè)計(jì)目標(biāo)是,為系統(tǒng)的啟動(dòng)和管理提供一套完整的解決方案。根據(jù) Linux 慣例,字母 d 是守護(hù)進(jìn)程(daemon)的縮寫。 Systemd 這個(gè)名字的含義,就是它要守護(hù)整個(gè)系統(tǒng)。使用了 Systemd,就不需要再用 init 了。Systemd 取代了 initd,成為系統(tǒng)的第一個(gè)進(jìn)程(PID 等于 1),其他進(jìn)程都是它的子進(jìn)程。

[root@xieshan system]# pwd

/usr/lib/systemd/system ? ? ? ?

systemctl可以管理/usr/lib/systemd/system這個(gè)目錄下所有以.service結(jié)尾的服務(wù),例如Network.service,nginx.service

本質(zhì)上systemctl還是執(zhí)行一個(gè)可執(zhí)行文件來管理那個(gè)服務(wù),只是這樣比較方便,通過systemctl來管理,不需要我們?nèi)フ业侥莻€(gè)文件再執(zhí)行

[root@xieshan system]# cat NetworkManager.service?

ExecStart=/usr/sbin/NetworkManager --no-daemon???????? #例如systemctl start NetworkManager就是到/usr/sbin/NetworkManager去執(zhí)行那個(gè)文件

systemctl也就是創(chuàng)建一個(gè)鏈接,鏈接到的位置是/etc/systemd/system/multi-user.target.wants

[root@xieshan ~]# systemctl enable firewalld
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
[root@xieshan ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@xieshan ~]# cd /etc/systemd/system/multi-user.target.wants
[root@xieshan multi-user.target.wants]# ls
auditd.service      kdump.service      rhel-configure.service  tuned.service
chronyd.service     mariadb.service    rpcbind.service         vmtoolsd.service
crond.service       nfs-client.target  rsyslog.service
ipmi.service        postfix.service    sshd.service
irqbalance.service  remote-fs.target   sysstat.service

service和systemctl的區(qū)別/修改PATH的方法/一條命令查看IP地址和網(wǎng)關(guān)以及DNS服務(wù)器

systemctl ?disable ?firewalld ?設(shè)置firewalld服務(wù)開機(jī)不啟動(dòng) --》下一次開機(jī)的問題
systemctl ?enable ?firewalld ?設(shè)置firewalld服務(wù)開機(jī)啟動(dòng)
systemctl ?start ?firewalld ?立馬啟動(dòng)firewalld的服務(wù) ? --》本次
systemctl ?stop ?firewalld ? 立馬關(guān)閉firewalld的服務(wù)

service ? sshd ?start ?---> systemctl start sshd?
? ?舊式啟動(dòng)服務(wù)的方式 ? ? ? ? 新式啟動(dòng)服務(wù)的方式?

systemctl list-unit-files ? ? ? ? ? ? ? ?查看當(dāng)前哪些服務(wù)開機(jī)自啟,哪些服務(wù)開機(jī)不自啟,哪些服務(wù)是其他服務(wù)的依賴部分

service和systemctl的區(qū)別/修改PATH的方法/一條命令查看IP地址和網(wǎng)關(guān)以及DNS服務(wù)器 ????????

二.修改PATH環(huán)境變量的方法

1.臨時(shí)修改的方法

export PATH=變量路徑:$PATH或者直接PATH=變量路徑:$PATH

2.永久修改

修改 /root/.bashrc文件中的PATH變量

3.永久修改

修改/etc/profile文件,添加PATH=/sc:$PATH,在第一行添加就行。對(duì)所有的用戶都生效,都知道你的程序安裝的路徑了

三.編寫一個(gè)腳本,實(shí)現(xiàn)通過一條命令可以同時(shí)實(shí)現(xiàn)查看IP地址、網(wǎng)關(guān)、DNS服務(wù)器,并且設(shè)置為在哪里輸入這個(gè)命令都可以直接使用

[root@xieshan shell-test]# pwd
/lianxi/shell-test
[root@xieshan shell-test]# cat ip.sh?
#!/bin/bash
#獲得IP地址
ip=`ip add|awk -F' ' 'NR==9 {print $2}'`?
#獲得網(wǎng)關(guān)
route=`ip route|awk 'NR==1 {print $3}'`
#獲得DNS服務(wù)器
dns=`cat /etc/resolv.conf|awk 'NR==3 {print $2}'`
echo "IP地址為:"$ip,"GATEWAY為:"$route,"DNS服務(wù)器為:"$dns
[root@xieshan shell-test]# bash ip.sh?
IP地址為:192.168.2.43/24,GATEWAY為:192.168.2.1,DNS服務(wù)器為:114.114.114.114

以上這個(gè)簡(jiǎn)單功能就已經(jīng)實(shí)現(xiàn)了,但是只能在/lianxi/shell-test這個(gè)指定位置實(shí)現(xiàn),其他位置不能實(shí)現(xiàn)。接下來我們添加別名和修改PATH變量,達(dá)到在系統(tǒng)中的任意位置輸入ipa這個(gè)命令便可得得到以上效果文章來源地址http://www.zghlxwxcb.cn/news/detail-453878.html

[root@xieshan shell-test]# vim /root/.bashrc
[root@xieshan 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`        #給剛剛的腳本設(shè)置一個(gè)別名,輸入ipa可以得到同等效果

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi
PATH=/lianxi/shell-test/:/usr/local/sclilin99/sbin:/lianxi:    #修改path變量,增加自己腳本所在的路徑
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@xieshan shell-test]# ipa?
IP地址為:192.168.2.43/24,GATEWAY為:192.168.2.1,DNS服務(wù)器為:114.114.114.114
[root@xieshan shell-test]# cd ~
[root@xieshan ~]# ipa        #現(xiàn)在在任意位置都可以實(shí)現(xiàn)以上功能了
IP地址為:192.168.2.43/24,GATEWAY為:192.168.2.1,DNS服務(wù)器為:114.114.114.114

到了這里,關(guān)于service和systemctl的區(qū)別/修改PATH的方法/一條命令查看IP地址和網(wǎng)關(guān)以及DNS服務(wù)器的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • route命令行查看或者修改默認(rèn)路由

    route命令行查看或者修改默認(rèn)路由

    route print命令 打開CMD,輸入route print,就可以查看我們計(jì)算機(jī)的路由表,如圖 看第一項(xiàng)0.0.0.0的網(wǎng)關(guān)為192.168.1.1,說明我們計(jì)算機(jī)的網(wǎng)關(guān)為192.168.1.1,如果我們刪除自己的網(wǎng)關(guān),計(jì)算機(jī)還能正常運(yùn)行嗎?如圖 我們來看目前的網(wǎng)絡(luò)連接狀態(tài): 可以看到目前是:無網(wǎng)絡(luò)訪問權(quán)限,也

    2024年02月08日
    瀏覽(27)
  • systemctl enable docker.service報(bào)錯(cuò)“Failed to execute operation: Bad message“

    systemctl enable docker.service報(bào)錯(cuò)“Failed to execute operation: Bad message“

    將docker加入到開機(jī)自啟,報(bào)錯(cuò): 解決: ?重新粘貼復(fù)制:

    2024年02月03日
    瀏覽(21)
  • 計(jì)算節(jié)點(diǎn)systemctl status openstack-nova-compute.service起不來的解決方案

    報(bào)錯(cuò) [root@compute ~]# systemctl start libvirtd.service openstack-nova-compute.service Job for openstack-nova-compute.service failed because the control process exited with error code. See \\\"systemctl status openstack-nova-compute.service\\\" and \\\"journalctl -xe\\\" for details. ● openstack-nova-compute.service - OpenStack Nova Compute Server ? ?Loaded: loade

    2024年02月03日
    瀏覽(29)
  • Linux服務(wù)器中啟動(dòng)mysql出現(xiàn)Redirecting to /bin/systemctl start mysql.service錯(cuò)誤及處理

    Linux服務(wù)器中啟動(dòng)mysql出現(xiàn)Redirecting to /bin/systemctl start mysql.service錯(cuò)誤及處理

    service mysql start 啟動(dòng)mysql服務(wù)器時(shí),提示如下錯(cuò)誤: 原因推測(cè): service mysql start 是重定向到 /bin/systemctl restart mysql.service. mysql 與mysqld是不同的,前者交互式命令(客戶端),mysqld才是后端服務(wù)進(jìn)程,應(yīng)該是啟錯(cuò)了 使用 service mysqld start 或者 systemctl start mysqld 啟動(dòng) 附:其他操作

    2024年02月13日
    瀏覽(36)
  • systemctl start docker異常 Job for docker.service failed because the control process exited with error

    啟動(dòng)docker 異常了 Job for docker.service failed because the control process exited with error code. See \\\"systemctl status docker.service\\\" and \\\"journalctl -xe\\\" for details. ?如果在啟動(dòng)Docker時(shí)遇到\\\"Job for docker.service failed because the control process exited with error code.\\\"錯(cuò)誤,這表明Docker服務(wù)啟動(dòng)時(shí)出現(xiàn)問題。為了排查和解

    2024年02月07日
    瀏覽(307)
  • Job for nginx.service failed because the control process exited with error code. See “systemctl stat

    Job for nginx.service failed because the control process exited with error code. See “systemctl stat

    【這個(gè)報(bào)錯(cuò)表示nginx的默認(rèn)進(jìn)程被占用】 第一步:systemctl status nginx查看nginx報(bào)錯(cuò)信息 第二步:查看nginx配置文件,我這的nginx默認(rèn)端口使用了3306 第三步:使用netstat -tlnp查看目前的端口使用情況,發(fā)現(xiàn)mysql已經(jīng)占用了3306端口,和我們nginx的默認(rèn)端口沖突 第四步:接著使用ps -

    2024年02月03日
    瀏覽(103)
  • Linux 命令 systemctl 詳解

    Linux systemctl 命令是 systemd 系統(tǒng)和服務(wù)管理器的主要命令之一,它可以啟動(dòng)、停止、重啟、重新加載和查詢系統(tǒng)服務(wù)狀態(tài)等操作。以下是 systemctl 命令的常用選項(xiàng)和用法: OPTIONS : 可選參數(shù),用于指定 systemctl 的行為。 COMMAND : 必需參數(shù),用于執(zhí)行特定的 systemd 命令,例如啟動(dòng)、

    2024年02月11日
    瀏覽(16)
  • 【systemctl 常用命令】

    1、啟動(dòng)服務(wù) systemctl start 服務(wù)名 2、停止服務(wù) systemctl stop 服務(wù)名 3、重啟服務(wù) systemctl restart 服務(wù)名 4、查看服務(wù) systemctl status 服務(wù)名 5、開機(jī)自啟 systemctl enable 服務(wù)名 6、停止自啟 systemctl disable 服務(wù)名 7、查看服務(wù)是否為開機(jī)自啟動(dòng) systemctl is-enabled 服務(wù)名 8、查看所有已啟動(dòng)的

    2024年02月13日
    瀏覽(23)
  • systemctl命令

    systemctl命令主要有兩大功能 控制systemd系統(tǒng) 管理系統(tǒng)上運(yùn)行的服務(wù) systemctl 常用命令 1、啟動(dòng)服務(wù) systemctl start 服務(wù)名 2、停止服務(wù) systemctl stop 服務(wù)名 3、重啟服務(wù) systemctl restart 服務(wù)名 4、查看服務(wù)是否已啟動(dòng) systemctl is-active 服務(wù)名 5、查看服務(wù)的狀態(tài) systemctl status 服務(wù)名 6、啟

    2024年02月05日
    瀏覽(16)
  • systemctl命令詳解

    systemctl 命令詳解 systemctl 是linux方便管理一系列服務(wù)的命令 啟動(dòng)/重啟/查看狀態(tài) 開啟/關(guān)閉開機(jī)自啟動(dòng) 查看服務(wù)是否已啟動(dòng) 只重啟正在運(yùn)行中的服務(wù) 查看服務(wù)是否為開機(jī)自啟動(dòng) 顯示所有的服務(wù)狀態(tài)—(翻頁(yè):按空格,退出:輸入q) 查看啟動(dòng)成功的服務(wù)列表 查看啟動(dòng)失敗的

    2024年02月09日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包