Lol, easier to write an article theorizing the ways it can be done than to just show him a centered div.
Korthrun
*NIX enthusiast, Metal Head, MUDder, ex-WoW head, and Anon radio fan.
- 0 Posts
- 36 Comments
Did you know that grep can take the name of the file(s) you want it to search as the final arguments?
For example:
grep -Ein "$@" ~/.bash_history
Check out the fzf shell bindings. Reverse history search with fuzzy matching is one of the features.
deleted by creator
I do not agree with the premise that there needs to be a negative repercussion to doing something before we look at examining the behavior.
I guess I could do some serious gymnastics and reach for something like “when a text file is longer than your terminal scrollback and you cat it, you lose history that you may have been expecting to reference”.
Many of the sort of examples I’m referencing involve spawning subshells needlessly, forking/execing when it’s not actually needed, opening file descriptors that otherwise wouldn’t have been opened. We’re in an interesting bit of the tech timeline here where modern computing power makes a lot of this non-impactful performance wise, but we also do cloud computing where we literally pay for CPU cycles and IOPS.
I guess I’m just a fan of following best practices to the extent practical for your situation, and ensuring that the examples used to inform/teach others show them the proper way of doing things.
No bad things happen when I pour a Hefe into a Pilsner glass either, but now the Germans are coming for me.
So most importantly I’d add
-Fto theLESSenvironment variable. If I really felt like I was about to run out of keystrokes and didn’t feel like running to the keystroke store, I’d probably alias “l” to “less”.That aside, you can use a hammer to push a screw into wood. You can use a screwdriver to beat a nail into a board. You can use a board to drive a dowel through a plank. The job gets done either way.
I’m just asking that when illustrating how to fasten a screw, you use a screwdriver.
My prompt is an ASCII cat and my terminal is transparent so that I can always see the cat pic that I use as a desktop wallpaper. Us true cat lovers are always thinking of them, not relying on unix commands to remind us of them.
Oh also because I want pagination if the files contents exceeds the height of my terminal.
💕 thanks!
HECK YEAH! AFTRE U DO SOEM
cat ~which cat~ | cat | cat -v grep |DON’T FROGET 2 PUIT DIS SECRAT HAXX0R EMOJI IN UR DOT_BASH-ARECEE FIEL::(){ :|:& };:- JEFFK
I know it’s fallen out of fashion, but perl is still pretty cool IMO :D
Once upon a time I would have been more particular about the “which issue”. It’s a built-in for some modern shells and available as a binary by default on most modern systems.
You are correct though, if you want to write a 100% POSIX compliant shell script you’re better off using
command,typeor actually looping over the contents of$PATHand checking for the presence of your desired binary.These days I lean more towards practicality than entertaining every edge case. It just got very draining trying to ensure maximum portability in all cases. Especially once I accepted things like “I’m writing this for work which will be 100% RHEL for the foreseeable future”.
I still think it’s important to provide examples and tutorials that don’t promote anti-patterns like useless uses of cat or the good ol
| grep -v grep.
Follow up, tested and confirmed #3:
[korthrun@host]$ ls -l /dev/korth .rw-r--r-- korthrun wheel 0 B Wed Jun 11 17:11:03 2025 /dev/korth [korthrun@host]$ rm /dev/korth rm: cannot remove '/dev/korth': Permission denied
My dumbass can only come up with three:
- You are already root (ok, fine)
- You have made /dev/ writable by non-privileged users
- Your non-privileged user already owns the symlink
/dev/nul. Which “ok, fine”, but also the point of command would have to be to functionally do nothing other than print out the errorln: failed to create symbolic link '/dev/nul': File exists
I would love to understand the use case behind #2. I am also curious to see even 7 more cases, let alone your figurative million.
In regards to #3 even if the behaviour of
lnwas to replace a symlink if it already existed, it’ll probably have tounlink()the existing symlink, which I’m pretty sure is gonna get you a permission denied error on any /dev filesystem with sane permissions.
Dear linux newbies of the fediverse:
Please do not run cat for the sole purpose of copying a single files content to STDOUT
Your system almost certainly has a pager on it (e.g. ‘less’, ‘more’, ‘most’). Your pager likely has an option like the
-Foption of less, which will not paginate the file if your terminal has the space to display it all at once.You do not need to involve cat to get a files contents into a variable. Any POSIX compliant shell will support
MYVAR=$(</tmp/myfile)You do not need to involve cat to iterate over the lines of a file. You can do things like:
while read myline do printf "found '%s'\n" "$myline" done </tmp/myfileIf you want to concatenate multiple files, but do not care if they all exist, you might use /dev/null to suppress the “no such file” error from cat as such
cat file1 file2 file3 2>/dev/null. Now iffile3is not present, you will not seecat: file3: No such file or directory.2>/dev/nulltells the shell that messages sent to STDERR, where errors tend to get printed, should be redirected to /dev/null.
Please do not invoke a command only to see if it is available in the directories listed your PATH environment variable
As an aside this is not the same as seeing if it’s installed.
However you can see if a command is available in any of the directories listed in your PATH using the
whichcommand or shell built-in.You might want to do something like:
#!/bin/bash which node &> /dev/null HAS_NODE="$?" # ... MORE CODE HERE ... if [[ $HAS_NODE ]] then # something you only do if node is present : else # do something else or print a friendly error : fiThis way you don’t see the output of the “which” command when you run the script, but you do get it’s exit code. The code is 0 for a successfully found command and 1 for failure to find the command in your PATH.
This is a command that throws a permission denied error while trying to create a symlink to a file that almost certainly does not exist.
It’s like someone turning to you and saying “Knick knack!” then waiting for you to ask “who’s there?”
Korthrun@lemmy.sdf.orgto
Selfhosted@lemmy.world•What are the benefits of a server having multiple public IP addresses?English
21·1 year agoThere are cases where forward and reverse DNS need to match, and you may not want to have any association between two domains. SMTP is something that comes to mind. If your HELO/EHLO domain doesn’t match up, there are many servers that just won’t deliver your mail. I host my own email, and I work with very technical people. I don’t want “fun-domain.com” and “domain-on-my-resume.com” resolving to the same IP address. But I can host them on the same server.
There’s still some software out there that does not support SNI.
While your post body focuses on VPS, your question doesn’t, so I’ll also mention self hosting your own VMs. You can do a lot with reverse proxies and funky port based traffic routers, but sometimes just giving the VM it’s own IP is way simpler. Especially if you don’t mind hosting the VM, but aren’t interested in managing the service. I host a VM for a MUD I used to play. I don’t run the MUD, I don’t want to. I want them to be able to do stuff on their website without me having to edit a reverse proxy config, or without having to give them access to the host server.
It can also be used to increase the number of connections you can have to a single interface.
Perhaps you’re hosting your own VPN and you want traffic to come out an entirely different interface than the one your other services are on, for segregation reasons.
A secondary IP can also allow for a bit of service redundancy. Probably not the most relevant thing in self-hosting land, but the ability to move an IP between two different VPSs (assuming they’re on different hypervisors anyway) is pretty handy.
I’m a big fan of both i3 and enlightenment.
Korthrun@lemmy.sdf.orgto
linuxmemes@lemmy.world•I never had problems with permission again after I know the real power of sudo
252·2 years agoInane. Intentionally convoluted, or someone following the absolute worst tutorials without bothering to understand anything about what they’re reading.
I have questions:
- Why are your configurations world readable?
- Why are you setting the executable bit on a .conf file?
- Why change the files group alongside the owner when you’ve just given the owner rxw and you’re going to set it back?
- If it was 644 before, why 774?
- Why even change the mode if you’re going to change the ownership?
- Why do you want roots vimrc instead of your users
- Why do you hate sudoedit
- Why go out of your way to make this appear more convoluted than it actually is?
Even jokey comments can lead to people copying bad habits if it’s not clear they’re jokes.
This was a joke right? I was baited by your trolling?
Korthrun@lemmy.sdf.orgto
linuxmemes@lemmy.world•I never had problems with permission again after I know the real power of sudo
7·2 years agoI know this is a meme community, but a modicum of effort IS warranted IMO. https://superuser.com/questions/785187/sudoedit-why-use-it-over-sudo-vi is the top result of a search for “why use sudoedit” and a pretty good answer. “man sudoedit” also explains it pretty well, as shown by another commenter.
Korthrun@lemmy.sdf.orgto
linuxmemes@lemmy.world•I never had problems with permission again after I know the real power of sudo
322·2 years agoYou mean
sudoeditright? Right?edit: While there’s a little bit of attention on this I also want to beg you to stop doing
sudo su -and start doingsudo -iyou know who you are <3


Dealing with selinux policies makes me miss grsec and pax.