Table of contents
It is very important to create a user name that is the same as your windows git
Configure git username and email
Configure Alibaba Cloud codeup
Pulling the warehouse prompts file permission issues
Give user directory permission
Configure project file aliases
What about key_load_public: invalid format?
WSL ubuntu sshd: no hostkeys available -- exiting.
What to do if Golang executes go list -m -json all without permission
It is very important to create a user name that is the same as your windows git
Reason: wsl account permissions are very problematic, resulting in reinstalling ubuntu once
一、创建用户
1.创建用户:
useradd 用户名
useradd test
2.设置密码:
passwd userName 随后会提示输入密码
useradd test
二、赋予权限
Linux给用户和文件赋予权限
1、先对用户所属的的组赋权限:
chown -R 用户名:用户组 目录
su wangkai
sudo chown -R test:test -R /home
2、再对目录赋予权限:
chmod -R 775 目录
3、查看文件夹的权限
ls -la 目录
Configure git username and email
#配置git用户名邮箱
git config --global user.name wangkai
git config --global user.email [email protected]
#查看git cinfig
git config --global --list
Configure Alibaba Cloud codeup
su wangkai
ssh-keygen -t rsa -C "[email protected]"
cd /home/test/.ssh
cat /home/test/.ssh/id_rsa.pub
Pulling the warehouse prompts file permission issues
chmod 644 /home/test/.ssh/known_hosts
sudo chmod 600 /home/test/.ssh/config
sudo chmod 600 /home/test/.ssh/id_rsa.pub
Give user directory permission
sudo chown -R $USER /home
sudo chown -R test:test/home
Configure project file aliases
sudo vim ~/.bashrc
alias test='cd /home/gopath/environment_containers/code/test'
source ~/.bashrc
What about key_load_public: invalid format?
#查看秘钥是否存在
cd ~/.ssh && ll
#执行修复公钥命令,解决问题
ssh-keygen -f /home/test/.ssh/id_rsa -y > /home/test/.ssh/id_rsa.pub
WSL ubuntu sshd: no hostkeys available -- exiting.
What to do if Golang executes go list -m -json all without permission
#老方法 给用户和用户组权限,注意:我的go环境路径是 /usr/local/go
su test
sudo chown -R test:test -R /usr/local
chmod -R 777 /usr/local
wait for him to update
How to create a go environment without root installation for new users Find a way to share environment variables
Ubuntu 上配置环境变量后切换到root下环境变量无效 的解决方法。
原因:非root 和 root 下,环境变量的配置文件不同。
非root下,配置文件为:vim ~/.bashrc ,配置后执行更新: source ~/.bashrc
root下,配置文件为:vim /etc/profile ,配置后执行更新: source /etc/profile
解决:打开vim ~/.bashrc ,把里面相应的配置变量(环境路径),复制到 /etc/profile ,然后更新即可。
vim ~/.bashrc
source /etc/profile
但还有一个问题,关闭终端后,下次打开又无效了。解决方法:打开编辑.bashrc,在文件的末尾添加:
vim /root/.bashrc
source /etc/profile
然后执行更新,就搞定啦。
source /root/.bashrc
Related references: