r/bash

Image 1 — I found the hidden Advanced BIOS menu
Image 2 — I found the hidden Advanced BIOS menu
▲ 103 r/bash+12 crossposts

I found the hidden Advanced BIOS menu

I have been reverse-engineering the InsydeH2O firmware used by the Lenovo IdeaPad Gaming 3 15ARH05 (82EY / IP3GAMING-15ARH).

The project started because this model exposes only a very limited BIOS interface, while common unlock sequences such as Fn+R+N do not appear to work reliably on this generation.

So far, I have:

  • extracted Lenovo’s official FCCN21WW Windows update package;
  • recovered the complete 16 MiB update ROM;
  • parsed its AMD PSP directory;
  • decompressed and executed the x86 reset-stage image;
  • traced its reset loop under QEMU;
  • extracted the Setup Utility and reconstructed its IFR;
  • confirmed the existence of a separate hidden Advanced form set;
  • recovered its GUID, variable stores, offsets and option inventory;
  • tested an experimental SREP runtime patch without permanently modifying the firmware.

The hidden menu contains controls for:

  • PCIe GPP and power policies;
  • SATA/AHCI and RAID configuration;
  • TPM and fTPM;
  • USB controllers and individual ports;
  • ACPI features;
  • SVM, SVM Lock and SMM Code Lock;
  • DASH and AMD remote KVM;
  • Above 4 GB MMIO.

One particularly interesting result is that the Advanced form set is not surrounded by a top-level IFR SuppressIf condition. My current hypothesis is that Lenovo/Insyde hides it through a visibility table or registration logic inside H2OFormBrowserDxe, rather than through a simple “unlock” setup variable.

I also recovered this form-set GUID:

C6D4769E-7F48-4D2A-98E9-87ADCCF35CCC

However, the runtime SREP patch has not exposed the menu yet. The laptop currently runs FCCN19WW, while the analyzed update is FCCN21WW, so differences in modules, patterns or variable semantics may explain the failure.

The repository documents the full process, hashes, extraction commands, QEMU findings, IFR inventory, experimental SREP configuration and suggested next steps:

https://github.com/root-hunter/lenovo_bios

Update: the hidden Advanced BIOS menu has now been successfully unlocked on the test machine using SREP. This is a runtime unlock and does not require flashing a modified BIOS image.

The method remains experimental and model/firmware-specific. Hidden settings can still cause a brick, boot failure or no-display condition, so do not change unfamiliar options without a verified SPI backup and recovery plan.

I would especially appreciate help from anyone who:

  • owns the same 15ARH05 / 82EY model and can reproduce the unlock;
  • can test it on other FCCN firmware versions;
  • has experience with InsydeH2O, SREP or H2OFormBrowserDxe;
  • can help validate and document the exposed settings safely.

Issues, corrections and reproducible test results are welcome.

u/roothunter-dev — 1 day ago
▲ 43 r/bash

How Do You Name .sh Files?

I'm learning Bash to write some automation scripts and I'd like to know what the community recommends when it comes to naming .sh files.

From what I've found, the community generally seems to recommend kebab-case, while the Google Shell Style Guide recommends snake_case.

Which one do you prefer, and why?

reddit.com
u/RankedLOQ — 1 day ago
▲ 21 r/bash

want to use watch with my own command

[SOLVED] thanks to u/bac0on

i can now add this directly into .bash_aliases, or i can just paste the command into a terminal


alias las='
function what-changed() {
   find  -not  \( -path './snap/firefox/common' -prune \) -not \( -path './.cache'  -prune \) -type f -mmin -1  -printf "%C+ %p\n" | sort -n | tail -10
};
export -f what-changed && watch -x bash -c what-changed'

thanks for everyone's help.

[/SOLVED]

i have this command used to find recently changed files.

 find  -not  \( -path './snap/firefox/common' -prune \) -not \( -path './.cache'  -prune \) -type f -mmin -1  -printf "%C+ %p\n" | sort -n | tail -10

and i wanted to use watch to have it running in a window

however watch requires an executable, so i made a shell script that contained the command and then called

watch last_change

which works and allows me to make an alias for it .bash_aliases like

alias las='watch last_change'

all well and good

but then i had the bright idea to write this as a function instead of a script

