Wednesday November 22, 2006 (09:01 AM GMT)
By: Aleksey 'LXj' Alekseyev
Gentoo is one of the most difficult distributions to learn, though veteran Gentoo users might point out that its friendly community and extensive documentation can help new users. Here are some tips that might make Gentoo easier for anyone who wants to give it a try.
First, be prepared to read a lot of documentation, especially in the early stages of using the distribution. You won't even be able to install Gentoo without carefully examining the Gentoo Handbook.
Gentoo has a graphical installer, but I do not recommend it for inexperienced users. Installing Gentoo in the "traditional" way will force you to read the Handbook, and therefore you will not miss important points. Also Gentoo's installer is sometimes not as good at setting up needed drivers as other distributions'. Expecting Gentoo's graphical installer to work in ways similar to that of any other distribution's may lead to misunderstanding and frustration.
The Handbook contains basic information about Gentoo. Further topics (such as configuration of X and ALSA) are described on the Gentoo Documentation Resources page. Another important source of information is the Gentoo wiki.
If you have questions that aren't covered in those places, you can find answers on the Gentoo Forums or in the distro's IRC channels.
Portage basics
One fundamental element that distinguishes Gentoo from other distributions is its package management system, called Portage, which is primarily oriented to installing software from source. This allows a great deal of control and customization -- while in binary distributions users have several packages for the same software with different dependencies and options (which actually gives users limited control compared to the options available when building the package from source), with Portage you set so-called USE flags to select optional features for the whole system or selected packages.
For example, if you need to enable KDE support and disable GNOME dependencies globally, you'd add kde -gnome to your USE variable in /etc/make.conf. You can read more about USE flags in the Gentoo Handbook .
You use Portage by invoking the emerge command. To install package moo, for instance, you simply type emerge moo. Portage checks dependencies of the given package, downloads all the necessary source archives, compiles the package, and installs it. All the information it needs is stored in its database, which consists of ebuilds, which are bash scripts written in a specific way. Ebuilds are stored in /usr/portage.
Managing Portage settings
The first rule of Gentoo is that you have to keep your attention closely on the USE flags. Why is X.org installed when you emerge Midnight Commander? Because you have the X USE flag enabled. Why does your KDE not have KPDF? Because you do not have the pdf USE flag enabled (do not ask me why it contains KGhostScript, though).
Always install a new packages with emerge --ask --verbose (or emerge -av) to see which flags will be used before compilation starts. Install the gentoolkit package (emerge gentookit) -- among other useful things, it contains the euse utility, which is intended to simplify management of USE flags. Run euse -i flag to view a flag's description and see whether it is enabled. See euse's man page for more details (do not worry, it is short).
If you need to change a set of USE flags for some package, do not install it as USE="some flags" emerge moo. This will work, but the next time you update it, the package will be recompiled with the old set of flags. Changing USE flags is what the file /etc/portage/package.use is for. Just invoke echo "category/moo some flags" >> /etc/portage/package.use before installing.
The same applies to ACCEPT_KEYWORDS -- use /etc/portage/package.keywords. In Portage 2.1 you can use package.use and package.keywords directories instead of files to simplify management.
When should you use overlays?
Sometimes you need to install a package that is not in Portage. For instance, you may wish to install a (version of a) package that is deleted from Portage. You can fetch its ebuild from Portage's CVS repository. Sometimes you want to try update a new package and find an ebuild in Bugzilla. There may be a case when you decide to edit an ebuild from the official Portage tree.
In any case, you should place your ebuilds in a custom local overlay. An overlay is a custom set of ebuilds which you want to inject to a Portage database. Do not store custom ebuilds in the primary portage tree (/usr/portage), because they will be deleted the next time you sync. Create a directory for your overlay and create a directory structure similar to /usr/portage in it. Place your ebuild there accordingly. Add PORTDIR_OVERLAY="/path/to/local/overlay" to your /etc/make.conf file.
The usual place for overlays is /usr/local/overlays, so the overlay for your own ebuilds should be /usr/local/overlays/local. What else can /usr/local/overlays contain?
In many cases, when you seek packages not included in official Portage tree, you find not just ebuilds, but also overlays you can synchronize with. For example, one of the popular overlays is xgl-coffee, which contains all you need to use Xgl. You can install it to /usr/local/overlays/xgl-coffee to separate it from other overlays and update it via SVN.
You can find more information on managing overlays in the Gentoo Wiki. You will also find there a list of third-party overlays and information on how to synchronize with them.
How often should you update?
You should not sync your Portage tree more than once a day. Even that is usually more than enough. You can keep track of your favorite packages by visiting the packages.gentoo.org or gentoo-portage.com sites (or subscribing to the corresponding RSS feeds), and resync and update only when new versions of packages you use often make their way to Portage.
Keep your world clean
Whenever you emerge some-package , the name of the package is added to the /var/lib/portage/world file. When you wish to upgrade all your packages you are usually invoking something like emerge --update --deep world, and that is when this list is used. You should keep this list of packages as short as possible; only the packages you use directly should be there. If some package is installed as a dependency of another package, it should probably not be in your world file.
For example, if you install some package that uses the wxWidgets library, this library is installed as a dependency, and is not added to your world. If you uninstall all the packages using wxWidgets, this library will not be updated when you run emerge --update (...) world, and it will be uninstalled if you run emerge --depclean. The only reason you might add wxWidgets to your world is if you were a programmer developing your own applications using this library.
There is a script that can assist you in removal of unnecessary packages from the world list. To install a package without adding it to world, use the --oneshot (-1) option. It is also a good idea to use this option when you want to install some package temporarily.
Uninstalling packages
emerge --uninstall will not check whether you are trying to remove a package that is needed by another one. Sometimes even emerge --depclean can remove packages you actually need. That's why you should be very careful when uninstalling software.
Sometimes you remove an optional dependency of some package. In this situation the package may stop working until you re-emerge it. The revdep-rebuild utility from the gentoolkit package is used to locate and re-emerge such packages.
Portage logs
Whatever you do with emerge is reflected in /var/log/emerge.log. For example, if you want to know which package is being compiled at the moment, run tail /var/log/emerge.log (I use a simple Python script to convert timestamps into a readable format). A utility called genlop (emerge genlop) can retrieve some useful information from this log. For example, running genlop -c will tell you which package is currently being compiled, and will try to predict how much time the compilation will take.
Cleaning temporary files
When an emerge session is stopped with an error, it leaves a directory that contains the temporary files it created while compiling the last package in /var/tmp/portage. If you fix the problem immediately and successfully re-emerge that package, these files will be deleted. In other cases you can empty /var/tmp/portage manually.
After several updates you may end up with many files in /usr/portage/distfiles. Use the eclean utility from the gentoolkit package to delete source files you do not need anymore. This utility can also delete binary packages you have created (invoke it as eclean-dist and eclean-pkg accordingly). See the man page for possible options.
Gentoo gives you great powers to customize your system. I hope this article will help you turn those powers to your side. While Gentoo requires you to put some effort into learning its ins and outs, it gives you the satisfaction of controlling every aspect of your system. You will like that feeling.
Linux是一套免费使用和自由传播的类UNIX操作系统,主要用于基于Intel x86系列CPU的计算机上。Linux系统是由全世界各地的成千上万的程序员设计和实现的,其目的是建立不受任何商品化软件的版权所制约的、全世界都能 自由使用的UNIX兼容产品。也许有些准备和正在使用Linux的朋友对为什么使用Linux并不十分了解。本文试就这一问题给出答案,让人们真正了解 Linux带给我们的七件武器。Linux对比于商业软件,对学习者来说有一个境界上的差异,这个差异用一句话概述就是:以无法为有法,以无限为有限。这 个境界上的差异也就是Linux七种武器的精华所在。
一、拳头——编程能力
Linux产生于一群真正的黑客。尽管 人们习惯于认为Linus是Linux的缔造者,在linux包含的数以千计的文件中,也有一个名为Credits的文件记录了主要的Linux Hacker们的姓名和电子邮件地址(这个列表中包含了100多个名字,世界各地的都有),但没有人说得清究竟有多少人参与了Linux的改进。这一游戏 到今天并没有随着时间的推移而停止,相反却因为Linux的日益流行而爱好者甚众。因此开始使用Linux就犹如加入了一个高手如云的编程组织。你可以通 过互联网随时了解来自地球的某一个角落的该领域的最新进展;如果你的英文足够好,加入一个讨论组,你就可以得到不知来自什么地方的神密高手的点拨。由于 GPL的存在,你还可以得到开放的源代码,从而不用发愁学习资料的来源。
随着更多专业公司的介入,Linux可以提供的开发工具的功 能也越发强大。如TurboLinux就具有强大的应用程序开发环境,提供了各种开发应用程序的工具,具有对多种语言如:C、C++、Java、 Perl、Tcl/tk、Python和Fortran 77的编译器/解释器,以及集成开发环境、调试和其他开发工具。再如Janus Software公司开发的被称为Linux版VB的Phoenix Object Basic,它是一套独特的面向对象的Linux RAD(Rapid Application Development,快速应用软件开发工具)。它综合了Python和Perl等面向对象编程语言的强大功能,同时,提供了类似Visual Basic的易用性。熟悉Windows环境下Visual Basic的编程者都可以顺利地使用Phoenix Object Basic。LynuxWorks公司的VisualLynux可以和微软的Visual C++相媲美,它集成了微软Visual C++开发工具以支持Linux操作系统的产品,它不但兼容LynuxWorks公司的BlueCat Linux,而且还兼容其他的Linux 2.2.12版本。LynuxWorks公司甚至声称从此Visual C++就具备了开发嵌入式Linux应用程序的能力。嵌入式Linux系统现在相当热门,已经广泛地应用在各式各样的通信基础产品。我想可能有些 Visual C++的使用者看到这里已经动了心,想要尝试一把了。
强大的开发工具+开放源代码+高手点拨,结果是什么呢?想来编程狂热分子已经心知肚明。因此强烈建议对编程有狂爱、总喜欢用程序解决问题的人使用Linux,去拥有Linux提供的第一件武器——编程能力。
二、多情环——组网能力
Linux的组网能力非常强大,它的TCP/IP代码是最高级的。Linux提供了对于当前的TCP/IP协议的完全支持,并且包括了对下一代 Internet.协议Ipv6的支持。Linux内核还包括了IP防火墙代码、IP防伪、IP服务质量控制及许多安全特性。这些特性可以和像Cisco 这样的公司提供的高端路由设备的特性相媲美。此外,利用Redhat Linux提供的Samba组(并不是RedHat Linux独有),Linux可以作为Windows客户机的打印和文件服务器,还可以用做NT的文件和打印服务器。运用Linux包含的 AppleTalk模块,Linux甚至可以作为一个Macintosh客户机的文件和打印服务器。让Apache这个世界上应用范围最广的Web服务器 软件系统跑在linux上,你就可以运行自己的Intranet或者Internet web服务器。Linux还包含了一个Ftp服务程序、一个电子邮件传输代理程序以及,POP和IMAP邮件服务程序。如果你愿意,你还可以在 Internet上免费获得一个Linux的LDAP服务程序。面对如此强大的网络功能,我们强烈建议对构造网络有兴趣的人掌握Linux的第二件武器— 组网能力。
三、长生剑—创新能力
“如果你总是使用微软的开发工具,你一生只能做个操作人员。”这话一点都不假。Linux是自由软件,而自由软件和非自由软的区别在于:
1.自由软件是开放的,成千上万的人可以检查这个软件,快速地找到并修改其错误码。
2.最终用户可以按照自己的意愿自定义自由软件,有特殊需要的用户也可以完全按照他们认为合适的方式定制自己的Linux。
3.自由软件为了防止重复发明,通过共享源代码和思想来节省很多工作量。
以上这些特性是不是对有想法的好事者有莫大的吸引力?不仅如此,Linux由于自身的优点,应用领域也越来越广泛。如最近嵌入式Linux的应用相当热 门,已广泛应用于包括笔记本电脑、连网装置、网络电视等在内的各式各样的通信基础产品,而嵌入式操作系统正日益成为一种势不可挡的流行趋势,最终电脑、通 讯、家电会因为它的存在而成为一体。这些也为有想法的好事者提供了更广阔的发挥空间。在梦想就是力量的今天,没有了创新能力是不可想象的。因此强烈建议那 些具有较强的钻研精神,喜欢刨根问底的好事者学习使用Linux,利用Linux提供的第三件武器—创新能力。
四、碧玉刀——UNIX能力
人们所以选择Linux的又一个重要原因是在于它的UNIX兼容性。由于Linux是一套自由软件,用户可以无偿地得到它及其源代码,无偿地获得大量的 应用程序,还可以任意地修改和补充它们。这对用户学习、了解UNIX操作系统的内核非常有益。可以说Linux为广大用户提供了一个在家里学习和使用 UNIX操作系统的廉价的机会。
现在有了许多CD-ROM供应商和软件公司对Linux操作系统的支持,Linux成为 UNIX系统在个人计算机上的一个代用品。在用户级,Linux与UNIX非常相似,可以说了解UNIX,就了解了Linux的大部分内容;在编程级,大 多数应用程序只需要很少的工作就可以在Linux和UNIX间转换。而且Linux也有意设计为与UNIX兼容,从而便于利用UNIX软件的主体。 Linux能够很好地与其他UNIX机器相互操作,它使用了像RPC(远程过程调用)和NFS(网络文件系统)这样的标准UNIX服务。Linux还继承 了UNIX的灵活性和可定制性,使其适合于广泛的应用程序,包括适应于传统的服务器和桌面应用程序,以及像嵌入式系统这样的不常见的应用程序。
因此,如果一个用户在公司上班的时候在UNIX系统上编程,或者在工作中是一位UNIX的系统管理员,他就可以在家里安装一套UNIX的兼容系统,即 Linux系统。在家中使用Linux就能够完成一些工作任务。而急于通过Linux的学习掌握UNIX的目的想必不用多说了,在这个网络人才因稀缺而身 价倍增的年代,想靠技术吃饭又不想掌握服务器端技术的人才是真正的傻瓜。
五、离别钩——怀旧能力
在这 个IT技术日新月异的年代,怀旧应该不是一个好习惯,尽管怀旧可以有一种很不错的情调。但慢慢地我们发现我们不得不怀旧了,因为我们去年刚买的电脑现在已 经老掉牙了。尽管每个IT厂商都嚷着他们的产品可以有效地降低我们的TCO(总拥有成本),可我们手里设备的折旧速度还是在不断加快。如果你肯听我的,我 会说这世上从来就没有救世主,还是试试我推荐的Linux吧。
Linux非常小,可以有效地利用硬件。Linux的最小安装 仅需要4MB内存,而你也可以在你的486机器上安装Linux并将其用做防火墙或Web服务器。我读到的Linux名著中甚至记载了有人用二手386建 立了路由器和防火墙。Linux内核允许在运行时装载和卸载硬件的驱动程序。这样因为不必装载全部的驱动程序,就可以最大化地使用内存。总之Linux可 以使老机器获得新生,节省我们的财力。因此强烈建议那些跑Windows像蜗牛一样慢的电脑的机主们学习Linux。
六、霸王枪——稳定能力
运行Linux的机器启动一次可以运行数月。Linux提供了完全的内存保护,每个进程都运行在自己的虚拟地址空间中,并且不会损坏其他进程或内核使用 的地址空间。任务与内核间也是相互隔离,即行为不良或编写不良的程序只能毁坏自己。因此被破坏的进程几乎不可能使系统崩溃。Linux在和 Windows98和NT在安全性的较量中占有上风,和Windows2000的情况又怎么样呢?资深的系统安全分析家指出:Windows 2000在网络系统,服务器连接方面的工作准备不足,Linux仍然是目前最安全的操作系统。资深的系统安全分析家还预计到今年年底Windows 2000才能完成测试、除虫工作,目前比较安全的操作系统仍然是商业版本的UNIX和Linux。资深的系统安全分析家肯定地认为:在未来的5年里, Linux将成为最安全的操作系统。到2005年,管理和使用Linux将是一件十分容易的事情。
现在可以说Linux是一个非常坚固的系统了,因此强烈建议对于Windows的蓝屏死机极为厌恶的人学习Linux,使用Linux提供的第六件武器——稳定能力。
七、孔雀翎——支付能力
Linux提供的第七件武器和金钱有关,这是一个不容回避的问题。因为价格原因,每个人都可以拥有正版的Linux。此外Linux还是一个完全开放的 系统。它支持各种像POSIX标准这样的开放标准和TCP/IP的Internet工程任务组标准。由于避免了专有的API(应用程序接口)和协议,可以 减少对单一供应商的依赖。这样就不会出现像使用专用系统的情况:一旦犯了错误,只能继续使用原来的系统供用商的产品。也就是不会出现先享受低价,而在后期 需要付出高额服务费的情况。因此强烈建议不想花太多的钱,又想使用正版软件的人学习和使用Linux。
aptitude 与 apt-get 一样,是 Debian 及其衍生系统中功能极其强大的包管理工具。与 apt-get 不同的是,aptitude 在处理依赖问题上更佳一些。举例来说,aptitude 在删除一个包时,会同时删除本身所依赖的包。这样,系统中不会残留无用的包,整个系统更为干净。以下是笔者总结的一些常用 aptitude 命令,仅供参考。
命令 | 作用 |
aptitude update | 更新可用的包列表 |
aptitude upgrade | 升级可用的包 |
aptitude dist-upgrade | 将系统升级到新的发行版 |
aptitude install pkgname | 安装包 |
aptitude remove pkgname | 删除包 |
aptitude purge pkgname | 删除包及其配置文件 |
aptitude search string | 搜索包 |
aptitude show pkgname | 显示包的详细信息 |
aptitude clean | 删除下载的包文件 |
aptitude autoclean | 仅删除过期的包文件 |
当然,你也可以在文本界面模式中使用 aptitude。
If you have just installed GNU/Linux on your computer, and have only ever used Windows before, here are five things you need to know to get going rapidly.
Author: Olivier Cleynen
#1: App-searching is a pleasure, or:
How to install and uninstall programs
On Windows, you were probably used to find a given program on the Internet, download a setup.exe
file, and then install the program in something like C:\Program Files
.
Things are very different on GNU/Linux.
On most main distributions, finding, downloading, installing and uninstalling applications is done with one single add/remove program.
Pic.1 Software installation in Ubuntu
Within this program, a wealth of useful, free and gratis software has been listed, sorted and described for you. You need only select/deselect the programs you wish to install/uninstall, and apply your changes. The download and set-up will be done automatically.
You do not have to worry about where the program is installed. You do no have to worry about viruses, malware or “demo” programs (the application list has been constructed and checked carefully by your distribution’s programmers).
This aspect of GNU/Linux is probably the most satisfying and enjoyable to newcomers. Don’t be afraid to try new things out and enjoy your time!
Also on PolishLinux.org: a more advanced installation tutorial.
#2: Be wary when going root, or:
The command-line and the root user
Whichever operation you are doing on your GNU/Linux computer, it can be done by typing code.
Therefore, when you ask for advice, advanced users might reply with a series of coded commands for you to type in your computer, rather than long explanations on “where to click”. This method is called the command-line and code is entered through a small program called a terminal. You do not need to know how to type code for a normal use.
On Windows, the main computer user is allowed to run any program and change any system parameter. In the Linux world, however, things are different.
A normal user is allowed to perform normal actions, such as moving/writing files, launch normal applications, etc.
Only the root user, however, is able to modify system configuration, update the system, and install programs. This restriction makes sure that any malicious program inadvertently run by a normal user, because it hasn’t got root privileges, may not cause much harm.
When you attempt to do something only the root user can do, you will be prompted for the root password. Therefore, you should have a password set for the root user, even if it’s very simple: this will prevent yourself from inadvertently damaging your system.
Whenever your computer prompts you for a password, be wary and make sure you know what you are doing.
When using the command-line, getting root user privileges is done by typing sudo
before the command (it means: super-user do and you will be prompted for a password). If you are asked to type a command starting with sudo
and you are not sure what it means, ask in a forum (we suggest the beginner-friendly Nuxified.org).
More on PolishLinux.org: the terminal and the root account.
#3: Two (different) sides to a coin, or:
GNOME and KDE
You will quickly come across two frequently used names in the GNU/Linux world: GNOME and KDE.
Windows only has one look and feel, however, the GNU/Linux world has many. In particular, GNOME and KDE are the most popular desktop environments.
Under one desktop environment, you run the same computer, with the same Linux distribution, with the same files, as under another. What you alter is the graphical display: the way windows are managed and things are viewed.
Pic.3 Sample KDE desktop
Pic.4 Sample GNOME desktop
Most programs run equally well under KDE or GNOME. Some more specific applications –generally programs whose name starts with a K or G (such as KOffice or Gedit)– simply look better in their native environment.
You might find that KDE favors graphical artifacts, configuration menus, customization possibilities, to enable impressive desktops. GNOME, on the other hand, might appear more frugal for it favors simpler, cleaner and easier (if maybe less advanced) menus and graphical configuration. In any case, both enable very sleek, attractive and/or productive desktops -only in different ways.
GNU/Linux distributions often come with a default desktop environment (for example, Ubuntu with GNOME, and OpenSUSE with KDE), but you are able (and encouraged) to try a different one. There are also other desktop environments, perhaps most notably the less hardware-intensive Xfce.
More on desktop environments on PolishLinux.org
#4: You-may you-may-not, or:
File permissions
The file permissions determine who is able to access, move or modify each given file. The GNU/Linux system is very strict with these (there is no way to bypass or ignore them), and treats a folder the exact same way as a file.
Pic.5 File permissions in UNIX
There are three types of actions on the file: read (self explanatory), write (the ability to change and move the file), and execute. The latter, execute, is a bit peculiar:
- Setting a file as an executable means the system will try to run it as a program when you open it. This is potentially dangerous and you should never do this if you are unsure;
- Setting a folder as executable simply means that programs will be able to access its contents (this is a default property). For example, your
vacation photos
folder will be executable, so that you may browse your photos with your favorite program.
The file owner is the only user who can modify the permissions. He can set different permissions for himself (the “file owner“), defined groups of users (”user groups“), and all other users (”others“).
In practice, all of your files (usually stored in /home/your_user_name/
) will always have permissions set so that you may access and change them. You won’t be able to access other users’ files at all (they are usually stored in /home/someone_else/
), and you won’t be able to change system files (files such as the ones in /bin/
or /dev/
) without the root password.
#5: Five more quick tips, or:
Various additional details
Some miscellaneous points that might be useful:
-
No defragmenting needed
You may be used to regularly defragment your hard drive under Windows. Under GNU/Linux, however, the file systems in use are extremely resistant to fragmentation so that this is completely unnecessary.
-
Anti-viruses made redundant
Because GNU/Linux is very secure, running an anti-virus is not necessary either (unless you deal with Windows files under an emulator, or pass them on to Windows users). Be careful when you go root, and keep your system up-to-date with the automatic security updates: you’ll stay safe.
-
Case-sensitive filenames
Filenames under GNU/Linux are case-sensitive. This means that
report.odt
,Report.odt
, andreport.ODT
will all be different files that can be in one given folder. This is inherent to the system and you cannot change it. -
Hidden files start with a dot
Files and folders whose name starting with a dot (like a
.thumbnails
folder) are hidden. There are usually many such files and folders in your home directory, containing your settings for the programs you use (do not erase or alter them). You can activate the viewing of the hidden files usually through the “view” menu of your file manager. -
Accounting for hardware
There are sometimes different software versions, according to different hardware. “Normal” computers are often named “i386″ or “x86″ computers; But there are sometimes “64-bit” versions for 64-bit-processor computers, and versions for Mac hardware (including the G5, G4, G3 series). Unless you have special hardware, you can simply run the “x86″ (or “i386″) version.
Finally…
This is by no means a complete tutorial to GNU/Linux, merely a quick list of information to get newcomers going rapidly.
There is a great number of things you can learn to do with GNU/Linux, and the web is full of good places to guide you. You can start with the First steps section right here on PolishLinux.org, and then head off to the Nuxified.org forums where advanced users and beginners are all welcome.
Enjoy the free software world! You’ll never want to go back.
Archives
-
►
09
(1)
- ► March 2009 (1)
-
►
07
(87)
- ► October 2007 (8)
- ► September 2007 (3)
- ► August 2007 (2)
- ► April 2007 (23)
- ► March 2007 (10)
- ► February 2007 (2)
- ► January 2007 (10)