Debian notes

Notes about Debian

Query Debian version:

cat /etc/debian_version

Logs

Debian writes to /var/log/syslog not /var/log/messages.

Packages

List repositories

To see which repositories are being used:

cat /etc/apt/sources.list

Querying packages

List installed packages:

dpkg -l

E.g:

me@somewhere:~$ dpkg -l
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-============================================
ii  adduser        3.110          add and remove users and groups
ii  apache2        2.2.9-10+lenny Apache HTTP Server metapackage
...

The block at the top of the output indicates what the two character codes on the left mean:

The ii next to adduser means Desired=Install and Status=Inst. I.e. installed.
An rc would mean Desired=Remove and Status=Cfg-files. I.e. removed but config files remain.

Query package version:

dpkg -l [package]

Query which package a file belongs to:

dpkg -S /the/file/name

Finding packages

To search for packages:

apt-cache search [search pattern]

To search for an installed package:

dpkg -l | grep [search pattern] 

Maintaining packages

Install package:

apt-get install [package]

To install a .deb package that you have downloaded from internet (e.g. skype):

dpkg -i [package]x.x.x.deb

To reconfigure a package (e.g. server-xfree86):

dpkg-reconfigure [package]

To remove a package:

dpkg -e [package]x.x.x

To uninstall a package:

apt-get remove [package]

Or to uninstall a package and remove config files as well:

apt-get remove --purge [package]

(More on purging in the ‘config files’ section below)

Upgrade package:

apt-get upgrade [package]

Config files

It is possible to remove a package without removing its configuration files.

If dpkg -l shows rc status (as mentioned above) i.e. removed but config files remain, the files can be purged with:

dpkg --purge [package]

Some packages will create config files, e.g. ‘apt-get install locate’ will attempt to create /etc/cron.daily/locate. If you want to reinstall a package and have it also replace these config files you must remove with the –purge option..

apt-get remove [package] --purge
apt-get install [package]

Example of installing a package (locate) without using –purge flag versus using –purge:

  1. Install locate without –purge:

    apt-get install locate
    
  2. Receive prompt asking whether to replace /etc/cron.daily/locate. I say no because assumed existing one was there for a reason.
  3. Check contents of /etc/cron.daily/locate. t was only a holding script containing the instructions that it should be removed before installing locate!
  4. Remove file then try installation again:

    rm /etc/cron.daily/locate
    apt-get remove locate
    apt-get install locate
    
  5. The cron script was not created. Try again with –purge:

    apt-get remove locate --purge
    apt-get install locate
    
  6. Done. The cron script was created.

Services

Services are in kept in /etc/init.d/. These are linked to from the X runlevel directories /etc/rcX.d/.

update-rc.d

update-rc.d is a program to install and remove such System-V style init scripts (it actually removed the links from the /etc/rcX.d/ directories).

To remove a service from every runlevel:

update-rc.d -f [service] remove

-f to not remove the script from /etc/init.d/.

Show default serviecs

By default, Debian starts into runlevel 2, so see which init.d scripts are linked from rc2.d…

ls –l /etc/rc2.d/S*

Ports

To show details of processes using port 80:

lsof -i :80

Timezone

Auto

dpkg-reconfigure tzdata

Manual

  1. Write the timezone to /etc/timezone:

    echo "Europe/London" > /etc/timezone
    
  2. Link to timezone file from /etc/localtime:

    ln -s /usr/share/zoneinfo/Europe/London etc/localtime
    

    Or copy:

    cp /usr/share/zoneinfo/Europe/London etc/localtime
    

NTP

apt-get install ntp

It should auto start ntpd and add it to default runlevel.

Confirm it’s working by querying the list of time servers with ‘ntpq -p’.

Apache

Maintaining apache2 sites and modules lists

Virtual hosts

Config for each virtual host goes in /etc/apache2/sites-available/.

Enable a virtual host using the a2ensite command, disable with a2dissite. This will link/unlink to vhost config from /etc/apache2/mods-enabled/.

Reload config with /etc/init.d/apache2 reload

Modules

Config for each module goes in /etc/apache2/mods-available/.

Enable a module using a2enmod, disable with a2dismod. This will link/unlink to module config from /etc/apache2/mods-enabled/.

Reload config with /etc/init.d/apache2 reload

Git

Install git:

apt-get install git-core

(“git” is the GNU Interactive Tools)

References

Last modified: 30/01/2015 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top