Linux使用
目录
换源
镜像源参考列表
我使用的Ubuntu18.04,用的是阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
步骤
1.备份原始源文件source.list
桌面打开终端,执行命令:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.修改源文件source.list
-
执行命令:
sudo vim /etc/apt/source.list
打开文件进行编辑; -
复制镜像到文件中,然后保存
3.更新源
桌面终端执行命令:sudo apt update
更新软件列表,换源完成。
$ cd /etc/apt/ $ cp sources.list sources.list.bak ## 备份系统自带的source列表 ## 选择合适的镜像源,如阿里云的镜像 http://mirrors.aliyun.com/ubuntu $ sed -i 's/^(deb|deb-src) ([^ ]*) (.*)/1 http://mirrors.aliyun.com/ubuntu 3/' sources.list ## 更新apt $ apt-get update
发现大神换源的方法都和我们不一样。
修改终端
这一步可以参考这篇博客
终端是我们在linux中使用最多的一个东西,因此,一个功能强大,界面美观的终端是十分有必要的。
我个人十分喜欢zsh,功能强大,自定义程度高。
配置zsh主题
1.安装 zsh 软件包和 git
sudo apt -y install zsh git
2. 克隆 oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
3. 复制 .zshrc,修改命令提示符样式
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
4.修改主题
#查看可以修改的主题
ls ~/.oh-my-zsh/themes
vim .zshrc
#找到ZSH_THEME并修改为如下,eg修改为agnoster
ZSH_THEME="agnoster"
4. 修改 shell 类型
chsh -s /bin/zsh
配置高亮和补全
zsh-autosuggestions
安装zsh-autosuggestions
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
编辑~/.zshrc文件
vim ~/.zshrc
## 修改内容
plugins=(git zsh-autosuggestions)
##刷新
source ./zshrc
zsh-syntax-highlighting
下载zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
激活插件
vim ~/.zshrc
plugins=( [plugins...] zsh-syntax-highlighting)
source ~/.zshrc
配置环境
python3和pip3
linux一般是自代python2和pip2的
#安装python3
sudo apt search python3
sudo apt install python3.8-dbg
#安装pip3
sudo apt-get install python3-pip
sudo pip3 install --upgrade pip
安装docker
sudo apt-get install
apt-transport-https
ca-certificates
curl
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable"
sudo apt-get update
sudo apt-get install docker-ce
sudo docker run hello-world
安装常用程序
#用于从服务器上上传、下载文件
sudo apt install lrzsz
sudo apt install tree
#安装mysql服务
sudo apt-get install mysql-server
#配置初始化信息
sudo mysql_secure_installation
#配置远程访问
sudo mysql -uroot -p
use mysql;
select User,authentication_string,Host from user;
#设置权限与密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
#刷新cache中配置
flush privileges;