最近重新装了一次,再记录以下吧 2020/8/19更
第一件事所有的基础,必须做,除非你在国外
打开浏览器,百度阿里镜像源或直接进这个,然后选择Ubuntu,之后选择你对应的版本
https://developer.aliyun.com/mirror/developer.aliyun.com![a294d671cc49441002be8fb39ad1312a.png](https://i-blog.csdnimg.cn/blog_migrate/569da7b28564ffddbf68f5387ac2313e.png)
我的是2020,所以选择ubuntu 20.04(focal),复制一下里面的内容
ubuntu 20.04(focal)内容如下,其他版本,我就不一 一列举了
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
在命令行输入
sudo gedit /etc/apt/sources.list
把里面的内容全部删除 粘贴刚刚复制的东东
然后 更新一下源列表 才算设置完成,
sudo apt update
最后 更新一下你的软件和系统(时间可能有点久 看你网络情况 大概五分钟,有时候很慢直接跳到几百b, Ctrl+c 结束更新,然后再输入sudo apt upgrade 它还会接着之前的更新 速度会变快(我的是这样的))
sudo apt upgrade
有时候会报错,就是更新的问题,原因麻,很多,我的就报错了
Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
这是我的报错,额我就按照提示,输入
sudo apt upgrade --fix-missing
//卧槽,竟然成功了
//你得先看提示是不是一样,再决定是不是要执行这个命令
//如果还不行,我就没办法了,查查百度吧
//https://www.cnblogs.com/X-knight/p/10598076.html
更新完成后清理一下垃圾
sudo apt autoremove
第二件事 装个 vim 吧 (这个就是个文本编辑器,也是很必须装的)
sudo apt install vim
至于怎么操作,怎么用,就去百度吧
第三件事,装个git
你会用到,因为有时候下载插件也得用这个命令,比如vim插件 不知道是什么可以去查以下
sudo apt install git
//我发现系统貌似已经安装了
//好厉害,可能是刚进行的那个更新的缘故吧
然后你要是写C/C++再装个,但貌似系统也默认安装了
sudo apt-get install build-essential
顺便配置一下git
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --list检查一下
生成公钥之类的 在文章下面有讲
第四件事 装个Chrome
我比较喜欢Chrome,所以第四件事我做的就是这个
先去官网下载deb包(下载好了告诉我一声)滑稽
下载好了deb,怎么用呢?双击也行文件(在Document/Download),执行命令行安装也行
sudo dpkg -i 文件全名
//前提你已经在这个文件夹
//安装之欧,就可以把deb文件删除了
我查百度说有时候会报依赖关系的错误,可以使用以下的命令修复安装。
反正我的是没报,所以我不用执行下面这个
sudo apt-get install -f
还有个神奇的命令,以后肯定可以用到,
//列出你已经安装的软件
sudo dpkg -l
然后可以通过下面这个进行卸载
sudo dpkg -r 软件名
第五件事 装Chrome插件
艾,装了Chrome不装几个插件可还行?
这个现在有点忙,先放这,以后再补
第六件事 装截图工具
截图工具能少?
sudo apt-get install flameshot
//flameshot gui
得设置快捷键吧,在设置里,完美
![189f6c05b616b26e4c48d508a31fb0a9.png](https://i-blog.csdnimg.cn/blog_migrate/47a2e9f089edc05c1027bad6857d41d6.jpeg)
第七件事 装个oh-my-zsh和设置主题
就是让你的命令行更美,更方便
1安装zsh
sudo apt install zsh -y
2把zsh设置为默认shell然后重启
chsh -s /bin/zsh
reboot
3安装oh-my-zsh之前需要安装git(很好安装 sudo apt install git)
4然后输入
vim install.sh
按 i 之后把下面内容粘贴进去
#!/bin/sh
#
# This script should be run via curl:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
#
# As an alternative, you can first download the install script and run it afterwards:
# wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
# sh install.sh
#
# You can tweak the install behavior by setting variables when running the script. For
# example, to change the path to the Oh My Zsh repository:
# ZSH=~/.zsh sh install.sh
#
# Respects the following environment variables:
# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
# REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
# BRANCH - branch to check out immediately after install (default: master)
#
# Other options:
# CHSH - 'no' means the installer will not change the default shell (default: yes)
# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)
# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)
#
# You can also pass some arguments to the install script to set some these options:
# --skip-chsh: has the same behavior as setting CHSH to 'no'
# --unattended: sets both CHSH and RUNZSH to 'no'
# --keep-zshrc: sets KEEP_ZSHRC to 'yes'
# For example:
# sh install.sh --unattended
#
set -e
# Default settings
ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master}
# Other options
CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no}
command_exists() {
command -v "$@" >/dev/null 2>&1
}
error() {
echo ${RED}"Error: $@"${RESET} >&2
}
setup_color() {
# Only use colors if connected to a terminal
if [ -t 1 ]; then
RED=$(printf '033[31m')
GREEN=$(printf '033[32m')
YELLOW=$(printf '033[33m')
BLUE=$(printf '033[34m')
BOLD=$(printf '033[1m')
RESET=$(printf '033[m')
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
RESET=""
fi
}
setup_ohmyzsh() {
# Prevent the cloned repository from having insecure permissions. Failing to do
# so causes compinit() calls to fail with "command not found: compdef" errors
# for users with insecure umasks (e.g., "002", allowing group writability). Note
# that this will be ignored under Cygwin by default, as Windows ACLs take
# precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w
echo "${BLUE}Cloning Oh My Zsh...${RESET}"
command_exists git || {
error "git is not installed"
exit 1
}
if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
error "Windows/MSYS Git is not supported on Cygwin"
error "Make sure the Cygwin git package is installed and is first on the $PATH"
exit 1
fi
git clone -c core.eol=lf -c core.autocrlf=false
-c fsck.zeroPaddedFilemode=ignore
-c fetch.fsck.zeroPaddedFilemode=ignore
-c receive.fsck.zeroPaddedFilemode=ignore
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
error "git clone of oh-my-zsh repo failed"
exit 1
}
echo
}
setup_zshrc() {
# Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
# with datestamp of installation that moved them aside, so we never actually
# destroy a user's original zshrc
echo "${BLUE}Looking for an existing zsh config...${RESET}"
# Must use this exact name so uninstall.sh can find it
OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
# Skip this if the user doesn't want to replace an existing .zshrc
if [ $KEEP_ZSHRC = yes ]; then
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
return
fi
if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then
error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
error "re-run the installer again in a couple of seconds"
exit 1
fi
mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh."
"${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}"
fi
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}"
mv ~/.zshrc "$OLD_ZSHRC"
fi
echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
sed "/^export ZSH=/ c
export ZSH="$ZSH"
" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc
echo
}
setup_shell() {
# Skip setup if the user wants or stdin is closed (not running interactively).
if [ $CHSH = no ]; then
return
fi
# If this user's login shell is already "zsh", do not attempt to switch.
if [ "$(basename "$SHELL")" = "zsh" ]; then
return
fi
# If this platform doesn't provide a "chsh" command, bail out.
if ! command_exists chsh; then
cat <<-EOF
I can't change your shell automatically because this system does not have chsh.
${BLUE}Please manually change your default shell to zsh${RESET}
EOF
return
fi
echo "${BLUE}Time to change your default shell to zsh:${RESET}"
# Prompt for user choice on changing the default login shell
printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} "
read opt
case $opt in
y*|Y*|"") echo "Changing the shell..." ;;
n*|N*) echo "Shell change skipped."; return ;;
*) echo "Invalid choice. Shell change skipped."; return ;;
esac
# Check if we're running on Termux
case "$PREFIX" in
*com.termux*) termux=true; zsh=zsh ;;
*) termux=false ;;
esac
if [ "$termux" != true ]; then
# Test for the right location of the "shells" file
if [ -f /etc/shells ]; then
shells_file=/etc/shells
elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
shells_file=/usr/share/defaults/etc/shells
else
error "could not find /etc/shells file. Change your default shell manually."
return
fi
# Get the path to the right zsh binary
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
error "no zsh binary found or not present in '$shells_file'"
error "change your default shell manually."
return
fi
fi
fi
# We're going to change the default shell, so back up the current one
if [ -n "$SHELL" ]; then
echo $SHELL > ~/.shell.pre-oh-my-zsh
else
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
fi
# Actually change the default shell to zsh
if ! chsh -s "$zsh"; then
error "chsh command unsuccessful. Change your default shell manually."
else
export SHELL="$zsh"
echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}"
fi
echo
}
main() {
# Run as unattended if stdin is closed
if [ ! -t 0 ]; then
RUNZSH=no
CHSH=no
fi
# Parse arguments
while [ $# -gt 0 ]; do
case $1 in
--unattended) RUNZSH=no; CHSH=no ;;
--skip-chsh) CHSH=no ;;
--keep-zshrc) KEEP_ZSHRC=yes ;;
esac
shift
done
setup_color
if ! command_exists zsh; then
echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first."
exit 1
fi
if [ -d "$ZSH" ]; then
cat <<-EOF
${YELLOW}You already have Oh My Zsh installed.${RESET}
You'll need to remove '$ZSH' if you want to reinstall.
EOF
exit 1
fi
setup_ohmyzsh
setup_zshrc
setup_shell
printf "$GREEN"
cat <<-'EOF'
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ / __ / __ `__ / / / / /_ / / ___/ __
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
____/_/ /_/ /_/ /_/ /_/__, / /___/____/_/ /_/
/____/ ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us on https://twitter.com/ohmyzsh
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
EOF
printf "$RESET"
if [ $RUNZSH = no ]; then
echo "${YELLOW}Run zsh to try it out.${RESET}"
exit
fi
exec zsh -l
}
main "$@"
按esc之后再按 : w q这三个键(一定要在英文输入法下 )
下面这句话这是vim的最基础操作
先按 i 才能改写内容, 最后 按 ' : ' 然后输入wq 意思是 write(写入) 和 quit (退出)
w q 顺序不能错
5为脚本文件服务可执行的权限
sudo chmod +x install.sh
6运行脚本
./install.sh
安装成功
7配置主题,不去下载的话只有这两个主题,可以选择
vim ~/.zshrc
![0b3b99d2c62757fb4118cece9bfc8e6b.png](https://i-blog.csdnimg.cn/blog_migrate/0ec4a7abc4ddf3916fcdf7dfe8b9eeac.jpeg)
第八件事 设置oh-my-zsh一些插件(前提你安装了oh-my-zsh)
1 语法高亮
cd .oh-my-zsh/custom/plugins
//前提你已经在home目录,怎么确认? 可以直接cd 然后火车 就相当于进home目录了
然后执行下面这个命令
git clone https://github.com/zsh-users/zsh-syntax-highlighting
下一步要
vim ~/.zshrc
然后在截图位置加下面的内容
zsh-syntax-highlighting
![636a28185c99094efad3e88da7cee037.png](https://i-blog.csdnimg.cn/blog_migrate/30a39c940232a7d81ff810af6f57a08b.jpeg)
看一下效果吧,vim并没有变颜色
![6da956b4337a4d6f2e2a7ac80c4be0f5.png](https://i-blog.csdnimg.cn/blog_migrate/71338f7a0922cb11db93a93efff9db70.jpeg)
之后
![76f5b6aff6e30f6f5b8266bf7c239a06.png](https://i-blog.csdnimg.cn/blog_migrate/afca2538f4f603a7ff4d81e6e01025b2.png)
当然不止这些,sudo 等这种都会语法高亮
而且以后输入常用命令 可以使用tab键进行自动补全
第九件事 安装Skype 代替Q传文件
wget https://repo.skype.com/latest/skypeforlinux-64.deb && sudo dpkg -i skypeforlinux-64.deb
8/24更
平时cd Documents很麻烦
安装之后无论你在哪 你甚至可以 直接 J D就进去了 遇到相同开头的文件夹怎么办?它会根据你的历史输入判断哪个权重更高,第一个就进哪个
总之你用用就知道了,绝对值
今天才发现这个神器真是有点相见恨晚
git clone https://github.com/joelthelion/autojump.git
cd autojump
./install.py
//前提你安装了python 没安装的话 很简单: sudo apt install python
之后会有提示
![6e6dd5425c46e1e6a6904f288a1287aa.png](https://i-blog.csdnimg.cn/blog_migrate/63e73d023151ad3cdf2a0ae4b5205c3f.jpeg)
如果按照我前面的流程装了 zsh 那么 在你的home目录下,有个.zshrc文件夹 打开它 把这些家进去就行了
然后记得,还记得吗,这是点命令
source .zshrc
source命令:
source命令也称为“点命令”,也就是一个点符号(.)。source命令通常用于重新执行刚修改的初始化文件,使之立即生效,而不必注销并重新登录。
然后 你可以先cd 常用的文件夹 让autojump记住 之后就可以简单使用啦
奇淫技巧:
1自定义快捷键:
添加一条快捷键:j -a s /Users/XXX/Desktop/code/shark
这句代码的含义:j -a 你定义的快捷命令 ‘需要跳转的目录位置
此后要是想进入shark目录,除了传统的cd一级一级的进入,还可以直接使用命令:j s
2看命令权重
j -s
由于我也刚安装 也就cd Documents一次
显示如下
![49c02eefa396a62ab93ece60f6b46653.png](https://i-blog.csdnimg.cn/blog_migrate/dbc1d720db7f467c420dd127676b287b.png)
暂时先更这些吧,想起来再说
上下键 命令行 查看命令历史(还可自动筛选 如输入vim 后按上方向键,然后就会找以前书如果的以vim开头的命令)
history -c 清除命令行历史记录,重启命令行生效
Ctrl+u 清除已经输入的命令
Ctrl+a 跳命令开头
Ctrl+e 跳到命令结尾
第一件事更新软件源(手动去选择,我的Linux学习笔记有设置的方法)
第二件事 sudo apt update(更新软件源列表)
第三件事 sudo apt upgrade (更新软件)
第四件事 sudo apt install vim(安装vim)
第五件事: 你要知道vim的一些基础用法
vim a.txt
之后你要按 ' i '才能对文本进行编辑
修改后你要 先按ESC退出 然后 按' : ' 之后按 ' wq '
w的意思是写入, q的意思是退出,wq 先保存再退出,顺序别错
第五件事 sudo apt install git (安装git,以后能用到)
第六件事 可以安装一个tree: sudo apt install tree
然后你输入 tree -L 2
就能看当前目录结构了,也可以是1, 3, 4, 5, 6 ...等等
自己去试试
第七件事 你要习惯用top(直接命令行输入 top) 这个就是相当于我们win的任务管理器,能看到cpu内存占用情况
第八件事习惯用 df -h(直接命令行输入) 他能告诉你磁盘的使用情况大小剩余空间
第九件事,你要习惯用 ls 还有ls -all 它是查看你所在的目录下都是有什么文件
第十件事你要习惯用 reboot 命令(重启)
的十一件事 你要安装个 搜狗输入法,我的其他Linux 文章有介绍或者网上也有很多教程
第十二件事 你可以安装一个 skype 代替QQ 平时与手机互传文件 也可以用手机安装个 xender,离线传输,很好用,(下文有介绍自己找找)
一条命令直接安装,可以看看这条命令在做什么, 别一味复制粘贴, 要做到心中有x数
wget https://repo.skype.com/latest/skypeforlinux-64.deb && sudo dpkg -i skypeforlinux-64.deb
第十三件事 为我点赞(狗头保命)
第十四件事 你可以安装 oh-my-zsh 但在做这之前我希望你去搜搜 shell脚本语言是什么
简单看一下, 然后 看一下shell的分类,看看 bash和sh, zsh,这都是什么,做到心里有数
至于怎么安装文章最下面有介绍,你可以翻翻
第十五件事 右键命令行,可以设置字体颜色,大小,透明度,什么的,你要是喜欢可以去试试
你要是从事C/C++
第十六件事, 永远不要用 rm -rf /* 或者类似操作 rm -rf /
这个命令是直接强制删除你所有的东西,系统可能就不能用了
则有第n件事 sudo apt-get install build-essential
运行这个后,编译器,cmake都有了,也就是说你拥有了编译C/C++的环境
可以装个 clion 一般 sudo apt install clion 会出现错误无法定位package
这个时候你有两个选择
它提示你用snap
sudo snap install clion --classic
然后就可以安装
要是没提示,你可以去clion官网 下个64位的 包 tar.gz貌似
然后 进入 用户目录下的downloads
cd #进入用户目录
cd Downloads #进入下载目录
ls #进行确认有没有一个....tar.gz
然后
tar -zxvf 加你下的包的全名
解压后, 进入
cd 解压后的名字
cd bin #(进入bin目录)
执行 这个是执行脚本的意思,也希望你去查查Linux 的sh是什么,以及shell编程规范随便看看,比如至少知道echo 是干啥的
./clion.sh
git生成公钥
ssh-keygen -t rsa -C "yourEmail"
连续按三次回车,(人家提示你直接按回车就行)意思是不设置密码
看公钥在这id_rsa.pub是公钥
![c2c85b4b624107196a0e2bf7eea98cdb.png](https://i-blog.csdnimg.cn/blog_migrate/d792ca9b0c37d20890f85ba3aed5c920.jpeg)
关于git的学习:
kikyou:git常用命令入门学习zhuanlan.zhihu.com![ac8e03f070462da0d1a1286f18c2ac36.png](https://i-blog.csdnimg.cn/blog_migrate/641690a15c82f09e4234159bd38d72e8.jpeg)
安装pathogen 一个管理vim的插件
mkdir -p ~/.vim/autoload ~/.vim/bundle &&
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
注意以下 mkdir -p是什么,以及curl类似wget
应该会报错
curl: (7) Failed to connect to Build software better, together port 443: Connection refused
为什么,因为被污染了
改一下它的域名
sudo vim /etc/hosts
添加这个在最后一行
199.232.28.133 raw.githubusercontent.com
然后就行了,看一下这条命令干了什么,注意之前在~目录, 是不存在.vim这个文件夹的,然后我们创建了.vim,又下载了一点东西在里面
![5e146f30162055bbccabe9e8f643a393.png](https://i-blog.csdnimg.cn/blog_migrate/25bec5bcfe72b9cabcb62ef58b289a47.png)
添加以下代码到你的.vimrc 文件中(文件位于用户的家目录下,如果不存在该文件,可以新建一个在~目录下咯)
execute pathogen#infect()
syntax on
filetype plugin indent on
保存退出,这个插件的安装配置就完成了 先来看看vim插件是个什么东西,看上面的截图,也就是.vim的树形图
其中autoload放的是pathogen插件,所谓的插件其实就是一个脚本,当vim启动时,它会自动加载~/.vim/autoload目录下的脚本,由于你~/.vimrc里配置了execute pathogen#infect(),所以它会去自动的执行脚本里这个函数
这个函数的功能就是去加载~/.vim/bundle目录下你安装的所有插件,pathogen的管理方法大致就是这样
现在装个括号自动匹配的插件,仔细看看这个命令做了什么
git clone git://github.com/jiangmiao/auto-pairs.git ~/.vim/bundle/auto-pairs
gedit .vimrc 遇到
Failed to load module "appmenu-gtk-module"
解决:
sudo apt install appmenu-gtk2-module appmenu-gtk3-module
这是个什么东东呢 我也不知道
我查了一下gtk
GTK(GIMP Toolkit)是一个Linux平台下基于Xwindow图形窗口的图形用户编程接口工具,可以借助它来开发Linux平台下基于Xwindow的图形用户界面
又查了以下gedit
Linux命令gedit主要作用是:启动GNOME桌面环境下的文本编辑器gedit。
gedit是一个GNOME桌面环境下兼容UTF-8的文本编辑器,使用GTK+编写而成
emmm所以,自己体会吧