ubuntu安装go开发环境
想学习安全的小白 人气:0一、为ubuntu20.04更新源
- 给root用户设置密码:命令:
sudo passwd root
- 备份原来的源,命令:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
- 安装vim,命令:
sudo apt install vim
- 修改/etc/apt/sources.list文件,命令:
sudo vim /etc/apt/sources.list
,将里面的内容全删后,配置为清华源,清华源如下:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiversedeb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiversedeb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
- 更新源,命令:
sudo apt-get update
- 如出现依赖问题,解决方式如下:
sudo apt-get -f install
- 更新软件,命令:
sudo apt-get upgrade
二、设置允许以root用户登录
执行命令:sudo vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
, 把配置改为如下所示
[Seat:*] user-session=ubuntu greeter-show-manual-login= true all-guest=false #这个可以 不用配置
执行sudo vim /etc/pam.d/gdm-autologin
注释掉auth required pam_succeed_if.so user != root quiet_success这一行(第三行左右)
执行sudo vim /etc/pam.d/gdm-password
注释掉 auth required pam_succeed_if.so user != root quiet_success这一行(第三行左右)
执行sudo vim /root/.profile
修改配置文件如下
# ~/.profile: executed by Bourne-compatible login shells. if [ "$BASH" ]; then if [ -f ~/.bashrc ]; then . ~/.bashrc fi fi tty -s && mesg n || true mesg n || true
重启:reboot
,选择root用户
三、安装go
- 创建安装目录,命令:mkdir /home/go
- 下载go安装包,命令:wget https://golang.google.cn/dl/go1.17.8.linux-amd64.tar.gz
- 解压go安装包,命令:sudo tar -zxvf go1.17.8.linux-amd64.tar.gz
- 创建工作目录:命令:mkdir /home/go/goProject
- 配置环境变量,命令:sudo vim /etc/profile
export GOROOT=/home/go/go export GOPATH=/home/go/goProject export GOPROXY=https://goproxy.cn export PATH=$PATH:$GOROOT/bin
四、安装goland工具
- 下载golang工具,命令:
wget https://download.jetbrains.com.cn/go/goland-2021.3.3.tar.gz
- 解压,命令:
sudo tar -zxvf goland-2021.3.3.tar.gz
- 重命名为goland,命令:
mv GoLand-2021.3.3/ goland
- 启动goland,命令:
/home/go/goland/bin/goland.sh
五、安装ssh并配置允许root登录
安装ssh服务,命令:sudo apt-get install openssh-server
开启ssh的22端口,命令:sudo vim /etc/ssh/sshd_config
,将Port注释去掉
允许root用户远程登录,命令:sudo vim /etc/ssh/sshd_config
,修改成如下
重启服务,命令:sudo /etc/init.d/ssh restart
总结
加载全部内容