ArchLinux编程环境和其它环境安装

对于我用过的几个发行版本来说,ArchLinux算是天生对程序员亲和的,主要是有这几个原因,首先是官方源中维护了许多的编程环境的包,尤其是以Python维护的最多。其次是有AUR源,有许多人在共同的维护这个源,可以让开箱即用的包越来越多。最后的原因才是他是一个Linux的发行版本。

安装之前

在配置安装环境之前,我们得先对我们镜像源改造一下,这样才能继续我们之后的工作。我们得启用用multilibarchlinuxcn两个源。

multilib

/etc/pacman.conf中的multilib的注释取消了就行

arclinuxcn源

/etc/pacman.conf加入如下配置:

1
2
3
[archlinuxcn]
SigLevel = Optional TrustedOnly
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
1
2
3
sudo pacman -Syy
sudo pacman -S archlinuxcn-keyring
sudo pacman -S antergos-keyring

其它说法:

1
2
3
4
5
6
7
8
9
在终端输入
sudo pacman-mirrors -c China
sudo pacman-mirrors -i -c China -m rank
即可换成国内镜像
原有的被保存在/var/lib/pacman-mirrors/custom-mirrors.json
现在的被保存在/etc/pacman.d/mirrorlist
另外pacman的下载缓存在/var/cache/pacman中
对于始终无法信任的情况,选择Optional TrustAll 即可
原文:https://blog.csdn.net/izzxacbbt/article/details/80150176

排列源

1
2
sudo pacman-mirrors -g   #排列源

yaourt 或者 yay

Yaourt是archlinux方便使用的关键部件之一,但没有被整合到系统安装中的工具。建议在装完系统重启之后,更新完pacman和基本系统之后,就安装这个工具。
最简单安装Yaourt的方式是arclinuxcn源pacman -Syu yaourt

安装pacman -S archlinuxcn-keyring这个包导入秘钥就行。
对于这其中可能存在的两个问题,也就是由使用硬件时钟造成秘钥导入不成功的问题,可以使用以下方法进行解决:

  • 立即同步时间,不用修改系统的时间设置
  • 删除/etc/pacman.d/gnupg文件夹,然后运行pacman-key --initpacman-key --refresh-keys就可以解决这一个问题
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    sudo rm -R /etc/pacman.d/gnupg/
    sudo rm -R /root/.gnupg/
    sudo gpg --refresh-keys
    sudo pacman-key --init
    sudo pacman-key --populate archlinuxcn
    sudo pacman-key --populate archlinux manjaro
    sudo pacman-key --refresh-keys

    或者


    sudo pacman -Syu haveged
    sudo systemctl start haveged
    sudo systemctl enable haveged

    sudo rm -fr /etc/pacman.d/gnupg
    sudo pacman-key --init
    sudo pacman-key --populate archlinux
    sudo pacman-key --populate archlinuxcn
    sudo pacman-key --populate manjaro

安装 yay

1
sudo pacman -S yay

配置 yay

1
yay --aururl "https://aur.tuna.tsinghua.edu.cn" --save

修改的配置文件位于 ~/.config/yay/config.json ,还可通过以下命令查看修改过的配置:

1
yay -P -g

yay 的常用命令:

1
2
3
4
5
yay -S package # 从 AUR 安装软件包
yay -Rns package # 删除包
yay -Syu # 升级所有已安装的包
yay -Ps # 打印系统统计信息
yay -Qi package # 检查安装的版本

安装打包工具包

1
pacman -S base-devel 

中文字体

1
sudo pacman -S wqy-microhei ttf-dejavu wqy-zenhei wqy-microhei wqy-bitmapfont adobe-source-han-sans-cn-fonts adobe-source-han-serif-cn-fonts

输入法

安装 sunpinyin

1
sudo pacman -S fcitx-im fcitx-configtool  fcitx-sunpinyin

配置

1
2
3
4
5
vim ~/.xprofile

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"

软件/删除

1
2
#很好用的软件包管理工具
pamac-daemon

TIM QQ

yaourt qq

Python

对于Python编程环境来说,ArchLinux默认的Python环境是最新版本的Python3版本,所以在使用的时候需要注意这个问题,对于常见Python环境的安装方法如下:

