Arch Linux的正确使用方法
2017-05-24 10:06
谈起我的 Linux 学习之路,时间其实并不长。但是我却花了相对很少的时间,已经能达到把 Linux 当作自己的桌面系统的程度了。
Ubuntu 的体验令我有点沮丧,再者它也不适合我机子。后来我又知道了 Debian ,这个发行版据称稳定健壮。我这次怀着犹豫的心情去安装了,安装过程不像 Ubuntu 那样顺利,记得应该遇到过一点问题,但还是解决了。这次的 Debian 安装让我很满意,我的电脑像复活了一样,再也不会卡顿了。然而面对 Debian 我能干什么?我后来发现我什么也没干,我不了解任何东西,我也只会用鼠标点点,右键查看一下属性,双击点个可执行文件。就这样过了一两个星期(我是只有周末才有半天从学校回来碰个电脑的),有一天,我看到群里在讨论一个名为 Arch 的发行版,出于好奇我去搜索了一番,这便是我与 Arch 相遇的开始。
Arch Linux 的设计理念是 轻量 、 简洁。这点正符合我心意,二话不说我就开始了我的 Arch 之旅。当时我还不懂什么是命令行,安装过程完全是参照 Arch Wiki 的过程,虽然不懂为什么,但是我却是一次安装成功,看着自己一步一步敲命令安装的系统当时特有成就感。 Arch Wiki 提供了一条龙服务,刚安装完系统的 Arch 是不带桌面的,但是 Arch Wiki 提供了详细的桌面配置过程,以及输入法配置过程。查看自己的内存使用情况, LXDE + 32 位的 Arch Linux,我的内存占用才 70 M 左右,我知道我这次找到了真爱,于是一直使用 Arch 至今,也感谢我的电脑配置低,不然我很可能就停留在 Ubuntu 了。
A
使用 Arch Linux 的优势
至于我为什么要推荐 Arch Linux ?对于一个新手,它相对其他发行版有哪些优势呢?
不少人会说 Arch 太难了,不适合新手,对新手并不友好。可我却不这么认为,难是因为你站在了一个较高的起点,而这个高的起点会使你更快地进步,更快地了解 Linux 。Arch 所带给我的就是这样一种学习体验。我从不会到会,再到教别人所用的时间并不长,也许有人会说我只是个特例,那么这篇文章就是写给那些想成为特例的人。学习是靠自己的,只要自己有心,又有什么学不会呢?最近 “Linux 中国-新手村” QQ 群里的许多新人,总是自己一上来就要答案,但是却不曾想过,自己为这个问题做了什么尝试,自己是否有毅力去坚持学习 Linux ?
下面是自己认为推荐 Arch 的一些理由,仅代表我个人的观点:
Arch 使你站在一个较高的起点入门,但相应地,你会需要付出一点耐心去学习,并且你会学的更快
Arch Wiki 非常丰富,就是我们遇到问题时解决的利器。在遇到问题时先去 Arch Wiki 搜索一下,基本可以解决,这比搜索引擎搜索出来的 Blog 或别人写的一点笔记要靠谱的多
Arch 采用滚动更新的方式,因此你不用再考虑以后升级系统需要重装的问题
Arch 除了基础的软件包外,不会附加一些多余的东西,所以你的系统基本上是你所需要的东西
Arch 的 pacman 是非常简单高效的包管理工具,帮助你轻松管理系统
Arch 的 AUR 仓库包含大量软件包,只需一个 makepkg 命令即可构建,非常方便
基于上面的一些原因,我认为 Arch 其实是适合新手的。
首先它比其他大多数发行版要自由;其次它没有预先安装的图形包管理工具,这使得我们必须在终端下完成我们的大部分操作,这将是我们从 Windows 鼠标模式逃离出来的一种动力与压力,因为你拿着鼠标没什么可干的;最后便是 Arch Wiki 对于绝大多数软件包要如何配置,遇到问题怎么去解决,都有详细的说明,这对于新手来说肯定是一个福音。
我推荐 Arch 其实是把自己置于一个相对的窘迫的境地(但是其实笔者不觉得这是困境,我当时对 Arch 是一见钟情的,怀着极大的兴趣把 Arch 收下了),只有这样才会激活你的动力,战胜它,你就赢了自己,收获了技能,如果选择放弃,那么可能你不适合这种学习方式。
E
结束
可以说我学习 Linux 基本都得益于 Arch 的 Wiki ,是它为我解决了很多问题,再也不用像无头苍蝇一样去搜索答案,当然你使用其他发行版也可以参照 Arch Wiki ,不要浪费了这份宝贵的资源。另外如果你是真心想学习 Linux ,我推荐你看看 Linus 的自传 《just for fun》,还有鸟哥的 《鸟哥的 Linux 私房菜》。Linus 的自传会使你明白一小部分关于 Linux 的故事,我所做的也只是 just for fun ;而鸟哥的书则可以作为一本入门的书籍,鸟哥写的太详细了,选读部分内容就好。最后祝各位能在接下来的学习之路,奋勇向前。
以上是正文部分,下面是我在Arch使用过程中遇到过的一些问题,这些问题有的已经解决,有的仍是悬案。
archlinux安装后没有ifconfig命令
问:很多和网络有关的命令都没有,ifconfig,route ,nslookup这些都没有,变量没设置错误,用root也找不到,这是什么原因呢? 答:以前net-tools属于base组,装base时自动就装上了,现在哪个组都不属于了,这些工具需要单独安装。其中ifconfig、route在net-tools包中,nslookup、dig在dnsutils包中,ftp、telnet等在inetutils包中,ip命令在iproute2包中。
pacman -S net-tools dnsutils inetutils iproute2
显卡驱动
此部分内容主要来自ArchLinux官方Wiki页面:
首先要确定显卡类型,下面的命令可以看到自己的显卡信息:
$ lspci | grep VGA Intel显卡 # pacman -S xf86-video-intel Nvida显示
闭源驱动:
# pacman -S nvidia
注:如果是GeForce 6/7系列,请安装 nvidia-304xx
开源驱动
# pacman -S xf86-video-nouveau # pacman -S xf86-video-vesa AMD/ATI显卡
闭源驱动:参见Arch Wiki / AMD Catalyst
开源驱动:
pacman -S xf86-video-ati
输入法(Fcitx)
相关Wiki: Wiki:
https://wiki.archlinux.org/index.php/Fcitx_(简体中文)
pacman -S fcitx
为了在 gtk 与 qt 程序中获得良好的输入体验(例如光标跟随与显示预编辑字符串)并避免一些 xim 无法解决的 bug, 请根据需要安装对应的输入法模块: fcitx-gtk2, fcitx-gtk3, fcitx-qt4 以及 fcitx-qt5. 若要一次性安装 Fcitx 主程序和相关的模块,可使用此命令:
pacman -S fcitx-im
使用 FCITX 之前,必须先进行一些环境设定: 如果采用 KDM、GDM、LightDM 等显示管理器,请在~/.xprofile (没有则新建一个)中加入如下3行,如果你采用 startx 或者 Slim 启动 (即使用.xinitrc的场合),则在 ~/.xinitrc 中加入:
export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS="@im=fcitx"
另外Fcitx 提供了图形界面的配置程序,你可以安装他们:kcm-fcitx(基于KDE 的 kcm), fcitx-configtool(基于 gtk3)
在Fcitx上安装其它输入法 拼音输入法:fcitx-sunpinyin 五笔输入法:fcitx-table-extra(其中包括仓颉等输入法)
办公软件(WPS)
由于WPS只发布了32位的版本,因此如果ArchLinux是64位的系统需要添加multilib仓库,在/etc/pacman.conf文件中将下面两行内容解开注释即可:
Include = /etc/pacman.d/mirrorlist
安装WPS(原来叫kingsoft-office)
yaourt -S wps-office
在安装过程中有可能出现如下的错误(临时目录空间不足):
No space left on device ==> ERROR: A failure occurred in package(). Aborting... ==> ERROR: Makepkg was unable to build kingsoft-office. ==> Restart building kingsoft-office ?
解决方式是重新挂载/tmp
mount -t tmpfs -o size=2200M tmpfs /opt/
如果打开WPS应用时报“系统缺失字体...”的错误,可以将相应的字体下载下来放到~/.fonts目录中然后重启WPS即可。
虚拟机(VirtualBox)
在VirtualBox中启动操作系统时可能会遇到下面的错误:
Kernel driver not installed (rc=-1908)
下面的命令可以解决:
sudo modprobe vboxdrv
视频播放器(mplayer)
mplayer可以直接使用pacman安装。
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。
修改~/.mplayer/config:
font='文泉驿正黑' subcp=enca:zh:ucs-2
使用下面的命令手动加载字幕:
mplayer xxx.avi -sub xxxxx.srt
词典(stardict)
stardict(星际译王)由胡正开发,当前最新版本为3.0.5-1,发布于2014-6-28日;从这里可以看到它的信息:
https://www.archlinux.org/packages/community/x86_64/stardict/星际译王是跨平台的国际词典软件!它功能强大,实用性强;“通配符匹配”、“鼠标查词”、“模糊查询”等功能倍受青睐!星际译王3.0版更增加了全文翻译,网络词典等新功能。
stardict主页:
http://www.stardict.org
胡正的主页:
http://www.huzheng.org
安装stardict:
packman -S stardict
stardict默认不带词典,所以安装完软件后,需要下载安装相应字典;词典的安装很简单,去词典页面上下载词典压缩包,解压后将词典目录放到/usr/share/stardict/dic/目录中,如果dic目录不存在可手动创建。
词典下载:
http://abloz.com/huzheng/stardict-dic
以“朗道英汉字典”为例,其下载地址为:
http://abloz.com/huzheng/stardict-dic/zh_CN/stardict-langdao-ec-gb-2.4.2.tar.bz2
wget
http://abloz.com/huzheng/stardict-dic/zh_CN/stardict-langdao-ec-gb-2.4.2.tar.bz2 tar -jxvf stardict-langdao-ec-gb-2.4.2.tar.bz2 mv stardict-langdao-ec-gb-2.4.2 /usr/share/stardict/dic/
重新启动stardict加载词典即可。
作者:地球的外星人君
链接:
https://www.zhihu.com/people/diqiuyo/answers
Last edited by zzz19760225 on 2017-7-18 at 20:36 ]
### Correct Usage of Arch Linux
2017-05-24 10:06
Talking about my journey of learning Linux, the time is actually not long. But I spent relatively little time and have already reached the point where I can use Linux as my desktop system.
The experience with Ubuntu made me a bit frustrated, and besides, it wasn't suitable for my computer. Then I learned about Debian, which is said to be stable and robust. This time I installed it with a hesitant mood. The installation process wasn't as smooth as Ubuntu's. I remember I encountered some problems, but they were solved. This installation of Debian satisfied me, and my computer was revived like new, no longer stuck. However, what could I do with Debian? Later I found that I did nothing. I didn't understand anything, and I could only use the mouse to click, right-click to view properties, and double-click to run executable files. This went on for a week or two (I only had half a day from school to touch the computer on weekends). One day, I saw the group discussing a distribution called Arch. Out of curiosity, I searched for it, and this was the beginning of my encounter with Arch.
The design concept of Arch Linux is lightweight and simple. This exactly suits my heart, and I started my Arch journey without hesitation. At that time, I didn't understand what the command line was. I followed the process of Arch Wiki for the installation. Although I didn't understand why, I succeeded in one installation. I felt a great sense of accomplishment when I saw the system I installed step by step by typing commands. Arch Wiki provides a one-stop service. The newly installed Arch has no desktop, but Arch Wiki provides detailed processes for desktop configuration and input method configuration. Checking my memory usage, with LXDE + 32-bit Arch Linux, my memory usage was only about 70 MB. I knew I found my true love this time, so I have been using Arch ever since. Also, thanks to my low-configured computer, otherwise I might have stayed with Ubuntu.
A
### Advantages of Using Arch Linux
Why do I recommend Arch Linux? For a novice, what are the advantages compared to other distributions?
Many people say Arch is too difficult, not suitable for novices, and not friendly to novices. But I don't think so. Difficulty is because you stand at a higher starting point, and this high starting point will make you progress faster and understand Linux faster. Arch has brought me such a learning experience. The time from me not knowing to knowing and then to teaching others is not long. Maybe someone will say I'm just a special case, then this article is for those who want to be special cases. Learning depends on yourself. As long as you have the heart, what can't you learn? Recently, many new people in the "Linux China - Novice Village" QQ group always ask for answers as soon as they come up, but they never think about what attempts they have made for this problem and whether they have the perseverance to persist in learning Linux.
The following are some reasons I think recommend Arch, which only represent my personal views:
Arch makes you start at a higher starting point, but correspondingly, you will need to be patient to learn, and you will learn faster
Arch Wiki is very rich, which is a sharp tool to solve problems when we encounter them. When encountering a problem, first search on Arch Wiki, which can basically solve it. This is much more reliable than the blogs or notes written by others found by search engines
Arch uses a rolling update method, so you don't need to consider the problem of reinstalling the system when upgrading it in the future
Arch, in addition to basic software packages, won't attach some redundant things, so your system is basically what you need
Arch's pacman is a very simple and efficient package management tool, helping you easily manage the system
Arch's AUR repository contains a large number of software packages, which can be built with just one makepkg command, very convenient
For the above reasons, I think Arch is actually suitable for novices.
First, it is more free than most other distributions; second, it doesn't have pre-installed graphical package management tools, which makes us have to complete most of our operations in the terminal. This will be a driving force and pressure for us to escape from the Windows mouse mode, because you can't do much with the mouse; finally, Arch Wiki has detailed instructions on how to configure most software packages and how to solve problems when encountering them, which must be a gospel for novices.
I recommend Arch actually puts myself in a relatively embarrassing situation (but in fact, the author doesn't think this is a dilemma. I fell in love with Arch at first sight and took Arch with great interest). Only in this way will your motivation be activated, overcome it, you will win yourself and gain skills. If you choose to give up, then maybe you are not suitable for this learning method.
E
### Conclusion
It can be said that my learning of Linux basically benefits from Arch's Wiki. It has solved many problems for me. I no longer have to search for answers like a headless fly. Of course, you can also refer to Arch Wiki when using other distributions, don't waste this precious resource. Also, if you really want to learn Linux, I recommend you read Linus's autobiography "just for fun" and Bird Brother's "Bird Brother's Linux Private Kitchen". Linus's autobiography will make you understand a small part of the story about Linux. What I did is also just for fun; and Bird Brother's book can be used as an introductory book. Bird Brother wrote it very detailed. Just read some selected parts. Finally, I wish everyone to move forward bravely in the next learning journey.
The above is the main text part. The following are some problems I encountered during the use of Arch. Some of these problems have been solved, and some are still unsolved.
### No ifconfig command after Arch Linux installation
Q: Many commands related to the network are not available, such as ifconfig, route, nslookup, etc. There is an error in variable setting. I can't find them even with root. What is the reason?
A: Previously, net-tools belonged to the base group and was automatically installed when base was installed. Now it doesn't belong to any group. These tools need to be installed separately. Among them, ifconfig and route are in the net-tools package, nslookup and dig are in the dnsutils package, ftp, telnet, etc. are in the inetutils package, and the ip command is in the iproute2 package.
pacman -S net-tools dnsutils inetutils iproute2
### Graphics card driver
This part of the content mainly comes from the ArchLinux official Wiki page:
First, determine the type of graphics card. The following command can see your graphics card information:
$ lspci | grep VGA
For Intel graphics card: # pacman -S xf86-video-intel
For Nvida display:
For closed-source driver:
# pacman -S nvidia
Note: If it is GeForce 6/7 series, please install nvidia-304xx
For open-source driver:
# pacman -S xf86-video-nouveau # pacman -S xf86-video-vesa
For AMD/ATI graphics card:
For closed-source driver: Refer to Arch Wiki / AMD Catalyst
For open-source driver:
pacman -S xf86-video-ati
### Input method (Fcitx)
Related Wiki: Wiki:
https://wiki.archlinux.org/index.php/Fcitx_(Simplified Chinese)
pacman -S fcitx
To get a good input experience (such as cursor following and displaying pre-edited strings) in gtk and qt programs and avoid some bugs that xim can't solve, please install the corresponding input method modules as needed: fcitx-gtk2, fcitx-gtk3, fcitx-qt4 and fcitx-qt5. If you want to install the Fcitx main program and related modules at one time, you can use this command:
pacman -S fcitx-im
Before using FCITX, some environment settings must be done first: If you use display managers such as KDM, GDM, LightDM, etc., add the following 3 lines in ~/.xprofile (create one if it doesn't exist). If you start with startx or Slim (that is, in the case of using.xinitrc), add in ~/.xinitrc:
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
In addition, Fcitx provides a graphical configuration program. You can install them: kcm-fcitx (based on KDE's kcm), fcitx-configtool (based on gtk3)
To install other input methods on Fcitx: Pinyin input method: fcitx-sunpinyin; Wubi input method: fcitx-table-extra (which includes Cangjie and other input methods)
### Office software (WPS)
Since WPS only releases a 32-bit version, so if the ArchLinux system is 64-bit, you need to add the multilib repository. Uncomment the following two lines in the /etc/pacman.conf file:
Include = /etc/pacman.d/mirrorlist
Install WPS (originally called kingsoft-office)
yaourt -S wps-office
There may be the following error during the installation process (insufficient space in the temporary directory):
No space left on device ==> ERROR: A failure occurred in package(). Aborting... ==> ERROR: Makepkg was unable to build kingsoft-office. ==> Restart building kingsoft-office ?
The solution is to remount /tmp
mount -t tmpfs -o size=2200M tmpfs /opt/
If an error "The system is missing fonts..." occurs when opening the WPS application, you can download the corresponding fonts and put them in the ~/.fonts directory and then restart WPS.
### Virtual machine (VirtualBox)
When starting the operating system in VirtualBox, the following error may be encountered:
Kernel driver not installed (rc=-1908)
The following command can solve it:
sudo modprobe vboxdrv
### Video player (mplayer)
mplayer can be installed directly with pacman.
To make mplayer display subtitles correctly, the key is to make the encoding of the subtitle file consistent with the encoding used in the mplayer config. If the subtitle file encoding is gbk, then subcp=cp936; if the subtitle file encoding is utf-8, then subcp=utf8. If the subtitle file encoding is utf-8 and set to subcp=cp936, some garbled characters will appear. Another simpler method is to set it to subcp=enca:zh:ucs-2, and let enca be responsible for the encoding display of subtitles.
Modify ~/.mplayer/config:
font='文泉驿正黑'
subcp=enca:zh:ucs-2
Use the following command to manually load subtitles:
mplayer xxx.avi -sub xxxxx.srt
### Dictionary (stardict)
Stardict (StarDict) was developed by Hu Zheng. The current latest version is 3.0.5-1, released on June 28, 2014; you can see its information from here:
https://www.archlinux.org/packages/community/x86_64/stardict/ StarDict is a cross-platform international dictionary software! It is powerful and practical; functions such as "wildcard matching", "mouse word lookup", "fuzzy query" are highly favored! StarDict 3.0 version has added new functions such as full-text translation and network dictionary.
Stardict homepage:
http://www.stardict.org
Hu Zheng's homepage:
http://www.huzheng.org
Install stardict:
packman -S stardict
Stardict does not bring dictionaries by default, so after installing the software, you need to download and install the corresponding dictionaries; the installation of dictionaries is very simple. Go to the dictionary page to download the dictionary compressed package, decompress it, and put the dictionary directory in the /usr/share/stardict/dic/ directory. If the dic directory does not exist, you can create it manually.
Dictionary download:
http://abloz.com/huzheng/stardict-dic
Take "Langdao English-Chinese Dictionary" as an example, its download address is:
http://abloz.com/huzheng/stardict-dic/zh_CN/stardict-langdao-ec-gb-2.4.2.tar.bz2
wget
http://abloz.com/huzheng/stardict-dic/zh_CN/stardict-langdao-ec-gb-2.4.2.tar.bz2
tar -jxvf stardict-langdao-ec-gb-2.4.2.tar.bz2
mv stardict-langdao-ec-gb-2.4.2 /usr/share/stardict/dic/
Restart stardict to load the dictionary.
Author: Alien of the Earth
Link:
https://www.zhihu.com/people/diqiuyo/answers
Last edited by zzz19760225 on 2017-7-18 at 20:36 ]