Linux Troubleshooting and scripts

Welcome to Linux Troubleshooting and Scripts. This community is for providing scripts that help with installing or maintaining Linux computers, primarily Home computers with desktop Linux. You can also post scripts or ask for support on home servers. this is a community for sharing your scripts that help when working with Linux as well a general troubleshooting. **Rules** - Absolutely NO NSFW posts. break this rule and you will be removed from this community. NO EXCEPTIONS! - Only post scripts that help yourself and others. All scripts will be tested on my machine personally, any malicious scripts will be removed immediately. - This community is for the benefit of other Linux users. no bigotry, hate, nudes, malicious scripts or politics allowed. Feel free to ask any kind of support questions, as we grow more succinct answers will be available. Let’s make this community grow. We are important to one another, not only in the Linux world but also in the Fediverse as a whole. Feel free to reach out to me with questions or concerns, as we grow bigger I will look into adding mods. (This section will be updated as needed.)

8
1
https://ibb.co/pnzKZdd

cross-posted from: https://lemm.ee/post/35034629 > I am having issues with Mangohud and Goverlay. > > Upon opening Goverlay it gives a black box and has issues closing without forcing it shutdown. > > https://ibb.co/pnzKZdd > > OS: Arch Linux x86_64 > Kernel: Linux 6.9.5-zen1-1-zen > DE: KDE Plasma 6.0.5 > WM: KWin (Wayland) > CPU: 12th Gen Intel(R) Core(TM) i7-12700KF (20) @ 5.00 GHz > GPU: NVIDIA GeForce RTX 3090 [Discrete] > Memory: 4.09 GiB / 62.60 GiB (7%) > > I have tried uninstalling both Goverlay and Mangohud > > I have also removed .conf files from: > ~/.config/MangoHud > /usr/share/doc/mangohud > > Is there more that I need to do to clean uninstall and reinstall? > > Any help would be appreciated

6
2
9to5linux.com

Today KDE released 6.1. Now we wait for the distros to put it in their repos.

15
7

Having issues with the display when waking up resolution and position is reverting on one of the monitors. OS: Arch Linux x86_64 Kernel: Linux 6.9.5-zen1-1-zen DE: KDE Plasma 6.0.5 WM: KWin (Wayland) CPU: 12th Gen Intel(R) Core(TM) i7-12700KF (20) @ 5.00 GHz GPU: NVIDIA GeForce RTX 3090 [Discrete] Unsure of how to go about this. I am using Display Port (unsure of what version but it supports sound too.) Not sure where to look for logs, or what exactly could be the culprit. Any suggestions?

9
6

So, I was doing this: `ffmpeg -i /media/johann/5461-000B/DCIM/100MEDIA/IMAG0079.AVI -ss 00:00:00 -t 00:00:20 ~/Public/240321/240321_0079.avi ; rm /media/johann/5461-000B/DCIM/100MEDIA/IMAG0079.AVI` one at a time changing the IMAG0079 to IMAG0080 etc every time. I am sure there must be a way to perform two actions (ffmpg) and (rm) on each file in a folder. Can anyone help (For next time) Thanks!

8
2
https://pastebin.com/J5VT03eq

I use this in Hyprland to quickly switch between the headphone jack and a USB wireless dongle. Executing the script will show a dialog that lists all available audio sinks, with the active sink selected. It requires `pulseaudio` or `pipewire-pulse` for the `pactl` program, and `kdialog` for the dialog.

3
0

Hello everyone…I’m getting these integrity and confit errors during startup. Nothing seems broken. Does anyone know a fix or should i just ignore? Thanks!

9
4

Alright everyone, let’s get this party started. The title asks the question pretty well. What is the main use of your Linux install? Is it gaming, programming, just to dump windows etc… Let’s have some fun everyone.

6
10

Hey everyone, just wanted to touch base with y’all. I’m really a little worried about our community. As of this writing we have 295 members, but we only have 11 posts, including this one. We really need to get some quality posting going on here. So this is what I was thinking, let’s start a mega thread of conversations around Linux in general. I would like to see what we can get going here. Also please talk to your friends that are on here and invite them to the group. I know a lot of us, myself included, tend to just lurk until something pops up for us to interact with. I’m asking everyone here to help interact with our community. We aren’t just a help desk here, we can also have fun conversations.

10
0
github.com