1
2
3
4
5
6
7
8
# 安装Python,这里是2.7  
sudo pacman -S python2
# 安装Anaconda
sudo pacman -S anaconda
# 安装pyenv
sudo pacman -S pyenv
# 安装Pytcharm
sudo yaourt -S pycharm-professional
Java JDK

在ArchLinux中使用Java,可以选择两种JDK的版本,一种是使用openjdk,另外一个是使用Oracle jdk版本,并且在ArchLinux中,可以使用archlinux-java来切换不同的版本。对于Java环境的一些工具集,可以使用如下的命令进行安装。

  • 安装oracle jdk
    1
    sudo pacman -S jdk
  • 安装openjdk
    1
    sudo pacman -S jdk8-openjdk

chrome

1
sudo pacman -S google-chrome   #安装chrome

maven

1
sudo pacman -S maven

gradle

1
sudo pacman -S gradle

eclipse

Idea

1
sudo pacman -S intellij-idea-ultimate-edition

postman

1
sudo pacman -S postman

wget

1
sudo pacman -S wget 

vim

1
sudo pacman -S vim 

安装netstat\ifconfig等等net工具

1
2
3
4
5
6
7
8
9
10
11
sudo pacman -S net-tools 
​```bash

#### PostgreSQL
​```bash
sudo pacman -S postgresql
sudo passwd postgres
sudo echo -e "postgres ALL=(ALL) ALL" >> /etc/sudoers
su postgres
sudo chmod +w /var/lib/
initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'

Redis

1
2
3
4
5
wget http://download.redis.io/releases/redis-5.0.4.tar.gz
tar -zxvf redis-5.0.4.tar.gz
cd redis-5.0.4
sudo pacman -S gcc make
make && make install

wiki-Redis

redis-desktop-manager

1
sudo pacman -S redis-desktop-manager

Node环境

和大部分的平台的安装配置一样,就是有可能需要配置以下全局的npm包的安装位置和一些目录,可以使用

1
sudo pacman -S nodejs npm

可以在~/.npmrc中写入如下配置:

$HOME为你home目录路径的全写
1
2
cache=$HOME/.node_modules
prefix=$HOME/.node_modules

markdown Typora

1
2
# yaourt typora 现在pacman 也加入了 typora
sudo pacman -S typora

yaourt foxit

小巧强大的截图工具深度截图:

1
sudo pacman -S deepin-screenshot

zsh

强大的shell命令脚本解释器zsh: https://www.zhyong.cn/posts/edab/#安装zsh

you-get

强大的Web内容(视频,音频,图片)下载工具you-get:

1
sudo pacman -S you-get

brook

轻量级跨平台的go语言代理工具brook:

1
sudo pacman -S brook

aria2

强大的命令行下载工具aria2:

1
sudo pacman -S aria2

fzf

模糊搜素神奇fzf:

1
sudo pacman -S fzf

具体配置查看文档,我的配置是添加alias:alias fzf=“fzf –height 40%”,可在oh-my-zsh配置文件中添加fzf插件。
个人认为通过vim **再按Tab键更好地利用了fzf命令,类似的还有kill **等。

ag

一个速度极快的类似ack的代码搜索工具ag:

1
sudo pacman -S the_silver_searcher

thefuck

自动纠正上一个控制台命令thefuck:

1
sudo pacman -S thefuck

tmux

强大的终端复用工具tmux:

1
sudo pacman -S tmux

tig

字符模式下交互查看git项目tig:

1
sudo pacman -S tig

安装配置Git

1
sudo pacman -S git 

设置个人github信息:

1
2
3
4
git config --global user.name "github昵称" 
git config --global user.email "注册邮箱"
git config --global user.name "maxzhao"
git config --global user.email "1441439636@qq.com"

集合

1
sudo pacman -S  python2 anaconda pyenv pycharm-professional maven gradle    intellij-idea-ultimate-edition  wget vim nodejs npm git openssh file-roller unrar unzip p7zip

安装网易云音乐

1
sudo pacman -S netease-cloud-music

即时聊天工具——wechat

Github上electronic-wechat开源项目(据说比腾讯官方开发的要好-)

可以直接使用:

1
sudo pacman -S electronic-wechat 

