User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
playground:playground [2022/02/08 13:21] normanplayground:playground [2025/08/21 11:11] (current) – [Create Users Trash Bin] norman
Line 1: Line 1:
-====== Some Random helpers: ======+====== PlayGround ======
  
 +===== Create Users Trash Bin ======
  
- 
-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 
- 
-  * Create a /etc/systemd/system/getty@tty1.service.d/override.conf through ; 
- 
-  * 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 getty@tty1.service then reboot. 
- 
-  * systemctl enable getty@tty1.service 
-  * 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 ====== 
- 
- 
-<code>du -h /home --max-depth=1 | sort -hr</code> 
- 
----- 
- 
-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  
 <code> <code>
-apt-get update && apt-get install -y \ +cd /to/folder
-    libmagickwand-dev --no-install-recommends \ +
-    && pecl install imagick \ +
- && docker-php-ext-enable imagick+
 </code> </code>
- 
-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. 
- 
-<code>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</code> 
- 
-**byobu new -s my-other-session -> start another session** 
- 
-type “Exit” to close unwanted window 
- 
-<code>byobu-enable -> enable byobu to start automatically with system 
-byobu-disable -> disable byobu to start automatically with system</code> 
-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 ====== 
- 
-<code>wget --recursive wget -r -np -R "index.html*" http://example.com/configs/.vim/</code> 
-To avoid downloading the auto-generated index.html files, use the -R/--reject option: 
-<code>wget -r -np -R "index.html*" http://example.com/configs/.vim/</code> 
-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: 
-<code>wget -e robots=off http://www.example.com/</code> 
- 
- 
-====== Linux autocrop images ====== 
- 
-Using ImageMagick: 
- 
-<code>convert -trim image.jpg image.jpg</code> 
-To trim/autocrop the whole directory: 
- 
-<code>for a in *.jpg; do convert -trim "$a" "$a"; done</code> 
-Or using find: 
- 
-<code>find -name "*.jpg" -exec convert -trim "{}" "{}" \;</code> 
- 
- 
-====== Usefull Dmesg command ===== 
- 
-<code>dmesg --follow</code> 
- 
- 
-====== Reconfigure Debian Time Zone ====== 
- 
-<code>dpkg-reconfigure tzdata</code> 
- 
- 
-====== How to stop kernel messages from flooding my console? ====== 
- 
-Alter <code>nano /etc/sysctl.conf</code> 
-# Uncomment the following to stop low-level messages on console 
-<code>kernel.printk = 3 4 1 3</code> 
- 
-====== How can I tell Ubuntu to do nothing when I close my laptop lid ====== 
- 
-<code>echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf</code> 
- 
-Restart the systemd daemon (be aware that this will log you off) with this command: 
-<code>service systemd-logind restart</code> 
- 
-====== How do I change the font or the font size in the TTY (console) Debian ====== 
- 
-<code>dpkg-reconfigure console-setup</code> 
-or edit: <code>nano /etc/default/console-setup</code> 
- 
-After, for permanent saving (must work): 
-<code>update-initramfs -u</code> 
- 
-====== Gentoo Add GB locale ====== 
- 
-Needed for showing time in 24h format. 
-Maybe not correct, but working. 
-Edit locale config: 
-<code>nano -w /etc/locale.gen</code> 
-Add following lines (Maybe enough with one: 
-<code>en_GB.UTF-8 
-en_GB UTF-8</code> 
-Then: 
-<code>locale-gen</code> 
-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: 
-<code>eselect locale list</code> 
-With eselect locale set <NUMBER> the correct locale can be selected: 
-<code>eselect locale set 9</code> 
-Now reload the environment: 
-<code>env-update && source /etc/profile && export PS1="(chroot) ${PS1}"</code> 
- 
- 
-====== Debian Keep audio “awake” ====== 
- 
-Edit <code>nano /etc/pulse/default.pa</code> and comment the following line: 
- 
-<code>load-module module-suspend-on-idle</code> 
-which becomes: 
- 
-<code># load-module module-suspend-on-idle</code> 
-Then restart the sound server. 
- 
-====== Generate a Random Password Linux shell====== 
- 
-<code>date +%s | sha256sum | base64 | head -c 32 ; echo</code> 
- 
-Source: https://www.howtogeek.com/howto/30184/10-ways-to-generate-a-random-password-from-the-command-line/ 
- 
- 
-====== 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. 
- 
-<code>smbpasswd -a root 
-smbpasswd -a pi</code> 
- 
-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. 
- 
- 
-<code>pdbedit -L</code> 
- 
- 
-====== Terminal Disk Usage (Debian's) ====== 
- 
-Install: 
- 
-<code>wget http://ftp.us.debian.org/debian/pool/main/g/gdu/gdu_4.6.3-1_amd64.deb && dpkg -i gd*.deb</code> 
- 
-First, navigate to directory or simply and run gdu: 
-<code>cd / && gdu</code> 
- 
-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 ====== 
- 
 <code> <code>
-#!/bin/bash +mkdir -m777 -v .Trash-$UID
-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+
 </code> </code>
  
-====== GDU Terminal Disk Usage ====== 
- 
-[[https://github.com/dundee/gdu/releases|https://github.com/dundee/gdu/releases]] 
- 
- 
-====== Jellyfin-FFmpeg ====== 
 <code> <code>
-./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+chown $USER .Trash-$UID
 </code> </code>
- 
- 
-===== Debian List Installed Packages ===== 
- 
- 
-<code>dpkg --list | more</code> 
- 
- 
-==== Gentoo Apache with php ==== 
- 
-edit: <code>nano /etc/conf.d/apache2</code> 
- 
-need to add "-D PHP" ... 
- 
-<code>APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP"</code> 
- 
-Restart apache. 
- 
- 
-==== Make Use with X proc's ====or compress 
- 
- 
-<code>make -j $(nproc)</code> 
- 
-==== Sed replace ==== 
- 
-<code>sed -i 's/stretch/buster/g' /etc/apt/sources.list</code> 
- 
-====== Linux Shell Find images ====== 
- 
-<code>find . -name '*' -exec file {} \; | grep -o -P '^.+: \w+ image'</code> 
-or 
-<code>find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) print $1}'</code> 
-or compress 
-<code>find . -type f -exec file --mime-type {} \+ | awk -F: '{if ($2 ~/image\//) printf("%s%c", $1, 0)}' | tar -cvf /tmp/file.tar --null -T -</code> 
- 
-====== Linux netstat command find out which process is listing upon a port ====== 
-<code>netstat -tulpn</code> 
- 
-======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  
-<code>nano ~/.config/htop/htoprc</code> file if it is writable by your user. 
-You might make it writable like this: 
- 
-<code>chown $USER ~/.config/htop/htoprc</code> 
-Or you can try removing it and let htop generate a new one, maybe the old one is corrupted somehow. 
- 
-<code>rm ~/.config/htop/htoprc</code> 
- 
-====== Reconfigure python ====== 
- 
-cd install dir and 
-<code>./configure --enable-loadable-sqlite-extensions && make && sudo make install</code> 
- 
-====== Synaptic lost quick index filter ====== 
- 
- 
-<cls>apt-get install apt-xapian-index --reinstall 
-apt-get install apt aptitude synaptic --reinstall</cls> 
- Restart Synaptics. May need restart system... 
- 
-