Usage for testing: `./get_latest_jsons.sh` `./show_human_readable_timestamps.sh` If - for example - that showed that the latest JSON was 1691258704964.json: `./tcbot.sh TEST 1691258704964 0` This will show Community subscriber growth between the latest update and what happens to be currently be in the TEST folder (1691042690884.txt, from 2023-08-03), and then the data from "1691258704964" would become the new base, for the next update to compare its data to. The REAL mode is what updates !trendingcommunities@feddit.nl Requires bash, curl, bc, and jq. Don't think anything is particularly version-dependent, though. Comments are welcome. I'm not too fussed about efficiency, as the bulk of it only runs once a day, but any suggestions for improvement are welcome.

4
3

Hi all, I really appreciate the number of member we have here at linuxscripts, and we have had a few posts besides my own on here. What I would really like is for some of you to post things if you have them, and of course let others know about our existence. You don’t have to post content to o be a member here, but please help contribute in any manner you can. I am opening the community up to more content today allowing for memes and crossposts of news surrounding Linux. If you cross post please denote that in your post so others know. I do ask that you don’t cross post unsolved help posts unless it is your own. However, if you get a solution to your problem and it’s not on here please let me know so it can be locked. Thanks everyone.

3
0

This is a database script i made to trigger when database events trigger a database lockup. ``` # Make sure to change your database info and what instance of DB you are using (i.e. sqlite3, mysql, postgres etc...) # This script will rotate for a total of 5 logs so you can compare previous errors with current one without taking unnecessary space # There's no strict requirement to place it in the root directory of the server, but you have some options for where to put it: # Root Directory: Placing the script in the root directory could work, but it's generally not recommended to clutter the root directory # with scripts. It's better to create a specific directory for your application and put the script there. # Custom Directory: Create a specific directory for your application, and place the script there. # For example, you could create a directory called "my_app" or "database_error_logger" and place the script in that directory. # Scripts Directory: Some servers have a designated directory for executable scripts. # You might check if your server has a "scripts" directory where you can place your script. # Regardless of the location, it's essential to consider file permissions. # Ensure that the script has the necessary permissions to execute. You may need to use the chmod command to set the appropriate # permissions, depending on your server's configuration. # Lastly, consider setting up a virtual environment for your Python script to isolate dependencies and avoid conflicts with other # applications on the server. This can help ensure that the required Python libraries are installed locally for your script # without interfering with system-wide packages. # This script was created by Edward Freeman and is covered under GPL V3. You can modify this script as you need # However, you must retain this GPL V3 standard, and leave credit where credit is due to the original author. import logging from logging.handlers import RotatingFileHandler import sqlite3 #Make sure you change this to the correct Database provider (sqlite3, mysql, postgres etc..) import sys # Configure logging with rotating file handler log_file = 'database_errors.log' log_handler = RotatingFileHandler(log_file, maxBytes=1024 * 1024, backupCount=5) log_formatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s') log_handler.setFormatter(log_formatter) logger = logging.getLogger('DatabaseErrorLogger') logger.setLevel(logging.ERROR) logger.addHandler(log_handler) def perform_database_operation(): try: # Replace the following line with your actual database connection and query connection = sqlite3.connect('your_database.db') cursor = connection.cursor() # Replace the following line with your actual database operation cursor.execute('SELECT * FROM your_table;') # Don't forget to commit the changes if you are performing write operations connection.commit() connection.close() except Exception as e: # Log the error with the traceback using the logger logger.exception("Error occurred while performing the database operation.") raise # Raising the error again allows the script to terminate or handle it at a higher level if needed def custom_exception_handler(exctype, value, traceback): # Log uncaught exceptions using the logger logger.exception("Uncaught exception occurred.", exc_info=(exctype, value, traceback)) # Set the custom exception handler for uncaught exceptions sys.excepthook = custom_exception_handler # Call the function to perform the database operation try: perform_database_operation() except Exception as e: print("Error occurred during the database operation:", str(e)) ```

1
2
https://imgur.com/a/EcMbW26