function what-changed() {
     find  -not  \( -path './snap/firefox/common' -prune \) -not \( -path './.cache'  -prune \) -type f -mmin -1  -printf "%C+ %p\n" | sort -n | tail -10
};
watch what-changed

but it does not work.

watch says it can't find what-changed even tho it's right there and if i define this function in a console window, i can call it by itself and it will run.

but watch does not find it.

feels like i'm missing something simple, to help watch find it like it can find my script... something like a $PATH statement, but not that.

anyone see the issue?

reddit.com
u/skyfishgoo — 2 days ago
▲ 5 r/bash+2 crossposts

Created a CLI tool because I was tired of googling the same commands over and over

Every week I'd hit some flag combo I'd used before, forget it, and end up back googling the same thing — or get lucky and find it in my shell history, if I remembered it just a little bit.

So I created recall — save a command once, label it your way, then find it and run it straight from your shell. No copy-paste required.

The one that finally pushed me to build this: I SSH into a bunch of different servers, each with its own port, key, and options. I got tired of digging up or copy-pasting the right command every time.

github.com/parthsigdel/recall — feel free to give it a try, still actively working on it.

u/Strong_Plenty_3743 — 2 days ago
▲ 43 r/bash

When do you stop using Bash and switch to Python/JS?

Lately I tried to write a slightly longer Bash script, and honestly, I didn't really enjoy it. I realized I don't understand Bash syntax nearly as well as I thought I did.

Even with AI helping me, I actually want to understand the code I'm writing instead of just having AI fix everything for me.

So I'm curious: Do you still use Bash for longer scripts, or do you have a point where you just switch to another language?

reddit.com
u/EntrepreneurWaste579 — 4 days ago
▲ 11 r/bash

What is bash's grammar

Hello

I've been reasearching the rules of bash's parsing, like how does bash parse the commands, according to spaces, pipes, and redirections, is there anything else?

reddit.com
u/hzgrace — 3 days ago
▲ 127 r/bash

learning sed, awk and regex

Looking to learn sed, awk, and regular expressions properly.

What are the best free resources—books, websites, tutorials, courses, or hands-on exercises—you’d recommend?

Also, any good book recommendations for learning these tools from beginner to advanced?

reddit.com
u/broken_py — 5 days ago
▲ 6 r/bash+3 crossposts

Sib: A standard Unix LLM client that uses Git in place of SQLite

I've had this program in mind for quite a while.

Back when ChatGPT first came out, it had no way to group existing conversations into folders, and I set out to build one. My conversation list kept getting longer and finding old chats was getting hard.

Not long after - before I built it - a browser extension came out that did exactly that. I never used it. At the time I'd assumed I would want to revisit old conversations, but whenever I actually found one and tried to read it from the top, the sheer volume of slop gave me a headache.

Later, during a phase where I was deep into Unix pipelines, I wrote an LLM API client only depending on jq and curl, partly as shell scripting practice. But since the context went into a single jsonl file, I had to either invent something like a date-based filename convention myself or push that job onto the user. Both were more annoying than the web UI, so I didn't use it.

After that I read a post explaining how git works, and it struck me that git fits LLM conversations pretty well. Isn't "the commit DAG is already the right data structure for LLM conversations, where forking happens constantly" something everyone has thought at least once?

The reason I like git is that the source tree snapshot and the commit structure itself are always immutable, and destructive operations like switch/restore/reset are really just renaming a ref file that holds a commit object id. Once you understand that, no matter how hard the CLI is to make sense of, you never hesitate to run a command. You can always get it back.

LLM conversations aren't as fragile to change as a source tree, but for me an auto-generated SHA-1 hash is more comforting than an auto-generated session title ^~^

That's the feeling sib was built on. The README has actual explanations though.

The project is in its early stages and contributions are welcome. If you've worked with git plumbing commands, it'll be easy to hack on - and I think it'll be pretty fun.

github.com
u/dilluti0n — 4 days ago
▲ 25 r/bash+2 crossposts

Terminal Based Universal-Downloader - Supports Youtube/Flathub/Github/Torrents/Direct Links

Hello everyone.

This is my small contribution to Linux community, I made this bash script in 2022 and i've been using it ever since and now i've also included Flatpak(Flathub) support aswell.

