Linux

Howto copy a Python3 virtual environment to another location

0

If you want to copy a python3 virtual environment to another location do the following:

sudo apt install -y python3-pip build-essential \
libssl-dev libffi-dev python3-dev python3-venv
mkdir Python-Envs
cd Python-Envs
python3.6 -m venv env

Make a entry point for the various projects

cd Python-Envs
mkdir src

To activate:

cd Python-Envs
source env/bin/activate

cd src[My project]

Do your stuff

to deactivate:

deactivate

In case you want to move a virt to another machine:
In the source env do:

pip3 freeze > requirements.txt

Copy that requirements.txt file to the other virt
in the other virt do:

pip3 install -r requirements.txt

rip music from a youtube url

0

Use the youtube-dl tool to rip music from a youtube url.
youtube-dl --extract-audio --audio-format mp3 [URL]

Getting Debian 9 “Stretch” using a password for the mysql root user

0

As it turns out Debian 9 is using “unix_socket” and not a password for the mysql/maria root user.
Here’s a explanation and solution:
https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost

It boils down to, in my case, these commands:

stas@HAL9000:~$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
stas@HAL9000:~$ sudo mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.23-MariaDB-9+deb9u1 Debian 9.0

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;
+------+-----------+-------------+
| User | Host      | plugin      |
+------+-----------+-------------+
| root | localhost | unix_socket |
+------+-----------+-------------+
1 row in set (0.00 sec)

MariaDB [mysql]> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> SELECT User, Host, plugin FROM mysql.user;+------+-----------+-----------------------+
| User | Host      | plugin                |
+------+-----------+-----------------------+
| root | localhost | mysql_native_password |
+------+-----------+-----------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> exit
Bye
stas@HAL9000:~$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.23-MariaDB-9+deb9u1 Debian 9.0

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

Sound volume issues when using kivy on Debian with gnome and pulse audio fixed

0

When using kivy on a Debian system running pulse audio (gnome) you would encounter issues with the sound volume due to the fact that kivy would set the volume to 100% each time it uses the soundcard.
The problem is in pulse audio, what’s new 🙁 as it’s the from the same author who brings us systemd.
You can remove pulse audio as much of gnome depends on it.
You can however disable pulse and use good old alsa.

Disable pulse in /etc/pulse/client.conf uncomment the line “autospawn = yes” and set it to “autospawn = no”
Install gnome alsa mixer, sudo apt-get install gnome-alsamixer
Restart alsa, sudo alsa force-reload
Or use alsamixer (console) to control the volumes.

Tried to use key shortcuts in gnome but that doesn’t work correctly.
Just use trusted xbindkeysrc always works 🙂

install xbindkeys, sudo apt-get install xbindkeys
Use this .xbindkeysrc file and your done (after logout and login)

#Alsa Volume Down
"amixer set Master 3- unmute"
   XF86AudioLowerVolume

#Alsa Volume Up
 "amixer set Master 3%+ unmute"
 XF86AudioRaiseVolume

#Alsa mute/unmute toggel
 "amixer sset Master toggle"
 XF86AudioMute

Backup and restore the packages on a debian system

0

This is only a way to backup and restore installed packages on your system.
I use this when I change from workstation to have my trusted set of packages installed 😉
You might need to install dselect as it’s no longer part of a standard Debian install:
apt-get install dselect

And then:
dpkg --get-selections > selections

Install the new Debian system, copy the selections file and then:
avail=`mktemp`
apt-cache dumpavail > "$avail"
dpkg --merge-avail "$avail"
rm -f "$avail"
dpkg --set-selections < selections apt-get dselect-upgrade

Flash TWRP on Samsung Tab2 10.1 using linux

0

Flashing TWRP on Samsung Tab2 10.1 using linux can brick your device
and I’m not responsible for any issues you might face.

As Samsung doesn’t have a “fastboot” mode but only “download” mode
you need Heimdall/Odin to flash TWRP onto the device.
As many members of my family have samsung tab2 tablet which are not getting
any updates from Samsung anymore they are getting slower and slower with
any app that’s updated.
As the tablets are in pefect working order and the problem is software related
it’s much better and cheaper to just replace the samsung OS with LineageOS to
gave them a second live 🙂

Put device into download mode (odin mode)
Power button and volume up (is the right side of the button)
Then push volume down (left side) and make sure the device says “Downloading…”

Now connect device by USB to your linux machine.

On your Linux machine:
sudo apt-get install heimdall
sudo heimdall detect
sudo heimdall print-pit --no-reboot

(Device might reboot without –no-reboot)
Go into download mode again

In the output of the ‘print-pit’ look for
“Partition Name: RECOVERY”

Use that as your partition name, sometimes it could be in small caps, then
use small caps.

sudo heimdall flash --RECOVERY twrp-3.1.0-0-p5110.img --no-reboot

Disconnect USB cable

