Arch配置安裝使用


Arch日常使用

使用Linux

Linux學習時間不長不短,但是深深的愛上了這個簡潔,高效,自由可定制化的操作系統,隨着對Linux操作系統了解使用的越多,對Windows的厭惡程度與日俱增,很早的時候就想將自己電腦更換成Linux發行版,在使用 Linux 系統的過程中,可以無形中接觸到各個方面的計算機知識,並且在未來的工作中也會為你帶來相關方面的優勢。

Arch linux

Arch Linux 的軟件包是最新的,這在日常使用中非常必要,你可以第一時間享受到新軟件的特性。ArchLinux 可以以超高的自由度來定制自己的系統,並且其擁有最完善的文檔,使得絕大多數問題都可以通過查看官方文檔的方式解決。同時在Arch發行版本上開發出來了BlackArch Linux系統該系統非常適合進行信安學習,因此我們只需要在Arch源添加BlackArch源既可以當做日常使用又可以進行工具使用
清華源下載地址

基礎配置

檢查安裝環境

# 查看啟動方式是否為uefi

ls /sys/firmware/efi/efivars

image-20210430221925110

網絡連接

# 無線網絡

# 進入交互式命令行
iwctl                          

# 列出設備名,比如無線網卡看到叫 wlan0
device list                 

# 掃描網絡
station wlan0 scan            

# 列出網絡 比如想連接CMCC-5AQ7這個無線
station wlan0 get-networks     

# 進行連接 輸入密碼即可
station wlan0 connect CMCC-5AQ7 

# 成功后exit退出
exit             

# 網絡測試
ping www.baidu.com

禁用reflector

# reflector會自動更新mirrorlist 可能在某些情況下會刪除有用的源信息

systemctl stop reflector.service && systemctl disable reflector.service

image-20210430223246989

更新時鍾

# ntp同步
timedatectl set-ntp true

# 查看ntp
timedatectl status

image-20210430223323205

更換網絡源

vim /etc/pacman.d/mirrorlist 
	
    # 添加如下鏡像 放在最上面
	Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
    Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
    Server = http://mirrors.aliyun.com/archlinux/$repo/os/$arch

# 系統更新鏡像源
pacman -Syy

分區

  • EFI:
  • 根目錄
  • 用戶家目錄
# # 磁盤類型選擇gpt
cfdisk

# 查看分區
fdsik -l

image-20210430224946057

格式化

# efi格式化
mkfs.vfat /dev/sda1

# 根目錄格式化
mkfs.ext4 /dev/sda2 

# 家目錄格式化
mkfs.ext4 /dev/sda3   

掛載

# 掛載根目錄
mount /dev/sda2 /mnt

# 創建家目錄
mkdir /mnt/home

# 掛載家目錄
mount /dev/sda3 /mnt/home

# 創建efi分區
mkdir /mnt/efi

# 掛載efi
mount /dev/sda1 /mnt/efi

image-20210430225910746

安裝系統

# 安裝系統以及基礎軟件

pacstrap /mnt base base-devel linux linux-firmware dhcpcd  iwd vim sudo bash-completion

生成fstab文件

# 定義磁盤分區
genfstab -U /mnt >> /mnt/etc/fstab

# 檢查
cat /mnt/etc/fstab

image-20210430230736840

更換系統

# 環境更換到/mnt下系統
arch-chroot /mnt

設置主機名稱

# 設置用戶sean
hostnamectl set-hostname sean

# 配置hosts文件
vim /etc/hosts
    127.0.0.1   localhost
    ::1         localhost
    127.0.1.1   sean.localdomain    sean

時區配置

# 設置時區為上海
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 講系統時間同步到硬件時間
hwclock --systohc

配置locale

# Locale 決定了軟件使用的語言、書寫習慣和字符集。
vim /etc/locale.gen
	# 取消en_US.UTF-8與zh_CN.UTF-8注釋
	
	177 en_US.UTF-8
	500 zh_CN.UTF-8
# 生成locale
locale-gen

# 向 /etc/locale.conf 輸入內容
echo 'LANG=en_US.UTF-8'  > /etc/locale.conf

安裝引導程序

# grub是啟動引導器,efibootmgr被 grub 腳本用來將啟動項寫入 NVRAM。
pacman -S grub efibootmgr --noconfirm   

# 取名為GRUB 並將grubx64.efi安裝到之前的指定位置
grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=GRUB 

# 生成配置文件
grub-mkconfig -o /boot/grub/grub.cfg

設置密碼

# root配置密碼

passwd root

完成安裝

# 退回安裝環境#
exit              

# 卸載新分區
umount -R  /mnt   

# 重啟
reboot             

開啟DHCP

# 開啟dhcp
systemctl start dhcpcd && systemctl enable dhcpcd

ip a

ping www.baidu.com

image-20210501135711513

ssh開啟

# 安裝ssh方便使用遠程工具進行連接
pacman -S --noconfirm openssh openssl

