Difference between revisions of "Post Installation Tips"

From ArchWiki
Jump to: navigation, search
m (Accessing the AUR Seamlessly)
(37 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[Category:Getting and installing Arch (English)]][[Category:HOWTOs (English)]]
#REDIRECT[[General Recommendations]]
Here are some sought-after tweaks and general information intended for Arch Linux newcomers.
{{i18n_entry|Česky|Poinstalační tipy (Česky)}}
{{i18n_entry|English|Post Installation Tips}}
{{i18n_entry|Français|Astuce post-installation}}
{{i18n_entry|Español|Consejos para después de Instalar (Español)}}
{{i18n_entry|Italiano|Suggerimenti Post Installazione}}
{{i18n_entry|Ελληνικά|Post Installation Tips (Ελληνικά)}}
{{i18n_entry|Türkçe|Kurulum Sonrası Ayarları (Türkçe)}}
===Hardware Auto-Recognition===
* [[hwdetect]] informs of what modules are needed for a particular device.
  # pacman -S hwdetect
* {{Package AUR|lshwd}} is an alternative.
===Lilo Boot Process Speed-Up===
To speed up [[lilo]]'s boot process, add the following command to {{Filename|/etc/lilo.conf}}:
===Start X at Boot===
See [[Start X at boot|Start X at Boot]]
===Activating Numlock on Bootup===
See [[Activating Numlock on Bootup]]
===End of the Boot Process===
After the boot process, the screen is cleared and the login prompt appears, leaving users unable to read init output or error messages. This default behavior may be modified in a few ways:
Add one of the following to the bottom of {{Filename|/etc/rc.local}}:
* Wait for a keypress before clearing the screen:
  read -n1
* Wait for at most 5 seconds or until a keypress occurs:
  read -t5 -n1
