學習Linux,被坑過的故障集合

那些年學習Linux,你被坑過的故障集合?

一. 文件和目錄類

1.1 File exist 文件已經(jīng)存在

[root@oldboyedu59 ~]# mkdir   /data   /lidao  [root@oldboyedu59 ~]# mkdir   /data   /lidao  mkdir: cannot create directory ‘/data’: File existsmkdir: cannot create directory ‘/lidao’: File exists

無法 創(chuàng)建 目錄 因為這個目錄已經(jīng)存在

1.2 No such file or directory 沒有這個文件或目錄(這個東西不存在)

沒有這個目錄:文件或路徑書寫錯誤

[root@oldboyedu59 ~]# mkdir  /oldboy[root@oldboyedu59 ~]# cd oldboy-bash: cd: oldboy: No such file or directory

mkdir命令本身問題:mkdir 命令默認只能創(chuàng)建1層目錄 創(chuàng)建多層報錯

-p解決

[root@oldboyedu59 ~]# mkdir  /data/oldboy/lidao/mkdir: cannot create directory ‘/data/oldboy/lidao/’: No such file or directory

touch命令只能創(chuàng)建文件,目錄不存在則會報錯

解決:先創(chuàng)建目錄,再創(chuàng)建文件

[root@oldboyedu59 ~]# ls /oldboy/oldboy.txt[root@oldboyedu59 ~]# touch /oldboy/lidao/alex/oldboy.txttouch: cannot touch ‘/oldboy/lidao/alex/oldboy.txt’: No such file or directory

排錯思路:

1、ls命令檢查對應的目錄是否存在?

2、目錄不存在 先創(chuàng)建目錄在創(chuàng)建文件/

1.3 command not found 命令找不到(沒有這個命令)

[root@oldboyedu59 ~]# mkdiy-bash: mkdiy: command not found

1.書寫錯誤

2.沒有安裝

1.4 invalid option 無效的參數(shù)(不可用的參數(shù))

[root@oldboyedu59 ~]# touch -p /oldboy/oldboy.txttouch: invalid option -- 'p'Try 'touch --help' for more information.

1.5 overwrite 覆蓋

cp 復制如果已經(jīng)存在這個文件會提示是否覆蓋

[root@oldboyedu59 ~]# cp  /oldboy/oldboy.txt   /tmp/cp: overwrite ‘/tmp/oldboy.txt’?

1.6 remove regular empty file 是否刪除普通文件(空的)?

[root@oldboyedu59 ~]# rm   /oldboy/oldboy.txtrm: remove regular empty file ‘/oldboy/oldboy.txt’?

1.7 is a directory xxx是一個目錄

rm 默認無法刪除目錄

解決:加上-r 或-rf

[root@oldboyedu59 ~]# rm /data/rm: cannot remove ‘/data/’: Is a directory

vi命令中 使用vi編輯目錄也會報錯

"/oldboy"E502: "/oldboy" is a directoryPress ENTER or type command to continue

1.8 descend into directory 是否進入目錄

[root@oldboyedu59 ~]# rm -r /data/rm: descend into directory ‘/data/’? yrm: remove regular empty file ‘/data/oldboy01.txt’? nrm: remove regular empty file ‘/data/oldboy02.txt’? nrm: remove regular empty file ‘/data/oldboy03.txt’? nrm: remove regular empty file ‘/data/oldboy04.txt’? nrm: remove regular empty file ‘/data/oldboy05.txt’? nrm: remove regular empty file ‘/data/oldboy06.txt’? nrm: remove regular empty file ‘/data/oldboy07.txt’? nrm: remove regular empty file ‘/data/oldboy08.txt’? nrm: remove regular empty file ‘/data/oldboy09.txt’? nrm: remove regular empty file ‘/data/oldboy10.txt’? nrm: remove directory ‘/data/’? n

1.9 Invalid level 無效的層數(shù),層數(shù)必須大于0

注意參數(shù)位置

[root@oldboyedu59 ~]# tree  -L -F 2 / tree: Invalid level, must be greater than 0.

1.10 Can't open file for writing 無法打開這個文件

vi中 如果目錄不存在就會提示

"/oldbyo/oldboy.txt""/oldbyo/oldboy.txt" E212: Can't open file for writingPress ENTER or type command to continue

1.11 No write since last change

