Package management

https://help.ubuntu.com/community/AptGet/Howto

Ubuntu comparison of apt-get vs. yum commands

# show installed packages
dpkg --list

# show info for a package
dpkg --status foobar

# show files owned by an installed package
dpkg --listfiles foobar

# show files owned by an uninstalled package
apt-file list foobar

# show which package owns a file
dpkg -S /usr/bin/foobar

# show which package will own a file
apt-file find /usr/bin/foobar

# 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

http://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it

http://askubuntu.com/questions/81585/what-is-dist-upgrade-and-why-does-it-upgrade-more-than-upgrade

User management

useradd -m myuser -s /bin/bash

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

Shutdown and restart

poweroff

reboot

Change default $EDITOR from nano to vim

update-alternatives --config editor

Choose "vim.basic".

Give user sudo access

newuser    ALL=(ALL:ALL) ALL

or

newuser    ALL=NOPASSWD: ALL

https://www.digitalocean.com/community/tutorials/how-to-add-delete-and-grant-sudo-privileges-to-users-on-a-debian-vps

iptables

# 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
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
: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
-A INPUT -j DROP
COMMIT
# Completed on Wed Oct 14 22:17:08 2015
root@server2:~#

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

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-iptables-on-ubuntu-14-04

Apache httpd

Install Apache

sudo apt-get install apache2

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts

Restart Apache

systemctl reload apache2

Enable site

a2ensite data.greptilian.com

Show enabled sites

apache2ctl -S

MySQL

sudo apt-get install mysql-server

https://www.digitalocean.com/community/tutorials/a-basic-mysql-tutorial

Timezone

sudo timedatectl set-timezone America/New_York

https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-18-04

Grub

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 https://www.digitalocean.com/community/questions/ubuntu-new-boot-grub-menu-lst-after-apt-get-upgrade

Installing Docker on Ubuntu 18.04

https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" apt install docker-ce usermod -aG docker pdurbin


Home | About | Sitemap | Recent changes | © Philip Durbin | @philipdurbin | philipdurbin@gmail.com