SysAdmin Notes

SipHead
SysAdmin

Initial notes about debian operating system

Create new user

New user
sudo useradd -m -c "The Allmigthy" ambagasdowa -s /bin/bash

Installing sudo

Login as root user
apt install sudo

Then add to sudoers group

as root
/sbin/adduser USERNAME sudo

Or :

run as root
usermod -aG sudo USERNAME
Can add to several groups at once
usermod -aG tty,dialup,video,audio USERNAME

Configuration overview

Now, if you want to allow certain users to execute certain programs, here’s a quick example (for more information, read the fine manual), which you can put in a file in /etc/sudoers.d, probably using visudo -f /etc/sudoers.d/myfile.

User_Alias      MYADMINS = jdoe

Cmnd_Alias      SHUTDOWN = /sbin/reboot, /sbin/poweroff
Cmnd_Alias      PKGMGMT = /usr/bin/dpkg, /usr/bin/apt-get, /usr/bin/aptitude

# Users listed above (MYADMINS) can run package managers and reboot the system.
MYADMINS ALL = PKGMGMT, SHUTDOWN

No password prompt for sudo user

If you want sudo group members to execute commands without password, add the line:

%sudo ALL=(ALL) NOPASSWD: ALL

Examples

# User

 root  ALL=(ALL:ALL) ALL

 myself  ALL=(ALL:ALL) NOPASSWD:/bin/apt update, PASSWD:/bin/apt install*

# Groups

 %sudo   ALL=(ALL:ALL) ALL

Code Snippets

Drop the extension of $i
1
2
3
# Usage mdx2rst input.md output.rst

for i in $(ls *.md) ;do mdx2rst $i "${i%.*}".rst  ; done

Scan Network

CIDR Network notation can be calculate with ipcal

Note

Classless Inter-Domain Routing CIDR

ipcal ip
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
ambagasdowa@Kalacmul:~$ ipcalc 10.8.0.9
Address:   10.8.0.9             00001010.00001000.00000000. 00001001
Netmask:   255.255.255.0 = 24   11111111.11111111.11111111. 00000000
Wildcard:  0.0.0.255            00000000.00000000.00000000. 11111111
=>
Network:   10.8.0.0/24          00001010.00001000.00000000. 00000000
HostMin:   10.8.0.1             00001010.00001000.00000000. 00000001
HostMax:   10.8.0.254           00001010.00001000.00000000. 11111110
Broadcast: 10.8.0.255           00001010.00001000.00000000. 11111111
Hosts/Net: 254                   Class A, Private Internet

ambagasdowa@Kalacmul:~$ ipcalc 10.44.46.0
Address:   10.44.46.0           00001010.00101100.00101110. 00000000
Netmask:   255.255.255.0 = 24   11111111.11111111.11111111. 00000000
Wildcard:  0.0.0.255            00000000.00000000.00000000. 11111111
=>
Network:   10.44.46.0/24        00001010.00101100.00101110. 00000000
HostMin:   10.44.46.1           00001010.00101100.00101110. 00000001
HostMax:   10.44.46.254         00001010.00101100.00101110. 11111110
Broadcast: 10.44.46.255         00001010.00101100.00101110. 11111111
Hosts/Net: 254                   Class A, Private Internet

How to Scan Networks with Nmap