* Remove the first 3 characters in {{Filename|/etc/issue}}, which form a "clear screen" escape code. This will also stop the screen from being cleared after logging out from regular sessions in addition to not clearing the screen after booting.
* Run {{Codeline|dmesg}} from the shell prompt to display all the boot messages generated by the kernel.
* Comment out the agetty instance that runs on <code>vc/1</code> in {{Filename|/etc/inittab}}:
#c1:2345:respawn:/sbin/agetty -8 38400 vc/1 linux
===Colorize the Console Prompt (PS1)===
Files {{Filename|~/.bashrc}} and {{Filename|/root/.bash_profile}} contain the default ''PS1'' (shell prompt) variables for normal user and root, respectively.
As an unprivileged user:
$ nano ~/.bashrc
Comment out the default prompt:
#PS1='[\u@\h \W]\$ '
And add:
PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'
This will give a very pleasing, colorful prompt and theme for the console with bright white text.
The string above contains color-set escape sequences (start coloring: ''\[\e[color\]'', end coloring: ''\[\e[m\]'') and information placeholders:
*'''\u''' - Username. The original prompt also has '''\h''', which prints the host name.
*'''\w''' - Current absolute path. Use '''\W''' for current relative path.
*'''\$''' - The prompt character (eg. '#' for root, '$' for regular users).
The last color-set sequence, "''\[\e[1;37m\]''", is not closed, so the remaining text (everything typed into the terminal, program output and so on) will be in that (bright white) color. It may be desirable to change this color, or to delete the last escape sequence in order to leave the actual output in unaltered color.
As root, edit {{Filename|/root/.bash_profile}}, copy it from {{Filename|/etc/skel}} if the file is unpresent:
# nano /root/.bash_profile
Comment out the default PS1:
#PS1='[\u@\h \W]\$ '
The following PS1 is useful for a root bash prompt, with red designation and green console text:
PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\] '
For more sophisticated options, see [[Color Bash Prompt]]
===Colorize the Output of 'ls'===
This will further enhance the colored {{Codeline|ls}} output; for example, broken (orphan) symlinks will show in red, etc.
File {{Filename|~/.bashrc}} should already have the following entry copied from {{Filename|/etc/skel/.bashrc}}:
alias ls='ls --color=auto'
The next step is adding the following to {{Filename|~/.bashrc}} and reloging:
eval `dircolors -b`
{{Note|These are not single quotes/apostrophes; these are backquotes/backticks/grave accents.}}
===Colorize the Output of 'grep'===
Beyond aesthetics, {{Codeline|grep}} color output is immensely useful for learning {{Codeline|regexp}} and {{Codeline|grep}}'s functionality.
To add it, write the following entry to {{Filename|~/.bashrc}}:
export GREP_COLOR="1;33"
alias grep='grep --color=auto'
The variable <code>GREP_COLOR</code> is used to specify the output color, in this example a light yellow color.
Although the {{Codeline|man}} page of {{Codeline|grep}} states that <code>GREP_COLOR</code> is deprecated and that <code>GREP_COLORS</code> is preferable, this variable will not work (as of grep version 2.5.4). Continue to use <code>GREP_COLOR</code> for now.
===Colorizing and the Emacs Shell===
By default, the [[emacs]] shell will rawly show escape sequences used to print colors. In other words, it will display strange symbols in place of the desired colored output.
Including the following into {{Filename|~/.emacs}} ammends the problem:
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
===Getting a Colored Manpage===
For some users, color-enabled manpages allow for a clearer presentation and easier digestion of the content. Given that users new to linux are prone to spend a considerable amount of time familiarizing themselves with basic userspace tools, setting up a comfortable environment is a necessity to most.
There are two prevalescent methods for achieving colored manpages: using {{Codeline|most}}, or opting for {{Codeline|less}}. The former is simpler to configure, at the expense of the advanced functionality that is native to {{Codeline|less}}.
====First Method: Using 'most'====
# pacman -S most
This is similar to {{Codeline|less}} and {{Codeline|more}}, but also allows to render text in color in an easier way.
Edit {{Filename|/etc/man_db.conf}}, uncomment the pager definition and change it to:
DEFINE    pager    most -s
Test the new setup by typing:
$ man whatever_man_page
Modifying the color values requires editing {{Filename|~/.mostrc}} (creating the file if it is not present) or editing {{Filename|/etc/most.conf}} for system-wide changes. Example {{Filename|~/.mostrc}}:
% Color settings
color normal lightgray black
color status yellow blue
color underline yellow black
color overstrike brightblue black
Another example showing keybindings similar to {{Codeline|less}} (jump to line is set to 'J'):
% less-like keybindings
unsetkey "^K"
unsetkey "g"
unsetkey "G"
unsetkey ":"
setkey next_file ":n"
setkey find_file ":e"
setkey next_file ":p"
setkey toggle_options ":o"
setkey toggle_case ":c"
setkey delete_file ":d"
setkey exit ":q"
setkey bob "g"
setkey eob "G"
setkey down "e"
setkey down "E"
setkey down "j"
setkey down "^N"
setkey up "y"
setkey up "^Y"
setkey up "k"
setkey up "^P"
setkey up "^K"
setkey page_down "f"
setkey page_down "^F"
setkey page_up "b"
setkey page_up "^B"
setkey other_window "z"
setkey other_window "w"
setkey search_backward "?"
setkey bob "p"
setkey goto_mark "'"
setkey find_file "E"
setkey edit "v"
====Second Method: Using 'less'====
Alternatively, getting an approximate coloured result in manual pages with {{Codeline|less}} is also a possibility. This method has the advantage that {{Codeline|less}} has a bigger feature set than {{Codeline|most}}, and that might be the preference for advanced users.
Just add the following to {{Filename|~/.SHELLrc}} (where SHELL is the name of the shell in use):
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
To customize the colors, see http://en.wikipedia.org/wiki/ANSI_escape_code for reference.
Source: http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html
===Changing Console Fonts===
Terminus is a popular favorite amongst Arch users. Install with:
pacman -S terminus-font
Edit {{Filename|/etc/rc.conf}}:
Other fonts (with differing styles and sizes) can be found in {{Filename|/usr/share/kbd/consolefonts}}
Switch fonts instantaneously with {{Codeline|setfont}}:
setfont ter-v16b
If the console font is changed during the boot process and init shows strange character output, add the ''keymap'' hook to {{Codeline|/etc/mkinitcpio.conf}} and recreate the ''initramfs'' image:
mkinitcpio -p kernel26
See [[Mkinitcpio#Available_hooks|Available Hooks in Mkinitcpio]]
===Beautifying Fonts for LCDs===
See [[Fonts]]
==General Console Improvements==
===Enabling History Search===
By default, when typing (for example) {{Codeline|ls}} and pressing the ''<Up>'' key, current input will be replaced with the previously issued command. With history search enabled, only past commands beginning with {{Codeline|ls}} (the current input) will be completed.
Adding the following to {{Filename|/etc/inputrc}} or {{Filename|~/.inputrc}} enables history search:
===Fast Bash Completion===
By appending the following into {{Filename|~/.bashrc}}:
set show-all-if-ambiguous on
It is no longer necessary to hit the ''<Tab>'' key twice to produce a list of all possible completions, as a single ''<Tab>'' press will suffice.
===Advanced Bash Completion===
[[Bash]] can be extended to use smart, context-sensitive completion. This is a very handy feature that many {{Codeline|bash}} users take for granted.
Install it with:
# pacman -S bash-completion
Afterwards, add to {{Filename|~/.bashrc}}:
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
{{Note|It may be not needed the add the above ~/.bashrc entries, as /etc/bash.bashrc will activate bash-completion on login.}}
===Timesaving Command-Aliases===
alias ll="ls -lh"
alias la="ls -a"
alias exit="clear; exit"
alias x="startx"
Personal aliases are preferably stored in {{Filename|~/.bashrc}}, system-wide aliases (which affect all users) belong in {{Filename|/etc/profile.bashrc}}.
===Useful Commands & Programs===
* '''grep'''
:Searches for files by it's contents. Example:
  grep -i syslog /etc/*
:Searches all files in {{Filename|/etc}} for those containing the word "''syslog''", and the operand {{Codeline|-i}} enables case-insensitive matches.
* '''pkill''' and '''killall'''
:Kills processes by name. Example:
  killall kdm
:Kills every {{Codeline|kdm}} thread.
* '''pidof'''
:Finds the ''PID #'' of the processes, by name. Example:
  pidof init
:Prints the PID # of init.
* '''ps'''
:Displays process status. Example:
  ps xau
:Shows display all active processes.
* '''locate'''
:Quickly locate files on the hard drive (once a database has been created using {{Codeline|updatedb}}). Example:
  locate Xservers
:Finds all files named {{Filename|Xservers}} in the database path.
===Extracting Compressed Files===
For {{Codeline|tar}} archives, the easiest method is to let {{Codeline|tar}} automatically handle the file according to it's contents:
  file.''EXTENSION'' : tar '''a'''xvf file.''EXTENSION''
Forcing a given format:
  file.tar : tar xvf file.tar
  file.tgz : tar xvzf file.tgz
  file.tar.gz : tar xvzf file.tar.gz
  file.bz : bzip -cd file.bz | tar xvf -
  file.bz2 : tar xvjf file.tar.bz2 <b>OR</b> bzip2 -cd file.bz2 | tar xvf -
  file.zip : unzip file.zip
  file.rar : unrar x file.rar
The construction of these tar arguments is considered archaic, but their inteded usefulness has retained when performing specific operations. Tar's ''manpage'', section ''Compatability'', shows how they work in detail.
The following function will decompress a wide range of compressed file-types. Add the function to {{Filename|~/.bashrc}} and use it with the syntax {{Filename|extract <file_name>}}:
extract () {
  if [ -f $1 ] ; then
      case $1 in
          *.tar.bz2)  tar xvjf $1    ;;
          *.tar.gz)    tar xvzf $1    ;;
          *.bz2)      bunzip2 $1    ;;
          *.rar)      unrar x $1    ;;
          *.gz)        gunzip $1      ;;
          *.tar)      tar xvf $1    ;;
          *.tbz2)      tar xvjf $1    ;;
          *.tgz)      tar xvzf $1    ;;
          *.zip)      unzip $1      ;;
          *.Z)        uncompress $1  ;;
          *.7z)        7z x $1        ;;
          *.exe)      cabextract $1  ;;
          *)          echo "'$1': unrecognized file compression" ;;
      echo "'$1' is not a valid file"
===Using 'less' for Browsing Compressed Files===
Frequent users of the command line interface might want to install {{Codeline|lesspipe}}:
# pacman -S lesspipe
It allows typing:
less compressed_file.tar.gz
To list the compressed files inside of an archive:
==> use tar_file:contained_file to view a file in the archive
-rw------- username/group  695 2008-01-04 19:24 compressed_file/content1
-rw------- username/group  43 2007-11-07 11:17 compressed_file/content2
compressed_file.tar.gz (END)
It also grants {{Codeline|less}} the ability of interfacing with files other than archives; serving as an alternative for the specific command associated for that file-type.
Relogin after installing {{Codeline|lesspipe}} in order to activate it, or source {{Filename|/etc/profilde.d/lesspipe.sh}}
===Enabling Console Mouse Support (gpm)===
Installing {{Codeline|gpm}} provides console mouse support:
# pacman -S gpm
To start it right away:
# /etc/rc.d/gpm start
If the mouse is not working properly, edit {{Filename|/etc/conf.d/gpm}}:
* For PS/2 mice, replace the existing line with:
GPM_ARGS="-m /dev/psaux -t ps2"
* For USB mice, replace the existing line with:
GPM_ARGS="-m /dev/input/mice -t imps2"
* For IBM Trackpoint, replace the existing line with:
GPM_ARGS="-m /dev/input/mice -t ps2"
Once a suitable configuration has been found, adding {{Codeline|gpm}} into the <code>DAEMONS</code> array in {{Filename|/etc/rc.conf}} will make {{Codeline|gpm}} load at boot. Example:
DAEMONS=(syslog-ng '''gpm''' network netfs crond)
==Mantaining and Compiling Packages==
In addition to [[Pacman|pacman]]'s standard set of features, there are ways to extend it's usability through rudimentary ''bash'' commands/syntax.
* To install a number of packages sharing similar patterns in their names - not the entire group nor all matching packages - eg. <code>kdemod</code>:
  pacman -S kdemod-{applets,theme,tools}
* Of course, that is not limited and can be expanded to however many levels needed:
  pacman -S kdemod-{ui-{kde,kdemod},kdeartwork}
* Pacman has the {{Codeline|-q}} operand to hide the version column, so it is possible to query and reinstall packages with "compiz" as part of their name:
  pacman -S `pacman -Qq | grep compiz`
* The above can be achieved without {{Codeline|-q}} by issuing an {{Codeline|awk}} operation:
  pacman -S `pacman -Q | awk '/compiz/ { print $1 }'`
On the subject of '''reinstalling every package''': listing currently installed packages will output everything, including packages that are local and/or might not be available for installation any longer.
Simply running:
pacman -S `pacman -Qq`
Will output errors because some (or many) of the packages were not found in the repositories. There needs to be a way to list only packages that can be installed from the repositories present in {{Codeline|pacman}}'s database. In order to do so, combining a command to list all packages, and another to hide the list of foreign packages is required.
This is achieved by using {{Codeline|comm -3}} to show only the packages that are not foreign packages:
pacman -S $(comm -3 <(pacman -Qq) <(pacman -Qqm))
====Pacman Aliases====
Copy these into {{Filename|~/.bashrc}} or {{Filename|~/etc/profile.bash}}:
# Search through all available packages simply using 'pacsearch packagename'
alias pacsearch="pacman -Sl | cut -d' ' -f2 | grep "
# sudo pacman -Syu by typing pacup (sudo must be installed and configured first)
alias pacup="sudo pacman -Syu"
# sudo pacman -S by typing pac
alias pac="sudo pacman -S"
# Colorized pacman -Ss search output:
alias pacs="pacsearch"
pacsearch() {
    echo -e "$(pacman -Ss "$@" | sed \
      -e 's#^core/.*#\\033[1;31m&\\033[0;37m#g' \
      -e 's#^extra/.*#\\033[0;32m&\\033[0;37m#g' \
      -e 's#^community/.*#\\033[1;35m&\\033[0;37m#g' \
      -e 's#^.*/.* [0-9].*#\\033[0;36m&\\033[0;37m#g' ) \
Downloading {{Package AUR|pacman-color}} allows for more options.
===Accessing the AUR Seamlessly===
Everyone should know how to use the [[AUR]], [[ABS]], and [[makepkg]] if they want to build packages. Tracking and updating custom built packages can become tedious, especially if they are numerous in quantity.
There are some programs and scripts that help building packages more convenient. See a [[AUR Helpers|list of programs that help accessing the AUR]]
===Using ABS to Recompile Packages===
''ABS'' is an automated toolkit that allows rebuilding any of pacman's packages, allowing the user to apply custom compiler and linker settings for the purpose of optimization, debugging, etc. Simply executing {{Codeline|abs}} will synchronize all ''PKGBUILD'' scripts from the Arch source repository into {{Filename|/var/abs}}.
# pacman -S abs
It is not recommended to build packages inside of the main {{Filename|/var/abs}} tree. Copying the PKGBUILD and all accompanying files to an empty directory is more practical, since there is no risk of getting modifed PKGBUILD files overwritten by newer ones when updating the abs tree. Keeping a copy of the PKGBUILD (even after the resulting package has already been installed) eases updating and keeping track of package changes across version increments.
===Optimizing Packages===
''Makepkg'' is an automated tool to create packages - it automates the <code>./configure && make && make install</code> procedure, (or whatever combination of commands involved in the building of the application) and packs it  into a .pkg.tar.gz for easy installation with <code>pacman</code>. It uses a script file called a ''PKGBUILD'' which must exist in the build directory. View a PKGBUILD file and read the installation document to learn more about how to work with {{Codeline|makepkg}}.
For optimizing the packages built using {{Codeline|makepkg}} (the kernel is a good example), editting <code>/etc/makepkg.conf</code> is recommended:
  # Example for an Athlon CPU
  CFLAGS="-march=athlon -O2 -pipe -fomit-frame-pointer"
  CXXFLAGS="-march=athlon -O2 -pipe -fomit-frame-pointer"
See [[Safe Cflags|Safe CFlags]] for more information.
==Miscellaneous Tips==
===Disabling IPv6===
Until the widespread adoption of IPv6, you may benefit from [[IPv6_-_Disabling_the_Module|disabling the IPv6 module]]
===Speeding up DNS Queries===
See [[Speeding up DNS with dnsmasq]]

Revision as of 03:24, 16 January 2010