User Tools

Site Tools


playground:playground

Some Random helpers:

Linux Enable H.264 codec support for Opera browser

Works With: Opera One(version: 107.0.5045.36)

For Debian distros can use this: External Link

wget https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases/download/0.85.0/0.85.0-linux-x64.zip
unzip 0.85.0-linux-x64.zip
mv libffmpeg.so /opt/opera/

libffmpeg.so source: External Link

how to remove all characters after and including "[" in filename?

for f in ./*\[*; do
mv -n "$f" "${f%%\[*}.mp3";
    echo mv -n "$f" "${f%%\[*}.mp3"
done

Install Script Internal

apt install -y curl; curl -fsSL http://data.free.fm/deb_mount-serv.sh | sh

Changing the default text editor on Linux

The default command line text editor on Linux (and BSD varaiants) determines what is used when you run commands such as “crontab -e” and is often not what you want to use yourself. Typcially vi/vim is the default text editor; many people prefer emacs or other editors, and I prefer to use nano myself.

It’s easy to change this default text editor by using the system’s environment variables. Both the EDITOR and VISUAL environment variables determine which text editor is used at the default, and you can set either to change the default behaviour to the text editor you prefer like so from the command line:

  • export EDITOR=nano

The above example will make “nano” the default editor, and you can substitute “nano” for your preferred editor. You don’t have to specify the full path to the application, as long as it is located in one of the paths specified by the PATH variable, but it’s probably a good idea to, eg:

  • export EDITOR=/usr/bin/nano

You can find the full path to a file using the “whereis” command like so:

  • $ whereis nano

nano: /usr/bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz Setting the EDITOR environment variable from the command line as shown above will only last as long as your current session; once you log out the default behaviour will apply again when you next log in. To make the change permanent, add the export value to your ~/.bash_profile file.

Adding the entry to your ~/.bash_profile file won’t take affect until it is re-read, which will happen when you log in again. You can re-read the file immediately by doing this:

  • . ~/.bash_profile

To make the default editor change global and apply to all users, unless overridden in their ~/.bash_profile file, you add the entry to the /etc/profile file.


Check if website down: http://downforme.org/

  • sox ./stundu_teksti.mp3 ./stundu_teksti2.mp3 channels 2

for i in *.mp3; do sox “$i” –channels 2 “ ${i%.mp3}.mp3” done


HOW DO I CONVERT A PDF TO TEXT?

Convert a pdf file called hp-manual.pdf to hp-manual.txt, enter:

  • $ pdftotext hp-manual.pdf hp-manual.txt

Specifies the first page 5 and last page 10 (select 5 to 10 pages) to convert, enter:

  • $ pdftotext -f 5 -l 10 hp-manual.pdf hp-manual.txt

Convert a pdf file protected and encrypted by owner password:

  • $ pdftotext -opw ‘password’ hp-manual.pdf hp-manual.txt

Convert a pdf file protected and encrypted by user password:

  • $ pdftotext -upw ‘password’ hp-manual.pdf hp-manual.txt

Sets the end-of-line convention to use for text output. You can set it to unix, dos or mac. For UNIX / Linux oses, enter:

  • $ pdftotext -eol unix hp-manual.pdf hp-manual.txt

To be more specific, editing ~/.openshot_qt/openshot.settings I actually had to change

  • {“value”: true, “title”: “”, “type”: “hidden”, “category”: “Tutorial”, “se tting”: “tutorial_enabled”}

to this:

  • {“value”: “”, “title”: “”, “type”: “hidden”, “category”: “Tutorial”, “se tting”: “tutorial_enabled”}

cd ~/Downloads # or wherever you downloaded a font pack. unzip .zip # for a single user mkdir -p ~/.fonts cp *otf *otc ~/.fonts fc-cache -f -v # optional # for all users sudo mkdir -p /usr/share/fonts/opentype/noto sudo cp *otf *otc /usr/share/fonts/opentype/noto sudo fc-cache -f -v # optional


  • normalize-audio -b -v -l ./*.mp3

Disable suspend and hibernation For systems which should never attempt any type of suspension, these targets can be disabled at the systemd level with the following:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target To re-enable hibernate and suspend use the following command:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target


# background color using ANSI escape

  • bgBlack=$(tput setab 0) # black
  • bgRed=$(tput setab 1) # red
  • bgGreen=$(tput setab 2) # green
  • bgYellow=$(tput setab 3) # yellow
  • bgBlue=$(tput setab 4) # blue
  • bgMagenta=$(tput setab 5) # magenta
  • bgCyan=$(tput setab 6) # cyan
  • bgWhite=$(tput setab 7) # white

# foreground color using ANSI escape

  • fgBLack=$(tput setaf 0) # black
  • fgRed=$(tput setaf 1) # red
  • fgGreen=$(tput setaf 2) # green
  • fgYellow=$(tput setaf 3) # yellow
  • fgBlue=$(tput setaf 4) # blue
  • fgMagenta=$(tput setaf 5) # magenta
  • fgCyan=$(tput setaf 6) # cyan
  • fgWhite=$(tput setaf 7) # white

# text editing options

  • txBold=$(tput bold) # bold
  • txHalf=$(tput dim) # half-bright
  • txUnderline=$(tput smul) # underline
  • txEndUnder=$(tput rmul) # exit underline
  • txReverse=$(tput rev) # reverse
  • txStandout=$(tput smso) # standout
  • txEndStand=$(tput rmso) # exit standout
  • txReset=$(tput sgr0) # reset attributes

rdfind -makehardlinks true /servers2/*


Selecting the Primary Audio Device If your system keeps on using the wrong device (HDMI instead of PCH or vica versa for example), you can force ALSA to use the correct device. Start by getting a list of your audio devices with the command:

cat /proc/asound/cards

Note the number of the sound device that you want to make the primary. Then using a text editor, put the following into /etc/asound.conf (You may need to create /etc/asound.conf if it doesn’t already exist).

defaults.pcm.card 1 defaults.ctl.card 1

serverim, HDMI, Audacity paliidz identificeet. defaults.pcm.card 1 defaults.ctl.card 1

defaults.pcm.!device 7 defaults.ctl.!device 7


Use vlc as root:

  • sed -i ‘s/geteuid/getppid/’ /usr/bin/vlc
  • mp3info -p “%f %o \n” ./*.mp3

You can rotate your virtual framebuffers using fbcon. 0 through 3 to represent the various rotations:

0 – Normal rotation 1 – Rotate clockwise 2 – Rotate upside down 3 – Rotate counter-clockwise These can be set from the command line by putting a value into the correct system file. Rotate the current framebuffer:

echo 1 | sudo tee /sys/class/graphics/fbcon/rotate Rotate all virtual framebuffers:

echo 1 | sudo tee /sys/class/graphics/fbcon/rotate_all If you want this to happen automatically when you start your system, you need to modify your boot loader configuration to give it the correct options. In /etc/default/grub add fbcon=rotate:1 to the GRUB_CMDLINE_LINUX line:

GRUB_CMDLINE_LINUX=”fbcon=rotate:1″ (Don’t forget to run sudo update-grub after changing this file.)


Autologin Debian console:

Edit your /etc/systemd/logind.conf ,

  • change #NAutoVTs=6 to NAutoVTs=1
  • systemctl edit getty@tty1

Past the following lines

<webcode name=“Default” frameborder=0 width=100% scrolling=yes externalResources=“,” renderingMode=story > [Service] ExecStart= ExecStart=-/sbin/agetty –autologin root –noclear %I 38400 linux </webcode>

enable the [email protected] then reboot.


runaajosh pulktens Linuxaa..

echo “Its” `date “+%H and %M now”` | festival –tts apt install festival -y

# Balss variants apt install festvox-kdlpc16k

export XDG_RUNTIME_DIR=”/run/user/1000”


Gentoo: When you emerge ices and icecast Portage does not create startup or shutdown scripts for you. You can use the following scripts to start and stop ices and icecast:

Code Listing 3.1: /etc/init.d/ices Code: <webcode name=“Default” frameborder=0 width=100% scrolling=yes externalResources=“,” renderingMode=story > #!/sbin/runscript # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2

depend() { need icecast net use dns }

start() { ebegin “Starting ices” start-stop-daemon –start –chuid icecast –quiet –exec /usr/bin/ices \ — /home/icecast/ices-playlist.xml >/dev/null 2>&1 eend $? }

stop () { ebegin “Stopping ices” start-stop-daemon –stop –retry 5 –quiet –exec /usr/bin/ices eend $? } </webcode>

Disk usage

du -h /home --max-depth=1 | sort -hr


MySQL by default listens only on the localhost (127.0.0.1) interface.

From configuration file above: Code: # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. # bind-address = 127.0.0.1 Uncomment the bind-address line, and bind to 0.0.0.0 to bind to all addresses on the system…


Rename word in file sed -i ‘s/source/newname/g’ /filename


make options

To uninstall:

  • make uninstall #as root

To clean the build after modifying code:

  • make clean

To clean and remove previous configure options:

  • make distclean

It can be installed using sudo apt-get install ifmetric. This command can be used to change the metric of any interface. The interface with lower metric is preferred for Internet.

root@icecast ~ # route -n Kernel IP routing table <webcode name=“Default” frameborder=0 width=100% scrolling=yes externalResources=“,” renderingMode=story > Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.254 0.0.0.0 UG 202 0 0 eth0 0.0.0.0 192.168.1.254 0.0.0.0 UG 350 0 0 wlan0 192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 350 0 0 wlan0 </webcode>

  • ifmetric eth0 10

Install php-imagick deb based sys

Firstly need to link sed for phpize

  • sudo ln -s /bin/sed /usr/bin/sed

Then: RUN

apt-get update && apt-get install -y \
    libmagickwand-dev --no-install-recommends \
    && pecl install imagick \
	&& docker-php-ext-enable imagick

After that You should add “extension=imagick.so” to php.ini

  • Restart Your webserver.
  • /etc/init.d/apache2 restart

How To Use Byobu

This is very small manual with most common shortcuts.

SHIFT + F2 -> open new window
SHIFT + F7 -> Not sure, but sometimes without it don.t activating all commands.
SHIFT + F8 -> tile windows vericaly, i more than 2, then differnet variations.
SHIFT + F5 -> refresh all windows
SHIFT + F6 -> close byobu
SHIFT + Arrow (depends from window location) -> Move between windows
SHIFT + LeftAlt + Arrow (depends from window location) -> resize window

byobu new -s my-other-session → start another session

type “Exit” to close unwanted window

byobu-enable -> enable byobu to start automatically with system
byobu-disable -> disable byobu to start automatically with system
If multiple sessions started, should ask which session to use. If want to use multiple, recommend to name it nice, as its can not offer session choice. For example, byobu new -s session1 , byobu new -s session2 …

May be different on different byobu versions.

Full list of commands can find in https://www.byobu.org/

Some bits for Gentoo

For laptops may need set max brightness at system boot. This is for Intel graphics. Others need change intel to Your graphics card

  • open crontab -e as root
  • enter following line

<webcode name=“Default” frameborder=0 width=100% scrolling=yes externalResources=“,” renderingMode=story > @reboot cat /sys/class/backlight/intel_backlight/max_brightness > /sys/class/backlight/intel_backlight/brightness </webcode>

Linux wget

wget --recursive wget -r -np -R "index.html*" http://example.com/configs/.vim/
To avoid downloading the auto-generated index.html files, use the -R/–reject option:
wget -r -np -R "index.html*" http://example.com/configs/.vim/
For anyone else that having similar issues. Wget follows robots.txt which might not allow you to grab the site. No worries, you can turn it off:
wget -e robots=off http://www.example.com/

Linux autocrop images

Using ImageMagick:

convert -trim image.jpg image.jpg
To trim/autocrop the whole directory:

for a in *.jpg; do convert -trim "$a" "$a"; done
Or using find:

find -name "*.jpg" -exec convert -trim "{}" "{}" \;

Usefull Dmesg command

dmesg --follow

Reconfigure Debian Time Zone

dpkg-reconfigure tzdata

How to stop kernel messages from flooding my console?

Alter

nano /etc/sysctl.conf
# Uncomment the following to stop low-level messages on console
kernel.printk = 3 4 1 3

How can I tell Ubuntu to do nothing when I close my laptop lid

echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf

Restart the systemd daemon (be aware that this will log you off) with this command:

service systemd-logind restart

How do I change the font or the font size in the TTY (console) Debian

dpkg-reconfigure console-setup
or edit:
nano /etc/default/console-setup

After, for permanent saving (must work):

update-initramfs -u

Gentoo Add GB locale

Needed for showing time in 24h format. Maybe not correct, but working. Edit locale config:

nano -w /etc/locale.gen
Add following lines (Maybe enough with one:
en_GB.UTF-8
en_GB UTF-8
Then:
locale-gen
Locale selection Once done, it is now time to set the system-wide locale settings. Again we use eselect for this, now with the locale module.

With eselect locale list, the available targets are displayed:

eselect locale list
With eselect locale set <NUMBER> the correct locale can be selected:
eselect locale set 9
Now reload the environment:
env-update && source /etc/profile && export PS1="(chroot) ${PS1}"

Debian Keep audio “awake”

Edit

nano /etc/pulse/default.pa
and comment the following line:

load-module module-suspend-on-idle
which becomes:

# load-module module-suspend-on-idle
Then restart the sound server.

Generate a Random Password Linux shell

Creating samba users

These users must represent Linux users but their password can and should be different to the Linux password for security. This is not enforced, though. Using the command smbpasswd as the root user we can add new samba users. A user must have a password in samba to access shares.

smbpasswd -a root
smbpasswd -a pi

The above commands add root and pi as samba users. By default, a TDB database is used to store this information. You can list current samba users with the command pdbedit.

pdbedit -L

Terminal Disk Usage (Debian's)

Install:

wget http://ftp.us.debian.org/debian/pool/main/g/gdu/gdu_4.6.3-1_amd64.deb && dpkg -i gd*.deb

First, navigate to directory or simply and run gdu:

cd / && gdu

Since it has terminal user interface (TUI), you can navigate through directories and disk using arrows. You can also sort the result by file names or size.

Here’s how to do that:

  • Unordered List ItemUp arrow or k to move cursor up
  • Unordered List ItemDown arrow or j to move cursor down
  • Unordered List ItemEnter to select directory / device
  • Unordered List ItemLeft arrow or h to go to parent directory
  • Unordered List ItemUse d to delete the selected file or directory
  • Unordered List ItemUse n to sort by name
  • Unordered List ItemUse s to sort by size
  • Unordered List ItemUse c to sort by items

Small Linux script to change default gw

#!/bin/bash
route=$(route | grep default | cut -b 17- | cut -b -13)
echo $route

if [[ $route == *'192.168.1.254'* ]]; then
	route del default gw 192.168.1.254
route add default gw 192.168.8.1

else

	route del default gw 192.168.8.1
route add default gw 192.168.1.254

fi

sleep 1
echo ""
tput bold
tput setaf 1
route | grep default | cut -b 17- | cut -b -13
tput sgr0

GDU Terminal Disk Usage

Jellyfin-FFmpeg

./configure --disable-doc --enable-ffplay --disable-shared --enable-libxcb --disable-sdl2 --disable-xlib --enable-gpl --enable-version3 --enable-static --enable-libfontconfig --enable-fontconfig --enable-gmp --enable-gnutls  --enable-libdrm --enable-libvorbis --enable-libx264 --enable-libx265 --toolchain=hardened

Debian List Installed Packages

dpkg --list | more

Gentoo Apache with php

edit:

nano /etc/conf.d/apache2

need to add “-D PHP” …

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP"

Restart apache.

==== Make Use with X proc’s ====or compress

make -j $(nproc)

Sed replace

sed -i 's/stretch/buster/g' /etc/apt/sources.list

Linux Shell Find images

find . -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image'
or
find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}'
or compress
find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) printf("%s%c", $1, 0)}' | tar -cvf /tmp/file.tar --null -T -

Linux netstat command find out which process is listing upon a port

netstat -tulpn

HTOP How can I save the view to sort by CPU usage?

Run htop, press F6, select CPU%.

Quit by using F10

If it doesn’t remember your settings check your

nano ~/.config/htop/htoprc
file if it is writable by your user. You might make it writable like this:

chown $USER ~/.config/htop/htoprc
Or you can try removing it and let htop generate a new one, maybe the old one is corrupted somehow.

rm ~/.config/htop/htoprc

Reconfigure python

cd install dir and

./configure --enable-loadable-sqlite-extensions && make && sudo make install

Synaptic lost quick index filter

apt-get install apt-xapian-index --reinstall
apt-get install apt aptitude synaptic --reinstall
Restart Synaptics. May need restart system…

Android Screen Saver Start Time

You can customize the screen saver timeout via adb shell. To check what the screensaver is currently set to:

adb shell settings get system screen_off_timeout

Return value is in milliseconds, so for example 300000 would be 5 minutes.

To set a new value (let’s say 30 seconds, which is 30000 ms)

adb shell settings put system screen_off_timeout 30000

Numlock on tty

#!/bin/sh
for t in /dev/tty[0-9]*; do setleds -D +num <$t; done

linux grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.

You need to change the label type, from boot to bios_grub for example through parted:

parted /dev/sdX
set 1 boot off
set 1 bios_grub on

Execute command before shutdown/reboot

ln -s /etc/init.d/<your_file> /etc/rc0.d/k99stop_vm
ln -s /etc/init.d/<your_file> /etc/rc6.d/k99stop_vm
chmod a+x /etc/init.d/<your_file>

playground/playground.txt · Last modified: 2024/03/11 08:15 by norman