The Linux Thread - The Autist's OS of Choice

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
Mentally I fluctuate somewhere between a snotty teenager and a stuck-up boomer. DOS/cmd is a good starting point just to get the grasp of what a command line is. And IMO it's good to get the hand of the Batch retardation given how the Bash retardation of Linux is not that far off, and PowerShell's verbose commands and scripting syntax is too unique for that. PowerShell is a cross between a programming language and a command line, and for raw command line experience it's better to go the hard way.
No. Just use PowerShell on Linux you retard
 
powershell is amazing, the object oriented nature makes some complex tasks super easy.

i think PowerShell is great to start on, its baby's first python, and i say that as someone who does not really use python.
i think it is a better introduction to a true programing language, and still mainting some simplicty of a scriping language.

are you saying that cmd/dos has better logic? why would you suggest someone start on it over powershell?
the consistent nature of ps and the fact that most objects are chainable together makes many admin tasks a breze.

here lets play a game, i want a report of all users on a domain with the name dave, include there email address, format it into a table and send it in an email.

get-aduser|where $_.name -eq "dave"|ft --property fullname,email |send-mailmessage --to someuser@fake.com --from someuser@fake.com --subject "Dave Report "

(i probably have a typo, im at home and dont have a domain system to test this on right now but i wrote this from memory because its so intuitive )
all of these commands are extremely intuitive, now try and do the same in cmd and lets see what it looks like, no way its this clean and readable.


now on the linux vs windows cli, i dont think there is really a difference, the name of the commands may be different but what you are trying to accomplish is the same, eg rm vs del, ls vs dir.
once you know what is possible and how you are going to accomplish it, it is just a matter of finding the correct power word to cast your spell.

edit: i asked deepseek to make this in cmd to see how horrifying it looked and it needed external tools to send the email, and i had to instruct it to not use powershell as it was just going to invoke ps from cmd.

Method 1: Using CSVDE and Blat (Third-party email tool)​

First, you'll need to download and install Blat (a command-line email tool):

batch
@echo off
setlocal enabledelayedexpansion

:: Set variables
set DOMAIN=yourdomain.com
set SMTP_SERVER=smtp.yourdomain.com
set FROM_EMAIL=report@yourdomain.com
set TO_EMAIL=recipient@yourdomain.com
set REPORT_FILE=dave_users_report.txt
set CSV_FILE=dave_users.csv

echo Generating report for users named Dave...

:: Extract users with name containing "Dave" using CSVDE
csvde -f %CSV_FILE% -r "(&(objectCategory=person)(objectClass=user)(|(name=*Dave*)(sn=Dave*)(givenName=Dave*)))" -l "name,mail,samAccountName,displayName"

:: Create formatted table
echo User Report - All Users Named Dave > %REPORT_FILE%
echo ================================= >> %REPORT_FILE%
echo. >> %REPORT_FILE%
echo "Display Name","Username","Email Address" >> %REPORT_FILE%
echo -------------------------,----------------,------------------------- >> %REPORT_FILE%

:: Parse CSV and format as table
for /f "skip=1 tokens=1,2,3,4 delims=," %%a in (%CSV_FILE%) do (
set "displayName=%%a"
set "email=%%b"
set "username=%%c"
set "name=%%d"

:: Remove quotes
set "displayName=!displayName:"=!"
set "email=!email:"=!"
set "username=!username:"=!"
set "name=!name:"=!"

:: Only include if email exists and name contains Dave
if not "!email!"=="" (
echo "!displayName!","!username!","!email!" >> %REPORT_FILE%
)
)

:: Send email using Blat
blat %REPORT_FILE% -to %TO_EMAIL% -f %FROM_EMAIL% -server %SMTP_SERVER% -s "Domain Users Report - Users Named Dave" -body "Attached is the report of all users named Dave in the domain."

:: Clean up temporary files
del %CSV_FILE%

echo Report generated and sent successfully!
echo Report file: %REPORT_FILE%

Method 2: Using Net Command (Simpler approach)​

batch
@echo off
setlocal enabledelayedexpansion

:: Set variables
set DOMAIN=yourdomain.com
set SMTP_SERVER=smtp.yourdomain.com
set FROM_EMAIL=report@yourdomain.com
set TO_EMAIL=recipient@yourdomain.com
set REPORT_FILE=dave_users_report.txt

echo Generating report for users named Dave...

:: Create report header
echo User Report - All Users Named Dave > %REPORT_FILE%
echo ================================= >> %REPORT_FILE%
echo. >> %REPORT_FILE%
echo "Display Name","Username","Email Address" >> %REPORT_FILE%
echo -------------------------,----------------,------------------------- >> %REPORT_FILE%

:: Get users and attempt to extract email (limited by net command)
net user /domain | findstr /i "dave" > temp_users.txt

