Score:0

Bash based Operating system

kn flag

long time reader, 1st time asking a question...

So I've been trying to "build a basic bash based OS" (for lack of a better term), using only built in bash commands

So far I have 2 scripts that I've managed to put together, 1 provides network info, the other provides basic system information:

NETWORK SCRIPT:

    #!/bin/bash
    watch -t -n 1 "echo 'NETWORK:' && date &&
    echo 'Hostname: $(uname -n)'
    echo 'Host I.P : $(ip r | grep src | awk '{print $9}')'
    echo 'Uptime: $(uptime)'
    echo 'Users: $(users)'
    echo
    echo 'ROUTER:'
    echo 'I.P: $(ip r| grep 'default'| awk '{print $3}')'
    echo 'MAC: $(iwconfig | grep Access | awk '{print $6}')'
    echo 'ESSID: $(iwgetid -r)' 
    echo 'Public I.P: $(wget -qO- https://ipecho.net/plain)'
    "

Here is the SYSTEM script:

    #!/bin/bash
    watch -t -n 1 "
    echo 'SYSTEM:'
    date 
    uptime -s
    uptime -p
    echo '\\t\t\t\t PROCESSES:'
    ps aux | head -n7
    echo '\\t\t\t\t CPU:'
    lscpu | grep Hz
    echo
    echo '\\t\t\t\t RAM:'
    free -m -h
    echo
    echo '\\t\t\t\t STORAGE:'
    lsblk -l | grep sd
    echo
    "

With these, I'm using the watch command so that the output refreshes itself every second, but I was wanting to know if it was possible for me to add a "press Q to quit" option in there anywhere?..

The Idea is that I could have a "main menu" where I could select an option, and have it open up, preferably in the same window but no drama if I can't...

I also have another script that I can run, that will allow me to have both of these scripts open in their own window:

    #!/bin/bash
    # run v1.0.0.0
    # Automates loading:
    # SYSTEM INFORMATION:
    gnome-terminal -- sh -c "bash -c \"!!; exec bash system.sh \""
    # NETWORK INFORMATION:
    gnome-terminal -- sh -c "bash -c \"!!; exec bash network.sh \""

Keep in mind (as you can all probably tell),I'm still very new to this whole bash thing, so I would love to learn some wisdom from the gods.

Currently using Ubuntu 20.04

Any replies greatly appreciated

Artur Meinild avatar
vn flag
You should probably reconsider what you call an [Operating System](https://en.wikipedia.org/wiki/Operating_system). It's really fine that you do some shell scripts and customizations - but it's not an OS.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.