# 修改ssh配置文件允許root登陸
vim /ect/ssh/sshd_config
					# 修改為yes
	32 PermitRootLogin ---> yes
	
	# 取消注釋
	57 PasswordAuthentication 

systemctl start sshd && systemctl enable sshd

image-20210501140036164

配置桌面環境

上述配置如果沒有問題則已經成功配置了Arch命令行版本,但是作為日常主力系統肯定需要有相應的桌面環境,來保證我們更加愉快的使用Arch Linux

系統更新

# 更新所有包
pacman -Syyu  

生成非root用戶

# 加入wheel附屬組方便非root用戶可以更好的提權
useradd -m -G wheel -s /bin/bash sean

# 創建密碼
passwd sean

# 提權
EDITOR=vim visudo
# 將改行前面的注釋取消
 %wheel ALL=(ALL) ALL

image-20210501141733769

安裝KDE桌面環境

#  安裝軟件包與文件管理器
pacman -S --noconfirm plasma-meta  dolphin konsole bash-completion

安裝sddm桌面管理器

# 安裝好了桌面環境包以后,我們需要安裝一個圖形化的桌面管理器來幫助我們登錄並且選擇我們使用的桌面環境。
pacman -S --noconfirm sddm

# 開啟服務
systemctl start sddm && systemctl enable sddm

添加倉庫地址

sudo cp /etc/pacman.conf /etc/pacman.conf.backup

sudo vim /etc/pacman.conf
	# 取消[multilib]一節中兩行注釋
    
    # 添加blackarch源
    [blackarch]
    SigLevel = Optional TrustAll
    Server = https://mirrors.tuna.tsinghua.edu.cn/blackarch/$repo/os/$arch    
	
	# 末尾添加ArchLinuxCN源
	[archlinuxcn]
	SigLevel = Optional TrustAll
	Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

# 刷新數據庫
sudo pacman -Syyu

# 配置aur
sudo pacman -S --noconfirm yaourt 
# 備份
sudo cp /etc/yaourtrc /etc/yaourtrc.backup
sudo vim /etc/yaourtrc
	# 取消#AURURL 的注釋,並修改
    AURURL="https://aur.tuna.tsinghua.edu.cn"



# 添加yay源為國內源
yay --aururl "https://aur.tuna.tsinghua.edu.cn" --save

# 查看配置
yay -P -g

image-20210501155104859

關閉無線網絡防止沖突

# 確保iwd開機處於關閉狀態,其無線連接會與NetworkManager沖突
sudo systemctl disable iwd  
# 同上,立即關閉iwd
sudo systemctl stop iwd   
# 確保先啟動NetworkManager,並進行網絡連接 若iwd已經與NetworkManager沖突 則執行完上一步重啟一下電腦即可
sudo systemctl enable --now NetworkManager                     

基礎安裝包

# 識別NTFS格式的硬盤
sudo pacman -S --noconfirm ntfs-3g                                                      
# 安裝幾個開源中文字體 一般裝上文泉驛就能解決大多wine應用中文方塊的問題
sudo pacman -S --noconfirm adobe-source-han-serif-cn-fonts wqy-zenhei         
# 安裝谷歌開源字體及表情
sudo pacman -S --noconfirm  noto-fonts noto-fonts-cjk noto-fonts-emoji noto-fonts-extra  
# 安裝常用的谷歌瀏覽器
sudo pacman -S --noconfirm  chromium    
# 與dolphin同用右鍵解壓
sudo pacman -S --noconfirm  --noconfirm  ark  
# 確保Discover(軟件中心)可用 需重啟
sudo pacman -S --noconfirm packagekit-qt5 packagekit appstream-qt appstream  
# 圖片查看器
sudo pacman -S --noconfirm  gwenview                                                    

# 安裝yay
# cn源中的簽名(archlinuxcn-keyring在archLinuxCn)
sudo pacman -S --noconfirm archlinuxcn-keyring      
# yay命令可以讓用戶安裝AUR中的軟件(yay在archLinuxCn)
sudo pacman -S --noconfirm yay                                                      

配置輸入法

# 安裝軟件包
sudo pacman -S --noconfirm fcitx5-im fcitx5-chinese-addons fcitx5-pinyin-moegirl fcitx5-material-color

# 配置環境變量
vim ~/.pam_environment
	INPUT_METHOD DEFAULT=fcitx5
    GTK_IM_MODULE DEFAULT=fcitx5
    QT_IM_MODULE DEFAULT=fcitx5
    XMODIFIERS DEFAULT=\@im=fcitx5
    SDL_IM_MODULE DEFAULT=fcitx
  • 打開系統設置-->區域設置-->輸入法,點擊添加輸入法,選擇簡體中文下的pinyin點擊添加
  • 點擊pinyin右側編輯,開啟雲拼音在程序中顯示預編輯文本
  • 點擊配置附加組件,選擇classic user interface選擇喜歡的主題
  • 點擊系統設置-->開機與關機-->自動啟動-->添加-->添加應用-->fcitx5
  • 注銷重新登陸