Description:
A lightweight Linux Bash script that automatically detects the URL you provide and performs the appropriate action. Install Flatpak apps directly from Flathub, download YouTube and Instagram videos with yt-dlp, clone GitHub repositories, handle magnet links and torrent files with aria2 or download direct links with wget, Supports both Wayland and X11 clipboards, so you can simply run the script without arguments and it will use the URL you've already copied.

github.com
u/Sea-Macaroon9814 — 6 days ago
▲ 61 r/bash+1 crossposts

Quick Linux Tip #43 Question: How do I extract config values from between BEGIN and END markers?

Try: `sed -n '/BEGIN CERTIFICATE/,/END CERTIFICATE/p' /etc/ssl/certs/server.crt`

Info: `sed -n` suppresses automatic printing. The pattern `'/START/,/END/p'` prints all lines between two matching delimiters (inclusive).

Examples:

$ `sed -n '/^\[database\]/,/^$/p' config.ini` # Extract section until empty line

$ `awk '/BEGIN/,/END/' file.txt` # Equivalent using awk

$ `sed -n '/ERROR/,+5p' logfile` # Print ERROR line plus next 5 lines

https://www.linuxteck.com/linux-tips/linux-tips-sed-extract-text-between-markers/

Note: Range matching `/X/,/Y/` works line-by-line from first match of X to next match of Y. The `+N` relative line count syntax is a GNU `sed` extension.

Follow u/LinuxTeck for more #LinuxTips click here

u/Expensive-Rice-2052 — 7 days ago
▲ 131 r/bash+2 crossposts

Quick Linux Tip #41 Question: How do I find duplicate files even if they have different names?

Try: `find /home/linuxteck -type f -exec md5sum {} + | sort | uniq -w32 -D`

Info: `md5sum` hashes file contents, `sort` groups identical hashes, and `uniq -w32 -D` compares the 32-character hash to output all duplicate files.

Examples:

$ `find . -type f -exec md5sum {} + | sort | uniq -w32 -d` # Show 1 sample per duplicate set

$ `fdupes -r /home/linuxteck` # Dedicated tool (`apt install fdupes`)

$ `rdfind -deleteduplicates true /home/linuxteck` # Auto-delete duplicates safely

Note: For large directories, `fdupes` or `rdfind` are purpose-built and significantly faster. Use `sha256sum` instead of `md5sum` if collision risk is a concern.

Follow r/LinuxTeck for more LinuxTips click here

u/Expensive-Rice-2052 — 8 days ago
▲ 23 r/bash+1 crossposts

Quick Linux Tip #44 Question: My connections feel unreliable. How do I check for hidden packet loss?

Try: `ss -ti | grep -A3 'ESTAB' | head -20`

Info: `ss -ti` dumps TCP internal metrics. Look for `retrans:X/Y` (X current retransmits, Y total) and `rtt` (round-trip time). Non-zero retransmits signal packet loss or network congestion.

Examples:

$ `ss -ti state established '( dport = :443 )'` # Inspect HTTPS connections

$ `watch -n 1 'ss -s'` # Monitor overall socket summary

$ `netstat -s | grep -i 'retrans\|reset'` # Global TCP retransmission counters

Note: When retransmissions occur, `cwnd` (congestion window) shrinks automatically. Persistent retransmits across multiple endpoints point to network hardware issues rather than application bugs.

https://www.linuxteck.com/linux-tips/linux-tips-check-tcp-packet-loss-ss/

Follow r/LinuxTeck for #LinuxTips click here : https://www.linuxteck.com/linux-tips/

u/Expensive-Rice-2052 — 7 days ago
▲ 29 r/bash

Run commands in parallel

I have a script that collects a list of directories that match a set of criteria and then goes into each one and runs a command. So something like this:

#!/bin/bash
startDir="$(realpath "$1")"
cd "$startDir" || exit
while IFS= read -r -d '' dir; do
  cd "$dir";
  printf '\n\n%s\n' "$(realpath .)";
  update-this-dir.sh --file "./name.txt"
  cd "$startDir";
done < <(find . -type d -iname '.config' -exec dirname {} \; | tr '\n' '\0')

It works wonderfully for my purpose.

But there's, like, a couple thousand directories and the update command takes some small amount of time in each directory, one after the other. How can I modify this script to either run the update for each directory in parallel (with some rate-limiting) or to break up the list into chunks of, say, 100 each and work on each sub-list in parallel?