在安装前需要安装node.js不然不能使用其中的命令安装
安装 Node.js 的最佳方式是使用 nvm。

  • cURL:$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
  • Wget: $ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh

安装完成后,重启终端并执行下列命令即可安装 Node.js。

1
npm install stable 

切换目录到下载git clone下载

1
git clone https://github.com/geeeeeeeeek/electronic-wechat.git

切换到wechat目录

1
cd electronic-wechat

安装运行

1
npm install && npm start

编译安装在本地(Linux选择linux,这个不用解释吧?)

1
2
3
4
npm run build:osx
npm run build:linux
npm run build:win32
npm run build:win64

国内版火狐浏览器

1
pacman -S firefox firefox-i18n-zh-cn 

压缩解压缩

1
pacman -S file-roller unrar unzip p7zip 

Git ssh

1
pacman -S git openssh 

Git kraken

1
sudo pacman -S gitkraken

安装wps

之前的安装方式,不在使用

1
2
3
4
5
6
#yaourt -S wps-office 
yay -S wps-office
sudo pacman -S ttf-ms-fonts:
yay -S wps-office-fonts
yay -S wps-office-mime
yay -S wps-office-mui-zh-cn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vim /etc/pacman-mirrors.conf
#文末添加
OnlyCountry = China

#然后执行
pacman-mirrors -g

sudo vim /etc/pacman.conf
#文末添加:
SigLevel = Optional TrustedOnly            
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch 

#然后执行:
sudo pacman -S archlinuxcn-keyring

# 最后安装 wps: 这个有时候会获取不到, sudo pacman -Ss wps-office 查询
sudo pacman -S wps-office

# wps字体
sudo pacman -S ttf-wps-fonts

如果安装上好搜狗和wps后不能输入中文的解决方法:
vim ~/.xprofile    
#在最后添加以下内容

1
2
3
4
5
6
7
8
export LC_ALL=zh_CN.UTF-8
export XIM=fcitx
export XIM_PROGRAM=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
eval `dbus-launch --sh-syntax --exit-with-session`
exec fcitx &

如果有重复登录不进界面系统的情况,则改为

1
2
3
4
export XIM_PROGRAM=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"

然后reboot即可


VSCode

1
sudo pacman -S visual-studio-code-bin

截图工具

1
sudo pacman -S spectacle

KDE安装NVIDIA驱动

打开设置页面,找到硬件设定,选择 Auto Install Proprietary Driver

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Starting
> Using config 'video-hybrid-intel-nvidia-prime' for device: 0000:01:00.0 (0300:10de:1c91) Display controller nVidia Corporation GP107M [GeForce GTX 1050 3 GB Max-Q]
> Using config 'video-hybrid-intel-nvidia-prime' for device: 0000:00:02.0 (0300:8086:3e9b) Display controller Intel Corporation UHD Graphics 630 (Mobile)
> Dependencies to install: video-modesetting
> Installing dependency video-modesetting...
Sourcing /etc/mhwd-x86_64.conf
Has lib32 support: true
Sourcing /var/lib/mhwd/db/pci/graphic_drivers/video-modesetting/MHWDCONFIG
Processing classid: 0300
Sourcing /var/lib/mhwd/scripts/include/0300
:: Synchronizing package databases...
core is up to date
extra is up to date
community is up to date
multilib is up to date
archlinuxcn is up to date
> Successfully installed dependency video-modesetting
> Installing video-hybrid-intel-nvidia-prime...
Sourcing /etc/mhwd-x86_64.conf
Has lib32 support: true
Sourcing /var/lib/mhwd/db/pci/graphic_drivers/hybrid-intel-nvidia-prime/MHWDCONFIG
Processing classid: 0300
Sourcing /var/lib/mhwd/scripts/include/0300
resolving dependencies...
looking for conflicting packages...

Packages (4) lib32-nvidia-utils-460.56-1 linux59-nvidia-460.56-1 nvidia-prime-1.0-4 nvidia-utils-460.56-2

