Awareness of the past, not remonstrance, knowing the future, can be pursued
C++ programmer, 2024 electronic information graduate student
Table of contents
find command (very important) -name
3. Shell command and operating principle
How to understand? Why can't I use the kernel directly?
1. Xshell configuration
session configuration
Connect again to succeed
log
At every critical moment when the program runs to itself, you need to log it yourself
Log: the time of the log, the level of the log, the specific information of the log, and other information, write the previous information to a
in a file, which we call the log
2. Instructions
date command
//时间戳
date %s
//如何将时间戳内的时间转换成我们能看得懂的时间
date +%Y:%m:%d_%H:%M:%S
//查看时间戳的起始时间--欧洲时间,这就是为什么我们查看的时间不是0点,而是八点
//这是因为东八区的时间和欧洲时间相差八小时
date +%Y:%m:%d_%H:%M:%S -d @0
The calculation of the timestamp time is actually calculated from January 1, 1970, and it is monotonically increasing
cal command
calendar function
//查看本月的日历
cal
//查看指定年日历
cal 2023
cal 1949
find command (very important) -name
//查找指定文件的路径
find ~ -name test.c
//搜索指令位置
which ls
which find
//whereis指令:在系统特定路径下查找,既可以找到特定可执行程序,又可以找到手册,
//安装包,压缩包等等
whereis ll
grep command
Line text filtering tool, line matching, if it matches, print it, if it does not match, filter it out
//行过滤
grep "world" test.c
//行过滤,同时忽略大小写
grep -i "world" test.c
//打印需要找到的命令的行数
grep -n "world" test.c
zip/unzip command
//压缩文件
zip d1.zip d1
//解压缩
unzip d1.zip
//压缩指定文件
zip -r d1.zip d1 log.txt
//进入管理员账号
su -
//然后输入密码即可
//再退出时,直接ctrl+D
question:
Why pack and compress?
What can be packaged and compressed must be a whole (dependency program), and one file is programmed from multiple files.
It is not easy to cause file loss, and packaging and compression can make the volume smaller (large volume, long download time, and large storage space)
tar command
Packing/unpacking does not open, directly view the content
//打包压缩
tar czf code.tgz d1
//tar->打包后缀
//.gz->压缩后缀
//预览
tar tzf code.tgz
//bc指令是Linux下的计算器
uname command
View server details
//查看主机的详细信息
//体系结构 内核版本
uname -a
//查看CPU的详细信息
lscpu
//向文件内输入内容
nano test.c
Commonly used hotkeys
Tab---command completion Tab---click twice to display system commands ctr+r to view recent historical commands
3. Shell commands and operating principles
How to understand? Why can't we use the kernel directly ?
Translate user commands to the core ( kernel ) for processing.At the same time, the processing results of the core are translated to the user.