Package management

Ubuntu comparison of apt-get vs. yum commands

# show installed packages
dpkg --list

# show info for a package
dpkg --status package_name

# show files owned by a package
dpkg --listfiles package_name

# resynchronize the package index files from their sources
apt-get update

# install the newest versions installed packages
apt-get upgrade

# install packages that are "kept back"
apt-get dist-upgrade

# for clearing out unused linux-headers, for example
apt-get autoremove

# search for packages with a given string (i.e. json)
apt-cache search json

apt-get dist-upgrade

"-y Assume Yes to all queries and do not prompt" is not recommended for apt-get dist-upgrade

User management

useradd -m myuser -s /bin/bash

Shutdown and restart



Change default $EDITOR from nano to vim

update-alternatives --config editor

Choose "vim.basic".

Give user sudo access

newuser    ALL=(ALL:ALL) ALL


newuser    ALL=NOPASSWD: ALL


# so that firewall rules load at boot
apt-get install iptables-persistent
# edit rules
vim /etc/iptables/rules.v4 
# reload rules
iptables-restore < /etc/iptables/rules.v4
# save rules
invoke-rc.d iptables-persistent save

Sample iptables firewall rules

root@server2:~# cat /etc/iptables/rules.v4
# Generated by iptables-save v1.4.21 on Wed Oct 14 22:17:08 2015
:OUTPUT ACCEPT [72:34181]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# Completed on Wed Oct 14 22:17:08 2015

Apache httpd

Install Apache

sudo apt-get install apache2

Restart Apache

systemctl reload apache2

Enable site


Show enabled sites

apache2ctl -S


sudo apt-get install mysql-server


sudo timedatectl set-timezone America/New_York


On a new installation of Ubuntu 18.04 on Digital Ocean I ran sudo apt-get dist-upgrade and saw this message:

"A new version of /boot/grub/menu.lst is available, but the version installed currently has been locally modified. What would you like to do about menu.lst?

I selected the first option called "install the package maintainer's version" even though the second option called "keep the local version currently installed" was highlighted. Showing differences didn't work. I rebooted the server and it came back up. There's a related post at

Home | About | Sitemap | Recent changes | © Philip Durbin | @philipdurbin |