for /f "tokens=1 delims=" %%a in (temp_users.txt) do (
set "userline=%%a"
set "username=!userline:~0,20!"
set "fullname=!userline:~20,30!"

:: Trim spaces
for /f "tokens=*" %%i in ("!username!") do set "username=%%i"
for /f "tokens=*" %%i in ("!fullname!") do set "fullname=%%i"

:: Get user info to try to find email
net user "!username!" /domain | findstr /i "comment" > temp_info.txt
set "email="
for /f "tokens=1,*" %%x in (temp_info.txt) do (
set "email=%%y"
)

if not "!email!"=="" (
echo "!fullname!","!username!","!email!" >> %REPORT_FILE%
) else (
echo "!fullname!","!username!","Not Available" >> %REPORT_FILE%
)
)

:: Send email (using Blat)
blat %REPORT_FILE% -to %TO_EMAIL% -f %FROM_EMAIL% -server %SMTP_SERVER% -s "Domain Users Named Dave Report" -body "Please find the attached report of users named Dave in the domain."

:: Clean up
del temp_users.txt
del temp_info.txt 2>nul

echo Report completed: %REPORT_FILE%

Method 3: Using WMIC (Alternative approach)​

batch
@echo off
setlocal enabledelayedexpansion

set REPORT_FILE=dave_users_report.txt
set SMTP_SERVER=smtp.yourdomain.com
set FROM_EMAIL=report@yourdomain.com
set TO_EMAIL=recipient@yourdomain.com

echo "Name","Username","Email" > %REPORT_FILE%
echo -------------------------,----------------,------------------------- >> %REPORT_FILE%

:: Use WMIC to get user information
wmic useraccount where "name like '%%dave%%'" get name,sid /value > temp_wmic.txt

for /f "tokens=1,2 delims==" %%a in (temp_wmic.txt) do (
if "%%a"=="Name" set "username=%%b"
if "%%a"=="SID" (
set "sid=%%b"
:: This is where you'd typically look up email, but WMIC doesn't provide it directly
echo "Dave User","!username!","See Active Directory" >> %REPORT_FILE%
)
)

:: Send email
blat %REPORT_FILE% -to %TO_EMAIL% -f %FROM_EMAIL% -server %SMTP_SERVER% -s "Dave Users Report" -body "Report of users named Dave"

del temp_wmic.txt
echo Report sent!

Setup Instructions:​

  1. Install Blat:
  2. Configure the script:
    • Replace email server details
    • Replace domain information
    • Replace email addresses
  3. Run the script as Domain Administrator for best results

Notes:​

  • Method 1 (CSVDE) is most reliable but requires proper AD permissions
  • Method 2 (Net Command) is simpler but has limited email extraction
  • The net user command doesn't directly provide email addresses, so you might need to rely on the "Comment" field or use CSVDE
  • For production use, consider storing email credentials securely if authentication is required
Would you like me to modify any part of this solution or help with the Blat configuration?
 
Last edited:
why would you suggest someone start on it over powershell?
It's a better baseline to start at IMO. As in, learning the command line in it's rawer form and not having to deal with any collisions between classic command line tasks and PowerShell objects. Yes, PowerShell is more powerful and intuitive than cmd, but if you never touched a command line it's best to start with something more tried and true to get the idea of how to use it.
 
It's a better baseline to start at IMO. As in, learning the command line in it's rawer form and not having to deal with any collisions between classic command line tasks and PowerShell objects. Yes, PowerShell is more powerful and intuitive than cmd, but if you never touched a command line it's best to start with something more tried and true to get the idea of how to use it.
what collisons are you having to worry about if you are not aware of the old cmd's? it would be better to just learn the modern commands.

collisions would only matter if you where already aware of the dos/cmd commands.
and im not sure what we are "learning"
how to cd to a dir and run myporngame.exe?
 
what collisons are you having to worry about if you are not aware of the old cmd's?
The moment you don't have PowerShell and you have to deal with something more old-school. It's best to set your expectations of a command line with something more traditional before you give PowerShell a whirl. That way you'll be mindful of the ways PowerShell differs from other command lines and not be confused when you can't do a PowerShell related task in cmd or Bash.

As for collisions, due to PowerShell having a completely different syntax from cmd, something as simple as running a program with a path can cause issues, since you'll have to first define you want to run it from the current directory with .\, and in my experience trying to get a path with spaces parsed through properly is insanely finnicky with PowerShell. That's why I believe that it's best to first get accustomed with MS-DOS/cmd if you've never touched a command line before.
 
The moment you don't have PowerShell and you have to deal with something more old-school. It's best to set your expectations of a command line with something more traditional before you give PowerShell a whirl. That way you'll be mindful of the ways PowerShell differs from other command lines and not be confused when you can't do a PowerShell related task in cmd or Bash.

As for collisions, due to PowerShell having a completely different syntax from cmd, something as simple as running a program with a path can cause issues, since you'll have to first define you want to run it from the current directory with .\, and in my experience trying to get a path with spaces parsed through properly is insanely finnicky with PowerShell. That's why I believe that it's best to first get accustomed with MS-DOS/cmd if you've never touched a command line before.
as this is the linux thread i would suggest bash for that.

