Astuce post-installation

From ArchWiki

Jump to: navigation, search


i18n
Česky
English
Français
Español
Italiano
Ελληνικά
简体中文
Türkçe
Image:Tango-preferences-desktop-locale.png This page was marked to be translated.
If you understand both "original" and "target" languages of this page, please help complete the translation.

Contents

Introduction

Voici quelques astuces, et informations utiles pour les débutants sous Arch Linux.

Auto-reconnaissance du matérielle

  • lshwd est votre outil d'auto-reconnaissance materielle. Il vous informera sur les modules que vous devez charger et utiliser.
  • Vous pouvez aussi utiliser hwdetect. Certains disent qu'il détecte plus de materiel et est plus rapide que lshwd.

Plus d'information : hwdetect

Accélération du processus de boot de Lilo

  • Pour accélérer le démarrage de Lilo, ajouter la commande suivante à votre /etc/lilo.conf:
 compact

Fin du démarrage

À la fin du démarrage, l'écran est effacé et l'invite de connexion apparaît. Certains voudront peut-être modifier ce comportement afin de pouvoir voir les messages du système en n'effaçant pas l'écran.

Il suffit d'ajouter une de ces lignes à la fin de votre fichier /etc/rc.local :

  • Attendre que vous appuyiez sur une touche pour effacer l'écran :
 read -n1
  • Même comportement que la commande précédente, mais l'écran s'effacera de lui-même après 5 secondes :
 read -t5 -n1

Ou :

  • Supprimez les 3 premiers caractères du fichier /etc/issue (qui servent à effacer l'écran). Évidemment, cela signifie aussi que l'écran ne sera pas effacé lors de chaque déconnexion.
  • Utilisez la commande dmesg pour voir les messages envoyés par le kernel.
  • Commentez l'instance de agetty qui tourne dans vc/1 dans le fichier /etc/inittab.
#c1:2345:respawn:/sbin/agetty -8 38400 vc/1 linux

Colorisez votre invite de commandes (PS1)

~/.bashrc et /root/.bash_profile contiennent les variables PS1 (invite de commande) pour l'utilisateur courant et root, respectivement.

En tant qu'utilisateur normal :

$ (votre éditeur) ~/.bashrc

Commentez l'invite de commande par défaut :

#PS1='[\u@\h \W]\$ '

Puis ajoutez :

PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] '

Vous obtiendrez une invite pleine de couleurs et du texte blanc. Cette chaîne de caractères étrange contient des séquences d'échappement (commencer la coloration : \[\e[couleur\], fin de la coloration : \[\e[m\]) et des indicateurs pour certaines informations :

  • \u - nom de l'utilisateur, l'ancienne invite avait aussi \h - nom de la machine
  • \w - chemin courant absolu, utilisez \W pour un chemin relatif
  • \$ - le caractère propre à l'invite (# pour root, par exemple)

La dernière séquence traitant de la couleur ( \[\e[1;37m\] ) n'est pas fermée et donc le reste du texte (ce que vous tapez) sera coloré de cette couleur (blanc). En la supprimant, vous obtiendrez la couleur par défaut (gris).

En tant que root, éditez /root/.bash_profile :

# (votre éditeur) /root/.bash_profile

Commentez l'invite par défaut :

#PS1='[\u@\h \W]\$ '

L'invite suivante est pratique pour l'utilisateur root, car elle le différencie de l'utilisateur courant :

PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\] '

Pour en savoir plus, consultez Color Bash Prompt.

Colorize the output of 'ls'

Your ~/.bashrc should already have the following entry copied from /etc/skel/.bashrc

alias ls='ls --color=auto'

Just add to your ~/.bashrc

eval `dircolors -b`

This will further enhance the colored ls output; for example, broken (orphan) symlinks will show in red, etc.
Note the backquote/backtick/grave accent character used here - this is not a single quote/apostrophe.

Colorize the output of 'grep'

Beyond aesthetics, grep color output is immensely useful for learning regexp & grep's functionality.

To add it, add the following entry:

export GREP_COLOR="1;33"
alias grep='grep --color=auto'

to ~/.bashrc

The variable GREP_COLOR is used to specify the output color, in this example a light yellow color. Although the man page of grep says that GREP_COLOR is deprecated and that we should use GREP_COLORS, this variable will not work (tested on grep version 2.5.4). Continue to use GREP_COLOR as of now.

Colorizing and the Emacs Shell: avoid strange symbols

