此文檔送給剛剛學(xué)習(xí)Linux的各位小伙伴
零.目錄
一. 文件和目錄類(lèi)
- File exist 文件已經(jīng)存在
- No such file or directory 沒(méi)有這個(gè)文件或目錄(這個(gè)東西不存在)
- command not found 命令找不到(沒(méi)有這個(gè)命令)
- invalid option 無(wú)效的參數(shù)(不可用的參數(shù))
- overwrite 覆蓋
- remove regular empty file 是否刪除普通文件(空的)?
- is a directory xxx是一個(gè)目錄
- descend into directory 是否進(jìn)入目錄
- Invalid level 無(wú)效的層數(shù),層數(shù)必須大于0
- Can't open file for writing 無(wú)法打開(kāi)這個(gè)文件
- No write since last change
- xx column window is too narrow 窗口只有xx列太窄了 無(wú)法完全顯示
- xxx not a directory 不是一個(gè)目錄
- 查看壓縮包的時(shí)候報(bào)錯(cuò)
- You have mail in /var/spool/mail/root
- permission denied
- Warning: Changing a readonly file
- 'readonly' option is set (add ! to override)
- cp: omitting directory ‘/oldboy/’
unexpected end of file 或 Unexpected EOF in archive
gzip: stdin: not in gzip format 壓縮包不是gzip格式或壓縮包損壞
二. 網(wǎng)絡(luò)連接類(lèi)
- 遠(yuǎn)程連接錯(cuò)誤 Connection Failed 連接失敗
- yum安裝軟件故障提示 Could not resolve host無(wú)法解析主機(jī)
- yum安裝軟件提示:Nothing to do (沒(méi)事做)
- 沒(méi)有找到叫treea的軟件包
- Name or service not known 域名無(wú)法識(shí)別(無(wú)法上網(wǎng))
- No route to host 沒(méi)有訪問(wèn)主機(jī)的路由(此路不通)
- Connection Refused 連接拒絕
三. 修改系統(tǒng)基礎(chǔ)配置類(lèi)
- 重啟網(wǎng)卡報(bào)錯(cuò) device not present
- 修改主機(jī)名過(guò)程中,命令行中主機(jī)名沒(méi)有變化
- hostname命令修改主機(jī)名(臨時(shí) 重啟服務(wù)器之后失效)
- 命令行中的主機(jī)名部分沒(méi)有改變婆翔?
四. 用戶(hù)相關(guān)錯(cuò)誤
- user 'oldboy' already exists
- no such user
- Only root can do that.
- Only root can specify a user name.
- Creating mailbox file: File exists
- warning: the home directory already exists.
- /etc/sudoers: syntax error near line 105 <<<
五.腳本及定時(shí)任務(wù)
- no crontab for root 沒(méi)有配置定時(shí)任務(wù)
- no crontab for root - using an empty one 沒(méi)有定時(shí)任務(wù),創(chuàng)建空的定時(shí)任務(wù)
- crontab: installing new crontab 更新定時(shí)任務(wù)配置
一. 文件和目錄類(lèi)
1. File exist 文件已經(jīng)存在
[root@oldboyedu59 ~]# mkdir /data /lidao
[root@oldboyedu59 ~]# mkdir /data /lidao
mkdir: cannot create directory ‘/data’: File exists
mkdir: cannot create directory ‘/lidao’: File exists
mkdir: cannot create directory ‘/lidao’: File exists
無(wú)法 創(chuàng)建 目錄 因?yàn)檫@個(gè)目錄已經(jīng)存在
2. No such file or directory 沒(méi)有這個(gè)文件或目錄(這個(gè)東西不存在)
沒(méi)有這個(gè)目錄:文件或路徑書(shū)寫(xiě)錯(cuò)誤
[root@oldboyedu59 ~]# mkdir /oldboy
[root@oldboyedu59 ~]# cd oldboy
-bash: cd: oldboy: No such file or directory
mkdir命令本身問(wèn)題:mkdir 命令默認(rèn)只能創(chuàng)建1層目錄 創(chuàng)建多層報(bào)錯(cuò)
-p解決
[root@oldboyedu59 ~]# mkdir /data/oldboy/lidao/
mkdir: cannot create directory ‘/data/oldboy/lidao/’: No such file or directory
touch命令只能創(chuàng)建文件,目錄不存在則會(huì)報(bào)錯(cuò)
解決:先創(chuàng)建目錄,再創(chuàng)建文件
[root@oldboyedu59 ~]# ls /oldboy/
oldboy.txt
[root@oldboyedu59 ~]# touch /oldboy/lidao/alex/oldboy.txt
touch: cannot touch ‘/oldboy/lidao/alex/oldboy.txt’: No such file or directory
排錯(cuò)思路:
1.ls命令檢查對(duì)應(yīng)的目錄是否存在?
2.目錄不存在 先創(chuàng)建目錄在創(chuàng)建文件/
find命令與|xargs ll 錯(cuò)誤
|xargs后面不支持別名
[root@kangxu ~]# find /oldboy -name "*.txt" -type f |xargs ll
xargs: ll: No such file or directory
3. command not found 命令找不到(沒(méi)有這個(gè)命令)
[root@oldboyedu59 ~]# mkdiy
-bash: mkdiy: command not found
1.書(shū)寫(xiě)錯(cuò)誤
2.沒(méi)有安裝
4. invalid option 無(wú)效的參數(shù)(不可用的參數(shù))
[root@oldboyedu59 ~]# touch -p /oldboy/oldboy.txt
touch: invalid option -- 'p'
Try 'touch --help' for more information.
5. overwrite 覆蓋
cp復(fù)制如果已經(jīng)存在這個(gè)文件會(huì)提示是否覆蓋
[root@oldboyedu59 ~]# cp /oldboy/oldboy.txt /tmp/
cp: overwrite ‘/tmp/oldboy.txt’?
6.remove regular empty file 是否刪除普通文件(空的)?
[root@oldboyedu59 ~]# rm /oldboy/oldboy.txt
rm: remove regular empty file ‘/oldboy/oldboy.txt’?
7. is a directory xxx是一個(gè)目錄
rm默認(rèn)無(wú)法刪除目錄
解決:加上-r 或-rf
[root@oldboyedu59 ~]# rm /data/
rm: cannot remove ‘/data/’: Is a directory
vi命令中 使用vi編輯目錄也會(huì)報(bào)錯(cuò)
"/oldboy"
E502: "/oldboy" is a directory
Press ENTER or type command to continue
8. descend into directory 是否進(jìn)入目錄
[root@oldboyedu59 ~]# rm -r /data/
rm: descend into directory ‘/data/’? y
rm: remove regular empty file ‘/data/oldboy01.txt’? n
rm: remove regular empty file ‘/data/oldboy02.txt’? n
rm: remove regular empty file ‘/data/oldboy03.txt’? n
rm: remove regular empty file ‘/data/oldboy04.txt’? n
rm: remove regular empty file ‘/data/oldboy05.txt’? n
rm: remove regular empty file ‘/data/oldboy06.txt’? n
rm: remove regular empty file ‘/data/oldboy07.txt’? n
rm: remove regular empty file ‘/data/oldboy08.txt’? n
rm: remove regular empty file ‘/data/oldboy09.txt’? n
rm: remove regular empty file ‘/data/oldboy10.txt’? n
rm: remove directory ‘/data/’? n
9. Invalid level 無(wú)效的層數(shù),層數(shù)必須大于0
注意參數(shù)位置
[root@oldboyedu59 ~]# tree -L -F 2 /
tree: Invalid level, must be greater than 0.
10. Can't open file for writing 無(wú)法打開(kāi)這個(gè)文件
vi中 如果目錄不存在就會(huì)提示
"/oldbyo/oldboy.txt"
"/oldbyo/oldboy.txt" E212: Can't open file for writing
Press ENTER or type command to continue
如果你對(duì)這個(gè)文件沒(méi)有權(quán)限 也會(huì)提示
11.No write since last change
E37: No write since last change (add ! to override)
粘包賴(lài)(你修改了內(nèi)容就無(wú)法使用:q退出 需要使用:q!
12. xx column window is too narrow 窗口只有xx列太窄了 無(wú)法完全顯示
這是w的坑 空間太小施展不開(kāi).
[root@oldboyedu60-lnb ~]# w
w: 39 column window is too narrow
13. xxx not a directory 不是一個(gè)目錄
背景:創(chuàng)建文件的時(shí)候多了一個(gè)空格
[root@ssdz ~]# touch /oldboy /oldboy.txt #此處要?jiǎng)?chuàng)建/oldboy/oldboy.txt 多個(gè)個(gè)空格 創(chuàng)建了2個(gè)文件 /oldboy和/oldboy.txt
[root@ssdz ~]# ls -l /oldboy/ #系統(tǒng)認(rèn)為oldboy是個(gè)目錄 所以報(bào)錯(cuò)
ls: cannot access /oldboy/: Not a directory
[root@ssdz ~]# touch /oldboy/oldboy.txt
touch: cannot touch ‘/oldboy/oldboy.txt’: Not a directory
[root@ssdz ~]# ls -l /oldboy
-rw-r--r--. 1 root root 0 Apr 9 15:23 /oldboy
14.查看壓縮包的時(shí)候報(bào)錯(cuò)
注意是否有特殊中文符號(hào)導(dǎo)致的掏婶。
[root@oldboy59 tmp]# tar ztf /tmp/etc.tar.gz
tar (child): \200\202\200\202\200\202\200\202/tmp/etc.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
15. You have mail in /var/spool/mail/root
你在這個(gè)文件/var/spool/mail/root 中有一個(gè)新郵件
16. permission denied
權(quán)限拒絕
17. W10: Warning: Changing a readonly file
使用vim的時(shí)候顯示的
表示:正在修改只讀文件
解決:1.查看對(duì)文件是否有rw權(quán)限
2.如果是root用戶(hù)可以修改后強(qiáng)制保存退出(:wq!)
18.no properly formatted MD5 checksum lines found
在使用md5sum -c (檢查的時(shí)候)
md5指紋信息文件中啃奴,格式不對(duì)
第1列是md5 信息 第2列文件名
解決:查看MD5文件內(nèi)容是否正確
檢查的命令是否正確 md5sum -c oldboy.md5
md5sum: /oldboy/mtime/access_2019-04-01.txt: no properly formatted MD5 checksum lines found
19. E45: 'readonly' option is set (add ! to override)
通過(guò)vi/vim 編輯文件保存的時(shí)候(:wq) 提示
這個(gè)文件只讀,:wq! 強(qiáng)制保存退出
20. cp: omitting directory ‘/oldboy/’
忽略這個(gè)目錄
cp默認(rèn)無(wú)法復(fù)制目錄
[root@oldboyedu64-lnb ~]# cp /oldboy/ /tmp/
cp: omitting directory ‘/oldboy/’
[root@oldboyedu64-lnb ~]# ls -l /tmp/
total 8
-rwx------. 1 root root 836 Jun 30 17:36 ks-script-gWLqG0
-rw-r--r--. 1 root root 400 Jul 7 14:51 oldboy.txt
drwx------. 2 root root 6 Jun 30 17:42 vmware-root_6749-3879179984
-rw-------. 1 root root 0 Jun 30 17:27 yum.log
21. Unexpected EOF in archive
未知的 壓縮文件結(jié)尾
主要原因是tar壓縮包損壞 重新下載
[root@web02 tools]# tar xf nginx-1.16.0.tar.gz
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
二. 網(wǎng)絡(luò)連接類(lèi)
1. 遠(yuǎn)程連接錯(cuò)誤 Connection Failed 連接失敗
使用Xshell遠(yuǎn)程連接失敗提示,檢查端口是否開(kāi)啟或正確
[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è)試端口是否打開(kāi)
[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端口沒(méi)有開(kāi)啟
Type `help' to learn how to use Xshell prompt.
端口開(kāi)啟
[c:\~]$ telnet 10.0.0.200 22
Connecting to 10.0.0.200:22...
Connection established. #端口開(kāi)啟
To escape to local shell, press 'Ctrl+Alt+]'.
SSH-2.0-OpenSSH_7.4
Protocol 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. yum安裝軟件故障提示 Could not resolve host無(wú)法解析主機(jī)
Could not resolve host無(wú)法解析主機(jī)
主要是系統(tǒng)能否上網(wǎng)和DNS問(wèn)題.
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.
3.yum安裝軟件提示:Nothing to do (沒(méi)事做)
有兩種情況:
情況1:軟件已經(jīng)安裝并且最新如下:
Package tree-1.6.0-10.el7.x86_64 already installed and latest version
tree軟件包已經(jīng)安裝并且是最新版本
Package 2:vim-enhanced-7.4.160-5.el7.x86_64 already installed and latest version
Package 1:bash-completion-2.1-6.el7.noarch already installed and latest version
Nothing to do
情況2:軟件名字寫(xiě)錯(cuò)或沒(méi)有配置yum源導(dǎo)致找不到這個(gè)軟件包
[root@oldboyedu60-lnb ~]# yum install treea -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.lzu.edu.cn
* extras: mirrors.nwsuaf.edu.cn
* updates: mirrors.nwsuaf.edu.cn
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
No package treea available.
#沒(méi)有找到叫treea的軟件包
Error: Nothing to do
情況3:你需要安裝軟件包而不是軟件包里面的命令
通過(guò)yum provides 查看命令屬于哪個(gè)軟件包
[root@oldboyedu59 ~]# yum install -y locate
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 187 kB 00:00:02
(2/2): updates/7/x86_64/primary_db | 3.4 MB 00:00:04
No package locate available.
Error: Nothing to do
[root@oldboyedu59 ~]# yum provides locate
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base/7/x86_64/filelists_db | 7.1 MB 00:00:03
extras/7/x86_64/filelists_db | 236 kB 00:00:00
updates/7/x86_64/filelists_db | 2.7 MB 00:00:01
mlocate-0.26-8.el7.x86_64 : An utility for finding files by name
Repo : base
Matched from:
Filename : /usr/bin/locate\
[root@oldboyedu59 ~]# yum install -y mlocate
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package mlocate.x86_64 0:0.26-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================
Installing:
mlocate x86_64 0.26-8.el7 base 113 k
Transaction Summary
=========================================================================================================================
Install 1 Package
Total download size: 113 k
Installed size: 379 k
Downloading packages:
mlocate-0.26-8.el7.x86_64.rpm | 113 kB 00:00:02
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mlocate-0.26-8.el7.x86_64 1/1
Verifying : mlocate-0.26-8.el7.x86_64 1/1
Installed:
mlocate.x86_64 0:0.26-8.el7
Complete!
[root@oldboyedu59 ~]# rpm -qa mlocate
mlocate-0.26-8.el7.x86_64
4. Name or service not known 域名無(wú)法識(shí)別(無(wú)法上網(wǎng))
原因1:DNS配置錯(cuò)誤
原因2:Linux無(wú)法上網(wǎng)原因 http://www.reibang.com/p/0bc0b596c1a0
[root@oldboyedu59 ~]# ping baidu.com
ping: baidu.com: Name or service not known
域名無(wú)法識(shí)別(無(wú)法將域名---->ip地址)
5. No route to host
- No route to host 沒(méi)有訪問(wèn)主機(jī)的路由(此路不通)
#原因 : 防火墻/selinux 沒(méi)有關(guān)閉導(dǎo)致,
三. 修改系統(tǒng)基礎(chǔ)配置類(lèi)
1. 重啟網(wǎng)卡報(bào)錯(cuò) 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.
查看詳細(xì)錯(cuò)誤原因
·journalctl -xe·
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
2. 修改主機(jī)名過(guò)程中,命令行中主機(jī)名沒(méi)有變化
1# hostname命令修改主機(jī)名(臨時(shí) 重啟服務(wù)器之后失效)
[root@oldboyedu59 ~]# hostname
oldboyedu59
[root@oldboyedu59 ~]# hostname oldboyedu59-lnb
2# 修改文件內(nèi)容(寫(xiě)合同 永久 重啟服務(wù)器之后生效)
vim /etc/hostname
oldboyedu59-lnb
3# 檢查
[root@oldboyedu59 ~]# hostname
oldboyedu59-lnb
[root@oldboyedu59 ~]# cat /etc/hostname
oldboyedu59-lnb
命令行中的主機(jī)名部分沒(méi)有改變雄妥?
解決:重新登錄下即可(斷開(kāi)連接最蕾,重新連接)
[root@oldboyedu59-lnb ~]#
3. unexpected EOF while looking for matching `"'
引號(hào)不成對(duì)
tail -2 /etc/profile
alias net="cat /etc/sysconfig/network-scripts/ifcfg-eth0
export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
[root@ssdz ~]# source /etc/profile
-bash: /etc/profile: line 78: unexpected EOF while looking for matching `"'
-bash: /etc/profile: line 79: syntax error: unexpected end of file
-bash: /etc/profile: line 78: unexpected EOF while looking for matching `"'
/etc/profile 第78行 出乎意料的結(jié)尾 正在找 '"' 這個(gè)雙引號(hào)的另一半
四. 用戶(hù)類(lèi)錯(cuò)誤
1. user 'oldboy' already exists
用戶(hù)已經(jīng)存在
[root@oldboyedu59 ~]# useradd oldboy
useradd: user 'oldboy' already exists
2. no such user
沒(méi)有這個(gè)用戶(hù)
[root@oldboyedu59 ~]# id lidao
id: lidao: no such user
3.Only root can do that.
只有root用戶(hù)可以使用 非交互式設(shè)置密碼方式
[oldboy@oldboyedu59 ~]$ echo 123456|passwd --stdin oldboy
Only root can do that.
4.Only root can specify a user name.
只有root用戶(hù) 運(yùn)行passwd的時(shí)候 后面能加上用戶(hù)名
普通用戶(hù)默認(rèn)只能運(yùn)行passwd 不能加用戶(hù)名 修改自己的密碼
[oldboy@oldboyedu59 ~]$ passwd oldboy
passwd: Only root can specify a user name.
5. Creating mailbox file: File exists 和warning: the home directory already exists.
添加用戶(hù)的時(shí)候提示:
Creating mailbox file: File exists 正在創(chuàng)建這個(gè)用戶(hù)的郵箱:郵箱已經(jīng)存在
warning: the home directory already exists. 這個(gè)用戶(hù)的家目錄已經(jīng)存在
刪除用戶(hù)的時(shí)候,默認(rèn)不刪除家目錄和郵箱.
再次添加就會(huì)提示家目錄存在和郵箱存在
[root@oldboyedu59 ~]# id stu01
uid=1005(stu01) gid=1006(stu01) groups=1006(stu01)
[root@oldboyedu59 ~]# userdel stu01
[root@oldboyedu59 ~]# useradd stu01
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
Creating mailbox file: File exists
6.user nginx is currently used by process 7540
用戶(hù)正在使用中 被pid是7540的進(jìn)程使用中
[root@web01 /usr/share/nginx/html/blog]# usermod -u 2222 nginx
usermod: user nginx is currently used by process 7540
五.腳本及定時(shí)任務(wù)
1. no crontab for root
root用戶(hù)沒(méi)有定時(shí)任務(wù)
[root@oldboyedu59 ~]# crontab -l
no crontab for root
root用戶(hù)沒(méi)有定時(shí)任務(wù)
2.no crontab for root - using an empty one
root用戶(hù)沒(méi)有定時(shí)任務(wù)老厌,給root創(chuàng)建了1個(gè)新的
這里實(shí)際上給root創(chuàng)建了定時(shí)任務(wù)文件 /var/spool/cron/root 空文件
3.crontab: installing new crontab
更新定時(shí)任務(wù)規(guī)則
4. bad xxx, errors in crontab file,can't install
錯(cuò)誤的{分|時(shí)|日|月|周},定時(shí)任務(wù)文件中有錯(cuò)誤瘟则,無(wú)法更新定時(shí)任務(wù)
分時(shí)日月周格式錯(cuò)誤01
#mei liangfenzhong xianshi xitong shijian zhuijiadao /tmp/oldboy.txt
* /1 * * * date >>/tmp/oldboy.txt
"/tmp/crontab.5UZIdI" 3L, 115C written
crontab: installing new crontab
"/tmp/crontab.5UZIdI":3: bad hour 3是第3行的意思,錯(cuò)誤的小時(shí) 小時(shí)位置書(shū)寫(xiě)錯(cuò)誤
errors in crontab file, can't install.
Do you want to retry the same edit?
分時(shí)日月周格式錯(cuò)誤02
時(shí)間范圍書(shū)寫(xiě)錯(cuò)誤 21-00錯(cuò)誤 改為 21-23,00 即可因?yàn)槎〞r(shí)任務(wù)的小時(shí)為00-23
crontab -e
#show time by liyy at 20190101
#*/2 * * * * date >>/tmp/time.log
#
00 21-00 * * * date >>/tmp/time.log
00 21-00 * * * date >>/tmp/time.log
#00 21-23,00 * * * date >>/tmp/time.log
#backup /etc/ to /tmp by liyy at 20190101
#00 00 * * * sh /server/scripts/bak-etc.sh
"/tmp/crontab.SpZAZH" 9L, 238C written
crontab: installing new crontab
"/tmp/crontab.SpZAZH":5: bad hour
errors in crontab file, can't install.
Do you want to retry the same edit?
5. You have new mail in /var/spool/mail/root
你有1個(gè)新郵件 在/var/spool/mail/root