#linux# su命令细节错误
2019獨角獸企業重金招聘Python工程師標準>>>
#前言#
在學習su命令時,幾乎所有的國內書籍都說是切換用戶功能。今天在linux系統下想開啟httpd(即Apache服務器),輸入指令<code>service httpd start</code>結果出現bash: service: command not found這個錯誤!感覺很詭異。
其實,我是通過<code>su root</code>命令來"切換"用戶的。后來探索得知:
su或者su root 只是相當于以root用戶身份來操作,實際的系統環境并沒有切換到root用戶的環境,而只是當前登錄用戶。
使用<code>su -,-l,--login</code>才算是真正切換至root的環境下。
這里就看下su命令:su --help 看到su命令的幫助信息: 用法:su [選項]... [-] [用戶 [參數]...] Change the effective user id and group id to that of USER.
-, -l, --login make the shell a login shell -c, --command=COMMAND pass a single COMMAND to the shell with -c --session-command=COMMAND pass a single COMMAND to the shell with -c and do not create a new session -f, --fast pass -f to the shell (for csh or tcsh) -m, --preserve-environment do not reset environment variables -p same as -m -s, --shell=SHELL run SHELL if /etc/shells allows it --help 顯示此幫助信息并退出 --version 輸出版本信息并退出
單獨的 - 代表 -l。如果未給出[用戶],則假定為 root。
轉載于:https://my.oschina.net/sunshinedabby/blog/125146
總結
以上是生活随笔為你收集整理的#linux# su命令细节错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于tkinter的九型人格测试系统介绍
- 下一篇: mysql 转换编码