ubuntu安装go开发环境

ubuntu安装go开发环境,第1张

一、为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 multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
deb-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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/989905.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存