Difference between revisions of "Help:Reading (正體中文)"

From ArchWiki
Jump to navigation Jump to search
(Source: translation)
Line 56: Line 56:
== Source ==
== Source ==
Some applications, notably [[command-line shell]]s, use scripts for their configuration: after modifying them, they must be ''sourced'' in order for the changes to be applied. In the case of [[bash]], for example, this is done by running (you can also replace {{ic|source}} with {{ic|.}}):
有些應用程式(如[[command-line shell]](命令列介面))使用script作為設定檔案,當這些設定檔案被更動之後,它們就應該要被''source'',才能夠引用改變之後的功能。以[[bash]]的情況為例,你可以執行以下指令(或是將{{ic|source}}替換為{{ic|.}})
  $ source ~/.bashrc
  $ source ~/.bashrc
When the wiki will suggest to modify such a configuration script, it will not explicitly remind you to source the file, and only in some cases it will point you to this section with a reminder link.
== Installation of packages ==
== Installation of packages ==

Revision as of 02:03, 20 October 2015

zh-CN:Help:Reading zh-TW:Help:Reading

翻譯狀態: 本文章是 Help:Reading 的翻譯版本。最近一次的翻譯時間:2015-10-19。點擊本連結查看英文頁面之後的變更。

由於Archwiki的絕大部分內容包含指令使用的指示,GNU/Linux新手必須釐清它們的使用方式。 因此撰寫這則簡單扼要的條目,其目的是避免理解文章的困擾,以及避免一再地重複這些提醒新手的內容。



# mkinitcpio -p linux


$ makepkg -s


Note: 以井字號#開頭的指令應該要在root shell裡被執行,這可以使用sudo -i指令來達成。從一個沒有權限的普通shell環境執行sudo command而非採用在root shell裡執行command的方式在大部分情況下亦有效,然而仍然有一些值得注意的例外,是必須在root shell環境之下執行的,例如 redirection以及substitution。也可以參考sudo條目。


# This alias makes ls colorize the listing(譯:這個別名令ls輸出彩色內容)
alias ls='ls --color=auto'

在這個例子中,井字符號之後的內容並非代表要作為一個指令執行,而是應該代表在檔案內編輯的實際情況。在這個例子裡面,井字號代表的是一個註解 。註解是解釋用的文字,而非具有程式功能的內容,只是恰好Bash script裡的註解符號與root的命令提示字元相等。進一步檢視這個用法,我們可以發現井字號之後的內容包含著英文的大寫字元。通常而言,Unix的指令不會有大寫字元,而且它們通常都是縮寫的英文字詞。例如代表複製的Copy指令為cp。



# This alias makes ls colorize the listing
alias ls='ls --color=auto


當指示說明提到以上動作時,請將之理解為「使用文字編輯器修改相關設定檔案」的動作。 以nano編輯器為例,可以使用下列方式新創不存在的檔案或是修改既有的檔案。

# nano /etc/bash.bashrc


# echo myhostname > /etc/hostname


# echo "[custom-repo]" >> /etc/pacman.conf


有些應用程式(如command-line shell(命令列介面))使用script作為設定檔案,當這些設定檔案被更動之後,它們就應該要被source,才能夠引用改變之後的功能。以bash的情況為例,你可以執行以下指令(或是將source替換為.):

$ source ~/.bashrc


Installation of packages

When an article invites to install some packages in the conventional way, it will not indicate the detailed instructions to do so, instead it will simply mention the names of the packages to be installed, possibly with a link pointing to this very article's section. The subsections below give an overview of the generic installation procedures depending on the package type.

Official packages

For packages from the official repositories you will read something like:

Install the foobar package.

This means that you have to run:

# pacman -S foobar

The pacman article contains detailed explanations to deal with package management in Arch Linux proficiently.

Arch User Repository

For packages from the Arch User Repository you will read something like:

Install the foobarAUR package.

This means that in general you have to follow the foobarAUR link, download the PKGBUILD archive, extract it, verify the content and finally run, in the same folder:

$ makepkg -sri

The Arch User Repository article contains all the detailed explanations and best practices to deal with AUR packages.

Control of systemd units

When an article invites to start, enable, stop or restart some systemd units (e.g. a service), it will not indicate the detailed instructions to do so, but instead you will read something like:

Start example.service.

This means that you have to run:

# systemctl start example.service

The Start link will lead you to the systemd article, which contains all the detailed explanations to deal with systemd units in Arch Linux proficiently.

System-wide versus user-specific configuration

It is important to remember that there are two different kinds of configurations on a GNU/Linux system. System-wide configuration affects all users. Since system-wide settings are generally located in the /etc directory, root privileges are required in order to alter them. For example, to apply a Bash setting that affects all users, /etc/bash.bashrc should be modified.

User-specific configuration affects only a single user. Dotfiles are used for user-specific configuration. For example, the file ~/.bashrc is the user-specific configuration file. The idea is that each user can define their own settings, such as aliases, functions and other interactive features like the prompt, without affecting other users' preferences.

Note: ~/ and $HOME are shortcuts for the user's home directory, usually /home/username/.

Common shell files

For ease of use, here is a selective listing of basic configuration files and their locations.


See also: Bash and man bash

Within Bash and other Bourne-compatible shells, such as Zsh, there is even further differentiation in the purposes of the configuration files. Some files only get sourced when Bash is starting as a login shell, whereas other files only do so when Bash is an interactive shell.

When Bash is run in a virtual console, for instance, it is started as a login shell. Bash shells started in a Xorg session, such as those employed by xterm, are interactive shells.

Common files:

  • /etc/bash.bashrc: System-wide settings; sourced only by a login shell
  • ~/.bashrc: Personal shell settings; sourced only by an interactive shell


See also: Zsh and man zsh

Common files:

  • /etc/zsh/zprofile: System-wide settings; sourced only by a login shell
  • ~/.zshrc: Personal shell settings; sourced only by an interactive shell

Pseudo-variables in code examples

Some code blocks may contain so-called pseudo-variables, which, as the name says, are not actual variables used in the code. Instead they are generic placeholders and have to be manually replaced with system-specific configuration items before the code may be run or parsed. In the articles that comply with Help:Style/Formatting and punctuation, pseudo-variables are formatted in italics.

For example:

  • Enable the dhcpcd@interface_name.service for the network interface identified from the output of the ip link command.

In this case interface_name is used as a pseudo-variable placeholder in a systemd template unit. All systemd template units, identifiable by the @ sign, require a system-specific configuration item as argument. See Systemd#Using units.

  • The command dd if=data_source of=/dev/sd"X" bs=sector_size count=sector_number seek=partitions_start_sector can be run as root to wipe a partition with the specific parameters.

In this case the pseudo-variables are used to describe the parameters that must be substituted for them. Details on how to gather them are elaborated on in the section Securely wipe disk#Calculate blocks to wipe manually, which features the command.

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Mention other examples, ideally from other device categories (e.g. storage), with links to background articles. The examples are meant to avoid duplicating existing explanations in other articles. (Discuss in Help talk:Reading (正體中文)#)

In case of file examples, pasting pseudo-variables in real configuration files might break the programs that use them.


In most cases ellipses (...) are not part of the actual file content or code output, and instead represent omitted or optional text that is not relevant for the discussed subject.

For example HOOKS="... encrypt ... filesystems ..." or:

Section "InputClass"
    Option      "CircularScrolling"          "on"
    Option      "CircScrollTrigger"          "0"

Be aware though that, in a few instances, ellipses may be a meaningful part of the code syntax: attentive users will be able to easily recognize these cases by the context.