[Linux] 50 necessary faults and causes

I File and directory classes

  • File exist file already exists
  • No such file or directory
  • Command not found command not found
  • invalid option invalid parameter (unavailable parameter)
  • Overwrite overwrite
  • remove regular empty file delete normal file (empty)?
  • is a directory xxx is a directory
  • descend into directory
  • Invalid level invalid number of layers. The number of layers must be greater than 0
  • Can't open file for writing
  • No write since last change
  • xx column window is too narrow
  • xxx not a directory is not a directory
  • An error is reported when viewing the compressed package
  • 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 or Unexpected EOF in archive

II Network connection class

  • Remote connection error Connection Failed connection failed
  • yum install software fault prompt Could not resolve host
  • yum install software tips: Nothing to do
  • No package named treea was found
  • Name or service not known

III Modify basic system configuration class

  • Error device not present when restarting the network card
  • During the process of modifying the host name, the host name does not change on the command line
  • The hostname command modifies the hostname (invalid after temporarily restarting the server)
  • The hostname part of the command line has not changed?

IV User related error

  • 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 <<<

V Script and scheduled tasks

I File and directory classes

1. The file exist file already exists

[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
The directory cannot be created because it already exists

2. No such file or directory

There is no such Directory: the file or path is incorrectly written

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

Problem with mkdir command itself: by default, mkdir command can only create 1-layer directory and create multi-layer error reports
-p solve

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

The touch command can only create files. If the directory does not exist, an error will be reported
Solution: create a directory before creating a file

[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

Troubleshooting ideas:
1.ls command checks whether the corresponding directory exists?
2. The directory does not exist. Create the directory before creating the file/

find command and xargs ll error
|Aliases are not supported after xargs

[root@kangxu ~]# find /oldboy  -name  "*.txt"  -type f |xargs ll
xargs: ll: No such file or directory

3. command not found command not found

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

1. Writing error
2. Not installed

4. invalid option invalid parameter (unavailable parameter)

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

5. overwrite

cp copy if the file already exists, you will be prompted whether to overwrite it

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

6.remove regular empty file delete normal file (empty)?

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

7. is a directory xxx is a directory

rm default directory cannot be deleted
Solution: add - r or - rf

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

Using vi to edit the directory in the vi command will also report an error

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

8. descend into directory

[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 is invalid. The number of layers must be greater than 0

Pay attention to the parameter position

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

10. Can't open file for writing

If the directory does not exist in vi, you will be prompted

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

If you don't have permission to this file, you will also be prompted

11.No write since last change

E37: No write since last change (add ! to override)
     Sticky bag Lai(You can't use it if you modify the content:q Exit required:q! 

12. xx column window is too narrow

This is w's pit. The space is too small to use

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

13. Xxx not a directory is not a directory

Background: there is an extra space when creating a file

[root@ssdz ~]# touch /oldboy /oldboy.txt  #Here you want to create / oldboy / oldboy Txt multiple spaces create two files / oldboy and / oldboy txt 
[root@ssdz ~]# ls -l /oldboy/         #The system thinks oldboy is a directory, so an error is reported
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. An error is reported when viewing the compressed package

Pay attention to whether there are special Chinese symbols.

[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

You have a new message in this file / var/spool/mail/root

16. permission denied

Permission denied

17. W10: Warning: Changing a readonly file

Displayed when using vim
Indicates that the read-only file is being modified
solve:

1. Check whether you have rw permission to file
2. If you are the root user, you can force save and exit after modification (: wq!)

18.no properly formatted MD5 checksum lines found

When using md5sum -c (when checking)
The format of md5 fingerprint information file is incorrect
The first column is md5 information, and the second column is file name
solve:

Check whether the content of MD5 file is correct
Check whether the command is correct 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)

Prompt when saving files by vi/vim editing (: wq)
This file is read-only,: wq! Force save exit

20. cp: omitting directory '/oldboy/'

Ignore this directory
cp cannot copy directories by default

[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

Unknown end of compressed file
The main reason is that the tar compressed package is damaged and downloaded again

[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

image.png

II Network connection class

1. Remote connection error Connection Failed

Use the Xshell remote connection failure prompt to check whether the port is open or correct

[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.

Use telnet to test whether the port is open

[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.   #Port 233 is not open

Type `help' to learn how to use Xshell prompt.

Port open

[c:\~]$ telnet 10.0.0.200 22
Connecting to 10.0.0.200:22...
Connection established.            #Port open
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 install software fault prompt Could not resolve host

Could not resolve host
The main problem is whether the system can access the Internet and 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.

3. Tips for installing software using Yum: Nothing to do

There are two situations:
Case 1: the software has been installed and the latest is as follows:

Package tree-1.6.0-10.el7.x86_64 already installed and latest version
tree The package is already installed and is the latest version
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

Case 2: the software package cannot be found because the software name is written incorrectly or the yum source is not configured

[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. 
#No package named treea was found
Error: Nothing to do

Case 3: you need to install the package instead of the commands in the package
Check which package the command belongs to through Yum providers

[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 the domain name is unrecognized (unable to access the Internet)

Cause 1: DNS configuration error
Reason 2: Why Linux can't access the Internet https://www.jianshu.com/p/0bc0b596c1a0

[root@oldboyedu59 ~]# ping baidu.com 
ping: baidu.com: Name or service not known
                 The domain name is not recognized (the domain name cannot be---->ip address)

III Modify basic system configuration class

1. Restart the network card and report an error 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.

View detailed error reasons
·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. During the process of modifying the host name, the host name in the command line does not change

After modifying the hostname of the temporary server (hostname# command fails)

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

2# modify the contents of the document (write the contract and take effect after permanently restarting the server)

vim /etc/hostname 
 oldboyedu59-lnb

3# inspection

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

The hostname part of the command line has not changed?

Solution: just log in again (disconnect, reconnect)

[root@oldboyedu59-lnb ~]# 

3. unexpected EOF while looking for matching `"'

Quotation marks are not paired

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 `"'
/The unexpected end of line 78 of etc/profile is looking for the other half of the double quotation mark '"'

IV User class error

1. user 'oldboy' already exists

User already exists

[root@oldboyedu59 ~]# useradd oldboy 
useradd: user 'oldboy' already exists

2. no such user

There is no such user

[root@oldboyedu59 ~]# id lidao 
id: lidao: no such user

3.Only root can do that.

Only root users can use non interactive password setting

[oldboy@oldboyedu59 ~]$ echo 123456|passwd --stdin oldboy
Only root can do that.

4.Only root can specify a user name.

Only the root user can add the user name when running passwd
Ordinary users can only run passwd by default, and cannot add a user name to change their password

[oldboy@oldboyedu59 ~]$ passwd oldboy 
passwd: Only root can specify a user name.

5. Creating mailbox file: File exists and warning: the home directory already exists

Prompt when adding users:

Creating mailbox file: File exists creating this user's mailbox: the mailbox already exists
warning: the home directory already exists. This user's home directory already exists

When deleting a user, the home directory and mailbox are not deleted by default
Adding it again will prompt the existence of home directory and mailbox

[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

The user is in use by a process whose pid is 7540

[root@web01 /usr/share/nginx/html/blog]#  usermod -u 2222   nginx 
usermod: user nginx is currently used by process 7540

V Script and scheduled tasks

1. no crontab for root

The root user has no scheduled tasks

[root@oldboyedu59 ~]# crontab -l
no crontab for root

The root user has no scheduled tasks

2.no crontab for root - using an empty one

The root user has no scheduled task and creates a new one for root
In fact, the scheduled task file / var/spool/cron/root empty file is created for root

3.crontab: installing new crontab

Update scheduled task rules

4. bad xxx, errors in crontab file,can't install

Wrong {minute | hour | day | month | week}. There is an error in the scheduled task file. The scheduled task cannot be updated

Time sharing day month week format error 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 It means line 3,Wrong hour position writing error 
errors in crontab file, can't install.
Do you want to retry the same edit?

Time sharing day month week format error 02
The time range writing error is 21-00, and the error is changed to 21-23,00, because the hour of the scheduled task is 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

You have a new email in / var/spool/mail/root

> Time sharing day month week format error 02
>  Time range writing error 21-00 Error changed to 21-23,00 That's because the hour of the scheduled task is 00-23



```html
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

You have a new email in / var/spool/mail/root

come from: https://www.jianshu.com/p/99ec5bb4183f?tdsourcetag=s_pctim_aiomsg

Posted by mikesmith76 on Sun, 22 May 2022 12:59:14 +0300