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

From ArchWiki
Jump to navigation Jump to search
(Installation of packages: translation)
(Control of systemd units: translation)
Line 90: Line 90:
 
[[Arch User Repository]]條目包含詳細的說明與練習,關於如何使用AUR套件。
 
[[Arch User Repository]]條目包含詳細的說明與練習,關於如何使用AUR套件。
  
== Control of systemd units ==
+
== 控制systemd元件 ==
  
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:
+
當一篇文章要求你''開始''''啟用''''停止''''重啟''某些systemd元件(或者說某些服務)時,它通常不會提供詳細的步驟,而是給出類似下列指令:
  
 
:[[Start]] {{ic|example.service}}.
 
:[[Start]] {{ic|example.service}}.
  
This means that you have to run:
+
這表示你應該要執行以下指令:
  
 
  # systemctl start example.service
 
  # 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.
+
上面的[[Start]]標籤連結至[[systemd]]條目。該條目包含所有流暢地使用systemd功能的細節。
  
 
== System-wide versus user-specific configuration ==
 
== System-wide versus user-specific configuration ==

Revision as of 02:32, 20 October 2015

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

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

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

一般使用者或root使用者

有些指令會以下列方式呈現:

# mkinitcpio -p linux

有些則有不同的提示字元:

$ makepkg -s

井字號(#)代表的是該指令應該以root使用者身份執行;相反地,錢字符號($)則代表該行應該以一般使用者身份執行。

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。

此外,許多文章也會直接提醒讀者如下:

將下列內容附加到~/path/to/file

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

Append(附加)、add(增加)、create(創造)、edit(編輯)

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

# nano /etc/bash.bashrc

也可以使用重新導向輸出的方式新創或是覆寫檔案:

# echo myhostname > /etc/hostname

或是使用類似的手法,附加字串到檔案的最後端:

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

Source

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

$ source ~/.bashrc

這個wiki的一些文章會建議使用者修改這些設定檔,然而通常不會特別提醒你source那些檔案。只有在一些情況下,那些頁面會指引你來到這個片段閱讀上述的說明。

安裝套件

當一則wiki條目要求你使用正常方式安裝某些套件,它並不會給予非常細節的安裝流程,而是提及應該要被安裝的套件名稱,或許會提供連結到這篇文章。於此介紹這種情況下,對應於不同類型的套件的通用安裝流程。

官方套件

對於official repositories(官方套件庫)裡的軟體,你可能會看到這樣的指示:

安裝foobar套件.

這表示你應該要執行這個指令:

# pacman -S foobar

pacman條目包含詳細的說明,介紹如何使用這個工具流暢地在Arch系統底下管理套件。

Arch使用者套件庫

對於Arch User Repository(Arch使用者套件庫,簡稱AUR)裡的軟體,你可能會看到這樣的指示:

安裝foobarAUR套件.

這表示一般而言你應該連結到foobarAUR所在的頁面,下載PKGBUILD的打包檔案、解開它、檢驗內容、然後在同一個目錄下執行:

$ makepkg -sri

Arch User Repository條目包含詳細的說明與練習,關於如何使用AUR套件。

控制systemd元件

當一篇文章要求你開始啟用停止重啟某些systemd元件(或者說某些服務)時,它通常不會提供詳細的步驟,而是給出類似下列指令:

Start example.service.

這表示你應該要執行以下指令:

# systemctl start example.service

上面的Start標籤連結至systemd條目。該條目包含所有流暢地使用systemd功能的細節。

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.

Bash

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

Zsh

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.

Ellipses

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:

/etc/X11/xorg.conf.d/50-synaptics.conf
Section "InputClass"
    ...
    Option      "CircularScrolling"          "on"
    Option      "CircScrollTrigger"          "0"
    ...
EndSection

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.