Difference between revisions of "Post Installation Tips"

From ArchWiki
Jump to navigation Jump to search
(fix double redirect)
 
(223 intermediate revisions by 38 users not shown)
Line 1: Line 1:
[[Category:Getting and installing Arch (English)]]
+
#REDIRECT [[General recommendations]]
[[Category:HOWTOs (English)]]
 
 
 
{{i18n_links_start}}
 
{{i18n_entry|English|Post Installation Tips}}
 
{{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|简体中文|ArchTips(简体中文)}}
 
{{i18n_entry|Türkçe|Kurulum Sonrası Ayarları (Türkçe)}}
 
{{i18n_links_end}}
 
 
 
Here are some performance tweaks and other useful information for Arch Linux newbies.
 
==== Hardware Auto-Recognition====
 
* <code>lshwd</code> is your hardware auto-recognition tool. It will inform you which module you need to load and set.
 
 
 
* Or you can use <code>hwdetect</code>. In my experience it detects more hardware and is faster than lshwd.  More information: [[hwdetect]]
 
 
 
====Lilo Boot Process Speed-Up====
 
* to speed up lilo boot process, add the following command to <code>/etc/lilo.conf</code>:
 
  compact
 
 
 
===End of Boot Process===
 
After the boot process; the screen is cleared and the login prompt appears.  Some users may want to modify this behaviour such that they can see the messages that appeared during the boot process still.
 
 
 
You can either add one of the following to the bottom of your /etc/rc.local file:
 
* Wait at the end of the process until you press a key before clearing the screen and letting you log in:
 
  read -n1
 
* Wait for at most 5 seconds or until you press a key:
 
  read -t5 -n1
 
 
 
Or:
 
* Remove the first 3 characters in <code>/etc/issue</code> file, which is a "clear screen" escape code.  Obviously this will stop the screen from being cleared after you log out from your login session as well as just after boot.
 
* Run <code>dmesg</code> from the shell prompt to display all the boot messages generated by the kernel.
 
 
 
===Colorize your console prompt (PS1)===
 
~/.bashrc and /root/.bashrc contain the default PS1 (shell prompt) variables for normal user and root, respectively.
 
 
 
