Date:2022-08-15
指定运行级别
:::info
0:关机
1:单用户【找回丢失密码】
2:多用户状态没有网络服务
3:多用户状态有网络服务
4:系统为使用保留给用户
5:图形界面
6:系统重启
:::
常用运行级别是
3
和5
,也可以指定默认运行级别
init 0
init 1
//....
//获取当前运行级别
systemctl get-default
//设置默认运行级别 reboot后生效
systemctl set-default multi-user.target
systemctl set-default graphical.target
找回root密码
- reboot
- 找到以 Linux16开头内容所在的行数,在行的最后输入
- init=/bin/sh
- 然后按
ctrl + x
进入单用户模式- 在光标闪烁的位置输入:mount -o remount,rw /
- 输入
passwd
- 输入两次密码
- touch /.autorelabel
- exec /sbin/init (此过程略长,请等待)
帮助指令
man + ls help 在linux下是以
.
开头的
cp code.txt copy
cp sub_dir/file copy
cp sub_dir/sub_dir_1/now /nobody
mv code.txt temp
mv code_1.txt temp/sub_dir_1
mv temp/code.txt /nobody/sub_dir/code.txt
mv ./target ./des/
mv ./sub_dir_1/sub_dir ./sub_dir_2/
mv ./sub_dir_1/temp .
rm code.txt
rm sub_dir/code.txt
rm sub_dir_1/sub_dir_1_1/code.txt
pwd
cd sub_dir
pwd
cd ..
pwd
cd sub_dir/sub_dir_2
cd ..
cd ../sub_dir_1/sub_dir_1_1
ls
ls -a
ls -l
diff file1 file2
diff -i file1 file4
diff -b file1 file3
df
df -a
df -T
name='Jack'
echo name
echo $name
stat temp1
stat -f temp1
stat *
cat file1
awk '{print $1,$4}' file1
cat file2
awk -F, '{print $1,$4}' file2
grep test file1
##########
grep test file*
##########
grep -c test file*
cat main.c
grep test *.c
grep -A1 test *.c
grep -B1 test *.c
cat file1
##########
cat file2
##########
comm file1 file2
##########
comm file2 file1
a=1,b=2
let a=1,b=2
let c=a+b
let a++
echo $a $b $c
fold temp
fold -w 12 temp
fold -s -w 12 temp
ls -l
ln temp.txt h-temp.txt
ls -l
ln -s /nobody/tmp /nobody/create-link-here/s-tmp
find -iname "apple*"
find -type f ! -size 0
find sub_dir -type f -size 0 > file
nl file
nl file | sed '2,5c these are 2-5 contents of file'
nl file | sed -n '5,70p'
nl file
sed 88d file
nl file | sed 88,99d
nl file
sed 88a'Hello world!' file
sed 99i'Hello world!' file
nl file
echo $PATH
which echo
which du
echo "Hello world!"
##########
echo '"Hello world!"'
##########
echo "Hello\nworld!"
##########
echo -e "Hello\nworld!"
cat file
##########
od -c file
##########
od -t d1 file
cat file
##########
od file
##########
od -d file
##########
od -x file
##########
od -A n file
ls -l
##########
ln -s temp.txt s-temp.txt
##########
ls -l
##########
ln -sb temp2.txt s-temp.txt
cut -b 4 temp.txt
##########
cut -b 1,2,3 temp.txt
##########
cut -c 2 temp.txt
##########
cut -d @ -f 1 temp.txt
less file1
##########
less file2
##########
cmp file1 file2
id
##########
id -un
##########
id -ur
whoami
id -un
id -gn
cut -b 4 temp.txt
##########
cut -b 1,2,3 temp.txt
##########
cut -c 2 temp.txt
##########
cut -d @ -f 1 temp.txt
comm file1 file2 -2 -3
##########
comm file1 file2 -2
##########
comm file1 file2 -1 -2