报错代码
if: Expression Syntax. then: Command not found.
分析
此时终端没有使用 bash 解释器,而是使用了简化版 sh 解释器
解决方法
> exec bash ; source ~/.bashrc
if: Expression Syntax. then: Command not found.
此时终端没有使用 bash 解释器,而是使用了简化版 sh 解释器
> exec bash ; source ~/.bashrc
当 /usr/bin/su 文件的权限设置不正确时,会出现运行 su 命令时正确密码输入无效的情况
# chown root:root /usr/bin/su ; chmod 4755 /usr/bin/su
/usr/bin/sudo must be owned by uid 0 and have the setuid bit set
当 /usr/bin/sudo 文件的权限设置不正确时,会出现运行 sudo 命令时报错的情况
# chown root:root /usr/bin/sudo ; chmod 4755 /usr/bin/sudo
#!/bin/bash
while ((1));
do
sleep 1
echo "infinite loop"
done
或者:
#!/bin/bash
while :
do
sleep 1
echo "infinite loop"
done
#!/bin/bash
i=1;n=5
while ((i <= n))
do
echo $i
let i++
done
或者:
#!/bin/bash
i=1;n=5
while [[ $i -le $n ]]
do
echo $i
let i++
done
#!/bin/bash
i=1
while ((i <= 5));
do
let sum=$sum+$i
let i++
done
echo $sum
或者:
#!/bin/bash
i=1
while [[ $i -le 5 ]];
do
let sum=$sum+$i
let i++
done
echo $sum
#!/bin/bash
sum=0
echo 'Please input number, you must press 'enter' after inputting each number, press 'ctrl' and 'd' at the same time to end the input"
while read num
do
let sum=$sum+$num
done
echo $sum
#!/bin/bash
while read line
do
echo $line
done < test.txt
或者:
#!/bin/bash
cat test.txt | {
while read line
do
echo $line
done }
或者:
#!/bin/bash
cat test.txt | while read line
do
echo $line
done
(补充:这里以阅读 test.txt 文件为例)
# vi test.txt
创建以下内容:
no1 user1 test1.txt
no2 user2 test2.txt
no3 user3 test3.txt
no4 user4 test4.txt
no5 uesr5 test5.txt
# cat test.txt | while read no user file ;do echo $no $file;done
no1 test1.txt
no2 test2.txt
no3 test3.txt
no4 test4.txt
no5 test5.txt
根据问题发生的时间线,回溯最近发生了哪些情况和做了哪些变更,通过回溯找到发生问题的原因
根据事件的重要性和特点找到其核心点,并根据核心点分析产生问题的核心
对发生的问题进行定义,对问题的特征进行描述,通过定义和特征逐一排查,找到可能导致问题的原因
大家一起什么都想,快速获得任何和问题相关的信息,但是得到信息往往不够客观
将发生的问题看成一个主线,分析每一条汇入这条主线的分线,这些分线都有可能导致最后出现在主线上的问题,最终找到导致主线问题的原因在哪条分线上
分析哪些问题影响最大,先解决所有问题中最重要的那 20%,因为往往解决最重要的 20% 问题可能就会达到 80% 的效果
5 个为什么只是一个抽象的概念,真实情况是对发生问题的原因一只追问下去,先问导致问题的原因是什么,根据这个原因再问导致这个原因的原因是什么,直到问到根本原因以后才停止,此方法由日本丰田公司大野耐一发明。使用此方法需要注意:
1) 避免使用借口回答问题
2) 避免在追问的过程中牵扯到人的心理
3) 避免回答问题时推卸责任
4) 避免各个问题之间没有层级关系