What to do if you have /tmp mounted with noexec, /boot available only on reboot and you want no problems when running the package management (apt-get, aptitude)?
The solution is pretty simple; you just have to populate /etc/apt/apt.conf
with the following:
core:~# cat /etc/apt/apt.conf DPkg { Pre-Invoke { "mount /tmp -o remount,exec;mount /boot" }; Post-Invoke { "mount /tmp -o remount,noexec;umount /boot" }; };
How to install the same debian packages on another system
With dpkg
and apt-get
:
1. Bacup on the source: source# dpkg --get-selections > /tmp/dpkg.log
;
2. Transfer the file dpkg.log
to the target system;
3. Run this on the target machine:
target# dpkg --set-selections < /tmp/dpkg.log target# apt-get -y update target# apt-get dselect-upgrade
With aptitude
:
1. Backup on the source: source# aptitude search -F '%100p' '~i!~M' > dpkg.log
;
2. Transfer the file dpkg.log
to the target system;
3. Run this on the target machine: target# xargs aptitude --schedule-only install < dpkg.log; aptitude install;
.
PS: if during the process you want to customize a bit the installation by editing dpkg.log, you have to flush the aptitude schedule with aptitude keep-all
command.
Debian apt-get NO_PUBKEY / GPG error
pm:/etc/apt# aptitude update [...] Fetched 168kB in 2s (60.7kB/s) Reading package lists... Done W: GPG error: http://ftp.debian.org squeeze-proposed-updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY [color=red]8B48AD6246925553[/color] W: You may want to run apt-get update to correct these problems
the fix:
pm:/etc/apt# gpg --keyserver pgpkeys.mit.edu --recv-key [color=red]8B48AD6246925553[/color] gpg: directory `/root/.gnupg' created gpg: new configuration file `/root/.gnupg/gpg.conf' created gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run gpg: keyring `/root/.gnupg/secring.gpg' created gpg: keyring `/root/.gnupg/pubring.gpg' created gpg: requesting key 46925553 from hkp server pgpkeys.mit.edu gpg: /root/.gnupg/trustdb.gpg: trustdb created gpg: key 46925553: public key "Debian Archive Automatic Signing Key (7.0/wheezy) <ftpmaster@debian.org>" imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) pm:/etc/apt# gpg -a --export [color=red]8B48AD6246925553[/color] | sudo apt-key add - OK
How to reconfigure time zone:
# dpkg-reconfigure tzdata
How to check to which package a file belongs:
jupiter:~# dpkg -S /usr/bin/iostat sysstat: /usr/bin/iostat
How to clean up Debian installation. In other words, remove unused packages and keep only what you really need:
NOTE: please pay attention, you may break your system if you do not know what you remove.
1. Mark all packages as automatically installed except those you do not need anymore. If the package is still needed will be marked automatically but if not, you must step in and choose to remove or keep it. The command [core]aptitude show[/code] will give you a bit of info about the package. Afterwards, you will be moved to the next one and so on up to the end. It can take some time, depending of how many packages you have installed.
for deb in $(aptitude search ~i | grep -v "i A" | cut -d " " -f 4) ; do aptitude show $deb ; echo "-= $deb marked as auto =-" ; aptitude markauto $deb; done
2. After uninstall, you can remove the configuration files too but please be careful to make a backup before (just in case, if you will ever need those configurations again):
for deb in $(dpkg -l | grep ^rc | cut -d " " -f 3) ; do dpkg -P $deb ; done
How to get the package name that provides a file
Let's say you have git executable which is /usr/bin/git and you want to see which package installed it.
In the example below, first command gives you the package and the second shows you the installed packages with git in the name. It is not necessary but just for the fun of it.
21:24:23 [root@pluto mysql]# dpkg -S /usr/bin/git git: /usr/bin/git 21:24:29 [root@pluto mysql]# aptitude search git | grep ^i i git - fast, scalable, distributed revision contr i A git-man - fast, scalable, distributed revision contr
How to list 3rd party software
root@sonic:~# aptitude search '~o'