What should a new Linux Admin never do?

@ericmarceau Prompt colors are changed as well but it is very clear to me when I see a particular background color, which system I’m on.

It was simple to do this using different profiles under gnome terminal and even easier under wezTerm.

3 Likes

Did the same thing. My Putty sessions for production boxes are always red background with white text. Danger Will Robinson!!! For dev boxes I use blue with white letters. Only problem is the color aliases that slip in and frequently aren’t friendly with these colors. Added a loop in my login profile to unalias any color aliases. for i in $(alias | grep color); do ## parse the alias and issue the unalias.

3 Likes

@nosugrof, if you have a script or setting that set the FG/BG colours, you can store a custom

  • ~/.dircolors

on each of those hosts, that suits each host uniquely. If you want details on what and how, I had a discussion topic, with an example, here:

3 Likes

That sounds pretty interesting. I’ve often thought the highlights could make life simpler but just never invested the time to figure it out. Quite often the default colors don’t work with my session colors so I’ve always just excluded the color option on commands. I’ll make a point of reading this.

Thanks for sharing!

3 Likes

Very interesting that there is so many references and comments about using rm -rf, particularly in the root directory, /!

It’s actually one of my favorite commands to use, but because of it’s power I use it with care and it’s rarely used.

My favorite memory of using rm -rf / was when I was leaving a company where I had been an engineer for many years. I knew that my workstation would be “re-purposed”, reused, and reinstalled by someone who would get it after me, and we were all in an OS organization anyway, so it’d be no problem install either a release, a nightly build, or whatever the person after me might choose, so it was a safe thing.

Given that such behavior is quite destructive, I wanted to see my workstation, which I had named TheMas, one nickname of my youth, and one implementation of rm even had an argument to show the files being removed, so I added that option and watched the system sink into the darkness, then I brought some of my friends to my favorite food and drink spot and we had a celebration that spanned our years of friendship. One guy a few of you may have heard of - famous in some circles as Jon ‘maddog’ Hall. We first met in Merrimack, NH one afternoon at the popcorn maker and remained friends for many years and chatted about Unix and Linux numerous times!

5 Likes

Never run a fork bomb.

Can you explain the following bash code or bash fork() bomb code?
:(){ :|:& };:

The fork bomb is a form of denial-of-service (DoS) attack against a Linux or Unix-based system. It makes use of the fork operation. The :(){ :|:& };: is nothing but a bash function. This function gets executed recursively. It is often used by sysadmin to test user process limitations on server. Linux process limits can be configured via /etc/security/limits.conf and PAM to avoid bash fork() bomb. Once a successful fork bomb has been activated in a system it may not be possible to resume normal operation without rebooting the system as the only solution to a fork bomb is to destroy all instances of it.

4 Likes

Hi Jymm :slight_smile:

Yes,

It starts with a function definition, redefining the command ‘:’

Everything between the braces is executed when the function is called.

Let’s first change the function name from ‘:’ to ‘bomb’ to make it more readable.
The first line is the function definition

bomb()
{
	bomb | bomb &
}
bomb

Here is how it works:

Let’s first take a look at the payload of the function ‘bomb()’

what does bomb | bomb & mean or do ?

what it literally means:

  1. start function ‘bomb’
  2. pipe the output to another (on the spot created ) instance of the function ‘bomb’
  3. run this in the background

What it does:

It starts the function bomb and sends the output to another instance of bomb via pipe and puts it in the background, thereby giving it its own process and environment space.
We have now two processes ‘bomb’ running

  1. They will never finish because the second instance of bomb is waiting for the first one to send something (i.o.w. read-locked) so they never exit.

  2. we now have two functions in a separate process (subshell) which takes up space

  3. In the meantime each “bomb” command is calling … itself
    Thereby putting new copies of itself in new background processes … in an endless recursive loop.

The last ‘bomb’ command is actually the command that starts it all.

5 Likes

Can you explain the following bash code or bash fork() bomb code?

That wasn’t me, that is how the article was formatted. But thanks for the explanation anyway, it’s a little more detailed than the article.

https://www.cyberciti.biz/faq/understanding-bash-fork-bomb/

3 Likes

Ah, thanks for the link. I’ll take a look.

2 Likes

Never guess. If you aren’t sure what to do or what a cmd does, isolate it and test it or seek assistance.

Although, we do grow from our mistakes. Create a test environment to grow in.

