亲宝软件园·资讯

展开

ubuntu安装go开发环境

想学习安全的小白 人气:0

一、为ubuntu20.04更新源

  1. 给root用户设置密码:命令:sudo passwd root
  2. 备份原来的源,命令:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  3. 安装vim,命令:sudo apt install vim
  4. 修改/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

二、设置允许以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

  1. 创建安装目录,命令:mkdir /home/go
  2. 下载go安装包,命令:wget https://golang.google.cn/dl/go1.17.8.linux-amd64.tar.gz
  3. 解压go安装包,命令:sudo tar -zxvf go1.17.8.linux-amd64.tar.gz
  4. 创建工作目录:命令:mkdir /home/go/goProject
  5. 配置环境变量,命令: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工具

  1. 下载golang工具,命令:wget https://download.jetbrains.com.cn/go/goland-2021.3.3.tar.gz
  2. 解压,命令:sudo tar -zxvf goland-2021.3.3.tar.gz
  3. 重命名为goland,命令:mv GoLand-2021.3.3/ goland
  4. 启动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

总结

加载全部内容

相关教程
猜你喜欢
用户评论