精品丰满熟女一区二区三区_五月天亚洲欧美综合网_亚洲青青青在线观看_国产一区二区精选

  • <menu id="29e66"></menu>

    <bdo id="29e66"><mark id="29e66"><legend id="29e66"></legend></mark></bdo>

  • <pre id="29e66"><tt id="29e66"><rt id="29e66"></rt></tt></pre>

      <label id="29e66"></label><address id="29e66"><mark id="29e66"><strike id="29e66"></strike></mark></address>
      學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > linux的su命令

      linux的su命令

      時(shí)間: 佳洲1085 分享

      linux的su命令

        Linux系統(tǒng)下su命令的作用是用于變更為其他使用者的身份。下面由學(xué)習(xí)啦小編為大家整理了linux的su命令的相關(guān)知識(shí),希望大家喜歡!

        linux的su命令詳解

        Linux su命令用于變更為其他使用者的身份,除 root 外,需要鍵入該使用者的密碼。

        使用權(quán)限:所有使用者。

        1.語法

        su [-fmp] [-c command] [-s shell] [--help] [--version] [-] [USER [ARG]]

        2.參數(shù)說明

        -f 或 --fast 不必讀啟動(dòng)檔(如 csh.cshrc 等),僅用于 csh 或 tcsh

        -m -p 或 --preserve-environment 執(zhí)行 su 時(shí)不改變環(huán)境變數(shù)

        -c command 或 --command=command 變更為帳號(hào)為 USER 的使用者并執(zhí)行指令(command)后再變回原來使用者

        -s shell 或 --shell=shell 指定要執(zhí)行的 shell (bash csh tcsh 等),預(yù)設(shè)值為 /etc/passwd 內(nèi)的該使用者(USER) shell

        --help 顯示說明文件

        --version 顯示版本資訊

        - -l 或 --login 這個(gè)參數(shù)加了之后,就好像是重新 login 為該使用者一樣,大部份環(huán)境變數(shù)(HOME SHELL USER等等)都是以該使用者(USER)為主,并且工作目錄也會(huì)改變,如果沒有指定 USER ,內(nèi)定是 root

        USER 欲變更的使用者帳號(hào)

        ARG 傳入新的 shell 參數(shù)

        linux的su命令實(shí)例

        變更帳號(hào)為 root 并在執(zhí)行 ls 指令后退出變回原使用者

        su -c ls root

        變更帳號(hào)為 root 并傳入 -f 參數(shù)給新執(zhí)行的 shell

        su root -f

        變更帳號(hào)為 clsung 并改變工作目錄至 clsung 的家目錄(home dir)

        su - clsung

        切換用戶

        hnlinux@w3cschool.cc:~$ whoami //顯示當(dāng)前用戶

        hnlinux

        hnlinux@w3cschool.cc:~$ pwd //顯示當(dāng)前目錄

        /home/hnlinux

        hnlinux@w3cschool.cc:~$ su root //切換到root用戶

        密碼:

        root@w3cschool.cc:/home/hnlinux# whoami

        root

        root@w3cschool.cc:/home/hnlinux# pwd

        /home/hnlinux

        切換用戶,改變環(huán)境變量

        hnlinux@w3cschool.cc:~$ whoami //顯示當(dāng)前用戶

        hnlinux

        hnlinux@w3cschool.cc:~$ pwd //顯示當(dāng)前目錄

        /home/hnlinux

        hnlinux@w3cschool.cc:~$ su - root //切換到root用戶

        密碼:

        root@w3cschool.cc:/home/hnlinux# whoami

        root

        root@w3cschool.cc:/home/hnlinux# pwd //顯示當(dāng)前目錄

        /root

      3624485