Now reboot into recovery by using keep pressed the buttons power + volume down (left side)
your device will reboot after 10 seconds and as soon as you see the samsung name on the screen
release the power button.

You are now in TWRP recovery and “swipe to allow modifications” to sideload a custom rom like LineageOS.
Make sure you “wipe” all the partitions in addition to a “factory reset” as I had issues on one tablet
where the ‘system’ partions wasn’t properly ‘wiped’ and I had to ‘wipe’ it separately.

sudo ./adb sideload lineage-13.0-20170401-nightly-espressowifi-signed.zip
sudo ./adb sideload open_gapps-arm64-6.0-pico-20170405.zip

Make gps working on your android phone if running LineageOS or cynagenmod

0

A known problem with LineageOS and cynogenmod on Android is that after an upgrade or first install the GPS isn’t working.
The solution is rather simple.
– Start your device in fastboot mode
Most of the times you start your phone with power and volume down pressed together and release power when the device starts.
– Your now in fastboot.
– Connect the phone by usb cable to you PC.
– Execute the following fastboot commands:
fastboot erase modemst1
fastboot erase modemst2

– Reboot phone.

Git list commit messages to create a changelog file

0

When you want to construct a changelog file from git commit messages you can use git log.
The way to construct such a list of commit messages is to use the git log command like this:
git log --since "DEC 1 2016" --until "FEB 3 2017" --pretty=format:"%s" > git.log.txt

This will only display the text of the commit message.
Other useful format options are :
git log --since "DEC 1 2016" --until "FEB 2 2017" --pretty=format:"%an %ad >> %s"
To get the author name and date.

More info can be found here: git-scm.com/docs/git-log

Bacula firewall settings

0

There are two excellent howtos on how to setup a bacula server and remote client(s) at digitalocean:
https://www.digitalocean.com/community/tutorials/how-to-install-bacula-server-on-ubuntu-14-04
https://www.digitalocean.com/community/tutorials/how-to-back-up-an-ubuntu-14-04-server-with-bacula

But as it tailored to be used in a digitalocean vps environment it lacks a firewall setup/issues.

On the server the ports 9102 and 9103 should be opened and on the client port 9102.
The client talks to the server and the server talks to the client (or so it seems)

Manually resize a SD card for your Raspberry Pi (version2)

0

Warning, use these instructions on your own risk.

 

When I tried to resize the 16GB SD card in the raspberry pi version 2 I got a corrupted file system and all other kinds
of nastiness.

So I decided to try to resize the thing manually.

First “dd” the image to the SD card.

Leave the card in the reader/writer and issue the following comands, replace the device for you own device
and use the units for your card.

 

$ sudo parted /dev/sdd
 GNU Parted 2.3
 Using /dev/sdd
 Welcome to GNU Parted! Type 'help' to view a list of commands.

 (parted) print
 Model: Generic- SD/MMC (scsi)
 Disk /dev/sdd: 16,1GB
 Sector size (logical/physical): 512B/512B
 Partition Table: msdos
Number Start End Size Type File system Flags
 1 4194kB 62,9MB 58,7MB primary fat16 lba
 2 62,9MB 3277MB 3214MB primary ext4

(parted) unit chs
 (parted) print
 Model: Generic- SD/MMC (scsi)
 Disk /dev/sdd: 1955,244,16
 Sector size (logical/physical): 512B/512B
 BIOS cylinder,head,sector geometry: 1955,255,63. Each cylinder is 8225kB.
 Partition Table: msdos
Number Start End Type File system Flags
 1 0,130,2 7,165,29 primary fat16 lba
 2 7,165,30 398,97,18 primary ext4

(parted) rm 2
 (parted) mkpart primary 7,165,30 1955,244,16
 (parted) quit

 Information: You may need to update /etc/fstab.

$ sudo e2fsck -f /dev/sdd2
 e2fsck 1.42.9 (4-Feb-2014)
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
 /dev/sdd2: 86233/196224 files (0.1% non-contiguous), 630146/784640 blocks

 $ sudo resize2fs /dev/sdd2
 resize2fs 1.42.9 (4-Feb-2014)
 Resizing the filesystem on /dev/sdd2 to 3912448 (4k) blocks.
 The filesystem on /dev/sdd2 is now 3912448 blocks long.

$ sudo parted /dev/sdd
 GNU Parted 2.3
 Using /dev/sdd
 Welcome to GNU Parted! Type 'help' to view a list of commands.
 (parted) print
 Model: Generic- SD/MMC (scsi)
 Disk /dev/sdd: 16,1GB
 Sector size (logical/physical): 512B/512B
 Partition Table: msdos
Number Start End Size Type File system Flags
 1 4194kB 62,9MB 58,7MB primary fat16 lba
 2 62,9MB 16,1GB 16,0GB primary ext4
(parted) quit
 $

 

And of course, don’t choose ‘resize’ when the rspi first boots 🙂

Go to Top