# Setup Ubuntu 20.04 (apt, snap, flatpak)


Part of [My Ubuntu 22.04 preferences](/ubuntu_setup/).

## apt: check diff (old-pc vs new-pc)



```bash
# on ssh-pc:
mkdir ~/logs/
ssh OLD_PC_IP apt list --installed > ~/logs/ubuntu_apt-list.old.txt
ssh NEW_PC_IP apt list --installed > ~/logs/ubuntu_apt-list.new.1.txt
# 20.04 focal
# 22.04 jammy
sed -E 's/focal/jammy/g' ~/logs/ubuntu_apt-list.old.txt   > ~/logs/ubuntu_apt-list.old.sed.txt
sed -E 's/\/.+$//g'      ~/logs/ubuntu_apt-list.old.txt   > ~/logs/ubuntu_apt-list.old.name-only.txt
sed -E 's/\/.+$//g'      ~/logs/ubuntu_apt-list.new.1.txt > ~/logs/ubuntu_apt-list.new.1.name-only.txt
# delta: https://github.com/dandavison/delta
delta ~/logs/ubuntu_apt-list.old.sed.txt       ~/logs/ubuntu_apt-list.new.1.txt
delta ~/logs/ubuntu_apt-list.old.name-only.txt ~/logs/ubuntu_apt-list.new.1.name-only.txt
```

## apt: install