Total Download Size: 131.55 MiB
Total Installed Size: 447.25 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
downloading nvidia-utils-460.56-2-x86_64.pkg.tar.zst...
downloading nvidia-prime-1.0-4-any.pkg.tar.zst...
downloading linux59-nvidia-460.56-1-x86_64.pkg.tar.zst...
downloading lib32-nvidia-utils-460.56-1-x86_64.pkg.tar.zst...
checking keyring...
checking package integrity...
loading package files...
checking for file conflicts...
checking available disk space...
:: Processing package changes...
installing nvidia-utils...
==> If you run into trouble with CUDA not being available, run nvidia-modprobe first.
Optional dependencies for nvidia-utils
gtk3: nvidia-settings [installed]
xorg-server-devel: nvidia-xconfig
opencl-nvidia: OpenCL support
installing nvidia-prime...
installing lib32-nvidia-utils...
Optional dependencies for lib32-nvidia-utils
lib32-opencl-nvidia
installing linux59-nvidia...
In order to use nvidia module, reboot the system.
:: Running post-transaction hooks...
(1/6) Creating system user accounts...
Creating group nvidia-persistenced with gid 143.
Creating user nvidia-persistenced (NVIDIA Persistence Daemon) with uid 143 and gid 143.
(2/6) Reloading system manager configuration...
(3/6) Arming ConditionNeedsUpdate...
(4/6) Updating module dependencies...
(5/6) Updating Kernel initcpios for Nvidia-DRM...
==> Building image from preset: /etc/mkinitcpio.d/linux59.preset: 'default'
-> -k /boot/vmlinuz-5.9-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.9-x86_64.img
==> Starting build: 5.9.16-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [keyboard]
-> Running build hook: [keymap]
loadkeys: Unable to open file: cn: No such file or directory
-> Running build hook: [filesystems]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.9-x86_64.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux59.preset: 'fallback'
-> -k /boot/vmlinuz-5.9-x86_64 -c /etc/mkinitcpio.conf -g /boot/initramfs-5.9-x86_64-fallback.img -S autodetect
==> Starting build: 5.9.16-1-MANJARO
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [keyboard]
-> Running build hook: [keymap]
loadkeys: Unable to open file: cn: No such file or directory
-> Running build hook: [filesystems]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-5.9-x86_64-fallback.img
==> Image generation successful
(6/6) Updating the desktop file MIME type cache...
nvidia-utils: install reason has been set to 'explicitly installed'
nvidia-prime: install reason has been set to
'explicitly installed'
lib32-nvidia-utils: install reason has been set to 'explicitly installed'
linux59-nvidia: install reason has been set to 'explicitly installed'
xorg configuration file: '/etc/X11/mhwd.d/nvidia.conf'
> Successfully installed video-hybrid-intel-nvidia-prime

GNOME安装显卡驱动

我的笔记本是Intel的集成显卡和英伟达的独立显卡,这里有一些相关描述:https://wiki.archlinux.org/index.php/NVIDIA_(简体中文)
sudo pacman -S xf86-video-intel
sudo pacman -S xf86-video-nouveau

GNOME安装NVIDIA显卡驱动

Manjaro虽然自带硬件管理,但无法在两个显卡之间自由切换,按照ArchLinux Wiki给出的方法,只有Bumblebee方案成功

1
sudo pacman -S bumblebee bbswitch

把用户添加到bumblebee组里:
sudo gpasswd -a XXX bumblebee      //XXX是用户名


启动bumblebeed服务:
sudo systemctl enable bumblebeed.service

安装依赖
sudo pacman -S bumblebee nvidia opencl-nvidia lib32-nvidia-utils lib32-opencl-nvidia mesa lib32-mesa-libgl xf86-video-intel

配置bumblebee:
编辑vim /etc/bumblebee/bumblebee.conf,修改以下内容:

1
2
3
Driver=nvidia # 指定nvidia
[driver-nvidia]
PMMethod=bbswitch       # 电源管理指定bbswitch

用vim编辑文件的保存方法:
编辑好以后按esc键退出,然后输入英文的冒号再输入wq,即保存并退出
reboot

开启NVIDIA显卡 sudo tee /proc/acpi/bbswitch <<< ON #关闭则是off

查看显卡状态 nvidia-smi

Steam配置
Manjaro 自带Steam,双击打开之后出现一个License界面之后再也没有反应,通过谷歌之后发现是缺少依赖:
sudo pacman -S steam-native-runtime
steam_install_workaround
等待依赖安装完成后就可以发现steam已经正常打开