檢查家目錄

# 檢查家目錄下的各個常見目錄是否已經創建,若沒有則需手動創建。
cd /home/sean

mkdir Desktop Documents Downloads Music Pictures Videos

ls

image-20210501150401039

開啟藍牙

sudo systemctl enable --now bluetooth

Science Internet

終端代理配置

# 安裝qvTworay與vTworay
# 由於不能出現某些非法字符 因此將2更改為Two
sudo pacman -S --noconfirm qvTworay vTworay

# 安裝proxychains進行代理
sudo pacman -S --noconfirm proxychains-ng

# 配置代理
sudo vim /etc/proxychains.conf
	# 把配置文件中最后一行刪除添加本地代理的 ip 和端口,如socks5 127.0.0.1 1089
    socks5  127.0.0.1 1089
    
# github設置全局代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1089
git config --global https.https://github.com.proxy socks5://127.0.0.1:1089
            
# 查看github代理
git config --global --list

image-20210501193522796

配置分流

# 配置分流允許我們國內網絡走直連 國外網絡走代理點擊如下代理地址

# 移動到vTworay下
sudo mv Downloads/geoip.dat geoip.site /etc/vTworay

image-20210501200116940
分流下載地址

使用方式

# 使用方式

proxychains + 需要被代理的命令

顯卡驅動

顯卡配置教視頻

英特爾核芯顯卡

# 英特爾顯卡

sudo pacman -S mesa lib32-mesa vulkan-intel lib32-vulkan-intel

英偉達獨立顯卡

# 新型號可以使用該命令
sudo pacman -S nvidia nvidia-settings lib32-nvidia-utils 

# 如果是 GeForce 630 以下到 GeForce 400 系列的老卡
yay -S nvidia-390xx-dkms nvidia-settings lib32-nvidia-390xx-utils

# 在老的顯卡使用開源驅動
sudo pacman -S mesa lib32-mesa xf86-video-nouveau

雙顯卡

若為同時擁有核芯顯卡與英偉達獨顯的筆記本電腦,同樣需要按照上述步驟先安裝各個軟件包。還需要安裝 optimus-mmanager。可以在核芯顯卡和獨立顯卡間輕松切換。optimus-manager 提供三種模式,分別為僅用獨顯,僅用核顯,和 hybrid 動態切換模式。

yay -S optimus-manager optimus-manager-qt

安裝完成后重啟即可使用。optimus-manager 安裝完成后會默認 enable optimus-manager 的服務,你可在重啟前檢查其狀態,若沒有 enable 則手動將其 enable。重啟后在菜單欄搜索 optimus-manager 點擊即可使用。可在其設置中設置開機自動啟動。

sudo systemctl enable optimus-manager

軟件安裝

通信軟件

# 基於deepin wine5的qq
yay -S com.qq.im.deepin 

# 基於deepin wine5的wechat
yay -S com.qq.weixin.deepin     

辦公娛樂

# 深度截圖
sudo pacman -S --noconfirm deepin-screenshot

# typora
sudo pacman -S --noconfirm typora

# wps
yay -S --noconfirm wps-office ttf-wps-fonts 

# 網易雲音樂
sudo pacman -S --noconfirm netease-cloud-music

# 百度網盤
yay -S --noconfirm baidunetdisk-bin

# picgo
yay -S picgo-appimage

# 向日葵
yay -S --noconfirm sunloginclient

開發工具

# Pycharm
sudo pacman -S --noconfirm pycharm-professional

# vscode
sudo pacman -S --noconfirm visual-studio-code-bin

# postman
sudo pacman -S --noconfirm postman-bin

# notepadqq
sudo pacman -S --noconfirm notepadqq

# dbeaver
sudo pacman -S --noconfirm dbeaver

# vmware
sudo pacman -S --noconfirm vmware-workstation

開發環境

LNMP搭建

Nginx

sudo pacman -S nginx --noconfirm

systemctl start nginx && systemctl enable nginx

systemctl status nginx

image-20210704104947906

Php

sudo pacman -S php-fpm --noconfirm

# 配置nginx
sudo vim /etc/nginx/nginx.conf
	# 找到location ~ \.php$這部分的配置,將這部分配置修改成如下。
	location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        
sudo systemctl start php-fpm

sudo systemctl enable php-fpm

# 添加測試
sudo vim /usr/share/nginx/html/test.php
	<?php
      phpinfo();
    ?>
    
# 重啟nginx
sudo systemctl restart nginx

image-20210704105355279

MySQL

# 安裝mysql5.7
yay -S --noconfirm mysql57

# 配置數據目錄
sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql

# 啟動mysql
sudo systemctl start mysqld && sudo systemctl enable mysqld

# 初始化密碼登錄
mysql -uroot -p

# 修改密碼
alter user 'root'@'localhost' identified by 'root';   

# 允許所有地址連接
use mysql;
update user set host = '%' where user = 'root';
flush privileges;
select host, user from user;

quit

image-20210704175058191


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM