noi_outline/senior/1.基础知识与编程环境.md
2024-10-22 10:59:11 +08:00

41 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Linux系统终端中常用的文件与目录操作命令
1. **cd 进入文件夹**
2. **ls 列出当前目录有什么文件,可以添加参数**
3. **pwd 当前在哪个目录**
4. **mkdir 创建文件夹 -p 递归创建**
5. **cp 复制文件**
6. **mv 移动文件**
7. **rm 删除文件 -r 递归删除 -f 强行删除**
8. chmod 更改文件权限
9. chown 更改文件所有者
10. g++ gcc 编译命令
1. **g++ [source file 1 .....] -o [output file] [-O1,-O2,-O3,-Ofast] [-I/path/to/include/dir] [-L/path/to/libdir] [-l/path/to/lib] 基本编译**
2. **gcc 与g++没有本质不同只是gcc没有链接c++标准库**
3. g++ -E [source file1...] -o [output file] 生成经过预处理器的文本文件
4. g++ -S [sourcefile1...] -o [output file] 生成经过汇编编码的汇编文件
5. g++ -c [source file1...] -o [output file] 生成没有链接的二进制文件
11. 在linux终端运行程序只需要输入程序的相对路径或者绝对路径如果出现权限错误请给可执行文件chmod +x /path/to/exe给他可执行权限
12. 测试程序运行时间time /path/to/exe
```
time ls
program public_html repo rocscm
real 0m0.002s
user 0m0.002s
sys 0m0.000s
```
1. real 外部能观测到的总时间
2. user 程序在用户态实际执行的时间(除了系统调用和内核线程切换)
3. sys 系统态时间程序在I/O交互或者硬件调用的时间
13. GDB 工具的使用
1. gdb /path/to/exe 调试可执行文件,注意编译时要使用-g编译添加调试符号性息优化最高开到-O2
2. 进入gdb页面后使用b <行号函数名>,添加断点
3. r 开始运行
4. c 继续运行
5. s 逐步运行
6. n 到下一步,不会进入下一级函数
7. quit 退出