Maintaining a clean *nix environment
Intro
I admit it. I'm a fan of the one-bucket-principle and a really efficient search.
That might appear messy. My emails have two folders: Inbox and Archive (and a nice search function in the UI). My own life's wiki has only one folder (and I rip/grep the shit out of it). But I am not not alone. Look at the Linux Foundation's Filesystem Hierarchy Standard. This is a mess, too. Some highlights:
Directory Description /bin Essential command binaries that need to be available in a single user mode; for all users, e.g., cat, ls, cp. /sbin Essential system binaries, e.g., fsck, init, route. /usr/bin Non-essential command binaries (not needed in single user mode); for all users. /usr/sbin Non-essential system binaries, e.g., daemons for various network-services.
What? 'Essential' binaries and 'Non-essential' binaries? How the hell do you differentiate between 'command' and 'system'?
And don't get me started with that /usr-directory, Rodrigo Silva did that already:
Back in the 70's, in Unix (yes, Unix, way before Linux), floppies had little space (no HD, remember?), and at a given point the system binaries grew too much in number and size to a point they would not fit a single disk, and developers had to split them across several media and thus create new mount points for them. /bin filesystem was full, so they installed the new binaries at... /usr/bin. And /usr was, at that time, their... user directory!
Oh yeah. "Back in the 70's"...
Part 1: Your home
So. As a Linuxgirl/boy, what shall we do if we start with a mess and want to have some structure now?
First, there is a default structure one is presented with Debian-based/RedHat's distros:
. ├── Desktop ├── Documents ├── Downloads ├── Music ├── Pictures ├── Templates └── Videos
For me it is still like this, though I added a src folder for everything I check out from any git repo and a dotfile directory.
A few years ago I wrote drhousemeister to clean up the insides my Downloads folder automatically, which helped a little bit. Note to self: Rewrite that with respect to the local directory structure (e.g., put 'Documents' directly into the ~/Documents folder and so on).
So today we solve the one-bucket-to-rule-them-all a little bit. Let's give it a go and let's start with the biggest mess of all: Pictures. There are nice solutions for this. E.g., Shotwell. So uninstall all the crap you installed as an imageviewer and just have one tool for the job and let it do the job (Speaking about Gnome's Shotwell... didn't I want to give Fedora and Gnome a try recently?).
After installing Shotwell, import all the pictures and let shotwell just do its job.
I'd like to recommend to do this with any other datatype to. There are plenty of programs which can handle this for you.
But what about duplicates and the niches? Eliminate the trash throughout your filesystem in the corner's which aren't that visible. There are two tools, which can help: BleachBit and fslint. Bleachbit is basically Linux's CCleaner, while fslint will identify duplicates and help with finding and ordering stuff by size.
For many users this is probably enough already. But not when you code and/or tend to be playful and try new stuff from time to time.
Part 2: Staying Experimental
To stay experimental while coding without messing up the 'main system' the solution of two machines exists. One which would be reinstalled occasionally and the precious main one.
Luckily, there are solutions for individual environments, like sdkman for Java or virtualenv for Python. However, what about not working with different environments/versions of one lang, but completely different environments?
Meet Vagrant and Docker
Both do similiar things: Give us parts of an operating system to play with. Let's compare them:
Feature Docker Vagrant Virtualization Type Virtual Environment Virtual Machine OS support *nix *nix, Windows Startup time usually Seconds Minutes Isolation Partial Full Weight of virt. sys. Light Heavy
Right now, Docker is all the rage since 2015. Let's give it a try:
Installation:
sudo apt install docker-ce
Or use Docker's fabulous documentation. Then.
User stuffs:
sudo groupadd docker sudo usermod -aG docker $USER
Logout. Login. And run:
docker run hello-world
If everything works according to plan you are greeted with:
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world d1725b59e92d: Pull complete Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
So, there you go. Try the more 'ambitious' suggestion from docker's hello-world and enjoy your new Lab(s). :)
Edit: Some might even say, that Kubernetes is a surprisingly affordable platform for personal projects... o_O
Sources:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
https://www.linux.com/learn/how-organize-your-linux-file-system-clutter-free-folders
https://askubuntu.com/questions/130186/what-is-the-rationale-for-the-usr-directory
https://stackoverflow.com/questions/16647069/should-i-use-vagrant-or-docker-for-creating-an-isolated-environment
