reddit.com
u/-lousyd — 8 days ago
▲ 0 r/bash

Run a company of AI agents in pure Bash

I open-sourced 5dive, a CLI for running a company of AI agents on a Linux box you own. ~96% bash.

Processing img t3zm9rzio5jh1...

GitHub: https://github.com/5dive-ai/5dive (MIT)

Each agent gets its own Linux user and runs an official CLI like Claude Code, Codex, Grok, Pi, Hermes, opencode, etc. under systemd.

Linux handles identity, isolation, process supervision, logs. SQLite is the shared task queue.

So instead of a big agent framework, it is mostly:

  • Bash
  • systemd
  • Unix users
  • journald
  • SQLite
reddit.com
u/ldrx — 7 days ago
▲ 18 r/bash

local -n can modify variables from other functions

In Bash, normal local variables are usually fine.
But with local -n (namerefs) I noticed they can sometimes change variables from outer/previous functions because of how scoping works.

To avoid problems I started giving local variables unique names (with prefixes) instead of short ones.

Anyone else ran into this with namerefs?

reddit.com
u/AlchemonDev — 8 days ago
▲ 16 r/bash

I don't know what this means

This is from a script that sends the output of an nmap scan to some files. But I can't figure out what "\|" does. Please help

RESULT=$(nmap -iL $(HOSTS) --open | grep "Nmap scan report\|tcp open")

What confuses me is that after running nmap, "\|" simply doesn't appear anywhere, then why is it included in grep?

I guess it could be an OR, but as far as I know OR= ||

I really have no idea, I also don't think it's to escape character becuase there are no pipes in the nmap results, I don't know

reddit.com
u/AcrobaticSilver4966 — 10 days ago
▲ 0 r/bash+1 crossposts

Another Bash Prompt Generator...but better!

I just released v1.0.0 of Promptr. I know there are many other prompt generators and customizers. What sets Promptr apart from them is:

  1. It's eye candy. It doesn't look like something straight out of 1995
  2. Users can authenticate with their Google account (Apple auth coming soon) to be able to actually store their saved prompts in one central location rather than keeping track of them in some Google doc. Logging in is entirely optional. The only thing that authentication provides is cloud storage for your saved prompts, otherwise it is saved locally in your web browser storage.
  3. It isn't live yet, but I intend to add a sort of "marketplace" where users can create and share their generated prompts and upvote which ones they find to be really cool and useful
  4. Basic syntax and security checks against the generated prompt to help prevent any malicious behavior. Don't forget that you are responsible for what commands are being run in your prompt config! Promptr can only protect you so much
  5. Users can apply tags to the various prompts they create so that you can have easy access to different prompt configurations for different environments and use cases
  6. A suggestion box! Please submit your feedback on the app or even any suggestions for new modules to be added that you might find useful!

This really started out because I was tired of trying to find that one bash prompt configuration I created ages ago. Rather than trying to find it, I decided to simply have a place that I can recreate it and store it long-term and build on it as new tooling and needs arise.

I hope it will be helpful for you!

promptr.sh
u/spartakick1080p — 10 days ago
▲ 3 r/bash+1 crossposts

ObiObi: A quiet shell helper that suggests commands in grey text instead of trying to run them for you

Most terminal AI tools these days lean heavily into the "agent" approach; running commands directly, managing sessions, or taking over the screen. That works for some, but I really just wanted a simple inline lookup for those moments where I forget command flags or syntax.

To be fair, I didn't search too hard to see what else might already be out there, I just kind of wanted to build my own solution as a quick weekend project. I called it ObiObi.

It works in bash/zsh:

  • Type ??ask: <whatever you want>
  • The answer appears in light grey underneath your line.
  • Hit Tab to accept it, or just keep typing to ignore it.

It indexed my local binaries once at setup so it actually knows what tools I have installed instead of guessing, and if a command looks destructive it forces you to hit Tab twice before it pastes it in. Nothing ever runs on its own, you're still the one hitting Enter.

You can run it completely local with Ollama or hook it up to whatever OpenAI-compatible API you use.

If you end up trying it out, let me know if anything breaks or if you have feedback!

u/RadioactiveSyrup — 8 days ago