Run nmap
sudo nmap -sn 192.168.1.0/24
ambagasdowa@Kalacmul:~$ nmap -sn 192.168.1.0/24
Starting Nmap 7.80 ( https://nmap.org ) at 2023-08-06 09:51 CST
Nmap scan report for 192.168.1.62
Host is up (0.078s latency).
Nmap scan report for 192.168.1.85
Host is up (0.021s latency).
Nmap scan report for 192.168.1.87
Host is up (0.0025s latency).
Nmap scan report for 192.168.1.99
Host is up (0.00088s latency).
Nmap scan report for 192.168.1.113
Host is up (0.19s latency).
Nmap scan report for 192.168.1.114
Host is up (0.049s latency).
Nmap scan report for 192.168.1.128
Host is up (0.11s latency).
Nmap scan report for 192.168.1.129
Host is up (0.37s latency).
Nmap scan report for 192.168.1.168
Host is up (0.10s latency).
Nmap scan report for 192.168.1.178
Host is up (0.25s latency).
Nmap scan report for Kalacmul.uruk (192.168.1.224)
Host is up (0.000079s latency).
Nmap scan report for 192.168.1.248
Host is up (0.13s latency).
Nmap scan report for 192.168.1.254
Host is up (0.0011s latency).
Nmap done: 256 IP addresses (13 hosts up) scanned in 14.50 seconds

Fing

Download Fing
wget https://www.fing.com/images/uploads/general/CLI_Linux_Debian_5.5.2.zip
Run Fing
sudo fing 192.168.1.0\24
Result
-------------------------------------------------------------------------------
| State | Host                              | MAC Address       | Last change |
|-----------------------------------------------------------------------------|
|  UP   | 192.168.1.62                      | CA:39:7B:D9:2A:40 | 09:58:08    |
|  UP   | 192.168.1.69                      | 54:92:09:6C:A0:1F | 09:58:08    |
|  UP   | 192.168.1.85                      | B4:E6:2D:6C:F0:3F | 09:58:09    |
|  UP   | 192.168.1.87                      | D8:BF:C0:EC:A1:69 | 09:58:09    |
|  UP   | 192.168.1.99                      | E4:C3:2A:1B:AD:68 | 09:58:08    |
|  UP   | 192.168.1.113                     | 10:D5:61:64:6F:3E | 09:58:09    |
|  UP   | 192.168.1.114                     | 9C:1C:37:0B:3B:F8 | 09:58:09    |
|  UP   | 192.168.1.128                     | 68:57:2D:AA:2F:57 | 09:58:10    |
|  UP   | 192.168.1.129                     | 10:D5:61:67:12:94 | 09:58:10    |
|  UP   | 192.168.1.131                     | A2:F5:09:FF:EB:C9 | 09:58:10    |
|  UP   | 192.168.1.168                     | 10:D5:61:69:F5:F6 | 09:58:10    |
|  UP   | 192.168.1.170                     | 10:D5:61:6F:41:D5 | 09:58:10    |
|  UP   | 192.168.1.176                     | 38:1F:8D:CA:D7:A3 | 09:58:10    |
|  UP   | 192.168.1.178                     | 94:D3:31:3E:84:C6 | 09:58:10    |
|  UP   | 192.168.1.224                     | FC:4D:D4:D1:A6:97 | 09:58:07    |
|  UP   | 192.168.1.248                     | 32:CA:0B:36:56:E0 | 09:58:12    |
|  UP   | 192.168.1.254                     | 78:B4:6A:8C:58:E9 | 09:52:12    |
-------------------------------------------------------------------------------

09:58:24 > Discovery round completed in 18.201 seconds.
09:58:24 > Network 192.168.1.0/24 has 203/17 hosts up.

CHD

source

CHD is a lossless compression format originally developed for MAME, for the hard-drive contents of certain arcade machines. It has since been used in several other emulators as a means of storing CD-ROM game data. For CD-based games, it compresses the contents of a disc image (.cue + .bin files) to a single .chd file.

Creating CHDs from CD-ROMs

CHD files can be created using the chdman program, developed by the MAME project.
It is a command line application and creating a .chd file from an existing .cue is performed by running:
chdman createcd -i <game.cue> -o <game.chd>

To compress every file in a directory, use:

cd /path/to/folder
for i in *.cue; do chdman createcd -i "$i" -o "${i%.*}.chd"; done

To compress every file in subdirectories within a folder, use:

cd /path/to/folder
for i in */*.cue; do chdman createcd -i "$i" -o "${i%.*}.chd"; done

Windows

The following archive contains a MAME 0.205 version of CHDMAN and Windows batch files that can be used to quickly convert your PSX games to CHD (V5): Download

Run the appropriate batch file in the same folder as the ROM(s) you wish to compress, and it will search subfolders for .cue files to compress. If a .chd is not generated after running the appropriate batch, then something is wrong with the ROM(s) .cue.

MacOS

In MacOS, chdman can be installed through Homebrew, with the following command:

brew install rom-tools

Linux

On Debian based systems, including RetroPie, chdman can be found in the mame-tools package and can be installed with:

sudo apt install -y --no-install-recommends mame-tools

Interesting Commands

Timezone

To view all available time zones

Listing timezones
1
timedatectl list-timezones

To set a time zone

Change the timezone
1
sudo timedatectl set-timezone <your_time_zone>

Progress bar

If you have a large collection of files or just very big files this command assembly is is pretty handy as it gets you a progress bar:

$ pv files.zip= | cat - > uberFile.zip
25.0GiB 0:50:24 [8.48MiB/s] [============================================================>] 100%
$ unzip uberFile.zip

Ethernet

The ethtool -s command can be used to change the current settings by defining the values for speed, duplex, and autoneg in the following format:

sudo ethtool -s [device_name] autoneg [on/off] speed [10/100/1000] duplex [half/full]

For example, to set the speed at 1000Mb/s, the duplex mode to full and the auto-negotiation to on the command would be:

sudo ethtool -s enp0s3 autoneg on speed 1000 duplex full

The ethtool [device_name] command is necessary to confirm that the changes have been applied.

SC-IM

For copy to system clipboard

To Clipboard
ccopy
From Clipboard
ccpaste

OrangePi

Installation

Both the Panfrost and Lima drivers are included in Mesa and should work out-of-the-box after installing the relevant packages (which are, in practice, libglx-mesa0 and libgl1-mesa-dri).

OpenCL support is not implemented yet. Hardware video acceleration is not within the scope of the Panfrost or Lima drivers.

Troubleshooting

  1. No video/GPU acceleration

If you see Couldn’t initialize GPU devfreq in the log files, then you’re running into the problem that a devfreq module wasn’t loaded (early enough). Try (as root or with sudo) if rmmod panfrost && modprobe governor_simpleondemand && modprobe panfrost fixes the problem. If it does, then add governor_simpleondemand to the initramfs modules and rebuild the initramfs.

You can do that as root (or with sudo) as follows:

echo governor_simpleondemand >> /etc/initramfs-tools/modules && update-initramfs -u -k $(uname -r)

How to enable 3d support in zero3

GPU is not enabled in the current builds be they 5.4 or 6.1 based, but you can enable it by editing the dtb.

# Edit the dts file
dtc -I dtb -O dts /boot/dtb/allwinner/sun50i-h616-orangepi-zero3.dtb >/tmp/op3.dts
# open /tmp/op3.dts with your favourite editor
# search for 'mali'

# in the section where you find it edit the line status='disabled' to status='okay'
# recompile
dtc -I dts -O dtb /tmp/op3.dts >zero3.dtb
# Then replace the original with this after backing up and reboot.
# glxinfo should then show the panfrost driver in action.

Python

To easiest way to get back the old pre-Debian12 behaviour just for your user, is to add break-system-packages = true in the [global] section of your ~/.config/pip/pip.conf, as noted in /usr/share/doc/python3.11/README.venv:

This can be overriden by passing the –break-system-packages option to pip. You do this at your own risk: pip may break Python modules that part of your Debian system depends on. This option can also be specified by exporting PIP_BREAK_SYSTEM_PACKAGES=1 or configuring the following in ~/.config/pip/pip.conf or /etc/pip.conf:

[global]
break-system-packages = true

OR

sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED

You can install unionfs-fuse for this: .. code-block:: bash

sudo apt-get install unionfs-fuse

Mounting:

unionfs-fuse /folder1=RW:/folder2=RW /mount/point

It will group all content from folder1 and folder2 (or more if you want) to your mount point

Umounting:

sudo umount /mount/point

For example for mame roms

unionfs-fuse -o allow_other,use_ino,suid,dev,nonempty /media/source/torrents/end/MAME\ 0.261\ ROMs\ \(bios-devices\)/=RO:/media/source/torrents/end/MAME\ 0.261\ ROMs\ \(merged\)/=RO:/media/source/torrents/end/MAME\ 0.261\ CHDs\ \(merged\)/=RO arcade

Scraper

Scraper

Directories in Emulation Station :

downloaded_media/
└── arcade
    ├── backcovers
    ├── covers
    ├── fanart
    ├── marquees
    ├── miximages
    ├── screenshots
    └── titlescreens

The Relation is

├── backcovers       ?
├── covers           fly
├── fanart           b
├── marquees         m
├── miximages        mix4,mix3,3b,b
├── screenshots      s
└── titlescreens     t
Example command for scrape
scraper -mame -mame_img "fly" -mame_src "gdb,adb,mamedb,ss" -image_dir ~/.emulationstation/downloaded_media/arcade/covers -image_suffix "" -img_format png -rom_dir /media/source/torrents/end/MAME\ 0.261\ ROMs\ \(merged\)/
scraper -ss_password `/usr/bin/cat $HOME/credentials/ss/password` -ss_user `/usr/bin/cat $HOME/credentials/ss/usr` -mame -console_src "ss,gdb,ovgdb,adb,mamedb" -console_img "mix3,mix4,3b,b,s,l,f,a,fly,t,m,c" -image_dir ~/.emulationstation/downloaded_media/arcade/covers/ -image_suffix "" -img_format png -rom_dir /media/source/torrents/end/MAME\ 0.261\ ROMs\ \(merged\)/
Init Scraper
Skyscraper -f emulationstation -p arcade -u user:pass -i /media/source/torrents/end/MAME\ 0.261\ ROMs\ \(merged\)/ -g  /home/ambagasdowa/.emulationstation/downloaded_media/arcade -o /home/ambagasdowa/.emulationstation/downloaded_media/arcade -s screenscraper -t 2

Skyscraper modules

  • screenscraper

  • arcadedb

  • thegamesdb

  • openretro

  • mobygames

The gathering phase
1
Skyscraper -f emulationstation -p arcade -i /media/Orangepi3b/roms/ -g  /home/ambagasdowa/.emulationstation/downloaded_media/arcade -o /home/ambagasdowa/.emulationstation/downloaded_media/arcade
The gamelist genertation phase
1
Skyscraper -f emulationstation -p arcade -u `/usr/bin/cat $HOME/credentials/ss/password`:`/usr/bin/cat $HOME/credentials/ss/usr` -i /media/Orangepi3b/roms/ -g  /home/ambagasdowa/.emulationstation/downloaded_media/arcade -o /home/ambagasdowa/.emulationstation/downloaded_media/arcade -t 2 -s arcadedb

Torrents

Install we-get

python3 -m pip install --user git+https://github.com/rachmadaniHaryono/we-get.git

Search torrents with we-get

we-get --search="roms"  --target the_pirate_bay,1337x,limetorrents,il_corsaro_nero,eztv,yts -n 300

Install aria2

sudo apt install aria2

config example

~/.config/aria2/aria2.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
bt-seed-unverified
max-overall-upload-limit=1M
max-upload-limit=128K
seed-ratio=5.0
seed-time=240
continue
daemon=true
dir=/home/ambagasdowa/torrents/download/
file-allocation=falloc
log-level=warn
max-connection-per-server=4
max-concurrent-downloads=3
max-overall-download-limit=0
min-split-size=5M
enable-http-pipelining=true

enable-rpc=true
rpc-listen-all=true
rpc-secret=secret

Aria2 as daemon

~/.config/systemd/user/aria2cd.service
1
2
3
4
5
6
7
8
9
[Unit]
Description=aria2 Daemon

[Service]
Type=forking
ExecStart=/usr/bin/aria2c --conf-path=/path/to/conf

[Install]
WantedBy=default.target

run the daemon

aria2c --enable-rpc --rpc-secret *** --dir ~/torrents/ --enable-dht=true

Restart the service

systemctl --user restart aria2cd.service

Install aria2p

python3 -m pip install aria2p[tui]

add Magnet with aria2p

aria2p --secret *** add "magnet:?xt=urn:btih:E9E403A06D08CA0FEC40BBC32AB2BDE5B51782BF..."

Whatch them

aria2p --secret *** top

Fetch monitors

TODO: Awesome Fetchs

  • neofetch

  • cpufetch

  • onefetch

Update OneFetch

cargo install onefetch --force

TIP: What is the meaning of USB DM?

  • The data pair in USB is differential. It is just normal practice to call the (-) side Data Minus (DM) and the (+) side Data Plus (DP).

Testing MPV

starts a temporary X session with mpv only, then shuts down once mpv exits.
startx /usr/bin/mpv --fs filename.mp4 -- :1

WSDD

sudo apt install wsdd

Read

Extract a content in file and put in vim buffer

:r! sed -n 147,227p /path/to/foo/foo.c

For example

Command used for scrape the code from bash_aliases
1
r! sed -n 313,391p ~/gitlab/notes/src/bash/bash_aliases
:put =readfile('/path/to/foo/foo.c')[146:226]
"I just had to do this in a code project of mine and did it this way:
"In buffer with /path/to/foo/foo.c open:

:147,227w export.txt

"In buffer I'm working with:

:r export.txt

PDF to Image

You can use pdftoppm from the poppler-utils package to convert a PDF to a PNG:

pdftoppm input.pdf outputname -png

This will output each page in the PDF using the format outputname-01.png, with 01 being the index of the page.

Converting a single page or a range of pages of the PDF

pdftoppm input.pdf outputname -png -f {page} -singlefile

Change {page} to the page number. It’s indexed at 1, so -f 1 would be the first page.

If you’d like to work on a range of pages, you can also specify a number for the flag -l (last page), so having -f 1 -l 30 would specify the pages from 1 to 30.

Note again that .png will be appended to outputname automatically, so there’s no need to include the extension. Also, -singlefile removes the -01 suffix cited above, since the output is known to have only one file.

Specifying the converted image’s resolution

The default resolution for this command is 150 DPI. Increasing it will result in both a larger file size and more detail.

To increase the resolution of the converted PDF, add the options -rx {resolution} and -ry {resolution}. For example:

pdftoppm input.pdf outputname -png -rx 300 -ry 300

You can use ImageMagick for this. Note that newer versions of ImageMagick have disabled the ability to convert PDF files to images, because of security vulnerabilities that are being exploited in the wild. See the comments for more details and for a workaround.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Install imagemagick by clicking here or by running:

sudo apt install imagemagick

# Using a terminal where the PDF is located:

# For the full document:

convert -density 150 input.pdf -quality 90 output.png

#For a single page:

convert -density 150 input.pdf[666] -quality 90 output.png

Whereby:

PNG, JPG or (virtually) any other image format can be chosen.
-density xxx will set the DPI to xxx (common are 150 and 300).
-quality xxx will set the compression to xxx for PNG, JPG and MIFF file formates (100 means no compression).

[666] will convert only the 667th page to PNG (zero-based numbering so [0] is the 1st page).

All other options (such as trimming, grayscale, etc.) can be viewed on the website of Image Magic.

Zathura

Make zathura the default pdf viewer

Ensures, for example, that xdg-open(1) will open pdf files with zathura.

First, ensure a desktop entry for zathura exists at /usr/share/applications/org.pwmt.zathura.desktop. If it does not, download the desktop entry from from the zathura repo to /usr/share/applications/org.pwmt.zathura.desktop.

Then, set zathura as default using xdg-mime(1)

$ xdg-mime default org.pwmt.zathura.desktop application/pdf

XDG-Desktop

To find out the default app for a particular type of file

xdg-mime query filetype Documents/test.pdf

application/pdf

To find out the mime for the extension

xdg-mime query default application/pdf
# Response:
okularApplication_pdf.desktop

to set default app for an mimetype

xdg-mime default zathura.desktop application/pdf

to test if applied successfully

xdg-open test.md

kitty Terminal

Update kitty
1
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin     installer=nightly

Printers

install pdf printer via cups
sudo apt install printer-driver-cups-pdf

list printers

List available printers
lpstat -v
1
2
3
4
device for DCP-1510: usb://Brother/DCP-1510%20series?serial=U63561K3N556616
device for HP040E3C84624F_HP_Laser_MFP_131_133_135_138_: implicitclass://HP040E3C84624F_HP_Laser_MFP_131_133_135_138_/
device for MFP137: dnssd://HP040E3C84624F%20(HP%20Laser%20MFP%20131%20133%20135-138)._printer._tcp.local/
device for PDF: cups-pdf:/

or

List Printers
lpstat -p -d
1
2
3
4
5
printer DCP-1510 disabled since Tue 02 May 2023 05:55:18 PM CST -
  Unplugged or turned off
printer MFP137 is idle.  enabled since Sat 13 Jan 2024 05:34:13 PM CST
printer PDF is idle.  enabled since Tue 16 Jan 2024 08:19:33 PM CST
system default destination: DCP-1510
Print to pdf -d:printer-device -P:list of pages
lp -d PDF -P 105 file.pdf

Set default printer

lpoptions -d MFP137

Add Printer

sudo lpinfo -v
output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
serial serial:/dev/ttyS0?baud=115200
serial serial:/dev/ttyS4?baud=115200
network http
network lpd
network smb
direct usb://SUPERRISC/S31
direct hpfax
network dnssd://HP040E3C84624F%20(HP%20Laser%20MFP%20131%20133%20135-138)._pdl-datastream._tcp.local/
network ipp://HP040E3C84624F%20(HP%20Laser%20MFP%20131%20133%20135-138)._ipp._tcp.local/
network dnssd://HP040E3C84624F%20(HP%20Laser%20MFP%20131%20133%20135-138)._printer._tcp.local/
sudo lpadmin -p SUPERRISC_S31 -D "Receipt Printer" -E -v usb://SUPERRISC/S31
printer DCP-1510 disabled since Tue 02 May 2023 05:55:18 PM CST - Unplugged or turned off
printer HP040E3C84624F_HP_Laser_MFP_131_133_135_138_ is idle.  enabled since Wed 14 Feb 2024 08:32:40 AM CST
printer MFP137 is idle.  enabled since Wed 14 Feb 2024 05:15:25 PM CST
printer PDF is idle.  enabled since Wed 07 Feb 2024 01:42:03 PM CST
printer SUPERRISC_S31 is idle.  enabled since Wed 14 Feb 2024 05:43:35 PM CST
system default destination: MFP137

FZF test

Workig code for search pattern inside a pdf

find "$1" -type f -iname "*.pdf" | xargs -d '\n' -I {} pdfgrep -H -n "$scrapePattern" {} | fzf --multi --cycle --prompt='▶ ' --pointer='→ ' --marker='✓ ' --layout 'reverse' | eval $(awk -F : '{ print "pdftotext -f "$2" -l "$2 " -layout \""$1"\" -" }') | cat -p --paging=never

# and for capture a image

find "$1" -iname '*.pdf' | xargs -d '\n' -I {} pdfgrep -H -n "$scrapePattern" {} |fzf --multi --cycle --prompt='▶ ' --pointer='→ ' --marker='✓ ' | eval $(awk -F : '{ print "pdftoppm -f "$2" -l "$2 " -png \""$1"\" /tmp/img" }') && imv-x11 -r -d /tmp/img-*.png

Find

Recursively find and replace in files

find . -type f -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g'

Whit fzf

find ./ -type f | xargs -d '\n' -I {} egrep --color -H 'pattern' {} | fzf --multi --cycle --prompt='▶ ' --pointer='→ ' --marker='✓ ' --layout 'reverse'

Find and replace

find docs/ -type f | xargs -d '\n' -I {} egrep -H --color "imscholar" {} \\
| fzf --multi --cycle --prompt='▶ ' --pointer='→ ' --marker='✓ ' \\
| eval $(awk -F: '{print "sed -i '' 's/imscholar/portalapps/g' "$1""}' )

Consulta RFC

RFC

Consulta CURP

CURP

Update Letsencrypt

sudo certbot renew

Add Certificates

certbot --nginx -d baizabal.xyz -d portaltms.com -d office.baizabal.xyz -d video.baizabal.xyz -d voip.baizabal.xyz -d time.baizabal.xyz -d music.baizabal.xyz -d portalapps.xyz -d radiobases.com -d tiamandados.com --post-hook "/usr/sbin/service nginx restart"

Audio & Video Stream

Convert RTSP stream to virtual web camera

You can easily do it on Ubuntu, Debian, Raspian, and Ubuntu Linux for Windows subsystems using the following method,

  1. Installing required libraries, v4l2loopback-dkms and ffmpeg:

sudo apt install v4l2loopback-dkms
sudo apt install ffmpeg
  1. Emulate a video device:

sudo modprobe v4l2loopback card_label="Webcam Stream Name" exclusive_caps=1
  1. Streaming from RTSP uri to the created virtual device:

ffmpeg -stream_loop -1 -re -i rtsp://uri -vcodec rawvideo -threads 0 -f v4l2 /dev/video0

You can replace the ‘0’ at the end of /dev/video0 with the number of the available and playable video device.

a better example

ffmpeg -stream_loop -1 -re -i rtsp://uri -vcodec rawvideo -threads 0 -pix_fmt yuv420p -preset ultrafast -b:v 600k -f v4l2 /dev/video0

Capture RTSP stream from IP Camera and store

ffmpeg -i rtsp://192.168.0.21:554/mpeg4 -vcodec copy -acodec copy -map 0 -f segment -segment_time 300 -segment_format mp4 "ffmpeg_capture-%03d.mp4"

Retransmision

ffmpeg -i rtsp://original-source \
-pix_fmt yuv420p -c:v libx264 -preset ultrafast -b:v 600k \
-c:a aac -b:a 160k \
-f rtsp rtsp://localhost:8554/mystream

Mediaplayer

creating a virtual microphone and streaming audio into it from RTSP IP camera

I need to create both virtual webcam and virtual microphone on an Ubuntu 16.04 machine for use in web application using WebRTC through my web browser.

I need to feed video and audio to these 2 virtual devices from an IP camera (RTSP stream). Playing RTSP stream directly in VLC works fine with both video and audio.

For this, I have created a /dev/video1 with video4linux2. I am able to feed the IP camera to /dev/video1.

ffmpeg -i rtsp://ip_address:554/streaming/channels/101/ -f v4l2 /dev/video1

If I look in VLC player, I can select /dev/video1 as a video device, but I have only “hw:0,0” as audio device, which is my in-built microphone.

How to properly feed such RTSP stream to both virtual webcam and virtual microphone?

You need some sort of loopback audio driver. If you want to do this at the Alsa level, you can lose the snd-aloop module. https://www.alsa-project.org/main/index.php/Matrix:Module-aloop#aloop_driver

If your intended destination supports Pulseaudio, you can add a null sink and use its monitor source to record from it.

pactl load-module module-null-sink sink_name=video1

The monitor source is then named video1.source.

https://wiki.archlinux.org/index.php/PulseAudio/Examples

Then, you need to add an additional output from FFmpeg. That might be as simple as adding something like -f pulse "video1" to the end of what you have now

Note

When I add -f pulse “video1”, the sound is played through my speakers directly (Monitor of Built-in Audio Analog Stereo) instead of the virtual microphone, maybe you have an idea why? Here is the command I used to play the sound through the ALSA virtual microphone: ffmpeg -re -i webcam_record.mp4 -f v4l2 /dev/video0 -f alsa hw:1,1. When I tested the result with VLC it did not work, I had to test with guvcview.

My goal is testing Video Room Application, so I’m going to create multiple virtual machines with virtual webcams and microphones.

Webcam is working fine with v4l2loopback, but microphone is not.

I’m trying to use ALSA.

ffmpeg -re -i cox.mp4 -map 0:0 -f v4l2 /dev/video0 -map 0:1 -f alsa hw:1

As a result, Firefox sees Dummy Video device and can use it. Firefox also sees Dummy analog stereo and Loopback analog stereo, but there is no sound from these ‘microphones’.

Something wrong with ffmpeg command or with ALSA itself or I’m just doing everything wrong?

Note

Thanks for the hint -f alsa hw:1, I managed to get it working by using -f alsa hw:1,1 instead. First, I had to enable the virtual microphone with modprobe snd-aloop (see this related question stackoverflow.com/a/43565890/1176454). Here is the full command I used: ffmpeg -re -i webcam_record.mp4 -f v4l2 /dev/video0 -f alsa hw:1,1. I then tested to play the fake webcam and microphone stream with VLC but it did not work. When I tried with guvcview it worked.

SSH

SSH notes

Generate Public keys

You can generate a new SSH key on your local machine. After you generate the key, you can add the public key to your account on GitHub.com or your own server to enable authentication for Git or Server operations over SSH.

Command to generate pairs keys
1
2
3
4
5
ssh-keygen -t ed25519 -C "your_email@example.com"

# For legacy

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Adding your SSH key to the ssh-agent

eval "$(ssh-agent -s)"

Add your SSH private key to the ssh-agent

If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.

ssh-add ~/.ssh/id_ed25519

Upload Public key to Server

ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 22 user@1.1.1.1
# OR
ssh-copy-id user@server.com

Configure ssh to use the key.

vim ~/.ssh/config

Your config file should have something similar to the following:

Host SERVERNAME
Hostname ip-or-domain-of-server
User USERNAME
PubKeyAuthentication yes
IdentityFile ./path/to/key

For example

ssh config file example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
Host foo.example.com
   KexAlgorithms +diffie-hellman-group1-sha1
   HostKeyAlgorithms +ssh-rsa
Host 192.168.1.147
    Ciphers 3des-cbc
    KexAlgorithms +diffie-hellman-group1-sha1
    User admin
Host 192.168.1.97
    Ciphers aes128-cbc
    KexAlgorithms +diffie-hellman-group1-sha1
    User admin
Host baizabal.xyz
    User ambagasdowa
Host gitdowa
  HostName baizabal.xyz
  Port 23231
Host kukulkan
    User ambagasdowa
Host uxmal
    User dula
Host *
    Port 22

Check that you are connecting to the correct server

ssh -vT git@github.com

Check logs in /var/log/auth.log

Disable password authentication

Most servers allow both username/password authentication and SSH key authentication, but if you want to allow only SSH key authentication, then you can disable the use of usernames and passwords. Be certain that you have thought through the ramifications before doing so, because once you take this action, successful certificate authentication will be the only way to access your server.

This is accomplished through the sshd_config file. The exact location of this file varies by Linux distribution. Often it’s in the /etc/ssh directory. Edit this file to include the following parameters:

/etc/ssh/ssh_config
1
2
3
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no

After change reload the server

sudo systemctl restart sshd.service

SSH Authentication Refused: Bad Ownership or Modes for Directory

check this permissions

SSH doesn’t like it if your home or ~/.ssh directories have group write permissions. Your home directory should be writable only by you, ~/.ssh should be 700, and authorized_keys should be 600 :

chmod go-w  ~/
chmod 700   ~/.ssh
chmod 600   ~/.ssh/authorized_keys

SOFT -GIT SERVER-

Debian/Ubuntu
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
sudo apt update && sudo apt install soft-serve

Soft-Serve

Serve

Add new user in the server

Create an user
ssh gitdowa user create ambagasdowa
Add pub-key
ssh gitdowa user add-pubkey ambagasdowa `echo /usr/bin/cat .ssh/id_ed25519.pub`
ssh gitdowa user create ambagasdowa '-k "`echo /usr/bin/cat .ssh/id_ed25519.pub`"'

Script for automate ssh commands

sshpass -p `/usr/bin/cat ~/credentials/db/baizabal.xyz/pw` runoverssh ambagasdowa "cd ~/gitlab/documents && ls" baizabal.xyz

Also works for rsync

sshpass -p `/usr/bin/cat ~/credentials/db/baizabal.xyz/pw` rsync -axPz ambagasdowa@baizabal.xyz:/var/www/cloud/public_html/data/username/files/ /media/backup/

Awk

Examples :

Extrac of the paz.html document
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<a href="sacrificio.html" class="otro">
 sacrificio
</a>
de Jesús
<cite>
 Jn 16,33
</cite>
; como en la tradición sinóptica, no tiene
nada que ver con la paz de este mundo.
</p>
<p>
Como el AT, que
veía en la
<a href="presencia_de_dios.html" class="otro">
 presencia
</a>
de Dios entre su pueblo el bien supremo de la paz (p.e.
<cite>
 Lev 26,12
</cite>
<cite>
 Ez 37,26
</cite>
curl -s https://hjg.com.ar/vocbib/art/paz.html | pup --color 'cite text{}' > ~/Documents/cites
Output from above command
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
Job 9,4
1Re 9,25
Ex 21,34
Sal 50,14
Ecl 3,8
Ap 6,4
Sal 38,4
2Sa 18,32
Gen 43,27
Gen 25,8
Gen 15,15
Lc 2,29
Jue 6,23
Dan 10,19
Jos 21,44
23,1
2Sa 7,1
1Re 5,4
1Par 22,9
Eclo 47,13
Sal 41,10
Jer 20,10

file cites_sort

LeonDufour Cites Catalog cross Biblical Order
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
1 1 Gen Génesis
2 1 Ex Éxodo
3 1 Lev Levitico
4 1 Num Números
5 1 Dt Deuteronomio
6 1 Jos Josué
7 1 Jue Jueces
8 1 Rut Rut
9 1 Sa Samuel
10 1 1Sa Samuel
11 1 2Sa Samuel
12 1 Re Reyes
13 1 1Re Reyes
14 1 2Re Reyes
15 1 Par Paralipómenos-Cronicas
16 1 1Par Paralipómenos-Cronicas
17 1 2Par Paralipómenos-Cronicas
18 1 Cro Cronicas
19 1 1Cro Cronicas
20 1 2Cro Cronicas
21 1 Esd Esdras
22 1 Neh Nehemías
23 1 Tob Tobías
24 1 Jdt Judit
25 1 Est Ester
26 1 Mac Macabeos
27 1 1Mac Macabeos
28 1 2Mac Macabeos
29 1 Sal Salmos
30 1 Cant Cantar
31 1 Lam Lamentaciones
32 1 Job Job
33 1 Prov Proverbios
34 1 Ecl Eclesiastés
35 1 Sab Sabiduría
36 1 Eclo Eclesiástico
37 2 Is Isaías
38 2 Jer Jeremías
39 2 Bar Baruc
40 2 Ez Ezequiel
41 2 Dan Daniel
42 2 Os Oseas
43 2 Jl Joel
44 2 Am Amos
45 2 Abd Abdias
46 2 Jon Jonás
47 2 Miq Miqueas
48 2 Nah Nahúm
49 2 Hab Habacuc
50 2 Sof Sofonias
51 2 Ag Ageo
52 2 Zac Zacarías
53 2 Mal Malaquias
54 4 Mt Mateo
55 4 Mc Marcos
56 4 Lc Lucas
57 4 Jn Juan
58 3 Act Actas-Hechos
59 3 Hch Hechos
60 3 Rom Romanos
61 3 Gal Gálatas
62 3 Cor Corintios
63 3 1Cor Corintios
64 3 2Cor Corintios
65 3 Ef Efesios
66 3 Flp Filipenses
67 3 Col Colosenses
68 3 Tes Tesalonicenses
69 3 1Tes Tesalonicenses
70 3 2Tes Tesalonicenses
71 3 Tim Timoteo
72 3 1Tim Timoteo
73 3 2Tim Timoteo
74 3 Tit Tito
75 3 Flm Filemón
76 3 Heb Hebreos
77 3 Pe Pedro
78 3 1Pe Pedro
79 3 2Pe Pedro
80 3 1Jn Juan
81 3 2Jn Juan
82 3 Sant Santiago
83 3 Jds Judas
84 3 Ap Apocalipsis

File paz_cites_lts.txt

File from scrape the LeonDufour html file after remove some duplicates
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
Job 9,4
1Re 9,25
Ex 21,34
Ecl 3,8
Ap 6,4
Gen 43,27
Gen 25,8
Gen 15,15
Lc 2,29
Jue 6,23-24
Dan 10,19
Jos 21,44
Jos 23,1
2Sa 7,1
1Re 5,4
1Par 22,9
Eclo 47,13
Jer 20,10
Num 25,12
Eclo 45,24
Jos 9,15
Jue 4,17
1Re 5,26
Lc 14,32
Act 12,20
Gen 26,29
2Sa 18,29-32
Dan 3,98
Flm 3
2Re 9,18
Jue 8,9
Jue 18,5s
1Sa 1,17
Jer 6.14
Is 57,18s
Lev 3,1
Prov 12,20
Prov 3,2
Lev 26,1-13
Is 45,7
Num 6,26
1Re 2,33
Mal 2,5
Is 26,3
Miq 3,5
Jer 14,13
1Re 22,13-28
Jer 23,9-40
Ez 13,15s
Jer 29,11
Jer 33,9
Ez 34,25-30
Ez 37,26
Os 2,20...
Am 9,13
Is 9,5-6
Zac 9,9s
Miq 5,4
Is 2,2..
Is 11,1..
Is 32,15-20
Is 65,25
Nah 2,1
Is 52,7
Is 55.12
Is 53,5
Is 60,17
Is 66,12
Is 48,18.22
Zac 8,12
Eclo 44,14
Sab 3,1ss
Sant 3,18
Lc 2,14
Lc 19,38
Lc 19,42
Lc 8,48 p
Lc 7,50
Lc 10,5-9
Lc 12.51
Lc 17,26-36
1Tes 5,3
Lc 24,36
Act 7,26
Act 9,31
Act 15,23
Act 24,2
Act 10,36
Ef 2,14-22
Col 1,20
Ef 4,3
2Cor 13,11
1Tes 5,23
Gal 5,22
Rom 14,17
Rom 8,6
Flp 4,7
Rom 5,1-5
1Cor 7,15
Rom 12,18
2Tim 2,22
Heb 13,20
Rom 16,20
Jn 16,33
Jn 14,27
Jn 20,19-23
Ap 21,2
Mt 5,9
Gal 3,28
Col 3,11-15
ordering lookup
1
awk 'NR==FNR{ a[$3]=$1;b[$3]=$2;next } { print a[$1],b[$1],$0}' cites_sort paz_cites_lts.txt
Result
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
32 1 Job 9,4
13 1 1Re 9,25
2 1 Ex 21,34
34 1 Ecl 3,8
84 3 Ap 6,4
1 1 Gen 43,27
1 1 Gen 25,8
1 1 Gen 15,15
56 4 Lc 2,29
7 1 Jue 6,23-24
41 2 Dan 10,19
6 1 Jos 21,44
6 1 Jos 23,1
11 1 2Sa 7,1
13 1 1Re 5,4
16 1 1Par 22,9
36 1 Eclo 47,13
38 2 Jer 20,10
4 1 Num 25,12
36 1 Eclo 45,24
6 1 Jos 9,15
7 1 Jue 4,17
13 1 1Re 5,26
56 4 Lc 14,32
58 3 Act 12,20
1 1 Gen 26,29
11 1 2Sa 18,29-32
41 2 Dan 3,98
75 3 Flm 3
14 1 2Re 9,18
7 1 Jue 8,9
7 1 Jue 18,5s
10 1 1Sa 1,17
38 2 Jer 6.14
37 2 Is 57,18s
3 1 Lev 3,1
33 1 Prov 12,20
33 1 Prov 3,2
3 1 Lev 26,1-13
37 2 Is 45,7
4 1 Num 6,26
13 1 1Re 2,33
53 2 Mal 2,5
37 2 Is 26,3
47 2 Miq 3,5
38 2 Jer 14,13
13 1 1Re 22,13-28
38 2 Jer 23,9-40
40 2 Ez 13,15s
38 2 Jer 29,11
38 2 Jer 33,9
40 2 Ez 34,25-30
40 2 Ez 37,26
42 2 Os 2,20...
44 2 Am 9,13
37 2 Is 9,5-6
52 2 Zac 9,9s
47 2 Miq 5,4
37 2 Is 2,2..
37 2 Is 11,1..
37 2 Is 32,15-20
37 2 Is 65,25
48 2 Nah 2,1
37 2 Is 52,7
37 2 Is 55.12
37 2 Is 53,5
37 2 Is 60,17
37 2 Is 66,12
37 2 Is 48,18.22
52 2 Zac 8,12
36 1 Eclo 44,14
35 1 Sab 3,1ss
82 3 Sant 3,18
56 4 Lc 2,14
56 4 Lc 19,38
56 4 Lc 19,42
56 4 Lc 8,48 p
56 4 Lc 7,50
56 4 Lc 10,5-9
56 4 Lc 12.51
56 4 Lc 17,26-36
69 3 1Tes 5,3
56 4 Lc 24,36
58 3 Act 7,26
58 3 Act 9,31
58 3 Act 15,23
58 3 Act 24,2
58 3 Act 10,36
65 3 Ef 2,14-22
67 3 Col 1,20
65 3 Ef 4,3
64 3 2Cor 13,11
69 3 1Tes 5,23
61 3 Gal 5,22
60 3 Rom 14,17
60 3 Rom 8,6
66 3 Flp 4,7
60 3 Rom 5,1-5
63 3 1Cor 7,15
60 3 Rom 12,18
73 3 2Tim 2,22
76 3 Heb 13,20
60 3 Rom 16,20
57 4 Jn 16,33
57 4 Jn 14,27
57 4 Jn 20,19-23
84 3 Ap 21,2
54 4 Mt 5,9
61 3 Gal 3,28
67 3 Col 3,11-15
awk 'NR==FNR{ a[$3]=$1;b[$3]=$2;next } { print b[$1]"&"$0}' cites_sort paz_cites_lts.txt | sort | pr -t4 -s"&"
1&1Par 22,9&1&Lev 3,1&2&Jer 23,9-40&3&Ef 4,3
1&1Re 22,13-28&1&Num 25,12&2&Jer 29,11&3&Flm 3
1&1Re 2,33&1&Num 6,26&2&Jer 33,9&3&Flp 4,7
1&1Re 5,26&1&Prov 12,20&2&Jer 6.14&3&Gal 3,28
1&1Re 5,4&1&Prov 3,2&2&Mal 2,5&3&Gal 5,22
1&1Re 9,25&1&Sab 3,1ss&2&Miq 3,5&3&Heb 13,20
1&1Sa 1,17&2&Am 9,13&2&Miq 5,4&3&Rom 12,18
1&2Re 9,18&2&Dan 10,19&2&Nah 2,1&3&Rom 14,17
1&2Sa 18,29-32&2&Dan 3,98&2&Os 2,20...&3&Rom 16,20
1&2Sa 7,1&2&Ez 13,15s&2&Zac 8,12&3&Rom 5,1-5
1&Ecl 3,8&2&Ez 34,25-30&2&Zac 9,9s&3&Rom 8,6
1&Eclo 44,14&2&Ez 37,26&3&1Cor 7,15&3&Sant 3,18
1&Eclo 45,24&2&Is 11,1..&3&1Tes 5,23&4&Jn 14,27
1&Eclo 47,13&2&Is 2,2..&3&1Tes 5,3&4&Jn 16,33
1&Ex 21,34&2&Is 26,3&3&2Cor 13,11&4&Jn 20,19-23
1&Gen 15,15&2&Is 32,15-20&3&2Tim 2,22&4&Lc 10,5-9
1&Gen 25,8&2&Is 45,7&3&Act 10,36&4&Lc 12.51
1&Gen 26,29&2&Is 48,18.22&3&Act 12,20&4&Lc 14,32
1&Gen 43,27&2&Is 52,7&3&Act 15,23&4&Lc 17,26-36
1&Job 9,4&2&Is 53,5&3&Act 24,2&4&Lc 19,38
1&Jos 21,44&2&Is 55.12&3&Act 7,26&4&Lc 19,42
1&Jos 23,1&2&Is 57,18s&3&Act 9,31&4&Lc 2,14
1&Jos 9,15&2&Is 60,17&3&Ap 21,2&4&Lc 2,29
1&Jue 18,5s&2&Is 65,25&3&Ap 6,4&4&Lc 24,36
1&Jue 4,17&2&Is 66,12&3&Col 1,20&4&Lc 7,50
1&Jue 6,23-24&2&Is 9,5-6&3&Col 3,11-15&4&Lc 8,48 p
1&Jue 8,9&2&Jer 14,13&3&Ef 2,14-22&4&Mt 5,9
1&Lev 26,1-13&2&Jer 20,10

The result above can be appended in a tex file

Awk Explaination

Here’s an awk solution,

$ <span class="hljs-built_in">cat</span> &gt; list
C1
C2
H3
H4
O5
$ <span class="hljs-built_in">cat</span> &gt; order
5
3
1
2
4
$ awk <span class="hljs-string">'NR==FNR{a[FNR]=$1;next} {print a[$1]}'</span> list order
O5
H3
C1
C2
H4

Brief explanation,

  • NR==FNR{a[FNR]=$1;next}: set the $1 for each record in list into the array element a[FNR]

  • print a[$1]: for $1 in each record in the file order, print corresponding a[$1]. In this case, the order would be kept.

PUP

Scrape contabo prices
1
curl -s https://contabo.com/en/vps/ | pup --color 'div.product-container > div.content span , + div .pre-decimal-col, + div.specs-container > div.spec > div.spec-info span json{}' | jq -r '.[] | .text'
Scrapes contabo bare metal servers
1
curl -s https://contabo.com/en/vps/ | pup --color 'div.product-container > div.content ,+span ,+ div.price-wrapper > div.pre-decimal-col text{}'  > /tmp/file
Clean empty lines
1
curl -s https://contabo.com/en/dedicated-servers/ | pup --color 'div.product-container > div.content ,+span ,+ div.price-wrapper > div.pre-decimal-col text{}' | grep -v '^[[:space:]]*$'
Cloud VPS 14
50
/ month
4 vCPU Cores
6 GB RAM
100 GB NVMe
or 400 GB SSD
1 Snapshot
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 29
50
/ month
6 vCPU Cores
16 GB RAM
200 GB NVMe
or 400 GB SSD
2 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 314
00
/ month
8 vCPU Cores
24 GB RAM
300 GB NVMe
or 1.2 TB SSD
2 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 426
00
/ month
12 vCPU Cores
48 GB RAM
400 GB NVMe
or 1.6 TB SSD
3 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 533
50
/ month
16 vCPU Cores
64 GB RAM
500 GB NVMe
or 2 TB SSD
3 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 661
50
/ month
24 vCPU Cores
120 GB RAM
600 GB NVMe
or 2.4 TB SSD
3 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 14
50
/ month
4 vCPU Cores
6 GB RAM
100 GB NVMe
or 400 GB SSD
1 Snapshot
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 29
50
/ month
6 vCPU Cores
16 GB RAM
200 GB NVMe
or 400 GB SSD
2 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 314
00
/ month
8 vCPU Cores
24 GB RAM
300 GB NVMe
or 1.2 TB SSD
2 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 426
00
/ month
12 vCPU Cores
48 GB RAM
400 GB NVMe
or 1.6 TB SSD
3 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 533
50
/ month
16 vCPU Cores
64 GB RAM
500 GB NVMe
or 2 TB SSD
3 Snapshots
32 TB Traffic*
Unlimited Incoming
------
Cloud VPS 661
50
/ month
24 vCPU Cores
120 GB RAM
600 GB NVMe
or 2.4 TB SSD
3 Snapshots
32 TB Traffic*
Unlimited Incoming
------
curl -s https://www.google.com/finance/markets/currencies | pup --color 'li > a[href*="-MXN"] div.ZvmM7 , li > a[href*="-MXN"] div.YMlKec text{}' | pr -t2 -s":"
USD / MXN:16.9724
EUR / MXN:18.2655
JPY / MXN:0.1109
GBP / MXN:21.2970
AUD / MXN:11.2035
curl -s https://www.google.com/finance/markets/currencies | pup --color 'li > a[href*="-MXN"] div.ZvmM7 , li > a[href*="-MXN"] div.YMlKec text{}' | pr -t2 -s":" | jq -cR | jq -s .
[
  "USD / MXN:16.9724",
  "EUR / MXN:18.2655",
  "JPY / MXN:0.1109",
  "GBP / MXN:21.2970",
  "AUD / MXN:11.2035"
]
curl -s https://www.google.com/finance/markets/currencies | pup --color 'li > a[href*="-MXN"] div.ZvmM7 , li > a[href*="-MXN"] div.YMlKec text{}' | pr -t2 -s":" | jq -Rs '{array:split("\n")|map(split(":")|{(.[0]):.[1]}?)}'

# OR

curl -s https://www.google.com/finance/markets/currencies | pup --color 'li > a[href*="-MXN"] div.ZvmM7 , li > a[href*="-MXN"] div.YMlKec text{}' | pr -t2 -s":"   | jq -nR '{currency: (reduce inputs as $line ([]; . + [$line | split(":") | {(.[0]):.[1]}]))}'
Output
{
  "array": [
    {
      "USD / MXN": "16.9724"
    },
    {
      "EUR / MXN": "18.2655"
    },
    {
      "JPY / MXN": "0.1109"
    },
    {
      "GBP / MXN": "21.2970"
    },
    {
      "AUD / MXN": "11.2035"
    }
  ]
}
input
curl -s https://www.google.com/finance/markets/currencies | pup --color 'li > a[href*="-MXN"] div.ZvmM7 , li > a[href*="-MXN"] div.YMlKec text{}' | pr -t2 -s":" |jq -R -n -c '[inputs|split(":")|{(.[0]):.[1]}]'
output
[{"USD / MXN":"16.9724"},{"EUR / MXN":"18.2655"},{"JPY / MXN":"0.1109"},{"GBP / MXN":"21.2970"},{"AUD / MXN":"11.2035"}]

Webdav

sudo wsgidav --host=192.168.1.1 --port=80 --root=/home/ambagasdowa/web/1603-SIP-1.0.1/ --auth=anonymous

How to install Wsgidav

Tftp

sudo ptftpd -p 69 -v -D end0 /home/ambagasdowa/ftp/cp69xx/

pipy

pypisearch scdbf

Automount

Automount without Graphical Enviroment
git clone https://github.com/raamsri/automount-usb.git

Certifica.jar

java -jar Certifica.jar

Half Life Clock

Firts install sox

Install sox
sudo apt install sox
Install all formats
sudo apt install libsox-fmt-all

Next Download the script and sounds

wget https://calomel.org/half_life_talking_clock.bz2

Note

  • Download the half_life_talking_clock.bz2 file which is only 169 kilobytes. It contains the perl script and the wav files in a nice little bzipped, tarball.

  • Untar and bzip decompress the file using “tar jxvf half_life_talking_clock.bz2”

  • cd into the script directory, “cd half_life_talking_clock”

  • execute the script “./half-life_clock.pl” to hear the current time.

Install NCHAT

Whatsapp and Telegram in a text mode user interface

Source:

To download the nchat application on a Debian/Ubuntu system, follow the following steps, or for other distributions, follow the guides on the github page at nchat

Compile
mkdir -p build && cd build && cmake .. && make -s
Install
sudo make install

Update Golang

wget https://go.dev/dl/go1.20.14.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz
in ~/.profile
export PATH=$PATH:/usr/local/go/bin
go version

VNC

Keyboard

Aula Keyboard

Automated Download PowerShell

Script for automated download and install connections script

Run Sudo command

sudo -- sh -c 'echo "ifconfig-push 10.44.45.151 255.255.255.0" >> ccd/consulta'

rename command

find . -depth -name "*.html" -exec sh -c 'f="{}"; mv -- "$f" "${f%.html}.php"' \;

For ce remove deb package ————————

sudo dpkg -r --force-depends "packagename"

XFS: Filesystem has duplicate UUID

How can I solve “_XFS Filesystem has duplicate UUID_” error message on my Linux server/Desktop?. If you get this error message in kernel _dmesg_ logs, it means you cannot mount your XFS partition. But don’t worry since we have a solution for you in this guide.

sudo mount -o rw,nouuid /dev/sda3  /mnt
Regenerate UUID
1
2
3
4
sudo xfs_admin -U generate /dev/sda3
Clearing log and setting UUID
writing all SBs
new UUID = 95d271cc-2987-43cd-abbb-bf44eddf158d

Monitoring a directory

watch --color -n0.1 tree -C --sort=ctime -trh --du /media/Black/Data/Roms/gc/{tmp,chd}

NFS

Test Block Device

time dd if=/dev/zero of=/home/ambagasdowa/remote-kukulkan/home/ambagasdowa/testfile bs=16k count=16384

Mount NFS device

for x in $(IFS=',';echo "White,Black,HGSDATA"); do mount -t nfs4 192.168.1.1:/media/"$x"; done
# OR if entry exists in fstab
for i in $(echo 'White,Black,HGSDATA' | tr ',' "\n" ) ; do mount /media/$i ; done
sudo mount -t nfs4 192.168.1.1:/media/HGSDATA /media/HGSDATA

Umount NFS

sudo umount /media/{White,Black,HGSDATA}

OrangeUserRemove

At least for Debian 12 Bookworm running on Orange Pi 5 Plus: took me hours to find, but this worked for me: To disable the autologin, you need to edit the override.conf file under /usr/lib/systemd/system/getty@.service.d/.

Open the file in a text editor with root privileges. For example, if you’re using nano as your text editor, you would use the following command:

sudo nano /usr/lib/systemd/system/getty@.service.d/override.conf

Once the file is open, you should see the line that reads:

ExecStart=-/sbin/agetty –noissue –autologin orangepi %I $TERM

Edit this line to remove the –autologin orangepi option. The line should then read:

ExecStart=-/sbin/agetty –noissue %I $TERM

Save the changes and exit the text editor. In nano, you can do this by pressing Ctrl+O to save, and Ctrl+X to exit.

Finally, you need to reload the systemd daemon to apply the changes. You can do this with the following command:

sudo systemctl daemon-reload

After these steps, the ‘orangepi’ user should no longer be logged in automatically. The next time you start your system, you should be prompted for a username and password.

sudo usermod -u 1000 ambagasdowa
sudo groupmod -g 1000 ambagasdowa
sudo vim /lib/systemd/system/getty@.service.d/override.conf
sudo vim /lib/systemd/system/serial-getty@.service.d/override.conf

sudo systemctl daemon-reload

"ps -aux | grep orangepi"

kill -9 <PID>

cat /etc/passwd | grep "ambagasdowa"
ambagasdowa:x:1000:1000:The Allmigthy:/home/ambagasdowa:/bin/bash

sudo find / -user 1003 -exec chgrp -h ambagasdowa {} \;

sudo find / -user 1003 -exec chgrp -h ambagasdowa {} \;

# Delete user
# ps aux | grep orangepi

# kill -9 <process ids of the orangepi user>

# userdel -f orangepi

find / -group 2000 -exec chgrp -h foo {} \;
find / -user 1005 -exec chown -h foo {} \;

Update Alternatives: Python

Add python 3.11

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 20

Check current config

sudo update-alternatives --config python

HostnameCtl

How to determine if our computer is a desktop or laptop

Using hostnamectl With the chassis Option or Using dmidecode

sudo dmidecode -s chassis-type

In case we use a laptop, the output of the command may be “Laptop“, “Notebook“, “Portable“, “Hand held” or “Sub Notebook” depending on the manufacturer’s designation.

The other possible outputs of this command are “computer-laptop” for the laptop type, and “computer-vm” for the virtual machine type.

How to know
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
ambagasdowa@kalacmul:~$ hostnamectl
 Static hostname: kalacmul
       Icon name: computer-desktop
         Chassis: desktop 🖥️
      Machine ID: c97baa23a9e24dcd87564c4c8bea7ff2
         Boot ID: 423e0e9b7f6041c5951742eb302df3e4
Operating System: Debian GNU/Linux 12 (bookworm)
          Kernel: Linux 6.1.0-25-amd64
    Architecture: x86-64
 Hardware Vendor: Lenovo
  Hardware Model: ThinkCentre M93p
Firmware Version: FBKT73AUS

Logs

logrotate

The safest mode to clean logs is using logrotate

logrotate -vf /etc/logrotate.conf

Cleaning /var/log/journal

journalctl --vacuum-time=10d

deleting :

sudo rm -rf /var/log/user.log
sudo rm -rf /var/log/syslog
sudo rm -rf /var/log/messages
systemctl restart syslog.service

In server lookup for highest log files and found debug and mail file ambagasdowa this files has up to 500 gb The working command is :

truncate -s 0 /var/log/debug
truncate -s 0 /var/mail/ambagasdowa

FFMPEG

Extract Video

how to extract from 0 sec to 5 secs

ffmpeg -i kcho_y.mp4 -ss 00:00:00 -t 00:00:05 -c copy VideoClip.mp4
ffmpeg -i video.mp4 -ss 00:00:02 -t 00:00:03 -c:v copy -c:a copy trim-2.mp4

Grab the Desktop

ffmpeg -f x11grab -y -r 30 -s 1920x1080 -i :0.0 -vcodec huffyuv out.avi

Compress

ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

For telegram and other

ffmpeg -i out.avi -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p out.mp4

Note

This was really driving me nuts: It’s important that the file extension is “.mp4”. If you upload a video with “.m4v” extension you’ll not see a preview window and the video is opened in an external player. So here is my final command to reencode and resize a video and send it to the bot using curl:

ffmpeg -i input -an -c:v libx264 -crf 26 -vf scale=640:-1 out.mp4
curl -v -F chat_id=CHATID -F video=@out.mp4 -F caption=foobar https://api.telegram.org/bot<TOKEN>/sendVideo

Routes

with german gateaway

0.0.0.0/1 via 10.44.45.1 dev tun1
default via 192.168.1.254 dev eno1 proto kernel onlink
10.14.17.0/24 dev vmbr1 proto kernel scope link src 10.14.17.1 linkdown
10.44.45.0/24 dev tun1 proto kernel scope link src 10.44.45.224
128.0.0.0/1 via 10.44.45.1 dev tun1
173.212.200.183 via 192.168.1.254 dev eno1
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.224

local internet gateaway

0.0.0.0/2 via 192.168.1.254 dev eno1
0.0.0.0/1 via 10.44.45.1 dev tun1
default via 192.168.1.254 dev eno1 proto kernel onlink
10.14.17.0/24 dev vmbr1 proto kernel scope link src 10.14.17.1 linkdown
10.44.45.0/24 dev tun1 proto kernel scope link src 10.44.45.224
64.0.0.0/2 via 192.168.1.254 dev eno1
128.0.0.0/2 via 192.168.1.254 dev eno1
128.0.0.0/1 via 10.44.45.1 dev tun1
173.212.200.183 via 192.168.1.254 dev eno1
192.0.0.0/2 via 192.168.1.254 dev eno1
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.224

Toggle GW-Tunnel

sudo ip r add 0.0.0.0/1 via 10.44.45.1 dev tun1
sudo ip r add 128.0.0.0/1 via 10.44.45.1 dev tun1

Enable NAT

echo 1 > /proc/sys/net/ipv4/ip_forward

Check DNS

#from local dns cache server (dnsmasq)
dig +short @127.0.0.1 A vgmrips.net
86.127.201.63
dig +short @1.1.1.3 A vgmrips.net
0.0.0.0
dig +short @1.1.1.1 A vgmrips.net
vampi.tech.
86.127.201.63
dig +short @192.168.1.1 A vgmrips.net
86.127.201.63
dig +short @1.1.1.1 A yahoo.com
98.137.11.163
74.6.231.21
98.137.11.164
74.6.143.25
74.6.231.20
74.6.143.26

Trace DNS query

dig +stats +trace baizabal.xyz

Check with drill

sudo apt install ldnsutils
drill baizabal.xyz | grep "Query time"

ImageMagick

convert to grayscale

mogrify -type Grayscale -path outPath -type Grayscale -gamma 1.8 -brightness-contrast +10 -normalize sourceImages/*.{jpg|png}

Note

Now as for your post… the complexity of the answer depends on the color transform involved. I’m no expert, but probably the easiest solution (based on what you seem to need) is to desaturate the image(s) and then increase contrast (and maybe brightness) using -brightness-contrast +5x25 (put in your own [brightness]x[contrast] values) or -normalize (automatic)

for png transparency can add

convert a.png -type Grayscale -transparent white b.png

Resize Image

convert -resize 20% source.png dest.jpg

proccess

Convert to pdf

convert '*'.jpg book.pdf
ssh connection log view
1
ssh -t ambagasdowa@baizabal.xyz "sudo /bin/zcat /var/log/nginx/access.log.*.gz ; sudo /bin/cat /var/log/nginx/access.{log.1,log}" >> access_baizabal.log && logstalgia 1280x720 -p 10 -s 20 access_baizabal.log -o /media/White/box/VideoManual/log/logstalgia.ppm
access log via ssh
ssh user@example.com tail -f /var/log/apache2/access.log | logstalgia --sync
ssh -t ambagasdowa@baizabal.xyz "sudo /bin/cat /var/log/nginx/access.log" >> access_baizabal.log && logstalgia 1280x720 -x -s .70 -p 5 access_baizabal.log -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -bf 0 /media/White/box/VideoManual/log/logstalgia_today.mp4
ssh + live example
ssh -t ambagasdowa@baizabal.xyz "sshpass -p password sudo /usr/bin/tail -f /var/log/nginx/access.log" | logstalgia --sync -x -s .30 -p 2
ssh + live & save example
ssh -t ambagasdowa@baizabal.xyz "sshpass -p password sudo /usr/bin/tail -f /var/log/nginx/access.log" | logstalgia --sync -x -s .30 -p 2 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -bf 0 /media/White/box/VideoManual/log/logstalgia_live.mp4

VPN Info

Active Certficates

sudo cat /etc/openvpn/easy-rsa/pki/index.txt | sudo grep ^V | awk -F "/" '{print $2}' | awk -F "=" '{print $2}' | wc -l

Connected clients

sudo cat /var/log/openvpn/status.log | sudo sed -n '/OpenVPN CLIENT LIST/,/ROUTING TABLE/p' | tail -n+4 | sed "s/ROUTING TABLE//g";

Over SSH

sshpass -p remorte-ssh-pass ssh -t ambagasdowa@hypervpn "sshpass -p remote-sudo-pass sudo cat /tmp/report.csv" >> ~/gitdowa/baizabal.xyz/docs/Baizabal/source/_static/Downloads/UES/python/log.log

Note

Generally, your situation seems to predicate CCD, “client config dir”. CCD is a directory containing one file per connection profile. The file is tied to a unique client key, so that the key “johndoe” gets the profile specified in ccd/johndoe assigned when connecting. With this approach, you know which IP a specific client has. However, if you just want to list connected clients together with IPs, you can specify “status openvpn-status.log” in your config file. Then openvpn-status.log will contain an updated list of connected clients.

Connected Users

sshpass -p remote-password ssh -t ambagasdowa@hypervpn 'sshpass -p remote-password sudo cat /var/log/openvpn/status.log | sshpass -p remote-password sudo sed -n "/OpenVPN CLIENT LIST/,/ROUTING TABLE/p" | sshpass -p remote-password sudo tail -n+4 | sshpass -p remote-password sudo sed "s/ROUTING TABLE//g"' >> ~/list.csv && sc list.csv

Telmex Connection

Nombre del Producto: HG8145V5 Descripción: EchoLife HG8145V5 GPON Terminal (CLASS B+/PRODUCT ID:2150083933AGL4035007/CHIP:00000020200317) Número de Serie: HWTCB316CBA2 Versión de hardware: 15ADA Versión de software: V5R020C10S230A Info de fabricación: 2150083933AGL4035007.C412

Nombre de la conecxion WAN 1_TR069_VOIP_INTERNET_R_VID_881

encapsulamiento: PPPoE Modo Wan: Wan de ruta Habilitar VLan : True ID Vlan : 881 MRU: 1492 Usuario: 00259ELHWTCB316CBA2@prodigyweb.com.mx Password: c572d4d0ddb4777e75beed3a79e09ca3f8d24f5e0359a625c6c82d5502e605d4 ID de VLAN multicast: 4001 deteccion de LCP: True opc asociacion :lan x 4 ,ssid obtencionIp:PPPoE HabilitaNAT:True ObtencionPreficjo:DHCP-PD

SAT Impuestos

Facturacion de Proveerores

  • Facturas de tipo Ingreso

  • Metodo de pago : Pago en una sola exhibicion (PUE)

  • Forma de pago Bancarizada Transferencia

  • CFDI Adquisicion de mercancias y Gastos en general

flowchart TB
    A(SA de CV) -->|Link text| B(Transferencia)
    B --> C{Decision}
    C -->|One| D[Resico A]
    C -->|Two| E[Resico B]
classDiagram
    class BankAccount
    BankAccount : (+) String owner
    BankAccount : (+) Bigdecimal balance
    BankAccount : (-) deposit(amount)
    BankAccount : (-) withdrawal
erDiagram
    CAR ||--o{ NAMED-DRIVER : allows
    CAR {
        string registrationNumber PK
        string make
        string model
        string[] parts
    }
    PERSON ||--o{ NAMED-DRIVER : is
    PERSON {
        string driversLicense PK "The license #"
        string(99) firstName "Only 99 characters are allowed"
        string lastName
        string phone UK
        int age
    }
    NAMED-DRIVER {
        string carRegistrationNumber PK, FK
        string driverLicence PK, FK
    }
    MANUFACTURER only one to zero or more CAR : makes

TEMARIO

Aplicación de la Resolución Miscelánea Fiscal en 2024

  • Uso obligatorio de la carta porte 3.0: – Contribuyentes obligados a emitirlo. – Entregas locales. – Campos de la versión 3.0. – Servicios de logística inversa, recolección o devolución para el traslado de los bienes y/o mercancías en autotransporte. – Plazo para seguir utilizando la versión 2.0 del complemento de carta porte.

  • Envío de la Contabilidad electrónica al SAT: – Contribuyentes obligados a llevar contabilidad. – Contribuyentes con la opción de utilizar MI CONTABILIDAD de MIS CUENTAS. – Contribuyentes con la opción de no enviar contabilidad.

  • Obligados a habilitar su buzón tributario en la página del SAT.

  • Régimen Simplificado de Confianza RESICO en 2024: – Tratamiento para 2024 de los contribuyentes que ya no puede tributar como RESICO. – Determinación de los pagos provisionales del RGL de los contribuyentes que tributaron en RESICO. – Obligaciones que debe de retomar el contribuyente que ya no puede tributar en el RESICO. – RESICO persona física que rebasan los $3,500,000, en algún mes del ejercicio 2023. – Personas morales del RESICO en liquidación. – Deducción de inventarios del RESICO persona moral. – Plazo para generar o renovar la e. firma.

  • Tablas del ISR para 2024 (anexo 8).

  • Revisando los cambios al Complemento de Pagos versión 2.0 revisión B, vigentes a partir del 15 de enero de 2024.

  • Cumplimiento de la obligación de presentar aviso de compensación.

  • Inscripción, reanudación y suspensión en el RFC de trabajadores.

  • Cédula de identificación fiscal y constancia de situación fiscal.

  • Saldos a favor de impuestos del ejercicio 2018 y anteriores fechas máximas para su compensación.

  • Clave 05 Sí objeto del impuesto, IVA crédito PODEBI del CFDI versión 4.0.

  • Reglas que se derogan.

Salarios mínimos de los trabajadores en 2024

  • Definición de salario mínimo: – Salario mínimo general. – Salario mínimo profesional.

  • Manejo del CFDI de trabajador de salario mínimo.

Ley de Ingresos de la Federación

  • Tasa de recargos y ejemplo de su determinación en el pago de impuestos.

  • Estímulos fiscales en 2024: – Diesel y biodiesel. – Concesión minera. – Libros periódicos y revistas. – Casetas.

  • Tasa de retención anual por intereses.

Ley del Seguro Social

  • Aportaciones voluntarias al Fondo Nacional de la Vivienda.

  • Aseguramiento voluntario al régimen obligatorio.

  • Definición: – Trabajador Independiente o por cuenta propia. – Unión civil. – Servicio de guardería.

Beneficios del taller en línea de ContadorMx

  • Sesión de preguntas y respuestas las cuales son contestadas completamente en vivo.

  • Conclusiones y recomendaciones.

  • Después del curso: soporte continuo a través de ContadorMx.


Last update: Nov 20, 2024