1. 程式人生 > 其它 >Linux修改/etc/profile導致錯誤:groups: command not found

Linux修改/etc/profile導致錯誤:groups: command not found

技術標籤:Linux 踩過的坑

有一次修改了/etc/profile配置檔案方法後,導致bash命令無法用,如執行vi /etc/profile命令結果如下:

Command 'vi' is available in '/usr/bin/vi'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
vi: command not found

使用視覺化finallshell工具,修改了/etc/profile檔案,然後執行:

# source /etc/profile

想讓配置檔案重新生效,然後不幸的是:

Command 'groups' is available in '/usr/bin/groups'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
groups: command not found

發現 source命令已經不認識!

度娘了一下,我們可以用命令,臨時新增配置環境變數,這個是不需要走配置檔案:

# export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/
sbin:/usr/bin:/root/bin

執行完以上的命令後,可以重新執行 source /etc/profile命令讓配置檔案生效。

在直接使用vi命令無法使用的情況下,你可以使用視覺化工具修改或是在vi前面加上命令的地址,其他命令同理:

#/usr/bin/vi /etc/profile

這樣就可以使用vi命令來修改啦!