As normal 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[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.
 
 
 
As root, edit the /root/.bashrc:
 
# nano /root/.bashrc
 
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, see the [[Color Bash Prompt]] wiki entry.
 
 
 
 
 
===Colorize the output of 'ls'===
 
Your <code>~/.bashrc</code> should already have the following entry copied from <code>/etc/skel/.bashrc</code>
 
alias ls='ls --color=auto'
 
 
 
Just add to your <code>~/.bashrc</code>
 
eval `dircolors -b`
 
This will further enhance the colored <code>ls</code> output; for example, broken (orphan) symlinks will show in red, etc.<br>
 
''Note the backquote/backtick/grave accent character used here - this is not a single quote/apostrophe.''
 
 
 
===Less on steroids===
 
If you are a frequent user of the command line interface, you might want to install lesspipe (that you will find on AUR). It will allow you to type:
 
less lesspipe.tar.gz
 
==> use tar_file:contained_file to view a file in the archive
 
-rw------- solstice/users  695 2008-01-04 19:24 lesspipe/PKGBUILD
 
-rw------- solstice/users  43 2007-11-07 11:17 lesspipe/lesspipe.sh
 
lesspipe.tar.gz (END)
 
 
i.e. use less to see the content of many files, instead of using specific command each time.
 
Use <tt>man lesspipe</tt> to see how to activate it.
 
 
 
===Change Console Fonts===
 
Terminus is a popular favorite amongst Archers. Install with:
 
pacman -S terminus-font
 
Edit /etc/rc.conf:
 
CONSOLEFONT="ter-v16b"
 
Switch fonts on-the-fly with '''setfont''':
 
setfont ter-v16b
 
 
 
===Getting a colored manpage===
 
If you're new to linux, you will have to read a lot of manpages if you want to learn. However color will allow a clearer presentation of the contents and hopefully easier digestion. To get manpages to render in color install a reader program like most(8).
 
 
pacman -S most
 
 
 
This is similar to less and more but also allows you to render text in color in an easier way.
 
 
 
To get it up and running change the /etc/man.conf file and change the PAGER and BROWSER variable to:
 
 
 
PAGER          /usr/bin/most -s
 
BROWSER        /usr/bin/most -s
 
 
 
Now you can type:
 
man whatever_man_page
 
to see it in clarifying colors.
 
 
 
If you want to modify the colors, experiment with the ~/.mostrc file (create it if it isn't there) or use /etc/most.conf.
 
 
 
example ~/.mostrc:
 
 
 
% Color settings
 
 
color normal lightgray black
 
color status yellow blue
 
color underline yellow black
 
color overstrike brightblue black
 
 
 
another example for less-like keybindings (jump to line with '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"
 
 
 
Alternatively you can get the same coloured result for manpages with less. This method has the advantage that less has many more features than most thus comes much more handy for advanced users. Just add the following to your .SHELLrc
 
 
 
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'
 
 
 
Source: http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html
 
 
 
===Accessing AUR seamlessly===
 
Everyone should know how to use AUR, ABS, and makepkg if they want to build packages. Tracking and updating your custom built packages can become tedious, especially if you have many. There are some programs and scripts that help make building packages more convenient.
 
 
 
The most popular third-party program that can search AUR is called [http://aur.archlinux.org/packages.php?ID=5863 yaourt].
 
 
 
[[AUR User Guidelines#List of AUR-DMS|See a list of other programs that help you access AUR]]
 
 
 
=== Enabling History Search ===
 
 
 
Usually, when typing <code>ls</code> and pressing <up> key, your current input will be replaced with the last command used. If you are using history seach, only past commands beginning with <code>ls</code> (the current input) will be shown.
 
 
 
You can enable this mode by adding to <code>/etc/inputrc</code> or your <code>~/.inputrc</code>:
 
"\e[A":history-search-backward
 
"\e[B":history-search-forward
 
 
 
===Enabling shellcompletion===
 
This is a very desirable feature that you will no doubt benefit greatly from.
 
 
 
pacman -S bash-completion
 
 
 
and afterwards add to ~/.bashrc
 
 
 
if [ -f /etc/bash_completion ]; then
 
    . /etc/bash_completion
 
fi
 
 
 
'''Note:''' You may not need the above ~/.bashrc entries as /etc/profile will load any profiles from /etc/profile.d<br>
 
In there, bash_completion.sh will source /etc/bash_completion anyway.
 
 
 
===Enabling mouse support in console (gpm)===
 
* You can enable mouse support in the console by installing <b>gpm</b>:
 
pacman -S gpm
 
* If you see the mouse cursor flickering and it doesn't work properly, you will need to change <code>/etc/conf.d/gpm</code>.
 
'''For PS/2 mouse replace the existing line with:'''
 
[ED: This is what works for my Synaptics touchpad, neither syn nor synps2 did.]
 
GPM_ARGS="-m /dev/psaux -t ps2"
 
'''For USB mouse 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"
 
 
 
* When it works, you can add <code>gpm</code> into <code>DAEMONS</code> array in <code>/etc/rc.conf</code> to have it started at boot.
 
* Mouse support in the console is useful for many things, including programs such as Links and Lynx.
 
 
 
===Start X at boot===
 
* [[Start X at boot]]
 
 
 
===Beautifying Fonts for LCD's===
 
See [[Fonts]]
 
 
 
===Activating Numlock on Bootup===
 
* [[Activating Numlock on Bootup]]
 
 
 
===ABS to build your own packages===
 
* If you use [[ABS]] to build your own packages, remember to do it outside of the main /var/abs tree. Copy the PKGBUILD and all accompanying files to an empty directory in your homedir and build from there. That way you won't risk your modifications getting overwritten on the next <code>abs</code> run and it's easier to keep track of them.
 
 
 
===Optimizing your packages===
 
* For optimizing the packages you build using makepkg (the kernel is a good example), set your GCC preferred settings in <code>/etc/makepkg.conf</code>:
 
  (example for Athlon CPU)
 
  export CFLAGS="-march=athlon -O2 -pipe -fomit-frame-pointer"
 
  export CXXFLAGS="-march=athlon -O2 -pipe -fomit-frame-pointer"
 
See [http://wiki.archlinux.org/index.php/Safe_Cflags Safe CFlags] for more info.
 
 
 
===Timesaving Command-aliases===
 
* You can create your own commands-aliases using <code><homedir>/.bashrc</code> or <code>/etc/profile</code>. Both can be used to define your own aliases:
 
<pre>
 
alias ll="ls -lh"
 
alias la="ls -a"
 
alias exit="clear; exit"
 
alias x="startx"
 
 
 
# Lets you 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"
 
</pre>
 
 
 
Colorized pacman -Ss search output: 
 
# colorized pacman output with pacs alias:
 
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' ) \
 
      \033[0m"
 
}
 
 
 
You can also download pacman-color from the [http://aur.archlinux.org/packages.php?ID=11827 AUR].
 
 
 
===Disabling IPv6===
 
Until the widespread adoption of IPv6, you may benefit from [[IPv6_-_Disabling_the_Module|disabling the IPv6 module]]. 
 
 
 
===Useful Commands & Programs===
 
*<code>grep</code> - searches for files by its contents (example: <code>grep -i syslog /etc/*</code> will search all files in /etc for those containing the word "syslog"; NOT case-sensitive (using the <code>-i</code> parameter))
 
*<code>pkill/killall <process_name></code> - kills processes by name (example: <code>killall kdm</code>)
 
*<code>ps</code> - display process status (example: <code>ps xau</code> will display all active processes)
 
*<code>locate</code> - quickly locates files on your hard drive (use <code>updatedb</code> to create a database of them first) (example: <code>locate Xservers</code> will find all files named Xservers)
 
 
 
====pacman====
 
There are some nice ways to do a bunch of things easily with bash commands. If we want to install a number of packages sharing similar patterns in their names - not the entire group nor all matching packages - eg. '''kdemod''', we can do:
 
pacman -S kdemod-{applets,theme,tools}
 
Of course, that is not limited and can be expanded to however many levels you need:
 
pacman -S kdemod-{ui-{kde,kdemod},kdeartwork}
 
Pacman has the '''-q''' option to hide the version column, and we can do something like reinstall packages with "compiz" as part of their name:
 
pacman -S `pacman -Qq | grep compiz`
 
The above can be achieved without '''-q''' by issuing an '''awk''' operation:
 
pacman -S `pacman -Q | awk '/compiz/ { print $1 }'`
 
Want to reinstall everything? Easy! Wait - not so fast. Listing currently installed packages will output everything including those that have been built with ''makepkg''. Simply running
 
pacman -S `pacman -Qq`
 
will output errors because some (or many) of them were not found in the database. We need a way to list only packages that have been installed by pacman. In order to do so, we must combine a command to list all packages, and another to hide the list of foreign packages. This, we achieve by using '''comm -3''' to show only the packages that are not foreign packages.
 
pacman -S $(comm -3 <(pacman -Qq) <(pacman -Qqm))
 
 
 
====makepkg====
 
An automated tool to create packages - it actually automates the <code>./configure && make && make install</code> procedure, (or whatever combination of commands involved in the building of the application) and packs it up into a .pkg.tar.gz to be easily installed with pacman. 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 makepkg.
 
 
 
====ABS====
 
An automated toolkit that allows you to rebuild any of pacman's packages (so you may provide your own compiler and linker settings, for better optimization, debugging info, etc). Simply executing abs will synchronize all PKGBUILD scripts from the SVN repository into <code>/var/abs</code>.
 
 
 
===Extracting compressed files===
 
  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 quite archaic (but nevertheless handy). Have a look at the bsdtar manpage, section COMPATIBILITY for how they work in detail. (bsdtar comes in the libarchive package)
 
 
 
===Speeding up DNS queries===
 
Some people may experience slow DNS lookups which will result in painfully slow pacman operations, et cetera. One way to solve this is using static DNS servers not acquired via dchp and dnsmasq for DNS query caching. (In this example we will use the OpenDNS servers.) The method is simple.
 
 
 
====Install dnsmasq====
 
Make sure the [extra] repository is enabled, then run <code>pacman -S dnsmasq</code>.
 
 
 
====Configure dnsmasq====
 
As root, using your preferred editor, edit <code>/etc/dnsmasq.conf</code>. Find the commented line containing the <code>listen-address=</code> directive and uncomment it by removing the # (hash) from the line, then add <code>127.0.0.1</code> as the value. Your line should look like the following figure:
 
  listen-address=127.0.0.1
 
 
 
====Edit resolv.conf====
 
As root, using your preferred editor, edit <code>/etc/resolv.conf</code>. dhcp should have automatically configured this for your router and LAN setup. This will be indicated by the following line:
 
<code># Generated by dhcpcd for interface ath0</code>
 
If this is the case, then leave the <code>search</code> directive as it is, and remove (or comment out) all the nameserver lines, then insert the following code. (If dhcp has not configured the search directive, use your network name as its value.) :
 
  # Route DNS requests through dnsmasq first
 
  nameserver 127.0.0.1
 
  # First OpenDNS server
 
  nameserver 208.67.222.222
 
  # Second OpenDNS server
 
  nameserver 208.67.220.220
 
If you are using NetworkManager, prevent it from overriding your resolv.conf, see here: [http://bbs.archlinux.org/viewtopic.php?id=45394].
 
 
 
====Configure dhcpcd====
 
Finally, we don't want <code>dhcpcd</code> overwriting our <code>resolv.conf</code> anymore, since it is customized. We do, however, want <code>dhcpcd</code> to continue to automatically set out IP, default gateway, et cetera. To cause this effect, we will edit <code>/etc/conf.d/dhcpcd</code> as root, with our favorite editor. The directive we are looking for is <code>DHCPCD_ARGS</code> and by default that directive would look as follows:
 
  DHCPCD_ARGS="-q"
 
 
 
As from dhcpcd 4.0.3 onwards the use of /etc/conf.d/dhcpcd is mostly depricated. Most configuration options can be given specified in /etc/dhcpcd.conf. Only command line arguments not supported by this config file should be specified in the DHCPCD_ARGS line in /etc/conf.d/dhcpcd.
 
 
 
The old-style /etc/conf.d/dhcpcd style of preventing the hook script from running and touching your DNS is adding the <code>-C resolv.conf</code> option to the DHCPCD_ARGS line:
 
  DHCPCD_ARGS="-q -C resolv.conf"
 
 
 
Previous versions of dhcpcd used the -R flag instead:
 
  DHCPCD_ARGS="-t 30 -h $HOSTNAME -R"
 
 
 
====Start dnsmasq====
 
With all the configuration done, you can now start dnsmasq. Issue the following command as root:
 
  /etc/rc.d/dnsmasq start
 
Once started, you should see the effects immediately. For a simple test, use dig from the <code>dnsutils</code> package. An example would be:
 
  dig example.com
 
The relevant test line would be the Query time line.
 
  ;; Query time: 105 msec
 
Now, issue a dig for the same host a second time. The Query time should be 0 msec. This means that the DNS query for example.com has been successfully cached.
 

Latest revision as of 03:15, 17 February 2014