Linux Troubleshooting and scripts

461 readers
6 users here now

this is a community for sharing your scripts that help when working with Linux as well a general troubleshooting.

Rules

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.)

founded 1 year ago
MODERATORS
1
 
 

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.)

2
3
 
 

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

4
5
 
 

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.

6
 
 

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!

7
8
 
 

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.

9
 
 

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
1
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

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.

11
 
 

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))
12
 
 

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 hoping that would help. Would appreciate some help or hints on how this cant be fixed. Thanks.

13
 
 

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
                                      /
  1. Mount this partition with sudo mkdir /mnt/windows-boot && sudo mount /dev/sda1 /mnt/windows-boot. (In this example sda1 is the partition needed)

  2. Copy the needed directory to boot folder with sudo cp -r /mnt/windows-boot/EFI/Microsoft /boot/EFI/Microsoft.

  3. Create the needed entrie config file

su -
cd /boot/loader/entries
touch windows.conf

and put this code inside :

title Windows 11
efi /EFI/Microsoft/Boot/bootmgfw.efi
  1. 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.

14
 
 

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.