sublimit官方地址

http://www.sublimetext.com/docs/3/linux_repositories.html#pacman

一些软件安装卸载的操作

  • 安装 pacman -S
  • 删除 pacman -R
  • 移除已安装不需要软件包 pacman -Rs
  • 删除一个包,所有依赖 pacman -Rsc
  • 升级包 pacman -Syu
  • 查询包数据库 pacman -Ss
  • 搜索已安装的包 pacman -Qs
  • 显示包大量信息 pacman -Si
  • 本地安装包 pacman -Qi
  • 清理包缓存 pacman -Sc

添加命令打别名,比如ll

1
2
3
vim ~/.bashrc
alias ll='ls -l'

其他安装及汇总

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# deepin 系的软件
sudo pacman -S deepin-picker # 深度取色器
sudo pacman -S deepin-screen-recorder # 录屏软件,可以录制 Gif 或者 MP4 格式
sudo pacman -S deepin-screenshot # 深度截图
sudo pacman -S deepin-system-monitor # 系统状态监控
yay -s deepin-wine-wechat #微信
yay -S deepin-wine-tim
yay -S deepin-wine-baidupan
yay -S deepin.com.thunderspeed #迅雷

# android投屏\安卓投屏神器
sudo pacman -S scrcpy
#GIF
yay -S peek

# 开发软件
sudo pacman -S jdk8-openjdk
sudo pacman -S make
sudo pacman -S cmake
sudo pacman -S clang
sudo pacman -S nodejs
sudo pacman -S npm
sudo pacman -S goland
sudo pacman -S vim
sudo pacman -S maven
sudo pacman -S pycharm-professional # Python IDE
sudo pacman -S intellij-idea-ultimate-edition # JAVA IDE
sudo pacman -S goland # Go IDE
sudo pacman -S visual-studio-code-bin # vscode
sudo pacman -S qtcreator # 一款QT开发软件
sudo pacman -S postman-bin
sudo pacman -S insomnia # REST模拟工具
sudo pacman -S gitkraken # GIT管理工具
sudo pacman -S wireshark-qt # 抓包
sudo pacman -S zeal
sudo pacman -S gitkraken # Git 管理工具

# 办公软件
sudo pacman -S google-chrome
sudo pacman -S foxitreader # pdf 阅读
sudo pacman -S bookworm # 电子书阅读
sudo pacman -S unrar unzip p7zip
sudo pacman -S goldendict # 翻译、取词
sudo pacman -S wps-office
yay -S typora # markdown 编辑
yay -S electron-ssr # 缺少我需要的加密算法
yay -S xmind #思维导图

# 设计
sudo pacman -S pencil # 免费开源界面原型图绘制工具

# 娱乐软件
sudo pacman -S netease-cloud-music #网易云音乐

# 下载软件
sudo pacman -S aria2 #下载神器,类似的还有axel
sudo pacman -S filezilla # FTP/SFTP

# 图形
sudo pacman -S gimp # 修图

# 系统工具
sudo pacman -S albert #类似Mac Spotlight,另外一款https://cerebroapp.com/
yay -S copyq # 剪贴板工具,类似 Windows 上的 Ditto

# 终端
sudo pacman -S screenfetch # 终端打印出你的系统信息,screenfetch -A 'Arch Linux'
sudo pacman -S htop
sudo pacman -S bat #cat的进阶版
sudo pacman -S yakuake # 堪称 KDE 下的终端神器,KDE 已经自带,F12 可以唤醒
sudo pacman -S net-tools # 这样可以使用 ifconfig 和 netstat
yay -S tldr
yay -S tig # 命令行下的 git 历史查看工具
yay -S tree #以树状图列出目录的内容
yay -S ncdu # 命令行下的磁盘分析器,支持Vim操作
yay -S mosh # 一款速度更快的 ssh 工具,网络不稳定时使用有奇效

本文地址:arch-gnome 编程环境和其它环境安装

Linux上IDEA激活
curl 与 wget 的区别
无法挂载参考链接
u盘安装manjaro——抛弃Centos的旅程开始

本文地址: https://github.com/maxzhao-it/blog/post/25441/