this is obsolete doc -- see http://doc.nethence.com/ instead

Debian / Ubuntu Server notes 

 

Enable FTP on Ubuntu Server, 

apt install vsftpd
cd /etc/
cp vsftpd.conf vsftpd.conf.dist
vi vsftpd.conf
anonymous_enable=YES
write_enable=YES
anon_upload_enable=YES
systemctl restart vsftpd

Note. no need to change ftp account's shell (/bin/false), it works anyway 

 

Post-installation 

Basically: 

- network config & remote access 

- apt full-upgrade + ksh screen wget lftp curl mc & screen config 

 

During the installation for ubuntu server, make sure OpenSSH server is checked. 

 

Get a temporary IP just to remote log in, 

sudo su -
ifconfig -a
ps aux | grep dhclient
#dhclient eth0

Note. dhclient is running by default on ubuntu and ubuntu server. 

 

Remote log in by SSH and, 

sudo su -

 

Configure the network, 

cd /etc/network/
cp interfaces interfaces.dist
vi interfaces
auto eth0
#iface eno16777984 inet static
iface eth0 inet static
        address 10.0.x.x
        netmask 255.255.x.0
        gateway 10.0.0.X
        dns-search example.local
        dns-nameservers DNS1 DNS2 DNS3

 

Eventually disable the firewall (ubuntu srv), 

ufw disable

 

Eventually send your SSH public key for easy root access. 

 

Eventually install a few packages, 

apt-get update
apt-cache search ksh
apt-get install \
screen \
ksh

and setup gnu screen, 

cd /etc/
mv screenrc screenrc.dist
wget http://pbraun.nethence.com/configs/misc/screenrc
cd ~/
wget http://pbraun.nethence.com/configs/misc/.screenrc
screen

 

Eventually install the community maintained vmware tools and make sure those are enabled, 

apt-get install open-vm-tools
/etc/init.d/open-vm-tools restart

note. if you get this error on Squeeze, 

 vmmemctlFATAL: Module vmmemctl not found.
 vmsyncFATAL: Module vmsync not found.

build the modules for your running kernel, 

uname -r
module-assistant auto-install open-vm -i
/etc/init.d/open-vm-tools restart

Refs. 

http://www.surlyjake.com/blog/2011/02/08/install-open-vm-tools-on-debian-6-squeeze/ 

http://www.vsysad.com/2014/02/install-open-vm-tools-on-debian-6-squeeze/ 

 

Eventually disable portmap and other services if not used. 

 

Add a few aliases to .bashrc, 

case "$-" in *i*)
        alias ll='ls -alkF'
        alias rm='rm -i'
        alias cp='cp -i'
        alias mv='mv -i'
        ;;
esac

 

Fix the locales, 

#dpkg-reconfigure locales
locale-gen
locale-gen C.UTF-8
#locale-gen en_US.UTF-8
vi /etc/default/locale
LANG=C.UTF-8
#LANG=en_US.UTF-8
#LC_MESSAGES=POSIX
dpkg-reconfigure locales
#apt-get install language-env
#set-language-env
vi ~/.pam_environment
LANG=C.UTF-8
#LANG=en_US.UTF-8
#LANGUAGE="en_US:en"

refs. 

https://help.ubuntu.com/community/Locale 

https://www.thomas-krenn.com/en/wiki/Configure_Locales_in_Ubuntu 

http://www.quennec.fr/trucs-astuces/syst%C3%A8mes/gnulinux/commandes/ubuntu-server/locale-fran%C3%A7aise-sur-ubuntu-server 

 

Updating the system 

Minor update, 

apt-get update
apt-get dist-upgrade
apt-get autoremove

 

Upgrading the system 

See what release you are running, 

cat /etc/debian_version 

 

See if you are running an x32 or x64 system, 

uname -a

 

Check what is the default grub option for GRUB1, 

catl /grub/grub.conf
cat /grub/menu.lst
cat /boot/grub/menu.lst

for GRUB2, 

cat /grub/grub.cfg

 

Update your mirror and major release pointers, 

cd /etc/apt/
#cp sources.list sources.list.lenny
vi sources.list
deb http://ftp.fr.debian.org/debian/ jessie main non-free contrib

or the full thing, 

deb http://httpredir.debian.org/debian jessie main
deb-src http://httpredir.debian.org/debian jessie main

 

deb http://httpredir.debian.org/debian jessie-updates main
deb-src http://httpredir.debian.org/debian jessie-updates main

 

deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

Note. Proceed step by step i.e. from lenny to squeeze to wheezy to jessie… 

Note. for older debian release you need to point to the archives, e.g. for Lenny, 

deb http://archive.debian.org/debian/ lenny main non-free contrib
deb-src http://archive.debian.org/debian/ lenny main non-free contrib
deb http://archive.debian.org/debian-security/ lenny/updates main non-free contrib
deb-src http://archive.debian.org/debian-security/ lenny/updates main non-free contrib

Other (older) examples for lenny, 

deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main
# backports
deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free
# Security updates for "lenny"
deb http://security.debian.org/ lenny/updates main contrib non-free
# For Clamav: special "volatile" distrib to get regular updates
deb http://ftp2.de.debian.org/debian-volatile lenny/volatile main
deb http://volatile.debian.org/debian-volatile lenny/volatile main
deb-src http://volatile.debian.org/debian-volatile lenny/volatile main
# Spamassassin is in "slopply"
deb http://ftp2.de.debian.org/debian-volatile lenny/volatile-sloppy main