By default the Emacs Shell will show rawly the escape sequences used to print the colors, that is, you will see a bunch of annoying strange symbols. You must include this into your .emacs configuration file:

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

Less on steroids

If you are a frequent user of the command line interface, you might want to install lesspipe (which you can find in the community repository). 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 man lesspipe 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"

Or find other fonts(with other sizes and styles) in /usr/share/kbd/consolefonts. Switch fonts on-the-fly with setfont:

setfont ter-v16b

If the console font is changed during the boot process and you get a strange character output, add the "keymap" hook to the mkinitcpio.conf and create the initramfs image again: available Hooks in mkinitcpio.

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. There are two ways to get color in your manpages.

First method

The first, more basic method is to 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

Note: As of February, 2009, Arch uses man-db instead of man. Edit /etc/man_db.conf, uncomment the pager definition, and change it to:

DEFINE          pager     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"

Second method

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, so it comes much more handy for advanced users. Just add the following to your ~/.SHELLrc (i.e., ~/.bashrc if you use bash, or ~/.zshrc if you use zsh). To customize the colors, use different ANSI color codes; see http://en.wikipedia.org/wiki/ANSI_escape_code.

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.

See a list of programs that help you access AUR

Enabling History Search

Usually, when typing ls and pressing <up> key, your current input will be replaced with the last command used. If you are using history search, only past commands beginning with ls (the current input) will be shown.

You can enable this mode by adding to /etc/inputrc or your ~/.inputrc:

"\e[A":history-search-backward
"\e[B":history-search-forward

Fast shellcompletion

If you put into ~/.bashrc

set show-all-if-ambiguous on

you will no longer have to hit the <Tab> key twice to produce a list of all possible completions. A single <Tab> will suffice.

Smart shellcompletion

Bash can be extended to use smart context-sensitive completion. This is a very handy feature.

# 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
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 gpm:
# pacman -S gpm

To start it right away:

# /etc/rc.d/gpm start
  • If you see the mouse cursor flickering and it doesn't work properly, you will need to change /etc/conf.d/gpm.

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 gpm into DAEMONS array in /etc/rc.conf to have it started at boot.
  • Mouse support in the console is useful for many things, including programs such as Links and Lynx.

Lancer X au boot

Beautifying Fonts for LCD's

See Fonts

Activer le pavé numerique au démarrage

ABS pour compiler vos propres paquets

  • Si vous utilisez ABS pour compiler vos propres paquets, faites-le à l'extérieur de l'arbre principal /var/abs. Copiez le PKGBUILD et tous les fichiers l'accompagnant dans un répertoire vide de votre /home et compilez de cet endroit. Ainsi, il vous est plus facile de garder la trace de ces paquets et vous évitez que vos modifications soit effacées à la prochaine synchronisation de ABS.

Compilation optimisée pour votre architecture

  • Pour optimiser la compilation de paquets compilés avec makepkg (le kernel est un bon exemple), modifiez vos préferences GCC dans votre /etc/makepkg.conf

Voir l'article Safe CFlags pour plus d'informations.

Timesaving Command-aliases

  • You can create your own commands-aliases using <homedir>/.bashrc or /etc/profile. Both can be used to define your own aliases:
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"

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 AUR.

Disabling IPv6

Jusqu'à ce que IPv6 soit répandu, vous pourriez bénéficier de la désactivation de ce module.

Useful Commands & Programs

  • grep - searches for files by its contents (example: grep -i syslog /etc/* will search all files in /etc for those containing the word "syslog"; NOT case-sensitive (using the -i parameter))
  • pkill/killall <process_name> - kills processes by name (example: killall kdm)
  • pidof <process_name> - find the pid of the processes by name (example: pidof init)
  • ps - display process status (example: ps xau will display all active processes)
  • locate - quickly locates files on your hard drive (use updatedb to create a database of them first) (example: locate Xservers 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 ./configure && make && make install 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 /var/abs.

Extracting compressed files

For tar archives, the easiest method is to let tar automatically handle the file according to its contents:

 file.EXTENSION : tar axvf file.EXTENSION (the file may be an uncompressed, gzipped or bzipped tar archive)

Or you can force 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 OR 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 tar manpage, section COMPATIBILITY for how they work in detail. (tar comes in the tar package)

The following function will decompress a wide range of compressed filetypes. Add the function to '~/.bashrc' and then run with the syntax 'extract MyCompressedFile'

 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        ;;
           *)           echo "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
 }

Speeding up DNS queries

Personal tools