E37: No write since last change (add ! to override) 粘包賴(你修改了內(nèi)容就無法使用:q退出 需要使用:q!

1.12 xx column window is too narrow 窗口只有xx列太窄了,無法完全顯示

這是w的坑 空間太小施展不開.

[root@oldboyedu60-lnb ~]# ww: 39 column window is too narrow

二. 網(wǎng)絡連接類

2.1 遠程連接錯誤 Connection Failed 連接失敗

使用Xshell遠程連接失敗提示,檢查端口是否開啟或正確

[c:\~]$ Connecting to 10.0.0.200:233...Could not connect to '10.0.0.200' (port 233): Connection failed.Type `help' to learn how to use Xshell prompt.

使用telnet測試端口是否打開

[c:\~]$ telnet 10.0.0.200 233 Connecting to 10.0.0.200:233...Could not connect to '10.0.0.200' (port 233): Connection failed. #233端口沒有開啟Type `help' to learn how to use Xshell prompt.

端口開啟

[c:\~]$ telnet 10.0.0.200 22Connecting to 10.0.0.200:22...Connection established. #端口開啟To escape to local shell, press 'Ctrl+Alt+]'.SSH-2.0-OpenSSH_7.4Protocol mismatch.Connection closed by foreign host.Disconnected from remote host(10.0.0.200:22) at 12:22:54.Type `help' to learn how to use Xshell prompt.[c:\~]$

2.2 yum安裝軟件故障提示 Could not resolve host無法解析主機

Could not resolve host無法解析主機

主要是系統(tǒng)能否上網(wǎng)和DNS問題.

http://mirrors.tuna.tsinghua.edu.cn/centos/7.6.1810/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.tuna.tsinghua.edu.cn; Unknown error"Trying other mirror.

2.3 yum安裝軟件提示:Nothing to do (沒事做)

有兩種情況:

情況1:軟件已經(jīng)安裝并且最新如下:

Package tree-1.6.0-10.el7.x86_64 already installed and latest versiontree軟件包已經(jīng)安裝并且是最新版本Package 2:vim-enhanced-7.4.160-5.el7.x86_64 already installed and latest versionPackage 1:bash-completion-2.1-6.el7.noarch already installed and latest versionNothing to do

情況2:軟件名字寫錯或沒有配置yum源導致找不到這個軟件包

[root@oldboyedu60-lnb ~]# yum install treea -yLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: mirror.lzu.edu.cn * extras: mirrors.nwsuaf.edu.cn * updates: mirrors.nwsuaf.edu.cnbase                                                                                              | 3.6 kB  00:00:00     extras                                                                                            | 3.4 kB  00:00:00     updates                                                                                           | 3.4 kB  00:00:00     No package treea available. #沒有找到叫treea的軟件包Error: Nothing to do

2.4 Name or service not known 域名無法識別(無法上網(wǎng))

原因:

1:DNS配置錯誤原因

2:Linux無法上網(wǎng)原因

[root@oldboyedu59 ~]# ping baidu.com ping: baidu.com: Name or service not known  域名無法識別(無法將域名---->ip地址)

三. 修改系統(tǒng)基礎配置類

3.1 重啟網(wǎng)卡報錯 device not present

[root@oldboyusd ~]# systemctl restart network Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

查看詳細錯誤原因

Apr 01 15:31:05 oldboyusd.1 network[7816]: Bringing up interface etho:  ERROR     : [/etc/sysconfig/network-scripts/ifup-eth] Device  does not seem to be present, delaying initialization.Apr 01 15:31:05 oldboyusd.1 /etc/sysconfig/network-scripts/ifup-eth[8019]: Device  does not seem to be present, delaying initializatio

3.2 修改主機名過程中,命令行中主機名沒有變化

1# hostname命令修改主機名(臨時 重啟服務器之后失效)

[root@oldboyedu59 ~]# hostnameoldboyedu59[root@oldboyedu59 ~]# hostname oldboyedu59-lnb

2# 修改文件內(nèi)容(寫合同 永久 重啟服務器之后生效)

vim /etc/hostname  oldboyedu59-lnb

3# 檢查

[root@oldboyedu59 ~]# hostnameoldboyedu59-lnb[root@oldboyedu59 ~]# cat /etc/hostname oldboyedu59-lnb

命令行中的主機名部分沒有改變?

解決:重新登錄下即可(斷開連接,重新連接)

[root@oldboyedu59-lnb ~]#
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容