examples for squeeze, 

# lenny to squeeze
deb http://ftp.fr.debian.org/debian/ squeeze main contrib
#deb-src http://ftp.fr.debian.org/debian/ squeeze main
deb http://security.debian.org/ squeeze/updates main contrib
#deb-src http://security.debian.org/ squeeze/updates main

 

deb http://ftp.debian.org/debian/ squeeze-updates main contrib non-free
deb http://security.debian.org/ squeeze/updates main contrib non-free
deb http://httpredir.debian.org/debian/ squeeze main contrib non-free
deb-src http://httpredir.debian.org/debian/ squeeze main contrib non-free

and some more examples, 

# stable security
deb http://security.debian.org/ stable/updates main contrib non-free
#deb-src http://security.debian.org/ stable/updates main contrib non-free
# stable volatile
deb http://volatile.debian.org/debian-volatile stable/volatile main contrib non-free
#deb-src http://volatile.debian.org/debian-volatile stable/volatile main contrib non-free
# stable multimedia
deb http://www.debian-multimedia.org stable main non-free
#deb-src http://www.debian-multimedia.org stable main non-free

 

Note. for java, 

deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main

 

Get rid of the packages you don't want anymore, 

dpkg -l | grep -i firefox
dpkg -l | grep -i mozilla
dpkg -l | grep -i xserver
dpkg -l | grep -i xorg
#apt-get remove --purge ...
#apt-get autoremove --purge
#apt-get install xauth

Refs. 

http://pc-freak.net/blog/debian-linux-remove-xorg-gnome-gdm-graphical-environment-packages-serverr/#sthash.87IgvKsF.dpuf 

http://forums.debian.net/viewtopic.php?p=113585 

 

Then remove all packages marked as rc by dpkg, 

dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs dpkg --purge

Ref. https://linuxprograms.wordpress.com/2010/05/12/remove-packages-marked-rc/ 

 

Proceed with the upgrade, 

apt-get update
apt-get dist-upgrade
apt-get autoremove
reboot

Note. alternate, 

apt-get dist-upgrade --no-install-recommends

 

Note. it may be useful to register new GPG keys to the apt system, 

key=XXXXXXXXXXXXX
gpg --keyserver pgpkeys.mit.edu --recv-key  $key
gpg -a --export $key | apt-key add -
unset key

Ref. Debian - Apt-get : NO_PUBKEY / GPG error: http://www.commentcamarche.net/faq/4445-debian-apt-get-no-pubkey-gpg-error 

 

If you just switched to GRUB2, 

upgrade-from-grub-legacy

and generally, 

grub-install /dev/sda
ls -l /boot/grub/grub.cfg
#grub-mkconfig -o /boot/grub/grub.cfg
update-grub2

 

Do not forget to check the timezone configuration, 

dpkg-reconfigure tzdata

 

Troubleshooting -- Packages 

If something goes wrong during the upgrades, those may be necessary, 

dpkg --configure -a
apt-get install -f

Ref. Problèmes avec les gestionnaires de paquets: http://doc.ubuntu-fr.org/probleme_apt 

 

If you get this error while installing or reinstalling a package, 

dpkg: error processing archive

with a weired conflict on two packages sharing the same unpacked file, then force the overwrite, 

dpkg -i --force-overwrite /var/cache/apt/archives/libgdict-common_3.16.2-1_all.deb

 

Network 

Setup the network, 

vi /etc/hostname
vi /etc/hosts
vi /etc/resolv.conf
vi /etc/network/interfaces

like, 

auto lo
iface lo inet loopback

 

#allow-hotplug eth0
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
        address x.x.x.x
        netmask 255.255.x.x
        gateway x.x.x.x
        dns-search example.local
        dns-nameservers DNS1 DNS2

Note. if you prefer to setup resolv.conf yourself (with no dns-search and dns-nameservers entries there), you need to disable resolvconf, 

systemctl status resolvconf
systemctl stop resolvconf
systemctl disable resolvconf

 

Miscellaneous 

Enable a service at boot time e.g., 

update-rc.d apache2 defaults
#update-rc.d apache2 enable
chkconfig --list | less

 

Disable a service at boot time e.g., 

update-rc.d -f apache2 remove
chkconfig --list | less

 

Switch to init 3 by default (not editing /etc/inittab on debian), 

/etc/init.d/gdm stop
update-rc.d -f gdm remove
service lightdm status
update-rc.d -f lightdm remove

 

Misc -- Packages 

To find what package name by file e.g., 

apt-get install apt-file
apt-file update
apt-file search /usr/lib/apache2/modules/mod_authnz_ldap.so

 

List package content, 

  dpkg -L package_name 

 

List package's dependencies, 

apt-cache rdepends unity
apt-cache showpkg lightdm

if it is a binary package file, 

dpkg -I package.deb

Refs. 

http://askubuntu.com/questions/128524/how-to-list-dependent-packages-reverse-dependencies 

http://askubuntu.com/questions/80655/how-can-i-check-dependency-list-for-a-deb-package 

 

Troubleshooting 

I had this log spam error on an old P2Ved Lenny (not sure it's really related to the P2V anyway), 

hdc: drive not ready for command

==> upgraded to Squeeze, vmware-tools-uninstall.sh and replace by open-vm-tools (contrib) did the trick