Part.1 重修C++之环境配置
本人CSDN连接: 01 重修C++之环境配置 文章均为自己搬自己,以后就不注明连接了
操作系统
虽然本人之前有一些使用Ubuntu的经验,但是由于想接触服务器后端所以本次决定使用比较偏向服务器的Linux发行版,CentOS8。安装到虚拟机VMware上。
安装过程这里不做过多描述,网上有很多教程,下面说一下安装后的一些设置和调整。
Terminal快捷键
之前使用Ubuntu有一组快捷键 Ctrl + Alt + T 能快速调出Terminal,但是这个功能在CentOS中不是默认支持的,需要手动设置。首先打开图形化界面的 Settings 找到
Devices ->Keyborad 拉到最下面会有一个 + 点击添加快捷键 Name:open-Terminal;Comman:/usr/bin/gnome-terminalShortcut:; Ctrl + Alt + T 。
添加root权限
CentOS默认的用户是没有root权限的,在不做修改的前提下是无法使用sudo的,需要用户自己添加,网上有许多方法,我认为最好用的是修改配置文件。下面为具体的操作步骤:
- 切换到root用户输入下面命令,并按照提示输入密码。
[wangs7@localhost ~]$ su root
Password:
- cd到
/etc目录下,查看文件sudoers的属性,发现是只读,修改文件属性允许root用户读写,使用vim修改文件
[root@localhost wangs7]# cd /etc/
[root@localhost etc]# ls -l sudoers
-r--r-----. 1 root root 4328 Feb 4 2021 sudoers
[root@localhost etc]# ls -l sudoers
-rw-rw----. 1 root root 4328 Feb 4 2021 sudoers
[root@localhost etc]# vim sudoers
修改配置文件,将这行的注释去掉 %wheel ALL=(ALL) ALL 这样所有用户就都能使用sudo了。
## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
## user MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
最后保存退出后修改回原来的文件属性。
[root@localhost etc]# chmod 440 sudoers
[root@localhost etc]# ls -l sudoers
-r--r-----. 1 root root 4328 Feb 4 2021 sudoers
修改yum源为阿里源
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
sudo yum clean all
sudo yum makecache
sudo yum update -y
编译环境
GCC、G++
[root@localhost etc]# yum install gcc
[root@localhost etc]# yum install gcc-c++
注意CentOS环境下的yum包管理器是不识别g++的,需要键入gcc-c++
Make、CMake
[root@localhost etc]# yum install make
[root@localhost etc]# yum install cmake
GDB
[root@localhost etc]# yum install gdb
VSCode
安装VSCode,参考官方文档:
We currently ship the stable 64-bit VS Code in a yum repository, the following script will install the key and repository:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
Then update the package cache and install the package using dnf (Fedora 22 and above):
dnf check-update
sudo dnf install code
# Or on older versions using yum:
yum check-update
sudo yum install code
最后建立然链接,通过软连接启动VSCode。
ln -s /usr/share/code/bin/code /home/wangs7/code
./code
下面是VSCode的一些插件:
C/C++
C/C++ Snippets
CMake
CMake Tools
Include AutoComplete
Rainbow Brackets
One Dark Pro
GBKtoUTF8
Chinese(Simplified)
vscode-icons
compareit
DeviceTree