```bash
rsync -av /etc/systemd/ /etc/systemd.orig/
sudo apt install tmux
tmux
bash

# [gui]     : don't install on Ubuntu server
# [systemd] : installs systemd unit file
#             echo > /tmp/apt_find_systemd_utils_done.txt
#             function find_systemd_units
#                 set -l PKG $argv[1]
#                 set_color green
#                 echo -n "$PKG"
#                 set_color normal
#                 grep -q $PKG /tmp/apt_find_systemd_utils_done.txt && echo ' skip' && return
#                 echo
#                 apt-file list $PKG | ag '/etc/init\.d|systemd'
#                 # TODO: recursive
#                 #   apt-cache depends --recurse nginx-extras  # too many...
#                 # TODO: asciidoctor -> <ruby:any>  # apt-file list '<ruby:any>'  # empty
#                 for pkg in (apt-cache depends $PKG | grep -P -o '(?<=^  Depends: ).+')
#                     echo -n "$PKG -> $pkg"
#                     grep -q $pkg /tmp/apt_find_systemd_utils_done.txt && echo ' skip' && continue
#                     echo
#                     apt-file list pkg | ag '^/etc/init\.d|systemd'
#                     echo "$pkg" >> /tmp/apt_find_systemd_utils_done.txt
#                 end
#                 echo "$PKG" >> /tmp/apt_find_systemd_utils_done.txt
#             end
#             find_systemd_units nginx-extras
#             find_systemd_units xl2tpd
#             #
#             ls -lrt /etc/init.d/
#             apt-file search /etc/init.d/nginx
#             ls -lrt --color /etc/systemd/system/ | tail -20
#             ls -lrt --color /etc/systemd/system/multi-user.target.wants | tail -20

apps=(
apt-file                          #
asciidoctor                       #
atop                              # [systemd] atop-rotate.service atop-rotate.timer atop.service atopacct.service
audacity                          # [gui]
autoconf                          #
automake                          #
autossh                           #
bear                              #
binutils                          #
binutils-arm-linux-gnueabi        #
binutils-arm-linux-gnueabihf      #
bison                             #
blender                           # [gui]
bmake                             #
bpfcc-tools                       #
bpftrace                          #
bridge-utils                      #
build-essential                   #
ccache                            #
cflow                             #
check                             #
chrome-gnome-shell                # [gui]
clang                             #
clang-format                      #
clang-tidy                        #
clang-tools                       #
clangd                            #
cloud-image-utils                 #
cloud-init                        #
cmake                             #
cmake-qt-gui                      # [gui] cmake-gui
compiz                            # [gui]
compizconfig-settings-manager     # [gui]
cowsay                            #
cppcheck                          #
cppcheck-gui                      # [gui]
crossbuild-essential-arm64        #
cscope                            #
csh                               #
cu                                #
curl                              #
cvs                               #
daemonize                         #
device-tree-compiler              # dtc
diffstat                          #
dnsutils                          #
doxygen                           #
duf                               #
dwarfdump                         #
dwarves                           # linux kernel config BTF
easystroke                        # [gui]
elfutils                          #
emacs                             #
entr                              #
ethtool                           #
expat                             #
expect                            #
fail2ban                          # fail2ban.service
faketime                          #
fasd                              #
ffmpeg                            #
flatpak                           # [systemd] flatpak-system-helper.service flatpak-oci-authenticator.service flatpak-portal.service flatpak-session-helper.service
flex                              #
fonts-ricty-diminished            # [gui]
g++                               #
gawk                              #
gcc                               #
gcc-arm-linux-gnueabi             #
gcc-arm-linux-gnueabihf           #
gcovr                             #
gdb-multiarch                     #
gdbserver                         #
gddrescue                         #
gettext                           #
gimp                              # [gui]
git                               #
git-cvs                           #
git-email                         #
git-lfs                           #
git-merge-changelog               #
git-svn                           #
gitk                              # [gui]
glibc-source                      #
gnome-tweaks                      # [gui]
gnulib                            #
gnumeric                          # [gui]
golang-go                         #
gpart                             # [gui]
gparted                           # [gui]
gperf                             #
gpick                             #
grabc                             # [gui]
graphviz                          #
groff                             #
gthumb                            # [gui]
htop                              #
hunspell                          #
hwinfo                            #
ibus-mozc                         # [gui]
iftop                             #
ike-scan                          #
inkscape                          # [gui]
inotify-tools                     #
iotop                             #
iperf                             #
iperf3                            #
jo                                #
jq                                #
kdiff3-qt                         # [gui] "kdiff3" has bug in pasting
ksh                               #
lame                              #
lcov                              #
ldap-utils                        #
ldnsutils                         #
libaio-dev                        #
libbind-dev                       #
libbluetooth-dev                  #
libboost-all-dev                  #
libbsd-dev                        #
libc-ares-dev                     #
libc++-dev                        #
libc6-dbg                         #
libcap-dev                        #
libcap-ng-dev                     #
libcap-ng-utils                   #
libclang-dev                      #
libcurl4-openssl-dev              #
libdbus-1-dev                     #
libdbus-glib-1-dev                #
libdvdnav4                        #
libdw-dev                         # dwarf
libdwarf-dev                      #
libedit-dev                       #
libelf-dev                        #
libev-dev                         #
libevent-dev                      #
libfuse-dev                       #
libgcrypt-dev                     #
libgtest-dev                      #
libimage-exiftool-perl            #
libmagic-dev                      #
libmpc-dev                        #
libncursesw5-dev                  #
libpcap-dev                       #
libreadline-dev                   #
libsmi2-dev                       #
libsource-highlight-dev           #
libsystemd-dev                    #
libtool                           #
libtool-bin                       #
libvirt-clients                   # [gui]
libvte-dev                        # [gui]
libwebkit2gtk-4.1-dev             # [gui]
libwireshark-dev                  # [gui]
libxtst-dev                       #
lld                               #
lldb                              #
llvm                              #
lnav                              #
ltrace                            #
mcomix                            # [gui]
mercurial                         #
meson                             #
minicom                           #
moreutils                         #
mosh                              #
musl                              #
musl-dev                          #
musl-tools                        #
net-tools                         #
ninja-build                       #
nkf                               #
nmap                              #
npm                               #
openssh-server                    # [systemd] rescue-ssh.target ssh.service ssh.socket ssh@.service
openssl                           #
pandoc                            #
peek                              # [gui]
perl                              #
php                               #
pinta                             # [gui]
pkg-config                        #
ppp                               #
ppp-dev                           #
pwgen                             #
pydf                              #
python-all-dev                    #
python3-all-dev                   #
python3-dbg                       #
python3-pip                       #
python3-venv                      #
qemu                              #
qemu-system-x86                   #
r-base-core                       #
readline-common                   #
recordmydesktop                   # [gui]
reptyr                            #
rr                                #
scons                             #
screen                            #
shellcheck                        #
silversearcher-ag                 #
smplayer                          # [gui]
sshfs                             #
subversion                        #
texinfo                           #
texlive                           #
tig                               #
tilix                             # [gui]
timidity                          #
tmux                              #
trash-cli                         #
tree                              #
uftrace                           #
unar                              # [gui]
unrar                             #
usbview                           # [gui]
valgrind                          #
vim-gtk                           # [gui]
vinagre                           #
virt-manager                      # [gui]
virtualbox                        #
virtualbox-guest-additions-iso    #
vlc                               # [gui]
wireshark-dev                     #
wmctrl                            #
xbindkeys                         # [gui]
xclip                             # [gui]
xdotool                           # [gui]
xsel                              # [gui]
zlib1g-dev                        #
zsh                               #
)

# not install
: <<'EOS'
# prompt apears and stops; install later

libdvd-pkg                        #
tshark                            #
ubuntu-restricted-extras          # [gui]
virtualbox-ext-pack               #
wireshark                         # [gui]

# don't install via apt; install according to the official website

adb                               #
docker-ce                         #
fish                              #

# unstable; maybe newer version exists; check manually

guile-2.2-dev                     #
guile-3.0-dev                     #
liblua5.4-0-dbg                   #
liblua5.4-dev                     #
libstdc++6-12-dbg                 #
libstdc++6-12-dbg-arm64-cross     #
libstdc++6-12-dbg-armhf-cross     #
lua5.4                            #
openjdk-18-dbg                    #
openjdk-18-doc                    #
openjdk-18-jdk                    #
openjdk-18-source                 #

# not frequently used

acct                              # [systemd] acct.service
aha                               #
android-sdk                       #
ant                               #
aqemu                             # [gui]
asunder                           # [gui]
at                                # [systemd] atd.service; replaced with systemd-run
composer                          # php
darktable                         # [gui]
ddd                               # [gui]
diodon                            # [gui] clipboard manager
exfat-fuse                        #
filezilla                         # [gui]
filter                            #
freeradius                        # [systemd] freeradius.service
ghc                               # haskell
git-flow                          #
gnome-shell-extensions-gpaste     # [gui]
gnome-software-plugin-flatpak     # https://flatpak.org/setup/Ubuntu/
gtick                             # [gui]
gtk-doc-tools                     #
hardinfo                          # [gui]
haskell-stack                     # haskell
help2man                          #
ifupdown                          # [systemd] ifup@.service ifupdown-pre.service ifupdown-wait-online.service networking.service
inetutils-telnetd                 #
intltool                          #
isc-dhcp-server                   # [systemd] isc-dhcp-server.service isc-dhcp-server6.service
ispell                            #
iwyu                              #
javacc                            #
kcachegrind                       # [gui]
kdialog                           # [gui]
keychain                          #
lirc                              # [systemd] irexec.service lircd-setup.service lircd-uinput.service lircd.service lircd.socket lircmd.service
lm-sensors                        # [systemd] lm-sensors.service
mininet                           #
mutt                              #
mysql-client                      #
nginx-extras                      # [systemd] nginx-common: /etc/init.d/nginx nginx.service
nodejs                            #
pavucontrol                       # [gui] https://askubuntu.com/a/229365/764025
pydf                              #
qtbase5-dev                       #
qtbase5-dev-tools                 #
qtmultimedia5-dev                 #
qttools5-dev                      #
qttools5-dev-tools                #
remake                            #
reportbug                         #
restic                            #
rubberband-cli                    #
samba                             # [systemd] /etc/init.d/nmbd /etc/init.d/samba-ad-dc /etc/init.d/smbd nmbd.service samba-ad-dc.service smbd.service
sbcl                              #
secure-delete                     #
setserial                         # [systemd] etc-setserial.service setserial.service
snmp                              #
snmp-mibs-downloader              #
snmpd                             # [systemd] snmpd.service
sparkleshare                      # [gui]
spell                             #
strongswan                        # [systemd] strongswan-starter: strongswan-starter.service
strongswan-pki                    #
sysstat                           # [systemd] sysstat-collect.service sysstat-collect.timer sysstat-summary.service sysstat-summary.timer sysstat.service
tcpreplay                         #
tftpd-hpa                         # [systemd] /etc/init.d/tftpd-hpa
thinkfan                          # [systemd] thinkfan-sleep.service thinkfan-wakeup.service thinkfan.service
tk                                #
tldr                              #
tlp                               # [systemd] tlp.service
tlp-rdw                           #
tp-smapi-dkms                     #
u-boot-tools                      #
uml-utilities                     # User-mode Linux
vlan                              #
vsftpd                            # [systemd] vsftpd.service
whois                             #
xl2tpd                            # [systemd] /etc/init.d/xl2tpd
xserver-xorg-dev                  # [gui]
xutils-dev                        #
EOS


# takes about 25min
sudo apt-get install -y "${apps[@]}"
#0 upgraded, 1927 newly installed, 0 to remove and 0 not upgraded.
#Need to get 3,022 MB/3,023 MB of archives.
#After this operation, 10.7 GB of additional disk space will be used.
# --install-suggests -> 3897 newly installed, 7,775 MB/7,847 MB, 24.7 GB

tail -c+0 -f /var/log/apt/term.log

# packages which need user interactions:
# TAB to switch choice
sudo apt install libdvd-pkg                # Configuring libdvd-pkg: Please run "sudo dpkg-reconfigure libdvd-pkg" to launch this process for the first time.  Enable automatic upgrades for libdvdcss2? Yes
sudo dpkg-reconfigure libdvd-pkg           # Download, build, and install libdvdcss2/1.4.3-1? Yes
sudo apt install tshark wireshark          # Configuring wireshark-common: Should non-superusers be able to capture packets? Yes
sudo apt install ubuntu-restricted-extras  # Configuring ttf-mscorefonts-installer:  Do you accept the EULA license terms?: Yes
sudo apt install virtualbox-ext-pack       # Configuring virtualbox-ext-pack: Do you accept the terms of the VirtualBox PUEL license?: Yes

# To reconfigure:
sudo dpkg-reconfigure libdvd-pkg
sudo dpkg-reconfigure wireshark-common
sudo dpkg-reconfigure virtualbox-ext-pack

# on ssh-pc:
__%pp:cut:begin__
ssh wsh79 apt list --installed > ~/logs/ubuntu_apt-list.new.2.txt
__%pp:cut:end__
ssh NEW_PC_IP apt list --installed > ~/logs/ubuntu_apt-list.new.2.txt
sed -E 's/\/.+$//g' ~/logs/ubuntu_apt-list.new.2.txt > ~/logs/ubuntu_apt-list.new.2.name-only.txt
delta ~/logs/ubuntu_apt-list.old.sed.txt     ~/logs/ubuntu_apt-list.new.2.txt
delta ~/logs/ubuntu_apt-list.old.name-only.txt ~/logs/ubuntu_apt-list.new.2.name-only.txt
delta /etc/systemd/  # check installed units
```

## flatpak

https://flatpak.org/setup/Ubuntu/

```bash
sudo apt install flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
#==== AUTHENTICATING FOR org.freedesktop.Flatpak.configure-remote ====
#Authentication is required to configure software repositories
#Authenticating as: wsh,,, (wsh)
#Password: 
# enter system password
```

https://github.com/phw/peek

```bash
# old; now can be installed with apt-get

# flatpak install flathub com.uploadedlobster.peek
# # install password 8 times...
# # TODO: next time: try sudo flatpak install ...
```

