drwxrwxr-x 2 gxm gxm 4096 10月 21 17:11 code d开头的代表目录
vim --help
man vim
linux速打:
打字母只要系统可以区分出来则按tab键可以自动补齐。
按上下方向键可以得到历史打过的字符串。
linux gcc编译指令:(下面死编译c的5个详细流程)
1.linux编译 gcc -E:(编译预处理) 预编译
-E选项,表示让gcc只进行“预处理”就行了。 所谓的预处理,就是把程序中的宏展开, 把头文件的内容展开包含进来等等一些编译前的预处理操作。
预处理结果会显示到屏幕上,如果需要保存,则得需要重定向。
把hello.c 预处理为hello.i
hello.c
#include<stdio.h>
int main()
{
printf("hello word!\n");
return 0;
}
~
gxm@gxm-VirtualBox:~/桌面/code$ gcc -E hello.c -o hello.i
gxm@gxm-VirtualBox:~/桌面/code$ ls
hello.c hello.i
hello.i:
# 1 "hello.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "hello.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 27 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 376 "/usr/include/features.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 1 3 4
# 385 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4
# 386 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4
# 375 "/usr/include/features.h" 2 3 4
# 398 "/usr/include/features.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 1 3 4
# 10 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 3 4
# 1 "/usr/include/x86_64-linux-gnu/gnu/stubs-64.h" 1 3 4
# 11 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 2 3 4
# 399 "/usr/include/features.h" 2 3 4
# 28 "/usr/include/stdio.h" 2 3 4
2。编译: 将高级语言(预处理指令)转为汇编语言 得到汇编文件 s文件 hello.i-》hello.s
gxm@gxm-VirtualBox:~/桌面/code$ gcc -S hello.i
gxm@gxm-VirtualBox:~/桌面/code$ ls
a.out hello.c hello.i hello.s
将预处理指令转为汇编语言:
hello.s(汇编语言)
.file "hello.c"
.section .rodata
.LC0:
.string "hello word!"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $.LC0, %edi
call puts
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
3.汇编: 将汇编语言翻译成机器指令,得到目标文件:
gxm@gxm-VirtualBox:~/桌面/code$ gcc -c hello.s
gxm@gxm-VirtualBox:~/桌面/code$ ls
a.out hello.c hello.i hello.o hello.s
hello.o
^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^A^@>^@^A^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@0^A^@^@^@^@^@^@^@^@^@^@@^@^@^@^@^@@^@^M^@
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @
......................
4.链接:将目标文件和标准库链接得到 可执行程序:
gxm@gxm-VirtualBox:~/桌面/code$ gcc hello.o -o hello
gxm@gxm-VirtualBox:~/桌面/code$ ls
a.out hello hello.c hello.i hello.o hello.s
hello:
^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^B^@>^@^A^@^@^@@^D@^@^@^@^@^@@^@^@^@^@^@^@^@<98>^Q^@^@^@^@^@^@^@^@^@^@@^@8^@ ^@@^@^^^@^[^@^F^@^@^@^E^@^@^@@^@^@^@^@^@^@^@@^@@^@^@^@^@^@@^@@^@^@^@^@^@ø^A^@^@^@^@^@^@ø^A^@^@^@^@^@^@^H^@^@^@^@^@^@^@^C^@^@^@^D^@^@^@8^B^@^@^@^@^@^@8^B@^@^@^@^@^@8^B@^@^@^@^@^@^\^@^@^@^@^@^@^@^\^@^@^@^@^@^@^@^A^@^@^@^@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@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^P^@^@^@^R^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@"^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@libc.so.6^@puts^@__libc_start_main^@__gmon_start__^@GLIBC_2.2.5^@^@^@^@^B^@^B^@^@^@^@^@^A^@^A^@^A^@^@^@^P^@^@^@^@^@^@^@u^Zi ^@^@^B^@1^@^@^@^@^@^@^@ø^O`^@^@^@^@^@^F^@^@^@^C^@^@^@^@^@^@^@^@^@^@^@^X^P`^@^@^@^@^@^G^@^@^@^A^@^@^@^@^@^@^@^@^@^@^@ ^P`^@^@^@^@^@^G^@^@^@^B^@^@^@^@^@^@^@^@^@^@^@(^P`^@^@^@^@^@^G^@^@^@^C^@^@^@^@^@^@^@^@^@^@^@H<83>ì^HH<8b>^E^M^L ^@H<
5.运行:
gxm@gxm-VirtualBox:~/桌面/code$ ./hello
hello word!
二、
步骤一:使用Wall选项产生尽可能多的警告
在控制台使用gcc -Wall HelloWorld.c命令一次性编译链接源文件HelloWorld.c时,如果源文件有问题,则会产生尽可能多的警告,以提示程序的问题所在。
步骤一:使用Werror选项将警告作为错误处理
在控制台使用gcc -Werror HelloWorld.c命令一次性编译链接源文件HelloWorld.c时,如果源文件有警告,建会按照错误处理。
步骤一:使用x选项指定源代码的语言
在控制台使用gcc -x c++ HelloWorld.c -l stdc++命令一次性编译链接源文件HelloWorld.c时,如果忽略源文件的扩展名,按照c++的源文件进行处理,-l是指在系统默认的目录上搜索相应的库。
echo是输出的意思:
gxm@gxm-VirtualBox:~$ echo message "我爱你"
message 我爱你
gxm@gxm-VirtualBox:~$ echo 我爱你
我爱你
gxm@gxm-VirtualBox:~$ ^C
gxm@gxm-VirtualBox:~$
4. export 赋值 export c=3
5。find 查找文件名:
gxm@gxm-VirtualBox:~$ find -iname code
find: `./.cache/dconf': 权限不够
./桌面/code
find: `./.dbus': 权限不够
6。ps -A 查找所有当前运行的进程
|管道是与 并且的意思
ps -A | grep some_command
grep命令索引是否有我们指定的bash进程运行
ps -A | grep some_command
7。安装 lynx
sudo apt-get install lynx-cur
lynx http://www.baidu.com 进百度