当前位置: 首页 > news >正文

基础开发工具(上)

文章目录

    • 1. 软件包管理器
    • 2. 编辑器Vim
    • 3. 编译器gcc/g++

1. 软件包管理器

软件包管理器

  1. 查看软件包
    通过 yum list 命令可以罗列出当前一共有哪些软件包。由于包的数目可能非常之多,这里我们需要使用 grep 命令只筛选出我们关注的包。
yum list | grep gcc
  1. 安装软件
yum install -y lrzsz
  1. 卸载软件
yum remove -y lrzsz
  1. 安装源
    Centos中yum源(就是图中所说的yum的配置文件,配置文件中记录了它应该到哪里去找软件并把它下载安装到我们自己的服务器上)的路径:
[root@VM-4-3-centos ~]# ll /etc/yum.repos.d
total 8
-rw-r--r-- 1 root root 614 Nov 12  2024 CentOS-Base.repo
-rw-r--r-- 1 root root 230 Nov 12  2024 CentOS-Epel.repo

安装源的代码可以在网上进行查找。(云服务器不用考虑,因为软件源都是国内的了)

2. 编辑器Vim

编辑器Vim

vim 有很多种模式,要查看所有模式:打开 vim,底行模式直接输入 help vim-modes

移动光标:

  • 按「e」:光标跳到这个字的字尾
  • 按「#l」:光标移到相对于光标现在位置的该行的第#个位置,如:5l,56l
  • 按「ctrl」+「b」:屏幕往“后”移动一页
  • 按「ctrl」+「f」:屏幕往“前”移动一页
  • 按「ctrl」+「u」:屏幕往“后”移动半页
  • 按「ctrl」+「d」:屏幕往“前”移动半页

复制:

  • 「yw」:将光标所在之处到字尾的字符复制到缓冲区中
  • 「#yw」:复制#个字到缓冲区

简单vim配置

配置文件的位置:

  • 在目录 /etc/ 下面,有个名为vimrc的文件,这是系统中公共的vim配置文件,对所有用户都有效。
  • 而在每个用户的家目录下,都可以自己建立私有的配置文件,命名为:“.vimrc”,这个配置文件只对自己有效,不会影响其他用户。

具体如何配置可以自行查找资料,或者用这个链接中的(只适用于Centos 7,想在哪个用户下让vim配置生效,就在哪个用户下执行这个指令,强烈 “不推荐” 直接在 root 下执行)。


一个普通用户要使用 sudo,需要先在 /etc/sudoers 中添加上自己的用户名。(用 root 账号打开这个文件,增加上这个普通用户的用户名,强制保存退出就可以了)

3. 编译器gcc/g++

编译器gcc/g++(1)

编译器gcc/g++(2)