and what are we working on in 2025 without PowerShell?
you can install powershell 2.0 on xp, and 7 had it by default. if you are running anything older then that you are a hobbyist who is doing it for there own pleasure/suffering, not a beginner trying to learn.
 
i just wish ms would bring over some basic gnu commands, what i would give to have grep and tail on a windows system, they say they have powershell equvelents, but what i would give to be able to tail a log file without having to wait for the entirety of it to print across the screen.

Who does this outside of IT department drones?
the department of fuck dave, thats who.


on another note, anyone here doing anything with k8's?
have been thinking about moving some of my docker workloads into it, just not sure if its worth the steep learning curve.
 
Normal command line usage and scripting are really two very different things, if you want to learn the former, I'm not sure it's worth fiddling too much with the latter, vice-versa (although users usually end up learning both). Bash as a scripting language is woefully inadequate, but as a job control/command line language it's kinda nice. Someone should figure out how to do a lisp without so many parentheses, that seems like it would be good at both.
 
on another note, anyone here doing anything with k8's?
have been thinking about moving some of my docker workloads into it, just not sure if its worth the steep learning curve.
Take this with a grain of I'm a professional salt

Early adopter of docker. Resisted k8s for years. Ended up having to learn it for a gig and now I love it. Being good with it makes you a god even among other coders that kinda grok it. E.g you might be able to solve a architecture problem or bug with a simple liveliness probe instead of waiting for your senior devs to get around to implementing the fix in the app. Professionally it offers so much and in a unix philosophy one small thing do it well way. Everything can be swapped out. Nerds will complain about micro services or w/e but idgaf I'm trying to reliably lay down software with a standard set of tools and train idiots to maintain it. It's a trade skill. K8s is becoming the industry standard by how we talk.

For home, k8s with argocd means I'll get an idea for something to add to the homelab while taking a shit, type it out in a editor on my phone. Save commit push and by the time I'm done washing up it's been deployed and infra as code with all the bells and whistles of a professionally built environment.

Then you dive into services built with it in mind like Prometheus, thanos, toss grafana in front and it's a rabbit hole.
 
Take this with a grain of I'm a professional salt
what are you running it on? hosted?
i spun up a talos cluster and liked it, but running it bare metal it took alot to even be able to get started, metallb for ips, an ingress, and storage fuck storage(rook/ceph is what i was thinking but ceph i dont think will work well at my small scale, and i would need to start small to be able to sell its use)


i liked argo but i need to take some more time to figure out how to tie it into git, i added a helm chart but im not sure how i am supposed to tie it into my git, and push and changes back into git, it just always stays out of sync as i make changes.

i can see why having basically a hypervisor that understands the desired state of your architecture and works to keep it as speced can be nice.

i was pretty meh on docker, just having to deal with it when i was running something that required it and did not like that i had to take care of the reverse proxy outside of the app.

but then i took some time when building a web app to learn to make a dockerfile and package my app up, and my god i just fell in love.
its like little linux vms, that i can spin up in seconds and tear down when not needed, that legacy version of mysql wont compile on ubuntu21, change the FROM line and im building it on ubuntu 18, faster then i could have downloaded an iso.

and k9 helped alot to unravel the mystery that is k8's it let me quickly see what really is going on behind the scenes.
 
pops didn't use bash. He used sh, ksh if he was very lucky. CCP on CP/M if he wasn't.
I was being literal, that's even older school. Pops used bash, our careers overlapped. Kinda a retard with computers but somehow retired still using an old school setup, ran X forwarded xterms on a Windows laptop into the 2010s. I recall him being a cygwin guy too.
what are you running it on? hosted?
Home: random servers running random flavors of Ubuntu (lame yes want to switch to something else someday) using microk8s. It's meh.

Work is all cloud shit. Eks gcp aks. The less I have to touch that shit the better.
 
Who does this outside of IT department drones?
I commonly parse through Active Directory trees when setting up my hosts file on my PC with addresses for every single client server or PC so that I don't need to worry about one of the five VPNs I have running replacing the default DNS server.
as this is the linux thread i would suggest bash for that.
Although it's still super easy to install on any modern Linux box.
Say what you will about either bash or plain jane POSIX but it's kinda satisfying making scripts that don't rely on external processes (commands like awk, cat, cut, echo, grep, etc.) for what you're wrapping around the focus command.
Or, for that matter, which if you need to make use of some external library you don't have to write your own helper program to deal with it.

Powershell lets you do practically anything you might need to do, importing .Net DLLs, creating objects with the types they define and using them as part of your script, calling methods on those objects or static methods. Anything that isn't super simple to do this way, you can just write a helper function in C# and include that as part of your script to be compiled on the fly. I can write bastardized python code as well, sure, and it'd be just as efficient for most tasks I use Powershell for, but Powershell is just so much nicer for not having that goddamn indenting.
 
Back
Top Bottom