linux修改profile檔案出錯,快速復原。

2021-09-26 08:21:05 字數 533 閱讀 5594

在linux系統中修改profile檔案,不小心出錯,導致除了cd外其他命令全都失效。

出錯後,首先找到profile檔案,利用記事本開啟,將錯誤修改過來,儲存退出,重啟系統然而並沒有用。

之後終端輸入命令 export path=/usr/bin:/usr/sbin:/bin:/sbin 重新配置path環境變數,使命令生效。利用 vi 再次進入profile,確認是否還有問題,改正過來,儲存退出 ,重新整理資源檔案 source /etc/profile ,一般情況下問題已經解決。

如果還沒解決使出終極大招。將原來出錯的profile檔案刪除, rm profile

建立新的profile檔案, touch profile

從其他linux系統中複製內容到新profile檔案中。

profile 預設許可權為 -rw-r–r-- ,可以在目錄下使用 ls -l 檢視。 所以建立新檔案後記得更改許可權 chmod 644 profile 。

完成後重啟 reboot 應該不會有問題了。

適當的時候可以拍點快照 ,便於出問題後的恢復。

linux系統 etc下的profile檔案

etc profile檔案 etc profile是全域性的,適用於所有的shell。在剛登入linux時,首先啟動 etc profile 檔案。profile檔案會告訴shell使用什麼語言,什麼shell,命令的搜尋路徑等。一些標準的環境變數 shell 預設shell lang 預設語言 p...

linux修改profile檔案出錯後恢復

linux修改profile檔案改錯了,恢復的方法 在改profile的時候,改出問題了,除了cd以外的命令基本都不能用了,連vi都不能用了,上網查了下,www.2cto.com 用export path usr bin usr sbin bin sbin usr x11r6 bin,然後就可以用命...

Linux修改profile檔案改錯了,恢復的方法

linux修改profile檔案改錯了,恢復的方法 在改profile的時候,改出問題了,除了cd以外的命令基本都不能用了,連vi都不能用了,上網查了下,用export path usr bin usr sbin bin sbin usr x11r6 bin,然後就可以用命令了,速度用vi把prof...