How to speed up package updates using apt-fast (Debian & Ubuntu)

apt-fast downloads repositories (package sources) and packages in parallel, which can greatly shorten the time it takes to update a system.  In contrast, the default package manager (apt-get or aptitude) downloads repositories and packages sequentially.

 

Step 1 – Install apt-fast

Add the apt-fast repository to your package sources.

 

If you don’t have the add-apt-repository tool, install it by running  sudo apt-get install software-properties-common

If the package configuration asks which package manager to use, choose apt-get if you are running Ubuntu, or aptitude if you are running Debian.

When asked for how many connections to use, enter a reasonable number based on your connection.  If you have a fast connection, the default of 15 will most likely suit you.  If you’re on a slower connection, consider entering 5 or 10.  Try different values to find what works best.

You can reconfigure at any time by running  sudo dpkg-reconfigure apt-fast

 

Step 2 – Create an alias

Add the following to the end of your  ~/.bashrc file to perform a normal upgrade by typing uu

 

Note the  -y argument.  This causes any prompts (such as the download confirmation) to be answered yes automatically.

If you want a more thorough upgrade (which installs new kernels) use  dist-upgrade rather than  upgrade

 

lonniebiz on reddit writes:

If you’d like to see this in the main repositories and Ubuntu Software Center, add some heat to this bug by indicating that it affects you:

https://bugs.launchpad.net/ubuntu/+bug/1173661

How to install a mail server (postfix) supporting IMAP and POP3 (Ubuntu)

Step 1 – Create mail.yourdomain.com

Add an MX record to your DNS using the following parameters:

  • Hostnamemail
  • Priority10

 

Step 2 – Install and configure postfix

Don’t enter anything during the installation.  In the next step we will be configuring postfix more precisely, and any configuration set now will be overwritten.

 

Reference my configuration if you aren’t sure what to enter:

  • General type of mail configurationInternet site
  • System mail namemail.notblog.org
  • Root and postmaster recipient: notblog  (Your sudo-privileged account, not root)
  • Other destinations to accept mail forlocalhost, mail.notblog.org, notblog.org
  • Force synchronous updates on mail queue?No
  • Local networks:  127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
  • Mailbox size limit
  • Local address extension character+
  • Internet protocols to useall

 

Step 3 – Change spool format to Maildir

 

Step 4 – Install IMAP and POP3 support

Answer No when asked about setting up a web interface.  There are much better alternatives to using courier for web mail.  I recommend roundcube.  Check back soon for a guide on using web mail.

 

Step 5 – Add aliases for multiple domains and mail accounts

This step is optional.  Following it will allow you to:

  • Handle mail for multiple domains with a single mail server.
  • Forward multiple mailboxes (webmaster, sysadmin, etc.) to a single mailbox.

 

  •  Line 1: Enter the domain name this mail server will be used for as well as any other domains hosted on this machine.  This will allow you to configure all of the domains to send mail to a single account.  Separate the domains with spaces.  If you aren’t using any other domains, enter the main domain only.
  • Line 2: This points postfix to the alias map at  /etc/postfix/virtual which we will be creating in the next step.  This file will describe where to forward mail sent to certain domains and/or mailboxes.

 

Write the following to /etc/postfix/virtual, adding domains and mailboxes you’d like to be forwarded:

 

Then run  postmap to optimize the alias map.  Postfix will read the file much more quickly if this step is taken.

 

Step 6 – Install dovecot

 

Step 7 – Restart postfix

How to monitor bandwidth usage with web-based (HTML) status reports

Example report

BandwidthD renders great bandwidth usage reports and is a breeze to install.

Step 1 – Install bandwidthd to monitor bandwidth usage

You most likely won’t need to enter any custom configuration values during installation.  Just make sure the interface to monitor is properly set, usually eth0.

Step 2 – Set up reverse DNS

By following this step your machine’s hostname will be displayed in the reports.  Without this step, only an IP address will be displayed.  Add a line to  /etc/hosts, consisting of your machine’s public IP address and its hostname.

 

Step 3 – Create symbolic link to status report directory

Bandwidthd writes its reports to  /var/lib/bandwidthd/htdocs/ by default.  We can easily serve these reports from a website by creating a symbolic link.

In this example, reports would be served at  http://notblog.org/bwstats/

 

How to log failed login attempts (Ubuntu)

  • Login: Attempted login user
  • Failures: Failed login attempts
  • Maximum: Allowed login failures before disabling the account
  • Latest: Date and time of last failed login
  • On: Where the failed login occurred

Step 1 – Enable pam_tally.so in /etc/pam.d/common-auth

Add the following lines to the top of the file:

 

Step 2 – Enable pam_tally.so in /etc/pam.d/sshd

Add the following lines immediately before  @include common-auth:

 

Step 3 – Enable PAM in /etc/ssh/sshd_config

Step 4 – Restart ssh