[gsm@VM-4-3-centos lesson6]$ ll
total 0
[gsm@VM-4-3-centos lesson6]$ vim code.c
[gsm@VM-4-3-centos lesson6]$ ll
total 4
-rw-rw-r-- 1 gsm gsm 286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ gcc code.c 
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:28 a.out
-rw-rw-r-- 1 gsm gsm  286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ ./a.out 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ rm a.out 
[gsm@VM-4-3-centos lesson6]$ gcc -o code code.c 
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:29 code
-rw-rw-r-- 1 gsm gsm  286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ ./code 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ rm code
[gsm@VM-4-3-centos lesson6]$ ll
total 4
-rw-rw-r-- 1 gsm gsm 286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ gcc code.c -o code
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:30 code
-rw-rw-r-- 1 gsm gsm  286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ ./code 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:30 code
-rw-rw-r-- 1 gsm gsm  286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ rm code
[gsm@VM-4-3-centos lesson6]$ ll
total 4
-rw-rw-r-- 1 gsm gsm 286 Oct 11 21:27 code.c
[gsm@VM-4-3-centos lesson6]$ gcc -o test code.c 
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rw-rw-r-- 1 gsm gsm  286 Oct 11 21:27 code.c
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:31 test
[gsm@VM-4-3-centos lesson6]$ ./test 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rw-rw-r-- 1 gsm gsm  286 Oct 11 21:27 code.c
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:31 test
[gsm@VM-4-3-centos lesson6]$ test
[gsm@VM-4-3-centos lesson6]$ vim code.c 
[gsm@VM-4-3-centos lesson6]$ gcc -o test code.c 
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rw-rw-r-- 1 gsm gsm  418 Oct 11 21:32 code.c
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:32 test
[gsm@VM-4-3-centos lesson6]$ test
[gsm@VM-4-3-centos lesson6]$ ./test 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ which test
/usr/bin/test
[gsm@VM-4-3-centos lesson6]$ ls /usr/bin/test
/usr/bin/test
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rw-rw-r-- 1 gsm gsm  418 Oct 11 21:32 code.c
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:32 test
[gsm@VM-4-3-centos lesson6]$ ./test 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ rm test
[gsm@VM-4-3-centos lesson6]$ gcc -o code code.c 
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:33 code
-rw-rw-r-- 1 gsm gsm  418 Oct 11 21:32 code.c
[gsm@VM-4-3-centos lesson6]$ ./code 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ code
-bash: code: command not found
[gsm@VM-4-3-centos lesson6]$ ll
total 16
-rwxrwxr-x 1 gsm gsm 8360 Oct 11 21:33 code
-rw-rw-r-- 1 gsm gsm  418 Oct 11 21:32 code.c
[gsm@VM-4-3-centos lesson6]$ rm code
[gsm@VM-4-3-centos lesson6]$ ll
total 4
-rw-rw-r-- 1 gsm gsm 418 Oct 11 21:32 code.c
[gsm@VM-4-3-centos lesson6]$ ll
total 4
-rw-rw-r-- 1 gsm gsm 418 Oct 11 21:32 code.c
[gsm@VM-4-3-centos lesson6]$ gcc -E code.c -o code.i
[gsm@VM-4-3-centos lesson6]$ ll
total 24
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
[gsm@VM-4-3-centos lesson6]$ vim code.i
[gsm@VM-4-3-centos lesson6]$ ll
total 24
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
[gsm@VM-4-3-centos lesson6]$ gcc -S code.i -o code.s
[gsm@VM-4-3-centos lesson6]$ ll
total 28
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ vim code.s
[gsm@VM-4-3-centos lesson6]$ gcc -c code.c -o code.o
[gsm@VM-4-3-centos lesson6]$ ll
total 32
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ vim code.o
[gsm@VM-4-3-centos lesson6]$ ll
total 32
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ ./code.o
-bash: ./code.o: Permission denied
[gsm@VM-4-3-centos lesson6]$ chmod u+x code.o
[gsm@VM-4-3-centos lesson6]$ ll
total 32
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rwxrw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ ./code.o
-bash: ./code.o: cannot execute binary file
[gsm@VM-4-3-centos lesson6]$ chmod u-x code.o
[gsm@VM-4-3-centos lesson6]$ ll
total 32
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ gcc -o code code.o
[gsm@VM-4-3-centos lesson6]$ ll
total 44
-rwxrwxr-x 1 gsm gsm  8360 Oct 11 21:55 code
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ ./code 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ ll
total 44
-rwxrwxr-x 1 gsm gsm  8360 Oct 11 21:55 code
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ ldd codelinux-vdso.so.1 =>  (0x00007ffc259e4000)libc.so.6 => /lib64/libc.so.6 (0x00007fe08b792000)/lib64/ld-linux-x86-64.so.2 (0x00007fe08bb60000)
[gsm@VM-4-3-centos lesson6]$ ll /lib64/libc.so.6
lrwxrwxrwx 1 root root 12 Jul  8  2024 /lib64/libc.so.6 -> libc-2.17.so
[gsm@VM-4-3-centos lesson6]$ which ls
alias ls='ls --color=auto'/usr/bin/ls
[gsm@VM-4-3-centos lesson6]$ ldd /usr/bin/lslinux-vdso.so.1 =>  (0x00007fff0c2ef000)libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fd8e18d2000)libcap.so.2 => /lib64/libcap.so.2 (0x00007fd8e16cd000)libacl.so.1 => /lib64/libacl.so.1 (0x00007fd8e14c4000)libc.so.6 => /lib64/libc.so.6 (0x00007fd8e10f6000)libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fd8e0e94000)libdl.so.2 => /lib64/libdl.so.2 (0x00007fd8e0c90000)/lib64/ld-linux-x86-64.so.2 (0x00007fd8e1af9000)libattr.so.1 => /lib64/libattr.so.1 (0x00007fd8e0a8b000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd8e086f000)
[gsm@VM-4-3-centos lesson6]$ which top
/usr/bin/top
[gsm@VM-4-3-centos lesson6]$ ldd /usr/bin/toplinux-vdso.so.1 =>  (0x00007ffe33dfb000)libprocps.so.4 => /lib64/libprocps.so.4 (0x00007f19fd898000)libsystemd.so.0 => /lib64/libsystemd.so.0 (0x00007f19fd667000)libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f19fd440000)libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f19fd216000)libdl.so.2 => /lib64/libdl.so.2 (0x00007f19fd012000)libc.so.6 => /lib64/libc.so.6 (0x00007f19fcc44000)libcap.so.2 => /lib64/libcap.so.2 (0x00007f19fca3f000)libm.so.6 => /lib64/libm.so.6 (0x00007f19fc73d000)librt.so.1 => /lib64/librt.so.1 (0x00007f19fc535000)libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f19fc30e000)liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f19fc0e8000)liblz4.so.1 => /lib64/liblz4.so.1 (0x00007f19fbed9000)libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x00007f19fbc58000)libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x00007f19fba53000)libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f19fb839000)libdw.so.1 => /lib64/libdw.so.1 (0x00007f19fb5e8000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f19fb3d2000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f19fb1b6000)/lib64/ld-linux-x86-64.so.2 (0x00007f19fdabf000)libattr.so.1 => /lib64/libattr.so.1 (0x00007f19fafb1000)libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f19fad4f000)libelf.so.1 => /lib64/libelf.so.1 (0x00007f19fab37000)libz.so.1 => /lib64/libz.so.1 (0x00007f19fa921000)libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f19fa711000)
[gsm@VM-4-3-centos lesson6]$ ldd /usr/bin/whoamilinux-vdso.so.1 =>  (0x00007ffd577df000)libc.so.6 => /lib64/libc.so.6 (0x00007fe83b41f000)/lib64/ld-linux-x86-64.so.2 (0x00007fe83b7ed000)
[gsm@VM-4-3-centos lesson6]$ ll
total 44
-rwxrwxr-x 1 gsm gsm  8360 Oct 11 21:55 code
-rw-rw-r-- 1 gsm gsm   418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm 17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm  1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm   934 Oct 11 21:44 code.s
[gsm@VM-4-3-centos lesson6]$ ldd codelinux-vdso.so.1 =>  (0x00007fff1d3f1000)libc.so.6 => /lib64/libc.so.6 (0x00007ff285040000)/lib64/ld-linux-x86-64.so.2 (0x00007ff28540e000)
[gsm@VM-4-3-centos lesson6]$ file code
code: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c9dee9b5e257c3a17d692e41c04f86f2f62453ee, not stripped
[gsm@VM-4-3-centos lesson6]$ ldd codelinux-vdso.so.1 =>  (0x00007ffcb69b3000)libc.so.6 => /lib64/libc.so.6 (0x00007fc57032b000)/lib64/ld-linux-x86-64.so.2 (0x00007fc5706f9000)
[gsm@VM-4-3-centos lesson6]$ gcc -o code_static code.s -static
[gsm@VM-4-3-centos lesson6]$ ll
total 888
-rwxrwxr-x 1 gsm gsm   8360 Oct 11 21:55 code
-rw-rw-r-- 1 gsm gsm    418 Oct 11 21:32 code.c
-rw-rw-r-- 1 gsm gsm  17201 Oct 11 21:41 code.i
-rw-rw-r-- 1 gsm gsm   1992 Oct 11 21:48 code.o
-rw-rw-r-- 1 gsm gsm    934 Oct 11 21:44 code.s
-rwxrwxr-x 1 gsm gsm 861216 Oct 12 15:09 code_static
[gsm@VM-4-3-centos lesson6]$ ./code_static 
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
hello bit, hello : 100
[gsm@VM-4-3-centos lesson6]$ file code_static 
code_static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, BuildID[sha1]=7cd8bff7f31e73bfe6397aab4e1a524044474f9f, not stripped
[gsm@VM-4-3-centos lesson6]$ ls /lib64/libc.a
/lib64/libc.a
[gsm@VM-4-3-centos lesson6]$ ls /lib64/libc.a -al
-rw-r--r-- 1 root root 5105516 Jun  4  2024 /lib64/libc.a
http://www.dtcms.com/a/490876.html

