How to keep Linux OS tidy over time?

I occasionally try out new distros from time to time. A while back I picked up Linux Mint and I’ve been using it for a while now.

Not so long ago I tried to build an old C++ project from source. I threw everything at it including the kitchen sink and copied all sorts of commands to install various C++ dependencies.

(Yes, don’t copy random commands from the web. I did review them to be necessary dependencies.) Finally, I got the thing to build successfully.

Some time then passed and now I think I might have somehow botched the audio setup. My question then is are there any strategies to keep a tidy OS to prevent this type of configuration drift?

  • Is using something like NixOs or Guix the way to go? I don’t know those tools but I’m curious about them.
  • Roll opp my sleves and debug the audio setup?
  • Or bite the bullet and reinstall the OS to get audio working again?

Curious about what y’all thoughts are on this? :sweat_smile:

2 Likes

I used to just make copies of my .bash_history every now and then, and search for “that one command” before I came across Zim Wiki someone suggested on the forum here.

Then when I have an issue, I create a sub page, and before trying stuff I Google, I try and make a note of it, and whether it works, in the wiki.

So many answers out there might be from older versions of software, but might still work.

As for tidy, I struggle with this.
Over a few distro’s, I’ve kept a separate /home partition, and ended up keeping .config directories running across several Installs.
I should really parse the ones I still need, and prune down the number.
(Thanks for the impetus)

I don’t know what real Linux users / experts do though

2 Likes

Thanks for the reply!

I just noticed that my PC speakers are making garbled noises when playing audio. But when I use a headset then audio is all well. Maybe this is just a hardware issue (speakers were working fine before), or maybe it’s a kernel upgrade that somehow messed with simple audio-over-minijack. :ghost:

A friend of mine has gotten really into using dotfiles for programmatically configuring a fresh system. Maybe that’s the way to go. Or maybe using Ansible to configure one’s own system. :thinking:

2 Likes

That is annoying, when a problem is inconsistent.
I guess I would check the connections and stuff, in case something worked loose, as it already looks like you poked around changing the audio sources software side.

Sorry I can’t help, but good luck with it man

1 Like

Thanks! I’ll see if I manage to debug this or go looking for another distro to try out. :slot_machine: :sparkles:

1 Like

Number one IMO would be installing software only from packages so stuff can be managed through the package manager. Running random install scripts is an easy way to mess up stuff especially when they require sudo to put executables into /usr/bin and other stuff whoknowswhere.

If you wanna use a software that is not in any repo you can find I’d personally start looking into how to build packages yourself. It’s really not hard and once you get into the flow of it it doesn’t take all that long either.

I don’t know about deb-based distros specifically, but on RPM-based distros writing a spec-file and running it through mock is super easy and quick to do. Depending what kind of software it is you might also just be able to host it on the launchpad PPAs (not sure if there are restrictions what you can put on there).

If you’re playing with config files I would suggest documenting your changes so you can later look at what you changed and why. In the last 3 years I only had to change a handful of system-configs and I put them in a markdown-doc in my home so I can come back when I start having issues and revert the changes.

And beyond that really all you can do is just following whatever the distro maintainers recommend when doing updates and upgrades.

As for your audio issue I would start looking into when it first occurred, was it after an update or something else you did. If that’s the case you can start by reverting whatever change you made and see if that helps.

3 Likes

That’s very hit or miss. IMO it’s better to just log all commands. There’s lots of ways to do this, f.ex. snoopy, PROMPT_COMMAND in bash, and a precmd hook in zsh. Some people load the commands into a database, but just grepping text logs works for me.

hey, yeah. didn’t mean it was a Good tactic, just a progression…

the self wiki much more meaningful… and useful.

The other posters advice about documenting your changes is good. I’m lazy, but I’ve learned that making diligent notes is the lazy thing to do in the long run.

Keeping Linux tidy… using btrfs can help with this.

  • You can back out changes painlessly, in seconds.
  • Experiment while booted to a snapshot, then discard it.
  • You can have multiple distros and instances in the same btrfs. (Some installers won’t facilitate that, but you can install to some random partition then move the install into a btrfs subvolume.) For me it’s a huge time saver as there’s no need to juggle space and partitions.

Some folks get right into VMs to keep their main install tidy. I must give that a go…

2 Likes

It may be helpful for your audio issue to rule a few things out first:

  • Are both the headphones and speakers analogue-input — neither is connecting via USB or Toslink-S/PDIF and has its own DAC?
  • Are they both being tested on the same audio jack?

If yes to both, my uneducated guess would be that it might a failure that is only visible when driving higher-impedance output; though most desktop speakers have their own power, so maybe one should not expect higher impedance from them.

My inclination is to assume hardware failure first, but to confirm this, you could try testing with a LiveCD. This would let you quickly rule out the possibility of your software configuration being the cause.

2 Likes

There is also the nuclear option, so to speak. I read a blog post two weeks ago about a guy that setup NixOS to effectively reinstall his system every time he reboots. I setup something similar and I quite like it. I went from manjaro xfce → nixos cinnamon. Everything works as expected, other than spotify requiring me to login every time I reboot ( I use the web player now ).

