四.Linux常用工具
1.vi编辑器
vim /etc/vimrc 查看vim设置
dd 删除当前行
ndd 向下删除n行
u 撤销上一步操作
U 撤销所有操作
:set nu 显示行号取消
:set nonu 取消行号
yy 复制一行
nyy 复制n行
p 粘贴
%s/old/new/g 替换所有
shift+zz 退出
gg 光标移到第一行
G 光标移到最后一行
H 屏幕第一行
L 屏幕第一行
nG 跳到第n行
:e otherfilename 编辑其他文件
/vpser 向下搜索
?vpser 向上搜索
2.gcc工具链
ELF表示是二进制文件
gcc test.c -o test 生成叫test的生成文件
编译分为四步:1)预处理(预编译)gcc -E test.c -o test.i 将头文件展开
2)编译 gcc -S test.i -o test.s 语法检查 生成汇编语言
3)汇编 gcc -c test.s -o test.o 生成二进制语言文件
4)链接 gcc test.o -o test 链接库函数
多个文件编译 gcc test.c print.c -o test
3.make和makefile
告诉make指令需怎么样去编译和链接程序
一个Makefile文件包含五个方面内容:具体规则,隐含规则,定义变量,指令,注释
公式: target:dependency
commond
范例: target=hello
object=hello.o print.o
CC=gcc
$(target):$(object)
$(CC)$(object) -o $(target)
.PHONY:clean
clean:
rm *.o $(target)
Makefile文件如在其他目录 make -C /home/
4.GDB调试工具
gdb test
list l 列表
break b 设置断点 b 16 在16行设置断点 info b 断点列表 b main 在main函数断点
continue c 继续
print p 显示一个变量
next n 跳过函数,一步一步运行
step s 进入函数,一步一步运行
return r 提前返回
quit q 退出
5.shell使用基础
命令解析器 将用户输入的指令转化为机器语言
#!/bin/bash
#comments 注释
chmod +x filename.sh 改属性
./filename.sh 执行
echo "${a}" 引用输出
echo 'hello world' 当前输出
echo "hello world">xxx 输出hello world 到xxx文件中并覆盖其他内容 >>表示不覆盖
echo $* 输出所有参数
echo $# 输出参数数量
1.vi编辑器
vim /etc/vimrc 查看vim设置
dd 删除当前行
ndd 向下删除n行
u 撤销上一步操作
U 撤销所有操作
:set nu 显示行号取消
:set nonu 取消行号
yy 复制一行
nyy 复制n行
p 粘贴
%s/old/new/g 替换所有
shift+zz 退出
gg 光标移到第一行
G 光标移到最后一行
H 屏幕第一行
L 屏幕第一行
nG 跳到第n行
:e otherfilename 编辑其他文件
/vpser 向下搜索
?vpser 向上搜索
2.gcc工具链
ELF表示是二进制文件
gcc test.c -o test 生成叫test的生成文件
编译分为四步:1)预处理(预编译)gcc -E test.c -o test.i 将头文件展开
2)编译 gcc -S test.i -o test.s 语法检查 生成汇编语言
3)汇编 gcc -c test.s -o test.o 生成二进制语言文件
4)链接 gcc test.o -o test 链接库函数
多个文件编译 gcc test.c print.c -o test
3.make和makefile
告诉make指令需怎么样去编译和链接程序
一个Makefile文件包含五个方面内容:具体规则,隐含规则,定义变量,指令,注释
公式: target:dependency
commond
范例: target=hello
object=hello.o print.o
CC=gcc
$(target):$(object)
$(CC)$(object) -o $(target)
.PHONY:clean
clean:
rm *.o $(target)
Makefile文件如在其他目录 make -C /home/
4.GDB调试工具
gdb test
list l 列表
break b 设置断点 b 16 在16行设置断点 info b 断点列表 b main 在main函数断点
continue c 继续
print p 显示一个变量
next n 跳过函数,一步一步运行
step s 进入函数,一步一步运行
return r 提前返回
quit q 退出
5.shell使用基础
命令解析器 将用户输入的指令转化为机器语言
#!/bin/bash
#comments 注释
chmod +x filename.sh 改属性
./filename.sh 执行
echo "${a}" 引用输出
echo 'hello world' 当前输出
echo "hello world">xxx 输出hello world 到xxx文件中并覆盖其他内容 >>表示不覆盖
echo $* 输出所有参数
echo $# 输出参数数量