最近重新裝了一次,再記錄以下吧 2020/8/19更
第一件事所有的基礎,必須做,除非你在國外
打開浏覽器,百度阿裡鏡像源或直接進這個,然後選擇Ubuntu,之後選擇你對應的版本
https://developer.aliyun.com/mirror/developer.aliyun.com
我的是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 "[email protected]"
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
得設定快捷鍵吧,在設定裡,完美
第七件事 裝個oh-my-zsh和設定主題
就是讓你的指令行更美,更友善
1安裝zshsudo 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 "[email protected]" >/dev/null 2>&1
}
error() {
echo ${RED}"Error: [email protected]"${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 "[email protected]"
按esc之後再按 : w q這三個鍵(一定要在英文輸入法下 )
下面這句話這是vim的最基礎操作
先按 i 才能改寫内容, 最後 按 ' : ' 然後輸入wq 意思是 write(寫入) 和 quit (退出)
w q 順序不能錯
5為腳本檔案服務可執行的權限sudo chmod +x install.sh
6運作腳本 ./install.sh
安裝成功
7配置主題,不去下載下傳的話隻有這兩個主題,可以選擇
vim ~/.zshrc
第八件事 設定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
看一下效果吧,vim并沒有變顔色
之後
當然不止這些,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
之後會有提示
如果按照我前面的流程裝了 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一次
顯示如下
暫時先更這些吧,想起來再說
上下鍵 指令行 檢視指令曆史(還可自動篩選 如輸入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是公鑰
關于git的學習:
kikyou:git常用指令入門學習zhuanlan.zhihu.com
安裝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,又下載下傳了一點東西在裡面
添加以下代碼到你的.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是以,自己體會吧