Hi, I am new to linux and started off with Nobara KDE, updated to latest and facing a problem with my new bluetooth keyboard. It can store upto 3 devices and can switch between them. Whenever I switch out of the system to my work laptop it force mutes all playback device without interfering with media and I have to toggle it back on manually. I have pulse audio and but I believe only pipewire-pulse is running under process. I am adding some [screen shots with imgur](https://imgur.com/a/EcMbW26) hoping that would help. Would appreciate some help or hints on how this cant be fixed. Thanks.

4
4

If you have a dual boot setup like mine and want to utilize Linux systemd-boot for managing the Windows dual boot, I've put together a concise guide for myself, which may also be of interest to a few people. Here are the steps you can follow: 1. Find the partition of the Windows EFI system with `lsblk`. (The partition must be around 100Mo) ``` NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 465,8G 0 disk ├─sda1 8:1 0 100M 0 part ├─sda2 8:2 0 16M 0 part ├─sda3 8:3 0 465G 0 part └─sda4 8:4 0 639M 0 part zram0 254:0 0 4G 0 disk [SWAP] nvme0n1 259:0 0 931,5G 0 disk ├─nvme0n1p1 259:1 0 511M 0 part /boot └─nvme0n1p2 259:2 0 931G 0 part /var/log /var/cache/pacman/pkg /home /.snapshots / ``` 3. Mount this partition with `sudo mkdir /mnt/windows-boot && sudo mount /dev/sda1 /mnt/windows-boot`. (In this example sda1 is the partition needed) 4. Copy the needed directory to boot folder with `sudo cp -r /mnt/windows-boot/EFI/Microsoft /boot/EFI/Microsoft`. 5. Create the needed entrie config file ``` su - cd /boot/loader/entries touch windows.conf ``` and put this code inside : ```conf title Windows 11 efi /EFI/Microsoft/Boot/bootmgfw.efi ``` 5. Reboot This guide is specifically tailored for an Arch Linux installation, but it can be easily adapted to suit other Linux distributions. Please note that the steps provided in this guide are primarily focused on configuring dual boot using Linux systemd-boot. While the overall process may be similar across various distributions, there might be slight variations in specific commands or file paths. Therefore, it's recommended to consult your distribution's documentation or community resources for any distro-specific instructions.

9
2

Run the "Basic Lemmy API login script" (see [here](https://feddit.nl/post/441747)) first to get value for 'jwt' ``` #!/bin/bash # Basic get unread replies script for Lemmy API # CHANGE THESE VALUES my_instance="" # e.g. https://feddit.nl my_username="" # e.g. freamon my_password="" # e.g. hunter2 jwt="" # run basic login script to get this ######################################################## # Lemmy API version API="api/v3" ######################################################## # Turn off history substitution (avoid errors with ! usage) set +H ######################################################## # Get inbox messages get_unread_replies() { end_point="user/replies" www_data="auth=$jwt&unread_only=true" url="$my_instance/$API/$end_point?$www_data" curl "$url" } get_unread_replies ``` Personally, I'd use the 'jq' program to de-serialize the reply, e.g. > get_unread_replies.sh | jq '.replies[].comment.content' My next plan is to use a script like this with a notification service like PUSHOVER, so it can ding my phone if I've an unread message For each API method, whether it's GET or POST and end_point can be found [here](https://join-lemmy.org/api/classes/LemmyHttp.html), and then each method has a click-through to see what parameters it can take.

7
0

``` #!/bin/bash # Basic login script for Lemmy API # CHANGE THESE VALUES my_instance="" # e.g. https://feddit.nl my_username="" # e.g. freamon my_password="" # e.g. hunter2 ######################################################## # Lemmy API version API="api/v3" ######################################################## # Turn off history substitution (avoid errors with ! usage) set +H ######################################################## # Login login() { end_point="user/login" json_data="{\"username_or_email\":\"$my_username\",\"password\":\"$my_password\"}" url="$my_instance/$API/$end_point" curl -H "Content-Type: application/json" -d "$json_data" "$url" } login # Make note of "jwt" from reply ``` This'll reply with JSON data, that includes a value for "jwt", to be used in other scripts that require you to be logged in. Personally, I'd use the 'jq' program to de-serialize the JSON data, but I thought I'd keep the script simple for now

13
5

Hello, I use Ubuntu 22.04.2 LTS and I got a strange problem without knowingly changing anything: Every now and then my primary display turns black for a second and then back on. My secondary display is working fine. My speakers are also connected to the display, so I'll hear a sound from them when it happens. I can't make out exactly what causes the turning off/on, but when I don't touch anything, it happens less frequently than when I'm working, switches windows, etc. Furthermore while my display works well with 144Hz refresh rate, my mouse input works at a noticably much lower refresh rate. I tried restarting my PC and replugging my DP-Cable and power cables. I'm relatively new to Linux so I don't know what the causes could be. I hope someone can help me :)

3
4

Thank you for subscribing. Pleeas help me populate this by posting tuts you have used or scripts you may have made. Also please designate what distro you re using them on to help newbies.

21
0