Date:2022-08-15
指定运行级别
:::info
0:关机
1:单用户【找回丢失密码】
2:多用户状态没有网络服务
3:多用户状态有网络服务
4:系统为使用保留给用户
5:图形界面
6:系统重启
:::
常用运行级别是
3和5,也可以指定默认运行级别
init 0init 1//....//获取当前运行级别systemctl get-default//设置默认运行级别 reboot后生效systemctl set-default multi-user.targetsystemctl 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 copycp sub_dir/file copycp sub_dir/sub_dir_1/now /nobodymv code.txt tempmv code_1.txt temp/sub_dir_1mv temp/code.txt /nobody/sub_dir/code.txtmv ./target ./des/mv ./sub_dir_1/sub_dir ./sub_dir_2/mv ./sub_dir_1/temp .rm code.txtrm sub_dir/code.txtrm sub_dir_1/sub_dir_1_1/code.txtpwdcd sub_dirpwdcd ..pwdcd sub_dir/sub_dir_2cd ..cd ../sub_dir_1/sub_dir_1_1lsls -als -ldiff file1 file2diff -i file1 file4diff -b file1 file3dfdf -adf -Tname='Jack'echo nameecho $namestat temp1stat -f temp1stat *cat file1awk '{print $1,$4}' file1cat file2awk -F, '{print $1,$4}' file2grep test file1##########grep test file*##########grep -c test file*cat main.cgrep test *.cgrep -A1 test *.cgrep -B1 test *.ccat file1##########cat file2##########comm file1 file2##########comm file2 file1a=1,b=2let a=1,b=2let c=a+blet a++echo $a $b $cfold tempfold -w 12 tempfold -s -w 12 templs -lln temp.txt h-temp.txtls -lln -s /nobody/tmp /nobody/create-link-here/s-tmpfind -iname "apple*"find -type f ! -size 0find sub_dir -type f -size 0 > filenl filenl file | sed '2,5c these are 2-5 contents of file'nl file | sed -n '5,70p'nl filesed 88d filenl file | sed 88,99dnl filesed 88a'Hello world!' filesed 99i'Hello world!' filenl fileecho $PATHwhich echowhich duecho "Hello world!"##########echo '"Hello world!"'##########echo "Hello\nworld!"##########echo -e "Hello\nworld!"cat file##########od -c file##########od -t d1 filecat file##########od file##########od -d file##########od -x file##########od -A n filels -l##########ln -s temp.txt s-temp.txt##########ls -l##########ln -sb temp2.txt s-temp.txtcut -b 4 temp.txt##########cut -b 1,2,3 temp.txt##########cut -c 2 temp.txt##########cut -d @ -f 1 temp.txtless file1##########less file2##########cmp file1 file2id##########id -un##########id -urwhoamiid -unid -gncut -b 4 temp.txt##########cut -b 1,2,3 temp.txt##########cut -c 2 temp.txt##########cut -d @ -f 1 temp.txtcomm file1 file2 -2 -3##########comm file1 file2 -2##########comm file1 file2 -1 -2