相关文章:

  • k8s lngress与安全机制
  • 大模型微调(一):有监督微调与困惑度
  • 网站建设步骤图片素材WordPress点击出现爱心
  • 《从零搭建现代 Android 模块化架构项目(2025 最新实践)》
  • 深圳燃气公司有哪些大型网站和小企业站优化思路
  • AWS CloudWatch Logs Insights:实时日志分析,让服务器问题无所遁形
  • 云服务器与传统服务器租用的核心差异解析(云服务器与服务器租用之间的区别在哪里?)
  • NewStarCTF2025-Week2-Web
  • 自己做网站需要做服务器如何用dw制作网页框架
  • 使用Deepseek解析PDF文件
  • 跨链协同制造中的服务博弈与激励机制
  • 在半导体制造中什么是晶圆退火工艺?
  • 赋能高效电池制造:圆柱电芯组合式双面自动点焊技术
  • 【项目】基于多设计模式下的同步异步日志系统 - 项目介绍与前置知识
  • saas建站和开源建站的区别哈尔滨建站怎么做
  • 鸿蒙Harmony实战开发教学(No.4)-RichText组件基础到高阶介绍篇
  • 外包网站价格介绍西安网页设计
  • yolov3代码详解
  • 第六篇移动端知识,vw/vmin适配方案...
  • kubuntu24.04 换国内ustc源
  • 查询计划:EXPLAIN解读,SQL性能怎样精准调优?
  • 大形电商网站开发费用广州seo关键词优化费用
  • 网站做迅雷下载链接网页制作软件
  • Flink ProcessFunction 与低层级 Join 实战手册:多流广告计费精确去重
  • jQuery Mobile 按钮图标:设计与实现指南
  • SQL MID() 函数详解与使用指南
  • 深度学习之yolov2
  • 【C语言加油站】C语言文件随机读写完全指南:fseek、ftell、rewind等五大函数深度解析
  • C++篇(13)计算器实现
  • 北京网站排行wordpress 搜索小工具栏