Ubuntu

From Dave's wiki
Jump to navigation Jump to search

General

Add user

sudo adduser newuser

# add to sudo group
# -a, Add the user to the supplementary group(s). Use only with the -G option.
# -G A list of supplementary groups which the user is also a member of
sudo usermod -aG sudo dtang

Update and install

sudo apt-get clean all && sudo apt-get update && sudo apt-get upgrade -y

Tools

Default Java Runtime Environment (11 at the time of writing).

sudo apt update
sudo apt install default-jre

Tools for compiling

sudo apt update
sudo apt install build-essential
sudo apt install autoconf
# msgfmt
sudo apt install gettext

See https://github.com/davetang/learning_docker/blob/master/Dockerfile.base for more essential tools for bioinformatics.

R

sudo apt install r-base

Docker (see https://docs.docker.com/engine/install/ubuntu/)

sudo apt-get update
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
 "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
 $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io

Add the user ubuntu to the docker group.

sudo groupadd docker
sudo usermod -aG docker ubuntu

Now log out and log back in.

docker run hello-world

Shared object

https://itsfoss.com/solve-open-shared-object-file-quick-tip/

Dynamic linker to locate required libraries

In C and/or C++, a .so (shared object) is a compiled library file. It is called shared object because this library file can be shared by several programs. These generated libraries are usually located in /lib or /usr/lib directories.

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/lib and /usr/lib). The cache is used by the run-time linker, ld.so or ld-linux.so. ldconfig checks the header and filenames of the libraries it encounters when determining which versions should have their links updated.

CA certificates

cd /usr/local/share/ca-certificates
wget https://curl.haxx.se/ca/cacert.pem
openssl x509 -outform der -in cacert.pem -out cacert.crt
update-ca-certificates

Firewall

Enable firewall; if you SSH into the system make sure you enable port 22!

ufw enable
# allow ports
ufw allow 1234
ufw allow 22
# check status
ufw status

SSH server

https://help.ubuntu.com/lts/serverguide/openssh-server.html

Mounting

sudo mkdir ~/test
cd /sbin/
sudo mount -t vboxsf Dropbox ~/test

Mount drive from Windows

sudo mkdir /mnt/data
sudo mount -t drvfs D: /mnt/data

Unmount

sudo umount /mnt/data

Setting up Samba

Install

sudo apt-get install samba4

https://help.ubuntu.com/community/Samba/SambaServerGuide

vi /etc/samba/smb.conf

Change into

[homes]
comment = Home Directories
browseable = yes

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = no

Add users who can access your shares with the 'smbpasswd' command.

sudo smbpasswd -a username

New SMB password:
Retype new SMB password:
Added user username.

sudo smbpasswd -e username

Restart Samba

sudo /etc/init.d/samba reload
Enabled user username.

Issues

Cannot make directory '/run/screen': Permission denied

The directory /var/run/screen/ is the socket directory for screen. Fortunately, screen reads a environment variable SCREENDIR to get an alternative socket directory. So to work around it, you can create a directory, such as ~/.screen:

mkdir ~/.screen && chmod 700 ~/.screen

and export the SCREENDIR to point to that directory:

export SCREENDIR=$HOME/.screen

You can also put this line into you ~/.bashrc so that it will also take effect afterwards.