Python3 and pip
apt install python3 python3-pip
Make sure to run python3 instead of the default python2: you need to run python3 and pip3, in your scripts you need #!/usr/bin/env python3
Create a python virtualenv
You need to have python and pip installed to do this.
This will create a virtual python environment inside a directory, in which you can install packages. You can then activate or deactivate the environment on demand, thus changing very easily your python configuration.
As root, install pip and then use it to install virtualenv:
pip3 install virtualenv
Set up a virtualenv
As a normal user:
mkdir {directory that will contain the virtual environment}virtualenv {directory you just created}
Using a virtualenv
source {virtualenv directory}/bin/activate
You can now directly run pip install to get new packages. They will be installed in the virtualenv.
Deactivating a virtualenv
Close the terminal, or execute deactivate.
TMPFS
TMPFS is a filesystem that resides in RAM (and eventually swap). By setting up a folder to be mounted as a tmpfs, you make its content temporary (deleted when the computer shuts down) and faster to access (since RAM is much faster than a disk).
Usually, tmpfs is used for folders such as /tmp. You should not use it on /var/tmp because that folder is meant for temporary files that are preserved across reboots.
Tmpfs are stored in RAM, but if the memory is needed by applications they will be moved (partially or entirely) to swap space. Therefore using a tmpfs will not "lock out" part of the ram. However, you should make sure that your swap space is big enough to store the tmpfs. A tmpfs will only use as much size as it needs: the "size" parameter is the maximum size of the filesystem.
By default they are created to use half of the available RAM, which is often a reasonable size for a /tmp folder.
- Edit
/etc/fstab- Add the line:
tmpfs {mountpoint (e.g. /tmp)} tmpfs {comma-separated options} 0 0, where options are:defaults: defaults options for filesystems. Seeman mount.size={size (e.g. 2G)}: maximum size of the filesystem. You can omit this parameter and will default to half of the RAM.nodev: don't allow special device files (e.g./dev/sda) to be created on the filesystem. Good security option for most filesystems.nosuid: ignore the suid bit on files. Good security options for shared filesystems (e.g./tmp)- Other mount options you would like to set. See
man mount.
- Add the line:
Cron-apt
Cron-apt is a service that will automatically execute apt jobs. Even though you could use it to automatically install updates, it's better to just use it for automatically downloading packages without installing them, this way the upgrades will be faster, since the packages are already downloaded.
- Install
cron-apt - By default it only does an update and download, but scripts may be added in
/etc/cron-apt/action.d/. Each script contains apt commands. Scripts are executed in alphabetical order.
Dhclient custom DNS
DNS servers used by a system are often pulled directly from the network to which it is connected, using DHCP.
This means that changes done to /etc/resolv.conf (the standard dns configuration files) are overwritten by the program that manages the connection.
In order to use you own favourite DNS servers, do the following:
If your connection is managed by NetowrkManager (default on Debian desktop computers) or another GUI tool, modify the parameters using the GUI.
If you connection is managed by dhclient (default on non-GUI systems) do the following:
- Edit
/etc/dhcp/dhclient.conf:- Uncomment or add the line
prepend domain-name-servers {dns server address};
- Uncomment or add the line
- The specified addresses will be added at the top of the list of DNS servers, and will therefore be contacted first.
Secure delete
Tools to safely erase files and memory.
apt install secure-delete
Note that the default settings for srm does a lot of rewrites of the files, and the less-secure version used when specifying the -l flag should suffice for most usages.