One more. Always, ALways, ALWays, ALWAYS, run pwd before rm -rf.

6 Likes

All this good insight. I think we have to start even lower though. My own insight offers the following two tips:

1 - never drink the kool-aid
2 - there is no such thing as permanance

I like to also sometimes remember, or, share, that: humans operate the machine and they have humanistic tendencies. Also, haven’t been an actual sysadmin in a long time.

5 Likes

In very simple terms you are adding a never ending repetition of the same function. So you start with one, create another, repeatedly until it consumes the entire system.

3 Likes

Although I’ve been doing Linux since the 90s, I made a really dumb mistake yesterday.

I followed the recommendation of an LLM to adjust a security setting on my ceph cluster. And lost everything. Thankfully I have backups of my personal data, but all my VMs and all the learning projects and staging areas for work are gone.

Rebuilding everything from scratch now - dns, dhcp, ntp, mail/antispam, vpns…

Refresher on postfix mail routing paths - relay_domains, my_networks, mydestination, virtual, etc

Everybody needs a hobby, right? The mission continues…

5 Likes

I feel this in my bones!!

As I was going through my suite of self-hosted apps and patching all of the PHP versions (thanks to the recent vulnerabilities), I set a secondary goal of bringing PHP up to 8.5.12 on all of my devices. I had some PHP 8.3, some PHP 8.4, and some PHP 8.5, and for some reason, my brain said: “You must have 8.5 on everything”.

So I logged in to a VM that’s hosting an app, installed PHP 8.5, verified the patched version got installed, then ran: sudo apt purge -y php8.4-*. What a mistake that was! I did not realize that the application, installed from apt, has a dependency on PHP 8.4! So I watched as apt did exactly as I told it, purged all PHP packages, their config files, and my self-hosted app and it’s config files. OOF.

Thankfully I also have backups of all the configs, so after panicking for several minutes, then several more minutes of hurling insults at myself for being dumb, I was able to get things up and running again.

It is always something!

5 Likes

How DO you work from root, even? I have only ever used sudo haha. Not that I want to do dangerous things in root, but I do think it would be good to have knowledge of that.

2 Likes

Ha, sticking with sudo is the right call. :slight_smile:

To answer your question. The easy way is sudo -i (or sudo su - if you’re old school), which drops you into a full root shell.

Your prompt flips from $ to #, which is basically Linux saying “ok, training wheels are off.”

There’s also su -, but that wants the actual root password, and on Ubuntu root is locked by default so it usually just fails.

To get out of root user, type exit or hit Ctrl+D.

SO yeah, get in, do the thing, get out, otherwise you end up posting here about the :warning: rm -rf :warning: you ran in the wrong directory. :laughing: :open_mouth: :skull:

1 Like

Okay thank you. It IS useful information for me because some things I have tried in the past seemed to require direct root access rather than sudo. Just in the past, I don’t remember what now. But for example the permissions on my Nobara Linux (Fedora type) for modifying the menus were not allowing me to change settings, and there wasn’t a GUI option to open the menu as root like there is on Linux Mint. It was weird too because I wasn’t doing anything crazy, these were options to change basic settings but were just greyed out with no way for me to change them haha. The safe solution I was told to do was “sudo chown $USER:$USER ~/.config/mimeapps.list”. That ungreyed the options and gave me the permissions I needed. I believe this is a mistake with Nobara honestly, because it doesn’t make sense to have these basic options (again, nothing crazy or system breaking) available on the GUI and then make them unavailable to the main system operator unless they enter the terminal. That’s a bit of an oversight imo, in terms of ease of use. But I suppose that is a price you pay for using a downstream fork of Fedora rather than the main one; it helped me learn more about my computer though, so I am not upset. But I do prefer how Linux Mint handles its similar situation when it happens; you just open the same menu as root, type your password, then you can change the permissions as needed.

4 Likes

Many live versions run as root until you install them, but they don’t change anything when ejected

I have enabled root to fix a problem before but disabled
it as soon as I had the problem fixed. I realized I might have to reinstall if I messed up, but I was going to have to reinstall anyway if I didn’t do anything. Luckily for me it worked out, but I wouldn’t have been out anything if I had borked my system. Risk vs reward. Also I keep very good backups.

4 Likes

What should a new Linux Admin never do?
Something that NONE of us who still want a job should save for elsewhere:
SLEEP on the job! :rofl:

4 Likes