All you need to boot is the /boot and /nix folders and nixos can reconstruct your filesystem from the /nix folder. I setup more or less the same thing as the guy in the blog post. The only data that exists between reboots is /boot, /nix, /persist and /home. rpool/local/root is mounted on / and gets formatted during every reboot.

zfs_lilst

That said, this is obviously a very adventurous solution. Do you own research and ideally setup this kind of thing up on a spare computer to see if you like it. Its a fair bit more effort to setup than a typical installation and the nix language is a pain. This isn’t a great solution to your audio problems, but its something to look into if you’re curious.

It is really cool though.

Top tip : remember to persist your configuration.nix or else it will get deleted. You’ll still be able to boot from the latest config, since its stored in /nix, but the editable configuration.nix will be gone and you’ll have to rewrite it from memory ( speaking from experience, for some stupid reason I thought it would stay). Another handy blog post.

3 Likes

I keep the host (zfs on linux) as ‘clean as possible’ (mileage varies, my new z690 is hacked to the gills just to get it to function properly), then create virtual machines and install all my crap in there.

I use zfs snapshots on the host (zsys & sanoid/syncoid both have their issues but are valuable) to protect against software-fails and sync filesystems to another machine for backups.

Auto-start (or not) a linux vm that contains the broswer, apps, etc, then open it (full-screen or not). (Virt-viewer works fine for 90% of use-cases) This gives the effect of having a thin host (without all the limitations of, say UNRAID, with good protection and few limitations. Yes, even on a pretty basic machine built in the last 10 years, running Firefox in a vm is performant enough that you’re probably not going to notice streaming videos and whatever if set up right)

Getting a windows vm going with gpu-passthru and using looking-glass with that is next. if done properly (becoming less & less of a black-art) you can get near(-ish) 100% performance of the host running windows bare-metal (yuck) but with all the linux zfs (etc) goodness. Windows needs to be put in a box where it can slowly die over time.

The only downside is this all takes more ram. And time to learn how to configure it up.

Someone (cough) @wendell (cough) should lead a project to create a turn-key linux distro that enables this stuff for the masses. It’s time has come.

Home on NFS :smiley:

1 Like

Personally I try to keep everything minimal. I’m going to far extremes, but that’s just me. You can keep a “basic” config and take a note of what stuff get installed, by maybe doing a history > history-$(date +%Y%m%d).txt and removing them after you know you don’t need them anymore.

While they certainly have their own appeal, they are very different beasts than normal Linux distros. I would say you start with Gentoo if you want to get into nixOS. But you don’t need to use them to keep your OS tidy.

Yes. Try migrating to pipewire, it is a drop-in replacement for pulseaudio, so it should be fairly easy. I did it a few weeks ago and I am not noticing any difference.

If you OS is bloated with junk beyond repair, then it’s your own choice to make. In all honesty, Ubuntu and Mint tend to get pretty heavy if you install stuff outside their official repos and it can become hard to look into what you added if you didn’t take a note when you added the software.

If you don’t close your terminal, history should be fine, but I did see it go weird if I had multiple terminals and closed them in different orders. Sometimes history doesn’t even get saved if you reboot or logout.

There are solutions for that, including using BTRFS, ZFS or even LVM snapshots and reverting to an earlier snapshot. Not necessarily on each reboot, but it can be done so.

I guess if you work strictly with Linux, you may want to look into LXC / LXD. I prefer LXD, but the fundamentals are the same, just the management is a bit different (easier on LXD). You can install stuff in a container, or for that matter, even in a simple chroot if that’s all you need and not have to taint your main system. I guess that could be another option to keep Linux tidy.

:heavy_plus_sign::heavy_plus_sign::heavy_plus_sign:

Ok, this is a rather interesting nixOS use. Nix admins surprise me just as much as Gentoo admins. They really know their systems.

I don’t have an immutable system, but I do make use of Alpine Linux diskless mode on my router (a Raspberry Pi 3). Because it always starts in a clean state, I can always install crap on it (like sshfs which I don’t always need, but may use every now and then, or enable the community repo and install neofetch), then reboot and it goes back to the way it was before.

If I install a certain package, or want to add a new location to be saved, like say /home, I just config lbu to backup stuff. I reboot from time to time, to get a clean OS state, then do a system update, then lbu commit to backup the system state (which is just a tar.gz archive, that gets copied into RAM when the rootfs gets mounted as a tmpfs). It’s pretty sweet, but it does come with its drawbacks, specifically the fact that the system will accumulate junk over time if you are not careful. LBU allows you to have multiple backups and rotates them as needed, and you can choose which to use by renaming and rebooting, or by doing a lbu revert [file-name].tar.gz.

Alpine diskless mode is a middle-ground between that nixOS fresh canvas at reboot and normal Linux distros. Well, I guess they may have more similarities though, even though they work in completely different ways. I like my minimal systems, so Alpine is rather nice. That and the fact that I never used nixOS before, because I didn’t take the time to look into how to manage it. I know that its build system and FHS are different than normal Linux distros.