https://wiki.archlinux.org/api.php?action=feedcontributions&user=%2Adavid+a%2A&feedformat=atomArchWiki - User contributions [en]2024-03-29T01:27:27ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Pacman/Tips_and_tricks&diff=265584Pacman/Tips and tricks2013-07-09T18:50:54Z<p>*david a*: /* Usage */ - clarified wording for pacupg</p>
<hr />
<div>[[Category:Package management]]<br />
[[es:Pacman Tips]]<br />
[[it:Pacman Tips]]<br />
[[ja:Pacman Tips]]<br />
[[ru:Pacman Tips]]<br />
[[tr:Pacman_ipuçları]]<br />
[[zh-CN:Pacman Tips]]<br />
{{Article summary start|Summary}}<br />
{{Article summary text|This is a collection of common tips for new pacman users.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|pacman}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|Creating Packages}}<br />
{{Article summary wiki|Custom local repository}}<br />
{{Article summary end}}<br />
<br />
== Cosmetic and Convienence ==<br />
<br />
=== Color output ===<br />
<br />
As of version 4.1, Pacman has a color option. Uncomment the "Color" line in {{ic|pacman.conf}}.<br />
<br />
=== Shortcuts ===<br />
<br />
The following instructions allow users to run some of the more common pacman commands without the need to type them fully via a script alias.<br />
<br />
==== Configure the shell ====<br />
<br />
Add the following examples, which work in both [[Bash]] and [[Zsh]]:<br />
{{bc|<nowiki> # Pacman alias examples<br />
alias pacupg='sudo pacman -Syu' # Synchronize with repositories and then upgrade packages that are out of date on the local system.<br />
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories<br />
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file <br />
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies<br />
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies<br />
alias pacrep='pacman -Si' # Display information about a given package in the repositories<br />
alias pacreps='pacman -Ss' # Search for package(s) in the repositories<br />
alias pacloc='pacman -Qi' # Display information about a given package in the local database<br />
alias paclocs='pacman -Qs' # Search for package(s) in the local database<br />
<br />
# Additional pacman alias examples<br />
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories<br />
alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package<br />
alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist<br />
</nowiki>}}<br />
<br />
==== Usage ====<br />
<br />
Perform the respective commands by simply typing the alias name. For example, to synchronize with repositories and then upgrade packages that are out of date on the local system:<br />
$ pacupg<br />
Install packages from repositories:<br />
$ pacin <package1> <package2> <package3><br />
Install a custom built package:<br />
$ pacins /path/to/<package><br />
Completely remove a locally installed package:<br />
$ pacrem <package><br />
Search for available packages in the repositories:<br />
$ pacreps <keywords><br />
Display information about a package (e.g. size, dependencies) in the repositories:<br />
$ pacrep <keywords><br />
<br />
==== Notes ====<br />
<br />
The aliases used above are merely examples. By following the syntax samples above, rename the aliases as convenient. For example:<br />
<br />
alias pacrem='sudo pacman -Rns'<br />
alias pacout='sudo pacman -Rns'<br />
<br />
In the case above, the commands {{ic|pacrem}} and {{ic|pacout}} both call your shell to execute the same command.<br />
<br />
=== Operations and Bash syntax ===<br />
<br />
In addition to pacman's standard set of features, there are ways to extend its usability through rudimentary [[Bash]] commands/syntax.<br />
<br />
* To install a number of packages sharing similar patterns in their names -- not the entire group nor all matching packages; eg. {{Pkg|kde}}:<br />
<br />
# pacman -S kde-{applets,theme,tools}<br />
<br />
* Of course, that is not limited and can be expanded to however many levels needed:<br />
<br />
# pacman -S kde-{ui-{kde,kdemod},kdeartwork}<br />
<br />
* Sometimes, {{Ic|-s}}'s builtin ERE can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field:<br />
<br />
# pacman -Ss '^vim-'<br />
<br />
* pacman has the {{ic|-q}} operand to hide the version column, so it is possible to query and reinstall packages with "compiz" as part of their name:<br />
<br />
# pacman -S $(pacman -Qq | grep compiz)<br />
<br />
* Or install all packages available in a repository (kde-unstable for example):<br />
<br />
# pacman -S $(pacman -Slq kde-unstable)<br />
<br />
== Maintenance ==<br />
<br />
''House keeping, in the interest of keeping a clean system and following [[The Arch Way]]''<br />
<br />
=== Listing all installed packages with size ===<br />
<br />
* You may want to get the list of installed packages sorted by size, which may be useful when freeing space on your hard drive.<br />
* Use {{ic|pacsysclean}} from {{Pkg|pacman}} package.<br />
* Install {{Pkg|expac}} and run {{ic| <nowiki>expac -s "%-30n %m" | sort -rhk 2</nowiki>}}<br />
* Invoke pacgraph with the -c option to produce a list of all installed packages with their respective sizes on the system. {{Pkg|pacgraph}} is available from [community].<br />
* {{ic|<nowiki>pacman -Qi | egrep "Name|Installed Size" | sed -e 'N;s/\n/ /' | awk '{ print $7, $3}' | sort -n</nowiki>}} (note that some packages with "Name" in their descriptions will disrupt this (e.g. {{Pkg|idnkit}}))<br />
<br />
=== Listing installed packages with version ===<br />
<br />
* You may want to get the list of installed packages with their version, which is useful when reporting bugs or discussing installed packages.<br />
* List all explicitly installed packages: {{ic| pacman -Qe }}.<br />
* List all foreign packages (typically manually downloaded and installed): {{ic| pacman -Qm }}.<br />
* List all native packages (installed from the sync database(s)): {{ic| pacman -Qn }}.<br />
* List packages by regex: {{ic| <nowiki>pacman -Qs <regex> | awk 'BEGIN { RS="\n" ; FS="/" } { print $2 }' | awk '{ if(NF > 0) print $1, $2 }'</nowiki>}}<br />
* Install {{Pkg|expac}} and run {{ic| expac -s "%-30n %v"}}<br />
<br />
=== Identify files not owned by any package ===<br />
<br />
Periodic checks for files outside of pacman database are recommended. These files are often some 3rd party applications installed using the usual procedure (e.g. {{ic|./configure && make && make install}}). Search the file-system for these files (or symlinks) using this simple script:<br />
<br />
{{hc|pacman-disowned|<nowiki><br />
#!/bin/sh<br />
<br />
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$<br />
db=$tmp/db<br />
fs=$tmp/fs<br />
<br />
mkdir "$tmp"<br />
trap 'rm -rf "$tmp"' EXIT<br />
<br />
pacman -Qlq | sort -u > "$db"<br />
<br />
find /bin /etc /sbin /usr \<br />
! -name lost+found \<br />
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"<br />
<br />
comm -23 "$fs" "$db"</nowiki>}}<br />
<br />
To generate the list:<br />
<br />
$ pacman-disowned > non-db.txt<br />
<br />
Note that one should '''not''' delete all files listed in {{ic|non-db.txt}} without confirming each entry. There could be various configuration files, logs, etc., so use this list responsibly and only proceed after extensively searching for cross-references using {{Ic|grep}}.<br />
<br />
=== Removing orphaned packages ===<br />
<br />
For ''recursively'' removing orphans:<br />
<br />
{{bc|# pacman -Rs $(pacman -Qtdq)}}<br />
<br />
The following '''alias''' is easily inserted into {{ic|~/.bashrc}} and removes orphans if found:<br />
<br />
{{hc|~/.bashrc|<nowiki># '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq &gt; /dev/null &amp;&amp; sudo /usr/bin/pacman -Rs \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;\$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
The following '''function''' is easily inserted into {{ic|~/.bashrc}} and removes orphans if found:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
orphans() {<br />
if [[ ! -n $(pacman -Qdt) ]]; then<br />
echo "No orphans to remove."<br />
else<br />
sudo pacman -Rs $(pacman -Qdtq)<br />
fi<br />
}</nowiki>}}<br />
<br />
=== Removing everything but base group ===<br />
<br />
If it is ever necessary to remove all packages except the base group, try this one liner:<br />
<br />
# pacman -Rs $(comm -23 <(pacman -Qeq|sort) <((for i in $(pacman -Qqg base); do pactree -ul $i; done)|sort -u|cut -d ' ' -f 1))<br />
<br />
Source: [https://bbs.archlinux.org/viewtopic.php?id=130176 Look at discussion here]<br />
<br />
Notes:<br />
<br />
# {{ic|comm}} requires sorted input otherwise you get e.g. {{ic|comm: file 1 is not in sorted order}}.<br />
# {{ic|pactree}} prints the package name followed by what it provides. For example:<br />
<br />
{{hc|$ pactree -lu logrotate|<br />
logrotate<br />
popt<br />
glibc<br />
linux-api-headers<br />
tzdata<br />
dcron cron<br />
bash<br />
readline<br />
ncurses<br />
gzip}}<br />
<br />
The {{ic|dcron cron}} line seems to cause problems, that is why {{ic|cut -d ' ' -f 1}} is needed - to keep just the package name.<br />
<br />
=== Listing official installed packages only ===<br />
<br />
pacman -Qqn<br />
<br />
This list packages that are found in the sync database(s). If the user has unofficial repositories configured, it will list packages from such repositories too.<br />
<br />
=== Getting the dependencies list of several packages ===<br />
<br />
Dependencies are alphabetically sorted and doubles are removed.<br />
Note that you can use {{ic|pacman -Qi}} to improve response time a little. But<br />
you won't be able to query as many packages. Unfound packages are simply skipped<br />
(hence the {{ic|2>/dev/null}}).<br />
You can get dependencies of AUR packages as well if you use {{ic|yaourt -Si}},<br />
but it will slow down the queries.<br />
<br />
$ pacman -Si $@ 2>/dev/null | awk -F ": " -v filter="^Depends" \ '$0 ~ filter {gsub(/[>=<][^ ]*/,"",$2) ; gsub(/ +/,"\n",$2) ; print $2}' | sort -u<br />
<br />
Alternatively, you can use {{ic|expac}}: {{ic|expac -l '\n' %E -S $@ &#124; sort -u}}.<br />
<br />
=== Getting the size of several packages ===<br />
<br />
You can use (and tweak) this little shell function:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
pacman-size()<br />
{<br />
CMD="pacman -Si"<br />
SEP=": "<br />
TOTAL_SIZE=0<br />
<br />
RESULT=$(eval "${CMD} $@ 2>/dev/null" | awk -F "$SEP" -v filter="^Size" -v pkg="^Name" \<br />
'$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3)<br />
<br />
echo "$RESULT"<br />
<br />
## Print total size.<br />
echo "$RESULT" | awk '{TOTAL=$1+TOTAL} END {printf("Total : %d KiB\n",TOTAL)}'<br />
}</nowiki>}}<br />
<br />
As told for the dependencies list, you can use {{ic|pacman -Qi}} instead, but<br />
not [[yaourt]] since AUR's PKGBUILD do not have size information.<br />
<br />
A nice one-liner:<br />
<br />
$ pacman -Si "$@" 2>/dev/null | awk -F ": " -v filter="Size" -v pkg="Name" '$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3 | tee >(awk '{TOTAL=$1+TOTAL} END {printf("Total : %d KiB\n",TOTAL)}')<br />
<br />
You should replace "$@" with packages, or put this line in a shell function.<br />
<br />
=== Listing changed configuration files ===<br />
If you want to backup your system configuration files you could copy all files in {{ic|/etc/}}, but usually you're only interested in the files that you have changed. In this case you want to list those changed configuration files, we can do this with the following command:<br />
# pacman -Qii | awk '/^MODIFIED/ {print $2}'<br />
The following script does the same. You need to run it as root or with sudo.<br />
{{hc|changed-files.sh|<nowiki><br />
#!/bin/bash<br />
for package in /var/lib/pacman/local/*; do<br />
sed '/^%BACKUP%$/,/^%/!d' $package/files | tail -n+2 | grep -v '^$' | while read file hash; do<br />
[ "$(md5sum /$file | (read hash file; echo $hash))" != "$hash" ] && echo $(basename $package) /$file<br />
done<br />
done<br />
</nowiki>}}<br />
<br />
=== Listing all packages that nothing else depends on ===<br />
If you want to generate a list of all installed packages that nothing else depends on, you can use the following script. This is very helpful if you are trying to free hard drive space and have installed a lot of packages that you may not remember. You can browse through the output to find packages which you no longer need.<br />
<br />
{{hc|clean|<nowiki><br />
#!/bin/bash<br />
<br />
# This script is designed to help you clean your computer from unneeded<br />
# packages. The script will find all packages that no other installed package<br />
# depends on. It will output this list of packages excluding any you have<br />
# placed in the ignore list. You may browse through the script's output and<br />
# remove any packages you do not need.<br />
<br />
# Enter groups and packages here which you know you wish to keep. They will<br />
# not be included in the list of unrequired packages later.<br />
ignoregrp="base base-devel"<br />
ignorepkg=""<br />
<br />
# Temporary file locations<br />
tmpdir=/tmp<br />
ignored=$tmpdir/ignored<br />
installed=$tmpdir/installed<br />
<br />
# Generate list of installed packages and packages you wish to keep.<br />
echo $(pacman -Sg $ignoregrp | awk '{print $2}') $ignorepkg | tr ' ' '\n' | sort | uniq > $ignored<br />
pacman -Qq | sort > $installed<br />
<br />
# Do not loop packages you are keeping<br />
loop=$(comm -13 $ignored $installed)<br />
<br />
# Check each remaining package. If package is not required by anything and<br />
# is not on your ignore list, print the package name to the screen.<br />
for line in $loop; do<br />
check=$(pacman -Qi $line | awk '/Required By/ {print $4}')<br />
if [ "$check" == 'None' ]; then echo $line; fi<br />
done<br />
<br />
# Clean up $tmpdir<br />
rm $ignored $installed<br />
</nowiki>}}<br />
<br />
If you install {{pkg|expac}} you can run {{ic|<nowiki>expac "%n %N" -Q $(expac "%n %G" | grep -v ' base') | awk '$2 == "" {print $1}'</nowiki>}} which should give the same results but much faster.<br />
<br />
The following script has the option to exclude files like above, but uses expac:<br />
<br />
{{hc|clean|<nowiki><br />
#!/bin/bash<br />
<br />
# Generate list of installed packages (leaves in package dependency tree).<br />
# Give it a list with packages that should be ignored in the final list, each<br />
# package on a separate line.<br />
<br />
# Temporary files<br />
IGNORED=$(mktemp)<br />
[ -n "$1" ] && cat "$1" >$IGNORED<br />
LIST="$(mktemp)"<br />
<br />
expac "%n %N" -Q $(expac "%n %G" | grep -v ' base') | awk '$2 == "" {print $1}' > "$LIST"<br />
<br />
# Sort both lists, so they can be diffed.<br />
TMPF=$(mktemp)<br />
sort "$IGNORED" | grep -v '^$' > "$TMPF"<br />
sort -o "$LIST" "$LIST"<br />
IGNORED="$TMPF"<br />
# Diff the lists.<br />
comm -13 "$IGNORED" "$LIST"<br />
</nowiki>}}<br />
<br />
=== Backing up Local database with Systemd ===<br />
<br />
[https://wiki.archlinux.org/index.php/Systemd Systemd] can take snapshots of the pacman local database everytime it is modified.<br />
<br />
{{Note| There is a more configurable version in the AUR: {{AUR|pakbak-git}}}}<br />
{{Tip| Save the following script as {{ic|/usr/lib/systemd/scripts/pakbak_script}}.}}<br />
{{Note| Change the value of {{ic|$pakbak}} to modify where the backed up database is stored.}}<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
declare -r pakbak="/pakbak.tar.xz"; ## set backup location<br />
tar -cJf "$pakbak" "/var/lib/pacman/local"; ## compress & store pacman local database in $pakbak<br />
</nowiki>}}<br />
<br />
{{Tip|Save the following [https://wiki.archlinux.org/index.php/Systemd#Writing_custom_.service_files service file] as {{ic|/usr/lib/systemd/system/pakbak.service}}.}}<br />
{{bc|<nowiki><br />
[Unit]<br />
Description=Back up pacman database<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/bin/bash /usr/lib/systemd/scripts/pakbak_script<br />
RemainAfterExit=no<br />
</nowiki>}}<br />
<br />
{{Tip|Save the following [https://wiki.archlinux.org/index.php/Systemd#Writing_custom_.service_files path] file as {{ic|/usr/lib/systemd/system/pakbak.path}}.}}<br />
{{bc|<nowiki><br />
[Unit]<br />
Description=Back up pacman database<br />
<br />
[Path]<br />
PathChanged=/var/lib/pacman/local<br />
Unit=pakbak.service<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{Tip|To start the backup service :<br />
{{bc|<nowiki><br />
# systemctl start pakbak.path<br />
</nowiki>}}<br />
To enable the backup service automatically on reboot :<br />
{{bc|<nowiki><br />
# systemctl enable pakbak.path<br />
</nowiki>}}<br />
}}<br />
<br />
== Installation and recovery ==<br />
<br />
''Alternative ways of getting and restoring packages.''<br />
<br />
=== Installing packages from a CD/DVD or USB stick ===<br />
<br />
To download packages, or groups of packages:<br />
<br />
# cd ~/Packages<br />
# pacman -Syw base base-devel grub-bios xorg gimp --cachedir .<br />
# repo-add ./custom.db.tar.gz ./*<br />
<br />
Then you can burn the "Packages" folder to a CD/DVD or transfer it to a USB stick, external HDD, etc.<br />
<br />
To install:<br />
<br />
'''1.''' Mount the media:<br />
<br />
# mkdir /mnt/repo<br />
# mount /dev/sr0 /mnt/repo #For a CD/DVD.<br />
# mount /dev/sdxY /mnt/repo #For a USB stick.<br />
<br />
'''2.''' Edit {{ic|pacman.conf}} and add this repository ''before'' the other ones (e.g. extra, core, etc.). This is important. Don't just uncomment the one on the bottom. This way it ensures that the files from the CD/DVD/USB take precedence over those in the standard repositories:<br />
<br />
{{hc|# nano /etc/pacman.conf|2=<br />
[custom]<br />
SigLevel = PackageRequired<br />
Server = file:///mnt/repo/Packages}}<br />
<br />
'''3.''' Finally, synchronize the pacman database to be able to use the new repository:<br />
<br />
# pacman -Sy<br />
<br />
=== Custom local repository ===<br />
<br />
pacman 3 introduced a new script named {{ic|repo-add}} which makes generating a database for a personal repository much easier. Use {{ic|repo-add --help}} for more details on its usage.<br />
<br />
Simply store all of the built packages to be included in the repository in one directory, and execute the following command (where ''repo'' is the name of the custom repository):<br />
<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/*.pkg.tar.xz<br />
<br />
Note that when using {{ic|repo-add}}, the database and the packages do not need to be in the same directory. But when using pacman with that database, they should be together.<br />
<br />
To add a new package (and remove the old if it exists), run:<br />
<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/packagetoadd-1.0-1-i686.pkg.tar.xz<br />
<br />
{{Note|If there is a package that needs to be removed from the repository, read up on {{Ic|repo-remove}}.}}<br />
<br />
Once the local repository has been made, add the repository to {{ic|pacman.conf}}. The name of the {{ic|db.tar.gz}} file is the repository name. Reference it directly using a {{ic|file://}} url, or access it via FTP using ftp://localhost/path/to/directory.<br />
<br />
If willing, add the custom repository to the [[Unofficial user repositories|list of unofficial user repositories]], so that the community can benefit from it.<br />
<br />
=== Network shared pacman cache ===<br />
<br />
==== Read-only cache ====<br />
<br />
If you're looking for a quick and dirty solution, you can simply run a standalone webserver which other computers can use as a first mirror: {{ic|darkhttpd /var/cache/pacman/pkg}}. Just add this server at the top of your mirror list. Be aware that you might get a lot of 404 errors, due to cache misses, depending on what you do, but pacman will try the next (real) mirrors when that happens.<br />
<br />
==== Read-write cache ====<br />
<br />
{{Tip|See [http://xyne.archlinux.ca/projects/pacserve/ pacserve] for an alternative (and probably simpler) solution than what follows.}}<br />
<br />
In order to share packages between multiple computers, simply share {{ic|/var/cache/pacman/}} using any network-based mount protocol. This section shows how to use shfs or sshfs to share a package cache plus the related library-directories between multiple computers on the same local network. Keep in mind that a network shared cache can be slow depending on the file-system choice, among other factors.<br />
<br />
First, install any network-supporting filesystem; for example [[sshfs]], [[shfs]], ftpfs, [[smbfs]] or [[nfs]].<br />
<br />
{{Tip|To use sshfs or shfs, consider reading [[Using SSH Keys]].}}<br />
<br />
Then, to share the actual packages, mount {{ic|/var/cache/pacman/pkg}} from the server to {{ic|/var/cache/pacman/pkg}} on every client machine.<br />
<br />
To have shared package databases, mount {{ic|/var/lib/pacman/sync/{core,extra,testing,community} }} in the same way. Proceed to place the appropriate lines in {{ic|/etc/fstab}}.<br />
<br />
==== Preventing unwanted cache purges ====<br />
<br />
By default, {{Ic|pacman -Sc}} removes package tarballs from the cache that correspond to packages that are not installed on the machine the command was issued on. Because pacman cannot predict what packages are installed on all machines that share the cache, it will end up deleting files that should not be.<br />
<br />
To clean up the cache so that only ''outdated'' tarballs are deleted, add this entry in the {{ic|[options]}} section of {{ic|/etc/pacman.conf}}:<br />
<br />
CleanMethod = KeepCurrent<br />
<br />
=== Backing up and retrieving a list of installed packages ===<br />
<br />
It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation.<br />
<br />
* First, backup the current list of non-local packages:<br />
<br />
: $ pacman -Qqen > pkglist.txt<br />
<br />
* Store the {{ic|pkglist.txt}} on a USB key or other convenient medium or gist.github.com or Evernote, Dropbox, etc.<br />
<br />
* Copy the {{ic|pkglist.txt}} file to the new installation, and navigate to the directory containing it.<br />
<br />
* Issue the following command to install from the backup list:<br />
<br />
: # pacman -S $(< pkglist.txt)<br />
<br />
In the case you have a list which was not generated like mentioned above, there may be foreign packages in it (i.e. packages not belonging to any repos you have configured, or packages from the AUR).<br />
<br />
In such a case, you may still want to install all available packages from that list:<br />
<br />
# pacman -S --needed $(comm -12 <(pacman -Slq|sort) <(sort badpkdlist) )<br />
<br />
Explanation:<br />
<br />
* {{ic|pacman -Slq}} lists all available softwares, but the list is sorted by repository first, hence the {{ic|sort}} command.<br />
* Sorted files are required in order to make the {{ic|comm}} command work.<br />
* The {{ic|-12}} parameter display lines common to both entries.<br />
* The {{ic|--needed}} switch is used to skip already installed packages.<br />
<br />
You may also try to install all unavailable packages (those not in the repos) from the AUR using [[yaourt]] (not recommended unless you know exactly what you are doing):<br />
<br />
$ yaourt -S --needed $(comm -13 <(pacman -Slq|sort) <(sort badpkdlist) )<br />
<br />
Finally, you may want to remove all the packages on your system that are not mentioned in the list.<br />
<br />
{{Warning|Use this command wisely, and always check the result prompted by pacman.}}<br />
<br />
# pacman -Rsu $(comm -23 <(pacman -Qq|sort) <(sort pkglist))<br />
<br />
=== List downloaded packages that are not in base or base-devel ===<br />
<br />
The following command will list any installed packages that are not in base/base-devel, and as such were likely installed manually by the user:<br />
<br />
$ comm -23 <(pacman -Qeq|sort) <(pacman -Qgq base base-devel|sort)<br />
<br />
=== Reinstalling all packages ===<br />
To reinstall all native packages, use:<br />
<br />
# pacman -Qenq | pacman -S -<br />
<br />
Foreign (AUR) packages must be reinstalled separately; you can list them with {{ic|pacman -Qemq}}.<br />
<br />
Pacman preserves the installation reason by default.<br />
<br />
=== Restore pacman's local database ===<br />
<br />
Signs that pacman needs a local database restoration:<br />
<br />
* {{ic|pacman -Q}} gives absolutely no output, and {{Ic|pacman -Syu}} erroneously reports that the system is up to date.<br />
* When trying to install a package using {{ic|pacman -S package}}, and it outputs a list of already satisfied dependencies.<br />
* When {{ic|testdb}} (part of {{Pkg|pacman}}) reports database inconsistency.<br />
<br />
Most likely, pacman's database of installed software, {{ic|/var/lib/pacman/local}}, has been corrupted or deleted. While this is a serious problem, it can be restored by following the instructions below.<br />
<br />
Firstly, make sure pacman's log file is present:<br />
<br />
$ ls /var/log/pacman.log<br />
<br />
If it does not exist, it is ''not'' possible to continue with this method. You may be able to use [https://bbs.archlinux.org/viewtopic.php?pid=670876 Xyne's package detection script] to recreate the database. If not, then the likely solution is to re-install the entire system.<br />
<br />
==== Log filter script ====<br />
{{hc|pacrecover|<nowiki><br />
#!/bin/bash -e<br />
<br />
. /etc/makepkg.conf<br />
<br />
PKGCACHE=$((grep -m 1 '^CacheDir' /etc/pacman.conf || echo 'CacheDir = /var/cache/pacman/pkg') | sed 's/CacheDir = //')<br />
<br />
pkgdirs=("$@" "$PKGDEST" "$PKGCACHE")<br />
<br />
while read -r -a parampart; do<br />
pkgname="${parampart[0]}-${parampart[1]}-*.pkg.tar.xz"<br />
for pkgdir in ${pkgdirs[@]}; do<br />
pkgpath="$pkgdir"/$pkgname<br />
[ -f $pkgpath ] && { echo $pkgpath; break; };<br />
done || echo ${parampart[0]} 1>&2<br />
done<br />
</nowiki>}}<br />
<br />
Make the script executable:<br />
<br />
$ chmod +x pacrecover<br />
<br />
==== Generating the package recovery list ====<br />
<br />
{{Warning|If for some reason your [[pacman]] cache or [[makepkg]] package destination contain packages for other architectures, remove them before continuation.}}<br />
<br />
Run the script (optionally passing additional directories with packages as parameters):<br />
<br />
$ paclog-pkglist /var/log/pacman.log | ./pacrecover >files.list 2>pkglist.orig<br />
<br />
This way two files will be created: {{Ic|files.list}} with package files, still present on machine and {{Ic|pkglist.orig}}, packages from which should be downloaded. Later operation may result in mismatch between files of older versions of package, still present on machine, and files, found in new version. Such mismatches will have to be fixed manually.<br />
<br />
Here is a way to automatically restrict second list to packages available in a repository:<br />
<br />
$ { cat pkglist.orig; pacman -Slq; } | sort | uniq -d > pkglist<br />
<br />
Check if some important ''base'' package are missing, and add them to the list:<br />
<br />
$ comm -23 <(pacman -Sgq base) pkglist.orig >> pkglist<br />
<br />
Proceed once the contents of both lists are satisfactory, since they will be used to restore pacman's installed package database; {{ic|/var/lib/pacman/local/}}.<br />
<br />
==== Performing the recovery ====<br />
<br />
Define bash alias for recovery purposes:<br />
<br />
# recovery-pacman() {<br />
pacman "$@" \<br />
--log /dev/null \<br />
--noscriptlet \<br />
--dbonly \<br />
--force \<br />
--nodeps \<br />
--needed \<br />
#<br />
}<br />
<br />
{{ic|--log /dev/null}} allows to avoid needless pollution of pacman log, {{Ic|--needed}} will save some time by skipping packages, already present in database, {{Ic|--nodeps}} will allow installation of cached packages, even if packages being installed depend on newer versions. Rest of options will allow '''pacman''' to operate without reading/writing filesystem.<br />
<br />
Populate the sync database:<br />
<br />
# pacman -Sy<br />
<br />
Start database generation by installing locally available package files from {{ic|files.list}}:<br />
<br />
# recovery-pacman -U $(< files.list)<br />
<br />
Install the rest from {{ic|pkglist}}:<br />
<br />
# recovery-pacman -S $(< pkglist)<br />
<br />
Update the local database so that packages that are not required by any other package are marked as explicitly installed and the other as dependences. You will need be extra careful in the future when removing packages, but with the original database lost is the best we can do.<br />
<br />
# pacman -D --asdeps $(pacman -Qq)<br />
# pacman -D --asexplicit $(pacman -Qtq)<br />
<br />
Optionally check all installed packages for corruption:<br />
<br />
# pacman -Qk<br />
<br />
Optionally [[#Identify files not owned by any package]].<br />
<br />
Update all packages:<br />
<br />
# pacman -Su<br />
<br />
=== Recovering a USB key from existing install ===<br />
<br />
If you have Arch installed on a USB key and manage to mess it up (e.g. removing it while it is still being written to), then it is possible to re-install all the packages and hopefully get it back up and working again (assuming USB key is mounted in /newarch)<br />
<br />
# pacman -S $(pacman -Qq --dbpath /newarch/var/lib/pacman) --root /newarch --dbpath /newarch/var/lib/pacman<br />
<br />
=== Extracting contents of a .pkg file ===<br />
<br />
The {{ic|.pkg}} files ending in {{ic|.xz}} are simply tar'ed archives that can be decompressed with:<br />
<br />
$ tar xvf package.tar.xz<br />
<br />
If you want to extract a couple of files out of a {{ic|.pkg}} file, this would be a way to do it.<br />
<br />
=== Viewing a single file inside a .pkg file ===<br />
<br />
For example, if you want to see the contents of {{ic|/etc/conf.d/ntpd.conf}} supplied within the {{Pkg|ntp}} package:<br />
<br />
$ tar -xOf /var/cache/pacman/pkg/ntp-4.2.6.p5-6-i686.pkg.tar.xz etc/conf.d/ntpd.conf<br />
Or you can use vim, then browse the archive:<br />
$ vim /var/cache/pacman/pkg/ntp-4.2.6.p5-6-i686.pkg.tar.xz</div>*david a*https://wiki.archlinux.org/index.php?title=Pacman/Tips_and_tricks&diff=265583Pacman/Tips and tricks2013-07-09T18:50:14Z<p>*david a*: /* Configure the shell */ - clarified wording for pacupg</p>
<hr />
<div>[[Category:Package management]]<br />
[[es:Pacman Tips]]<br />
[[it:Pacman Tips]]<br />
[[ja:Pacman Tips]]<br />
[[ru:Pacman Tips]]<br />
[[tr:Pacman_ipuçları]]<br />
[[zh-CN:Pacman Tips]]<br />
{{Article summary start|Summary}}<br />
{{Article summary text|This is a collection of common tips for new pacman users.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|pacman}}<br />
{{Article summary wiki|Mirrors}}<br />
{{Article summary wiki|Creating Packages}}<br />
{{Article summary wiki|Custom local repository}}<br />
{{Article summary end}}<br />
<br />
== Cosmetic and Convienence ==<br />
<br />
=== Color output ===<br />
<br />
As of version 4.1, Pacman has a color option. Uncomment the "Color" line in {{ic|pacman.conf}}.<br />
<br />
=== Shortcuts ===<br />
<br />
The following instructions allow users to run some of the more common pacman commands without the need to type them fully via a script alias.<br />
<br />
==== Configure the shell ====<br />
<br />
Add the following examples, which work in both [[Bash]] and [[Zsh]]:<br />
{{bc|<nowiki> # Pacman alias examples<br />
alias pacupg='sudo pacman -Syu' # Synchronize with repositories and then upgrade packages that are out of date on the local system.<br />
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories<br />
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file <br />
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies<br />
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies<br />
alias pacrep='pacman -Si' # Display information about a given package in the repositories<br />
alias pacreps='pacman -Ss' # Search for package(s) in the repositories<br />
alias pacloc='pacman -Qi' # Display information about a given package in the local database<br />
alias paclocs='pacman -Qs' # Search for package(s) in the local database<br />
<br />
# Additional pacman alias examples<br />
alias pacupd='sudo pacman -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories<br />
alias pacinsd='sudo pacman -S --asdeps' # Install given package(s) as dependencies of another package<br />
alias pacmir='sudo pacman -Syy' # Force refresh of all package lists after updating /etc/pacman.d/mirrorlist<br />
</nowiki>}}<br />
<br />
==== Usage ====<br />
<br />
Perform the respective commands by simply typing the alias name. For example, to synchronize with repositories before upgrading packages that are out of date on the local system:<br />
$ pacupg<br />
Install packages from repositories:<br />
$ pacin <package1> <package2> <package3><br />
Install a custom built package:<br />
$ pacins /path/to/<package><br />
Completely remove a locally installed package:<br />
$ pacrem <package><br />
Search for available packages in the repositories:<br />
$ pacreps <keywords><br />
Display information about a package (e.g. size, dependencies) in the repositories:<br />
$ pacrep <keywords><br />
<br />
==== Notes ====<br />
<br />
The aliases used above are merely examples. By following the syntax samples above, rename the aliases as convenient. For example:<br />
<br />
alias pacrem='sudo pacman -Rns'<br />
alias pacout='sudo pacman -Rns'<br />
<br />
In the case above, the commands {{ic|pacrem}} and {{ic|pacout}} both call your shell to execute the same command.<br />
<br />
=== Operations and Bash syntax ===<br />
<br />
In addition to pacman's standard set of features, there are ways to extend its usability through rudimentary [[Bash]] commands/syntax.<br />
<br />
* To install a number of packages sharing similar patterns in their names -- not the entire group nor all matching packages; eg. {{Pkg|kde}}:<br />
<br />
# pacman -S kde-{applets,theme,tools}<br />
<br />
* Of course, that is not limited and can be expanded to however many levels needed:<br />
<br />
# pacman -S kde-{ui-{kde,kdemod},kdeartwork}<br />
<br />
* Sometimes, {{Ic|-s}}'s builtin ERE can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field:<br />
<br />
# pacman -Ss '^vim-'<br />
<br />
* pacman has the {{ic|-q}} operand to hide the version column, so it is possible to query and reinstall packages with "compiz" as part of their name:<br />
<br />
# pacman -S $(pacman -Qq | grep compiz)<br />
<br />
* Or install all packages available in a repository (kde-unstable for example):<br />
<br />
# pacman -S $(pacman -Slq kde-unstable)<br />
<br />
== Maintenance ==<br />
<br />
''House keeping, in the interest of keeping a clean system and following [[The Arch Way]]''<br />
<br />
=== Listing all installed packages with size ===<br />
<br />
* You may want to get the list of installed packages sorted by size, which may be useful when freeing space on your hard drive.<br />
* Use {{ic|pacsysclean}} from {{Pkg|pacman}} package.<br />
* Install {{Pkg|expac}} and run {{ic| <nowiki>expac -s "%-30n %m" | sort -rhk 2</nowiki>}}<br />
* Invoke pacgraph with the -c option to produce a list of all installed packages with their respective sizes on the system. {{Pkg|pacgraph}} is available from [community].<br />
* {{ic|<nowiki>pacman -Qi | egrep "Name|Installed Size" | sed -e 'N;s/\n/ /' | awk '{ print $7, $3}' | sort -n</nowiki>}} (note that some packages with "Name" in their descriptions will disrupt this (e.g. {{Pkg|idnkit}}))<br />
<br />
=== Listing installed packages with version ===<br />
<br />
* You may want to get the list of installed packages with their version, which is useful when reporting bugs or discussing installed packages.<br />
* List all explicitly installed packages: {{ic| pacman -Qe }}.<br />
* List all foreign packages (typically manually downloaded and installed): {{ic| pacman -Qm }}.<br />
* List all native packages (installed from the sync database(s)): {{ic| pacman -Qn }}.<br />
* List packages by regex: {{ic| <nowiki>pacman -Qs <regex> | awk 'BEGIN { RS="\n" ; FS="/" } { print $2 }' | awk '{ if(NF > 0) print $1, $2 }'</nowiki>}}<br />
* Install {{Pkg|expac}} and run {{ic| expac -s "%-30n %v"}}<br />
<br />
=== Identify files not owned by any package ===<br />
<br />
Periodic checks for files outside of pacman database are recommended. These files are often some 3rd party applications installed using the usual procedure (e.g. {{ic|./configure && make && make install}}). Search the file-system for these files (or symlinks) using this simple script:<br />
<br />
{{hc|pacman-disowned|<nowiki><br />
#!/bin/sh<br />
<br />
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$<br />
db=$tmp/db<br />
fs=$tmp/fs<br />
<br />
mkdir "$tmp"<br />
trap 'rm -rf "$tmp"' EXIT<br />
<br />
pacman -Qlq | sort -u > "$db"<br />
<br />
find /bin /etc /sbin /usr \<br />
! -name lost+found \<br />
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"<br />
<br />
comm -23 "$fs" "$db"</nowiki>}}<br />
<br />
To generate the list:<br />
<br />
$ pacman-disowned > non-db.txt<br />
<br />
Note that one should '''not''' delete all files listed in {{ic|non-db.txt}} without confirming each entry. There could be various configuration files, logs, etc., so use this list responsibly and only proceed after extensively searching for cross-references using {{Ic|grep}}.<br />
<br />
=== Removing orphaned packages ===<br />
<br />
For ''recursively'' removing orphans:<br />
<br />
{{bc|# pacman -Rs $(pacman -Qtdq)}}<br />
<br />
The following '''alias''' is easily inserted into {{ic|~/.bashrc}} and removes orphans if found:<br />
<br />
{{hc|~/.bashrc|<nowiki># '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq &gt; /dev/null &amp;&amp; sudo /usr/bin/pacman -Rs \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;\$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
The following '''function''' is easily inserted into {{ic|~/.bashrc}} and removes orphans if found:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
orphans() {<br />
if [[ ! -n $(pacman -Qdt) ]]; then<br />
echo "No orphans to remove."<br />
else<br />
sudo pacman -Rs $(pacman -Qdtq)<br />
fi<br />
}</nowiki>}}<br />
<br />
=== Removing everything but base group ===<br />
<br />
If it is ever necessary to remove all packages except the base group, try this one liner:<br />
<br />
# pacman -Rs $(comm -23 <(pacman -Qeq|sort) <((for i in $(pacman -Qqg base); do pactree -ul $i; done)|sort -u|cut -d ' ' -f 1))<br />
<br />
Source: [https://bbs.archlinux.org/viewtopic.php?id=130176 Look at discussion here]<br />
<br />
Notes:<br />
<br />
# {{ic|comm}} requires sorted input otherwise you get e.g. {{ic|comm: file 1 is not in sorted order}}.<br />
# {{ic|pactree}} prints the package name followed by what it provides. For example:<br />
<br />
{{hc|$ pactree -lu logrotate|<br />
logrotate<br />
popt<br />
glibc<br />
linux-api-headers<br />
tzdata<br />
dcron cron<br />
bash<br />
readline<br />
ncurses<br />
gzip}}<br />
<br />
The {{ic|dcron cron}} line seems to cause problems, that is why {{ic|cut -d ' ' -f 1}} is needed - to keep just the package name.<br />
<br />
=== Listing official installed packages only ===<br />
<br />
pacman -Qqn<br />
<br />
This list packages that are found in the sync database(s). If the user has unofficial repositories configured, it will list packages from such repositories too.<br />
<br />
=== Getting the dependencies list of several packages ===<br />
<br />
Dependencies are alphabetically sorted and doubles are removed.<br />
Note that you can use {{ic|pacman -Qi}} to improve response time a little. But<br />
you won't be able to query as many packages. Unfound packages are simply skipped<br />
(hence the {{ic|2>/dev/null}}).<br />
You can get dependencies of AUR packages as well if you use {{ic|yaourt -Si}},<br />
but it will slow down the queries.<br />
<br />
$ pacman -Si $@ 2>/dev/null | awk -F ": " -v filter="^Depends" \ '$0 ~ filter {gsub(/[>=<][^ ]*/,"",$2) ; gsub(/ +/,"\n",$2) ; print $2}' | sort -u<br />
<br />
Alternatively, you can use {{ic|expac}}: {{ic|expac -l '\n' %E -S $@ &#124; sort -u}}.<br />
<br />
=== Getting the size of several packages ===<br />
<br />
You can use (and tweak) this little shell function:<br />
<br />
{{hc|~/.bashrc|<nowiki><br />
pacman-size()<br />
{<br />
CMD="pacman -Si"<br />
SEP=": "<br />
TOTAL_SIZE=0<br />
<br />
RESULT=$(eval "${CMD} $@ 2>/dev/null" | awk -F "$SEP" -v filter="^Size" -v pkg="^Name" \<br />
'$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3)<br />
<br />
echo "$RESULT"<br />
<br />
## Print total size.<br />
echo "$RESULT" | awk '{TOTAL=$1+TOTAL} END {printf("Total : %d KiB\n",TOTAL)}'<br />
}</nowiki>}}<br />
<br />
As told for the dependencies list, you can use {{ic|pacman -Qi}} instead, but<br />
not [[yaourt]] since AUR's PKGBUILD do not have size information.<br />
<br />
A nice one-liner:<br />
<br />
$ pacman -Si "$@" 2>/dev/null | awk -F ": " -v filter="Size" -v pkg="Name" '$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | sort -u -k3 | tee >(awk '{TOTAL=$1+TOTAL} END {printf("Total : %d KiB\n",TOTAL)}')<br />
<br />
You should replace "$@" with packages, or put this line in a shell function.<br />
<br />
=== Listing changed configuration files ===<br />
If you want to backup your system configuration files you could copy all files in {{ic|/etc/}}, but usually you're only interested in the files that you have changed. In this case you want to list those changed configuration files, we can do this with the following command:<br />
# pacman -Qii | awk '/^MODIFIED/ {print $2}'<br />
The following script does the same. You need to run it as root or with sudo.<br />
{{hc|changed-files.sh|<nowiki><br />
#!/bin/bash<br />
for package in /var/lib/pacman/local/*; do<br />
sed '/^%BACKUP%$/,/^%/!d' $package/files | tail -n+2 | grep -v '^$' | while read file hash; do<br />
[ "$(md5sum /$file | (read hash file; echo $hash))" != "$hash" ] && echo $(basename $package) /$file<br />
done<br />
done<br />
</nowiki>}}<br />
<br />
=== Listing all packages that nothing else depends on ===<br />
If you want to generate a list of all installed packages that nothing else depends on, you can use the following script. This is very helpful if you are trying to free hard drive space and have installed a lot of packages that you may not remember. You can browse through the output to find packages which you no longer need.<br />
<br />
{{hc|clean|<nowiki><br />
#!/bin/bash<br />
<br />
# This script is designed to help you clean your computer from unneeded<br />
# packages. The script will find all packages that no other installed package<br />
# depends on. It will output this list of packages excluding any you have<br />
# placed in the ignore list. You may browse through the script's output and<br />
# remove any packages you do not need.<br />
<br />
# Enter groups and packages here which you know you wish to keep. They will<br />
# not be included in the list of unrequired packages later.<br />
ignoregrp="base base-devel"<br />
ignorepkg=""<br />
<br />
# Temporary file locations<br />
tmpdir=/tmp<br />
ignored=$tmpdir/ignored<br />
installed=$tmpdir/installed<br />
<br />
# Generate list of installed packages and packages you wish to keep.<br />
echo $(pacman -Sg $ignoregrp | awk '{print $2}') $ignorepkg | tr ' ' '\n' | sort | uniq > $ignored<br />
pacman -Qq | sort > $installed<br />
<br />
# Do not loop packages you are keeping<br />
loop=$(comm -13 $ignored $installed)<br />
<br />
# Check each remaining package. If package is not required by anything and<br />
# is not on your ignore list, print the package name to the screen.<br />
for line in $loop; do<br />
check=$(pacman -Qi $line | awk '/Required By/ {print $4}')<br />
if [ "$check" == 'None' ]; then echo $line; fi<br />
done<br />
<br />
# Clean up $tmpdir<br />
rm $ignored $installed<br />
</nowiki>}}<br />
<br />
If you install {{pkg|expac}} you can run {{ic|<nowiki>expac "%n %N" -Q $(expac "%n %G" | grep -v ' base') | awk '$2 == "" {print $1}'</nowiki>}} which should give the same results but much faster.<br />
<br />
The following script has the option to exclude files like above, but uses expac:<br />
<br />
{{hc|clean|<nowiki><br />
#!/bin/bash<br />
<br />
# Generate list of installed packages (leaves in package dependency tree).<br />
# Give it a list with packages that should be ignored in the final list, each<br />
# package on a separate line.<br />
<br />
# Temporary files<br />
IGNORED=$(mktemp)<br />
[ -n "$1" ] && cat "$1" >$IGNORED<br />
LIST="$(mktemp)"<br />
<br />
expac "%n %N" -Q $(expac "%n %G" | grep -v ' base') | awk '$2 == "" {print $1}' > "$LIST"<br />
<br />
# Sort both lists, so they can be diffed.<br />
TMPF=$(mktemp)<br />
sort "$IGNORED" | grep -v '^$' > "$TMPF"<br />
sort -o "$LIST" "$LIST"<br />
IGNORED="$TMPF"<br />
# Diff the lists.<br />
comm -13 "$IGNORED" "$LIST"<br />
</nowiki>}}<br />
<br />
=== Backing up Local database with Systemd ===<br />
<br />
[https://wiki.archlinux.org/index.php/Systemd Systemd] can take snapshots of the pacman local database everytime it is modified.<br />
<br />
{{Note| There is a more configurable version in the AUR: {{AUR|pakbak-git}}}}<br />
{{Tip| Save the following script as {{ic|/usr/lib/systemd/scripts/pakbak_script}}.}}<br />
{{Note| Change the value of {{ic|$pakbak}} to modify where the backed up database is stored.}}<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
<br />
declare -r pakbak="/pakbak.tar.xz"; ## set backup location<br />
tar -cJf "$pakbak" "/var/lib/pacman/local"; ## compress & store pacman local database in $pakbak<br />
</nowiki>}}<br />
<br />
{{Tip|Save the following [https://wiki.archlinux.org/index.php/Systemd#Writing_custom_.service_files service file] as {{ic|/usr/lib/systemd/system/pakbak.service}}.}}<br />
{{bc|<nowiki><br />
[Unit]<br />
Description=Back up pacman database<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/bin/bash /usr/lib/systemd/scripts/pakbak_script<br />
RemainAfterExit=no<br />
</nowiki>}}<br />
<br />
{{Tip|Save the following [https://wiki.archlinux.org/index.php/Systemd#Writing_custom_.service_files path] file as {{ic|/usr/lib/systemd/system/pakbak.path}}.}}<br />
{{bc|<nowiki><br />
[Unit]<br />
Description=Back up pacman database<br />
<br />
[Path]<br />
PathChanged=/var/lib/pacman/local<br />
Unit=pakbak.service<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
</nowiki>}}<br />
<br />
{{Tip|To start the backup service :<br />
{{bc|<nowiki><br />
# systemctl start pakbak.path<br />
</nowiki>}}<br />
To enable the backup service automatically on reboot :<br />
{{bc|<nowiki><br />
# systemctl enable pakbak.path<br />
</nowiki>}}<br />
}}<br />
<br />
== Installation and recovery ==<br />
<br />
''Alternative ways of getting and restoring packages.''<br />
<br />
=== Installing packages from a CD/DVD or USB stick ===<br />
<br />
To download packages, or groups of packages:<br />
<br />
# cd ~/Packages<br />
# pacman -Syw base base-devel grub-bios xorg gimp --cachedir .<br />
# repo-add ./custom.db.tar.gz ./*<br />
<br />
Then you can burn the "Packages" folder to a CD/DVD or transfer it to a USB stick, external HDD, etc.<br />
<br />
To install:<br />
<br />
'''1.''' Mount the media:<br />
<br />
# mkdir /mnt/repo<br />
# mount /dev/sr0 /mnt/repo #For a CD/DVD.<br />
# mount /dev/sdxY /mnt/repo #For a USB stick.<br />
<br />
'''2.''' Edit {{ic|pacman.conf}} and add this repository ''before'' the other ones (e.g. extra, core, etc.). This is important. Don't just uncomment the one on the bottom. This way it ensures that the files from the CD/DVD/USB take precedence over those in the standard repositories:<br />
<br />
{{hc|# nano /etc/pacman.conf|2=<br />
[custom]<br />
SigLevel = PackageRequired<br />
Server = file:///mnt/repo/Packages}}<br />
<br />
'''3.''' Finally, synchronize the pacman database to be able to use the new repository:<br />
<br />
# pacman -Sy<br />
<br />
=== Custom local repository ===<br />
<br />
pacman 3 introduced a new script named {{ic|repo-add}} which makes generating a database for a personal repository much easier. Use {{ic|repo-add --help}} for more details on its usage.<br />
<br />
Simply store all of the built packages to be included in the repository in one directory, and execute the following command (where ''repo'' is the name of the custom repository):<br />
<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/*.pkg.tar.xz<br />
<br />
Note that when using {{ic|repo-add}}, the database and the packages do not need to be in the same directory. But when using pacman with that database, they should be together.<br />
<br />
To add a new package (and remove the old if it exists), run:<br />
<br />
$ repo-add /path/to/repo.db.tar.gz /path/to/packagetoadd-1.0-1-i686.pkg.tar.xz<br />
<br />
{{Note|If there is a package that needs to be removed from the repository, read up on {{Ic|repo-remove}}.}}<br />
<br />
Once the local repository has been made, add the repository to {{ic|pacman.conf}}. The name of the {{ic|db.tar.gz}} file is the repository name. Reference it directly using a {{ic|file://}} url, or access it via FTP using ftp://localhost/path/to/directory.<br />
<br />
If willing, add the custom repository to the [[Unofficial user repositories|list of unofficial user repositories]], so that the community can benefit from it.<br />
<br />
=== Network shared pacman cache ===<br />
<br />
==== Read-only cache ====<br />
<br />
If you're looking for a quick and dirty solution, you can simply run a standalone webserver which other computers can use as a first mirror: {{ic|darkhttpd /var/cache/pacman/pkg}}. Just add this server at the top of your mirror list. Be aware that you might get a lot of 404 errors, due to cache misses, depending on what you do, but pacman will try the next (real) mirrors when that happens.<br />
<br />
==== Read-write cache ====<br />
<br />
{{Tip|See [http://xyne.archlinux.ca/projects/pacserve/ pacserve] for an alternative (and probably simpler) solution than what follows.}}<br />
<br />
In order to share packages between multiple computers, simply share {{ic|/var/cache/pacman/}} using any network-based mount protocol. This section shows how to use shfs or sshfs to share a package cache plus the related library-directories between multiple computers on the same local network. Keep in mind that a network shared cache can be slow depending on the file-system choice, among other factors.<br />
<br />
First, install any network-supporting filesystem; for example [[sshfs]], [[shfs]], ftpfs, [[smbfs]] or [[nfs]].<br />
<br />
{{Tip|To use sshfs or shfs, consider reading [[Using SSH Keys]].}}<br />
<br />
Then, to share the actual packages, mount {{ic|/var/cache/pacman/pkg}} from the server to {{ic|/var/cache/pacman/pkg}} on every client machine.<br />
<br />
To have shared package databases, mount {{ic|/var/lib/pacman/sync/{core,extra,testing,community} }} in the same way. Proceed to place the appropriate lines in {{ic|/etc/fstab}}.<br />
<br />
==== Preventing unwanted cache purges ====<br />
<br />
By default, {{Ic|pacman -Sc}} removes package tarballs from the cache that correspond to packages that are not installed on the machine the command was issued on. Because pacman cannot predict what packages are installed on all machines that share the cache, it will end up deleting files that should not be.<br />
<br />
To clean up the cache so that only ''outdated'' tarballs are deleted, add this entry in the {{ic|[options]}} section of {{ic|/etc/pacman.conf}}:<br />
<br />
CleanMethod = KeepCurrent<br />
<br />
=== Backing up and retrieving a list of installed packages ===<br />
<br />
It is good practice to keep periodic backups of all pacman-installed packages. In the event of a system crash which is unrecoverable by other means, pacman can then easily reinstall the very same packages onto a new installation.<br />
<br />
* First, backup the current list of non-local packages:<br />
<br />
: $ pacman -Qqen > pkglist.txt<br />
<br />
* Store the {{ic|pkglist.txt}} on a USB key or other convenient medium or gist.github.com or Evernote, Dropbox, etc.<br />
<br />
* Copy the {{ic|pkglist.txt}} file to the new installation, and navigate to the directory containing it.<br />
<br />
* Issue the following command to install from the backup list:<br />
<br />
: # pacman -S $(< pkglist.txt)<br />
<br />
In the case you have a list which was not generated like mentioned above, there may be foreign packages in it (i.e. packages not belonging to any repos you have configured, or packages from the AUR).<br />
<br />
In such a case, you may still want to install all available packages from that list:<br />
<br />
# pacman -S --needed $(comm -12 <(pacman -Slq|sort) <(sort badpkdlist) )<br />
<br />
Explanation:<br />
<br />
* {{ic|pacman -Slq}} lists all available softwares, but the list is sorted by repository first, hence the {{ic|sort}} command.<br />
* Sorted files are required in order to make the {{ic|comm}} command work.<br />
* The {{ic|-12}} parameter display lines common to both entries.<br />
* The {{ic|--needed}} switch is used to skip already installed packages.<br />
<br />
You may also try to install all unavailable packages (those not in the repos) from the AUR using [[yaourt]] (not recommended unless you know exactly what you are doing):<br />
<br />
$ yaourt -S --needed $(comm -13 <(pacman -Slq|sort) <(sort badpkdlist) )<br />
<br />
Finally, you may want to remove all the packages on your system that are not mentioned in the list.<br />
<br />
{{Warning|Use this command wisely, and always check the result prompted by pacman.}}<br />
<br />
# pacman -Rsu $(comm -23 <(pacman -Qq|sort) <(sort pkglist))<br />
<br />
=== List downloaded packages that are not in base or base-devel ===<br />
<br />
The following command will list any installed packages that are not in base/base-devel, and as such were likely installed manually by the user:<br />
<br />
$ comm -23 <(pacman -Qeq|sort) <(pacman -Qgq base base-devel|sort)<br />
<br />
=== Reinstalling all packages ===<br />
To reinstall all native packages, use:<br />
<br />
# pacman -Qenq | pacman -S -<br />
<br />
Foreign (AUR) packages must be reinstalled separately; you can list them with {{ic|pacman -Qemq}}.<br />
<br />
Pacman preserves the installation reason by default.<br />
<br />
=== Restore pacman's local database ===<br />
<br />
Signs that pacman needs a local database restoration:<br />
<br />
* {{ic|pacman -Q}} gives absolutely no output, and {{Ic|pacman -Syu}} erroneously reports that the system is up to date.<br />
* When trying to install a package using {{ic|pacman -S package}}, and it outputs a list of already satisfied dependencies.<br />
* When {{ic|testdb}} (part of {{Pkg|pacman}}) reports database inconsistency.<br />
<br />
Most likely, pacman's database of installed software, {{ic|/var/lib/pacman/local}}, has been corrupted or deleted. While this is a serious problem, it can be restored by following the instructions below.<br />
<br />
Firstly, make sure pacman's log file is present:<br />
<br />
$ ls /var/log/pacman.log<br />
<br />
If it does not exist, it is ''not'' possible to continue with this method. You may be able to use [https://bbs.archlinux.org/viewtopic.php?pid=670876 Xyne's package detection script] to recreate the database. If not, then the likely solution is to re-install the entire system.<br />
<br />
==== Log filter script ====<br />
{{hc|pacrecover|<nowiki><br />
#!/bin/bash -e<br />
<br />
. /etc/makepkg.conf<br />
<br />
PKGCACHE=$((grep -m 1 '^CacheDir' /etc/pacman.conf || echo 'CacheDir = /var/cache/pacman/pkg') | sed 's/CacheDir = //')<br />
<br />
pkgdirs=("$@" "$PKGDEST" "$PKGCACHE")<br />
<br />
while read -r -a parampart; do<br />
pkgname="${parampart[0]}-${parampart[1]}-*.pkg.tar.xz"<br />
for pkgdir in ${pkgdirs[@]}; do<br />
pkgpath="$pkgdir"/$pkgname<br />
[ -f $pkgpath ] && { echo $pkgpath; break; };<br />
done || echo ${parampart[0]} 1>&2<br />
done<br />
</nowiki>}}<br />
<br />
Make the script executable:<br />
<br />
$ chmod +x pacrecover<br />
<br />
==== Generating the package recovery list ====<br />
<br />
{{Warning|If for some reason your [[pacman]] cache or [[makepkg]] package destination contain packages for other architectures, remove them before continuation.}}<br />
<br />
Run the script (optionally passing additional directories with packages as parameters):<br />
<br />
$ paclog-pkglist /var/log/pacman.log | ./pacrecover >files.list 2>pkglist.orig<br />
<br />
This way two files will be created: {{Ic|files.list}} with package files, still present on machine and {{Ic|pkglist.orig}}, packages from which should be downloaded. Later operation may result in mismatch between files of older versions of package, still present on machine, and files, found in new version. Such mismatches will have to be fixed manually.<br />
<br />
Here is a way to automatically restrict second list to packages available in a repository:<br />
<br />
$ { cat pkglist.orig; pacman -Slq; } | sort | uniq -d > pkglist<br />
<br />
Check if some important ''base'' package are missing, and add them to the list:<br />
<br />
$ comm -23 <(pacman -Sgq base) pkglist.orig >> pkglist<br />
<br />
Proceed once the contents of both lists are satisfactory, since they will be used to restore pacman's installed package database; {{ic|/var/lib/pacman/local/}}.<br />
<br />
==== Performing the recovery ====<br />
<br />
Define bash alias for recovery purposes:<br />
<br />
# recovery-pacman() {<br />
pacman "$@" \<br />
--log /dev/null \<br />
--noscriptlet \<br />
--dbonly \<br />
--force \<br />
--nodeps \<br />
--needed \<br />
#<br />
}<br />
<br />
{{ic|--log /dev/null}} allows to avoid needless pollution of pacman log, {{Ic|--needed}} will save some time by skipping packages, already present in database, {{Ic|--nodeps}} will allow installation of cached packages, even if packages being installed depend on newer versions. Rest of options will allow '''pacman''' to operate without reading/writing filesystem.<br />
<br />
Populate the sync database:<br />
<br />
# pacman -Sy<br />
<br />
Start database generation by installing locally available package files from {{ic|files.list}}:<br />
<br />
# recovery-pacman -U $(< files.list)<br />
<br />
Install the rest from {{ic|pkglist}}:<br />
<br />
# recovery-pacman -S $(< pkglist)<br />
<br />
Update the local database so that packages that are not required by any other package are marked as explicitly installed and the other as dependences. You will need be extra careful in the future when removing packages, but with the original database lost is the best we can do.<br />
<br />
# pacman -D --asdeps $(pacman -Qq)<br />
# pacman -D --asexplicit $(pacman -Qtq)<br />
<br />
Optionally check all installed packages for corruption:<br />
<br />
# pacman -Qk<br />
<br />
Optionally [[#Identify files not owned by any package]].<br />
<br />
Update all packages:<br />
<br />
# pacman -Su<br />
<br />
=== Recovering a USB key from existing install ===<br />
<br />
If you have Arch installed on a USB key and manage to mess it up (e.g. removing it while it is still being written to), then it is possible to re-install all the packages and hopefully get it back up and working again (assuming USB key is mounted in /newarch)<br />
<br />
# pacman -S $(pacman -Qq --dbpath /newarch/var/lib/pacman) --root /newarch --dbpath /newarch/var/lib/pacman<br />
<br />
=== Extracting contents of a .pkg file ===<br />
<br />
The {{ic|.pkg}} files ending in {{ic|.xz}} are simply tar'ed archives that can be decompressed with:<br />
<br />
$ tar xvf package.tar.xz<br />
<br />
If you want to extract a couple of files out of a {{ic|.pkg}} file, this would be a way to do it.<br />
<br />
=== Viewing a single file inside a .pkg file ===<br />
<br />
For example, if you want to see the contents of {{ic|/etc/conf.d/ntpd.conf}} supplied within the {{Pkg|ntp}} package:<br />
<br />
$ tar -xOf /var/cache/pacman/pkg/ntp-4.2.6.p5-6-i686.pkg.tar.xz etc/conf.d/ntpd.conf<br />
Or you can use vim, then browse the archive:<br />
$ vim /var/cache/pacman/pkg/ntp-4.2.6.p5-6-i686.pkg.tar.xz</div>*david a*https://wiki.archlinux.org/index.php?title=Talk:LXDE&diff=76799Talk:LXDE2009-09-29T15:00:49Z<p>*david a*: </p>
<hr />
<div>This page seems out of date or incomplete. LXDE requires a window manager, and currently none is automatically pulled in by the lxde package. The pacman command should probably be: 'pacman -Sy openbox lxde gamin' -- but I haven't tested that to see if it works. Alternatively, a section describing the alternative window managers that can be used with LXDE and how to install them should be added.<br />
<br />
(For now, added a note clarifying the fact that some window manager will have to be installed for LXDE to work. Agreed that a more extensive re-write of this page might be better, but I'll leave that for somebody who knows LXDE better than I do.)</div>*david a*https://wiki.archlinux.org/index.php?title=LXDE&diff=76764LXDE2009-09-29T06:08:23Z<p>*david a*: /* How to Install LXDE */</p>
<hr />
<div>[[Category:Desktop environments (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|LXDE}}<br />
{{i18n_entry|简体中文|LXDE (简体中文)}}<br />
{{i18n_entry|Español|LXDE (Español)}}<br />
{{i18n_entry|Italiano|LXDE (italiano)}}<br />
{{i18n_links_end}}<br />
<br />
== What is LXDE? ==<br />
LXDE is the abbreviation for '''L'''ightweight '''X'''11 '''D'''esktop '''E'''nvironment. ''LX'' also stands for ''L''inu''X''. You will find it different from other desktop environments, due to its discrete components, which can be used independently and with few dependencies. <br />
<br />
The LXDE project aims to provide a desktop environment which is intuitive, lightweight and useful, while also keeping system resource demands low. Development focuses on a balance of usability, speed, and memory usage.<br />
<br />
== Why should I use LXDE? ==<br />
LXDE has number of advantages and excellent features:<br />
* '''Lightweight''', runs with reasonable memory usage (After X11 and LXDE are started, the total memory usage is about 45 MB on i386 machines.)<br />
* '''Fast''', runs well even on older machines produced in 1999 (The hardware requirements of LXDE is similar to Windows 98)<br />
* '''Good-looking''', gtk+ 2 internationalized user interface<br />
* '''Easy-to-use''', the user interface is simple, intuitive and functional.<br />
* '''Desktop independent''' (Yes! Every component ''can be used without LXDE'')<br />
* '''Standards compliant''', follows the specs on freedesktop.org<br />
* '''Suitable for old machines''' ( Though LXDE itself has low hardware requirements, other X applications have higher resource demands. For example, Firefox and OpenOffice.org 2 are quite memory-hungry. It is therefore recommended that you have more than 128 MB RAM.)<br />
<br />
== What components does it contain? ==<br />
* '''[[PCManFM]]''': File manager, provides desktop icon and wallpaper.<br />
* '''[http://www.gnomefiles.org/app.php/LXPanel LXPanel]''': Feature-rich desktop panel (if you have problems with this version, use lxpanel-svn from aur)<br />
* '''[http://www.gnomefiles.org/app.php/LXSession LXSession]''': Standard-compliant X11 session manager with shutdown/reboot/suspend supports via HAL and gdm <br />
: (There are some bugs in lxsession related to session management. '''''lxsession-lite''''' is a version of lxsession which does not have the session management capability. The stability of lxsession-lite is better than lxsession, however it can not save and restore sessions. Thus it is recommended to use '''''lxsession-lite''''' till the problems in lxsession are fixed.)<br />
* '''[http://www.gnomefiles.org/app.php/LXAppearance LXAppearance]''': LXAppearance is a new feature-rich GTK+ theme switcher able to change GTK+ themes, icon themes, and fonts used by applications<br />
* '''[http://icculus.org/openbox/index.php/Main_Page Openbox]''': Lightweight, standard-compliant, and highly-configurable window manager (This is not developed by LXDE Project, but it's used as default window manager). This can be replaced by any other window manager like icewm, fluxbox, metacity, ...etc.<br />
* '''[http://lxde.sourceforge.net/gpicview/ GPicView]''': A very simple, fast, and lightweight image viewer featuring immediate startup.<br />
* '''[http://tarot.freeshell.org/leafpad/ Leafpad]''': Lightweight and simple text editor(This is not developed by LXDE Project, but it's suggested as the default text editor).<br />
* '''[http://xarchiver.xfce.org/ XArchiver]''': Lightweight, fast, and desktop-independent gtk+-based file archiver (This is not developed by LXDE Project, but you are suggested to use this as default archiver).<br />
* '''[http://lxde.sourceforge.net/about.html LXNM]''' (Still under development. Available through AUR): Lightweight network manager for LXDE supporting wireless connections (Linux-only)<br />
<br />
== How to Install LXDE ==<br />
LXDE is modular. You can pick and choose packages listed above, all of which can be grabbed via Pacman. (Ensure the [extra] and [community] repositories are enabled). For some packages, like LXNM, you might also need to utilize the [[AUR]] repository. <br />
<br />
The minimal obligatory packages which you have to install to run LXDE are Lxde-common, Lxsession, Openbox, and desktop-file-utils. The Openbox package can be replaced by any Window Manager you prefer.<br />
<br />
{{Box Note |Openbox is currently '''not''' automatically installed along with LXDE - you will need to install Openbox, or another window manager of your choice. (LXDE will of course not work properly if there is no window manager.)}}<br />
<br />
Install LXDE base packages:<br />
<br />
# pacman -Sy lxde gamin<br />
<br />
{{Box Note |Gamin conflicts with fam, so it will be uninstalled if you have it. The above command is generally safe because gamin 'provides fam' itself, so pacman will ask if it should replace fam. Don't worry about your package dependencies. For more information, see the [[gamin]] wiki page. After you removed fam, don't forget to remove it from the DAEMON list in /etc/rc.conf.}}<br />
<br />
This will install the following packages:<br />
<br />
# pacman -Sg lxde<br />
lxde gpicview<br />
lxde lxappearance<br />
lxde lxde-common<br />
lxde lxlauncher<br />
lxde lxpanel<br />
lxde lxrandr<br />
lxde lxsession-lite<br />
lxde lxtask<br />
lxde lxterminal<br />
lxde pcmanfm<br />
gamin<br />
<br />
Gamin is a file and directory monitoring system defined to be a subset of the FAM. However, it doesn't require a system-wide daemon running with root. It runs as general users on demand, so '''no''' manual configuration is needed. Don't add it to the DAEMON list in /etc/rc.conf.<br />
<br />
<br />
See: http://wiki.lxde.org/en/ArchLinux<br />
<br />
Other packages you may want are: leafpad, the default text editor for LXDE and obconf, a tool for changing openbox themes.<br />
<br />
== Running LXDE ==<br />
* If you are using display managers like [[GDM]] or [[KDM]], you should be able to select LXDE directly.<br />
* If you have an issue with [[KDM]] You will need to copy /usr/share/xsessions/LXDE.desktop to /usr/share/apps/kdm/sessions/LXDE.desktop. This will then allow LXDE as a login option with KDM.<br />
* If you don't have display manager, and want to start lxde from the shell using ''startx'' or ''xinit'', add this line at the end of ~/.xinitrc:<br />
exec startlxde<br />
The ~/.xinitrc file might not be present in a fresh install. In this case just create a new one with your favorite editor containing this line.<br />
* If your system runs a newer [[HAL]] version which uses consolekit/policykit capabilities, you may want to utilize a console kit session to start LXDE. Just put ck-launch-session before startlxde:<br />
* The following command is one way to help ensure that '''nm-applet''' is properly loaded.<br />
exec ck-launch-session startlxde<br />
in your ~/.xinitrc file. This solves some logout problems you might experience otherwise.<br />
* If you want to start LXDE directly from the command line without fixing the start instructions in ~/.xinitrc (useful if you want to interactively select between Window Managers/Desktop Environments without using a display manager) use this command ($ representing the bash user prompt):<br />
$ xinit /usr/bin/startlxde<br />
You will need the fully qualified path if there is a default "exec start-some-WM/DE" in your ~/.xinitrc already. Otherwise the system will probably want to start the session in ~/.xinitrc instead.<br />
<br />
It is certainly possible to start a console kit session from the command line as well:<br />
$ xinit /usr/bin/ck-launch-session startlxde<br />
* If you want to run ''startx'' at boot without user intervention, take a look at the [[Start X at boot#Starting X as preferred user without logging in | starting X at boot]] guide.<br />
<br />
== Tips ==<br />
=== Auto Mount === <br />
If you want a removable usb disk to mount automatically by [[PCManFM]], you must install [[HAL]] and add users to hal group. pmount is required for mounting removable devices without root access <br />
<br />
If your removable disk has an NTFS filesystem, you should install [[NTFS Write Support|NTFS-3G]] as well. <br />
Generally, PCManFM works well with [[HAL]]. Currently, there is one bug affecting NTFS users; If you have files or folders on an NTFS filesystem, the names of which contain non-latin characters (ie: Chinese Characters), the files or folders may disappear when opening (or automounting) the NTFS volume. This happens because the lxsession (or lxsession-lite) mounthelper is not correctly parsing the policies and locale option. There is a workaround for this: <br />
<br />
1) Remove the "/sbin/mount.ntfs-3g" which is a symlink. <br />
rm /sbin/mount.ntfs-3g<br />
2) Create a new "/sbin/mount.ntfs-3g" with a new bash script containing: <br />
#!/bin/bash<br />
/bin/ntfs-3g $1 $2 -o locale=en_US.UTF-8<br />
3) Make it executable: <br />
chmod +x /sbin/mount.ntfs-3g <br />
4) Add "NoUpgrade = sbin/mount.ntfs-3g" to pacman.conf under the "[options]"<br />
<br />
=== Autostart Programs ===<br />
The default '''system-wide''' startup config files can be found at /etc/xdg/lxsession/LXDE/autostart. If you choose to edit the autostart programs for '''all users''' you can Open the file /etc/xdg/lxsession/LXDE/autostart with a text editor and add the name of the program(s) you want to start at login.<br />
<br />
The system-wide autostart file can also be overridden by '''user-specific''' ones. If custom user specific config files are found in ~/.config/lxsession, the ones in /etc/xdg/lxsession will be overridden.<br />
<br />
Another way to start programs on session startup is to add their *.desktop<br />
files in ~/.config/autostart.<br />
<br />
=== Digital Clock Applet Settings ===<br />
You can find a manual with a complete list of options (and explainations) [http://tcl.activestate.com/man/tcl8.3/TclCmd/clock.htm here]<br />
<br />
=== lxpanel Add Launcher (application) ===<br />
lxpanel comes with a launcher applet by default and all you need to do to add new apps to it is:<br />
<br />
# Make sure launch bar applet is enabled: <br />
#*1a. right click the panel<br />
#*1b. select "add/remove panel items"<br />
#*1c. make sure "application launch bar" is listed (if it's not, select "add" and add it)<br />
# Right click anywhere on the launch bar applet<br />
# Choose "application launch bar settings"<br />
# Choose "add"<br />
# Direct it to the .desktop file of whatever application you want to add (found in usr/share/applications)<br />
<br />
=== lxpanel Add Launcher (location) ===<br />
To add a launcher to a specific location such as a media hard drive or folder you need to create a .desktop file and save it in /usr/share/applications. You can then add it the same way as adding an application to the panel.<br />
<br />
Here is a custom .desktop file as an example, edit lines "Exec" and "Icon" as needed:<br />
<br />
[Desktop Entry]<br />
Version=1.0<br />
Encoding=UTF-8<br />
Name=media<br />
Exec=pcmanfm /mnt/xbox (basically you're telling pcmanfm to open a specific location - /mnt/xbox in this case)<br />
Icon=xbmc.png (this should be the name of an icon in /usr/share/pixmaps)<br />
Terminal=false<br />
X-MultipleArgs=false<br />
Type=Application<br />
Categories=Application<br />
StartupNotify=true<br />
<br />
=== lxpanel Icons ===<br />
Default icons used by lxpanel are stored in /usr/share/pixmaps and any custom icons you want lxpanel to use need to be saved there as well. <br />
<br />
You can change default icons for applications by taking the following steps:<br />
# Save the new icon to /usr/share/pixmaps <br />
# Use a text editor to open the .desktop file of the program whose icon you want to change (.desktop files can be found in /usr/share/applications)<br />
# Change <br />
Icon=/default/icon/.png <br />
to <br />
Icon=/name/of/new/icon/added/to/pixmaps/.png<br />
<br />
=== Replace Window Manager === <br />
OpenBox, the default window manager of LXDE, can be easily replaced by any one you like, such as fvwm, icewm, dwm and awesome... etc.. <br />
<br />
The window manager LXDE will attempt to use is defined this file:<br />
::/etc/xdg/lxsession/LXDE/config<br />
Per default this is defined as<br />
[Session]<br />
window_manager=openbox-lxde<br />
Replace openbox-lxde with the window manager of your choice.<br />
<br />
It might be also worth looking at:<br />
::/etc/xdg/lxsession/LXDE/default<br />
<br />
These default settings however appear to be deprecated, as there is this note in the file:<br />
! This file is kept for backward compatibility.<br />
! Only used by obsolete lxsession, not lxsession-lite.<br />
<br />
Anyhow, for example, somebody's /etc/xdg/lxsession/LXDE/default looks like this:<br />
smproxy<br />
openbox<br />
lxpanel<br />
smproxy is a program provided in xorg. It provides session management support for programs which don't know X11 R6 session management protocol.<br />
It is highly recommended you include this line in your desktop.<br />
<br />
=== Shutdown and Reboot from LXDE ===<br />
To be able to shutdown, reboot, suspend and so on from lxde make sure that DBus and HAL are running. Then add your user to the power group. <br />
<br />
# gpasswd -a <USERNAME> power<br />
<br />
If you still encounter problems, add inbetween the <config></config> tags in /etc/PolicyKit/PolicyKit.conf the folowing lines:<br />
<br />
<match action="org.freedesktop.hal.power-management.shutdown"><br />
<return result="yes"/><br />
</match><br />
<match action="org.freedesktop.hal.power-management.reboot"><br />
<return result="yes"/><br />
</match><br />
Restart HAL and watch it work!<br />
<br />
=== Using KDEmod3 applications under LXDE ===<br />
<br />
As older versions of KDEmod[-legacy] are still installed under /opt/kde/bin, they are not automatically recognized by LXDE. To use them, you can either edit your PATH with the following command:<br />
echo 'PATH=$PATH:/opt/kde/bin' >> /etc/rc.local<br />
or you can add the following script to /etc/profile.d:<br />
#!/bin/sh<br />
PATH=$PATH:/opt/kde/bin<br />
Save it as "kde3path.sh" and make it executable:<br />
chmod +x /etc/profile.d/kde3path.sh<br />
<br />
== External Resources ==<br />
* [http://lxde.sourceforge.net LXDE Project]<br />
* [http://forum.lxde.org LXDE Forum]<br />
* [https://sourceforge.net/project/showfiles.php?group_id=180858 The Latest LX... Packages]<br />
* [https://sourceforge.net/project/showfiles.php?group_id=156956 PCMan File Manager]</div>*david a*