Why can’t a macOS be installed in a Windows computer?

Why can’t a macOS be installed in a Windows computer?

You can translate the content of this page by selecting a language in the select box.

Why can’t a macOS be installed in a Windows computer?

Why can’t a macOS be installed in a Windows computer?
Why can’t a macOS be installed in a Windows computer?

Apple don’t want that to happen.

Not because they want to extract more money from hardware sales (Apple hardware is actually cheap for the quality you get anyway), not because they wouldn’t sell OS X as a product if they could.

It’s really simple: they did the math on the support costs of random third party hardware, and the numbers came up “nope”.

Apple actually did this long before OS X was a thing; for a short while you could actually get a licensed non-Apple MacOS computer.

But the support costs killed it.

To actually do this and make money, they’d have to sell OS X for a couple of thousand dollars, or maybe a subscription at about $50/month. That’s to pay for the three or four thousand developers and ten or so thousand support people they’d have to hire to deal with all the random crap hardware out there.

And it still wouldn’t meet their quality targets anyway.

So how can Microsoft do it?

They get the OEMs and hardware manufacturers to deal with most of it. Which they mostly do badly, but people have somehow become used to the resulting mess.

Making the OS itself free does mean that they don’t want people to install it on third party hardware because that would mean zero profits from the extra user (unless they use services such as iCloud in a premium fashion — more than just what’s given free).

I guess that makes the hackintoshing phenomenon an issue. Now, when the support for the last Intel based Mac ends hackintoshing will be a real issue (I mean, some explicitly limit themselves to High Sierra because of some NVidia GPUs that aren’t supported on newer versions at all…). But for now, if you have good, compatible hardware, you can reap the benefits just fine.

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLFC01 book below.


I am currently a hackintosher but intend to get an actual MacBook Pro (Intel based) soon. Wouldn’t have happened if I didn’t get a good hackintosh. So I’d say, don’t fight those who try it out like this and then migrate to actual Apple products, since that’s actually a profit vector. Only fight those that do it despite that.

The better question to ask is “How does Linux do it?”. You can find drivers for most of “the random crap hardware out there”… You can “google yourself” the support for most of the issues you’d run into, unlike Windows, etc. Support is a “thing” mostly for corporate users. Companies need someone to sue in case they’d somehow lose a penny because of hw/sw issues.

Invest in your future today by enrolling in this Azure Fundamentals - Microsoft Azure Certification and Training ebook below. This Azure Fundamentals Exam Prep Book will prepare you for the Azure Fundamentals AZ900 Certification Exam.


Using Windows would be much better than hackintoshing. Windows has its issues, it is not as reliable as macOS. However, Windows is much more flexible than macOS. It is much more programmer friendly than macOS. Most of the advantages of macOS will cease to exist once you take it out of the integration with Apple hardware.

You can, not so easily, run the OSX on a windows machine as you would run a second version of windows or Linux or any other OS. My current machine has around 4 different OS in 2 drives. The machine was originally assembled keeping in mind running it on OSX, endearingly known by the community as Hackintoshs. I did run an OSX version of Snow Leopard for a few months but didn’t have much use of it as I already own a MacBook Pro. A fun project but not without hastles.

Also, I did shift my 10+ year old MacBooks drive into the machine, before writing this reply, just for fun. Given the changes over time, the OSX failed to recognise half the peripherals which is solvable, but would need a lot of work.

You can. Such computers are called a “Hackintosh.” The procedure is totally unsupported, but I suppose it can save the user some money, when it works.

It’s not that it can’t. It’s a violation of the end-user license. If you’d like to give a try, just google out Hackintosh. I am not aware of any prosecution if you do. Definitely nothing like the infamous Microsoft initiated BSA raids on companies and individual users.

  • Latest possible MacOS available for MacBook Pro 15" 2010, A1286
    by /u/ithakaa (Mac) on September 25, 2022 at 11:58 am

    Can someone please assist, I'm not having much luck getting the information I need for this older Mac submitted by /u/ithakaa [link] [comments]

  • Is it safe to leave a 2012 macpro running 24/7 as a server if the battery is bad and only running from charger? I’m using it now with no problems unless I unplug it.
    by /u/scuttdogg (Mac) on September 25, 2022 at 11:57 am

    submitted by /u/scuttdogg [link] [comments]

  • Should I change?
    by /u/jordiolle11 (Mac) on September 25, 2022 at 11:41 am

    Hi there, I'm a software developer, and I'm currently using the base model MacBook Pro 13 with Intel chip (the one before the M1). I'm thinking of selling it and buying the new Air M2, should I? View Poll submitted by /u/jordiolle11 [link] [comments]

  • MacBook for college?
    by /u/bouncy_cashewnutt (Mac) on September 25, 2022 at 11:32 am

    I will be joining a B.Tech course in Electrical Engineering and will be doing CS courses/ learning coding side by side I am most likely gonna learn a bit of video editing as well Which Mac is the best for me? I have an Intel i3 Air rn will that suffice? or do i need a new one if so then which one? M2 Air or Pro or wtv and should i spend the extra bucks on 16 GB ram or 512 SSD please help submitted by /u/bouncy_cashewnutt [link] [comments]

  • What charger do I need for a MacBook Pro 15" 2010, A1286 ?
    by /u/ithakaa (Mac) on September 25, 2022 at 11:03 am

    What charger do I need for a MacBook Pro 15" 2010, A1286 ? I'm a little lost to be honest, can someone assist please submitted by /u/ithakaa [link] [comments]

  • New to apple and thinking about M2 macbook...
    by /u/BiggestNintendoFan (Mac) on September 25, 2022 at 10:39 am

    Hey guys new apple user here.Thinking about buying an M2 macbook pro.But I never had an macbook or Mac before so that's why I'm here.What can a macbook do?Like can you just use Microsoft word,office for free? Tell me the good and bad about the macbook.Thanks submitted by /u/BiggestNintendoFan [link] [comments]

  • My Mac(Book) Pro Desk Setup
    by /u/Maximum_Wrongdoer_28 (Mac) on September 25, 2022 at 9:47 am

    Hey Guys. I want to show you my "new" Mac Desk-Setup, cause it's a bit uncommon. ​ https://preview.redd.it/ahanummr7zp91.png?width=3024&format=png&auto=webp&s=8735d213b8a9a26d044815aec5b5afa16bcee6ff ​ https://preview.redd.it/j8ffpvyv7zp91.png?width=4032&format=png&auto=webp&s=38a0bc637e78fe00b43ea26bdc4953b2d2627520 Befor I was using a (fully functioning) 15" MBP Retina Mid 2012 Top BTO. Since Catalina got it's last security update these days, I was looking for a replacement. I found a MBP 15" from 2018 with the 6 Core i7, 16GB RAM, 555X Pro and 512 GB SSD on Kleinanzeigen (German Version of Craigslist). Pro's: Dirt cheap! Keyboard replacement in 2020 (with new Battery, Trackpad and Topcase). ​ It has a few drawbacks: Screen is cracked to the point that it won't even show light. Touch Bar is not working. Overheating to the point that it throttles in even on IDLE. The seller showed me with a external screen that it is working, besides the issues which I described. He asked for 150€. I bought it, with the intention to fix it. It's clearly that the Screen can't be replaced in any economical way. For the money of a new screen I could buy a MBA M1 used in descent condition. The other issues was easy to fix. New Touch Bar cost me only 21€ refurbed from eBay. The overheating issue was addressed with a complete teardown, new thermal past and a complete clean with compressed air and rubbing alcohol. Cause the screen is not working, I decided to remove it completely. At UnboxTherapy's Podcast I heard that this way of using MBP's with faulty Display's as a Desktop Computer is a real thing in Asia. And voila! There it is my "Mac mini Pro" from 2018. I have all benefits that a Mac mini comes with, plus better Speakers, a Buildin Keyboard and Trackpad and I have a dedicated GPU. ​ My 2012 is already sold for 280€. That means I earned money and got a descent performance Update! submitted by /u/Maximum_Wrongdoer_28 [link] [comments]

  • Apple to allow NFTs but with apple way.
    by Metaverse Zeus (Apple on Medium) on September 25, 2022 at 8:46 am

    Continue reading on Medium »

  • What is the best alternative to iCloud to use on Mac.
    by /u/samwalruss (Mac) on September 25, 2022 at 8:41 am

    I am presently on Android and do not want to shift over to iOS. I tried the iPhone for a few days but it doesn't suit my work. I read a lot of pdf articles/ebooks and want them synced between my iPad pro, Macbook pro and my android. Sadly web-based iCloud is not really great for regular use on Android. Google drive seems power hungry on my Mac although on iPad it seems alright. TIA submitted by /u/samwalruss [link] [comments]

  • iPhone 14 Series Hands-on Experience
    by Sajjad Hussain (Apple on Medium) on September 25, 2022 at 8:20 am

    The future is now, and the iPhone 14 Pro and Pro Max are likely to be the start of a trend towards larger camera sizes on phones. We have…Continue reading on God Hardware »

  • Lag when connected to monitor
    by /u/Any-Temporary-2701 (Mac) on September 25, 2022 at 8:15 am

    So I recently purchased a BENQ 2480 monitor my MacBook Air M1(8GB RAM), and I've noticed since then that the machine is lagging randomly every 10 min or so when connected to the monitor. The cursor also glitches quite frequently(on both the monitor and the mac).It also takes 1-2 secs to wake up, and without the monitor it used to take a fraction of a second..like the screen used to be on even before I looked at it. Overall, the performance doesn't feel as snappy as it used to without the monitor. Does anyone else face this problem? Is there a fix for it? submitted by /u/Any-Temporary-2701 [link] [comments]

  • Should I Listen to This Guy on YouTube Regarding Mac Scaling and External Monitors?
    by /u/anon-5461281 (Mac) on September 25, 2022 at 8:09 am

    Here is the video. Why I RETURNED my 4k monitor // MacOS Scaling Explained! - YouTube Is this video legit and should I listen to him? I want an external monitor for my MacBook Air, but I do not want to spend a whole lot of money. Is this possible or am I going to have to shell $400+ for a monitor? Edit: I use my MacBook Air only for studying. I don't use it for content creation, social media, or YouTube. submitted by /u/anon-5461281 [link] [comments]

  • Apple Inc.: Our Modern-Day Symbol of Knowledge, Power, and Wealth
    by Investing.com (Apple on Medium) on September 25, 2022 at 7:21 am

    Since time immemorial, the apple has been viewed in world folklore, literature, and history as a symbol of knowledge, power, and wealth…Continue reading on investing.com »

  • Photos Library Backup
    by /u/ConsistentVersion337 (Mac) on September 25, 2022 at 6:46 am

    I currently back all my photos from my iPhone up to Photos on my MacBook. I then back up my whole Mac using time machine to an external hard drive. For the most part this is the perfect system for me. However, as I add more and more photos it makes me nervous just having a "Photos library" back up and not individual back ups of each photo. Is there any kind of app that would help me do this? Something where I could back up to Photos still, but also have a secondary storage location of each individual photo file for redundancy? Even better if it is something that could read my photos off of Photos and just back them off from there. Apologies of this is a confusing af question, I am happy to elaborate if I need to. submitted by /u/ConsistentVersion337 [link] [comments]

  • Broken keyboard problem
    by /u/Aromatic_Ad6134 (Mac) on September 25, 2022 at 6:35 am

    I have my mbp2015 15inch L shift key is constantly pressed right now so i cannot use it I have tried (1) reinstalling macOS (2) use it with external keyboard (3) Cmd +R+P power button (4) Replacing the whole keyboard but the L shift is still pressed The service techinician also tried using the replacing keyboard on another mac and it worked fine but if it is equipped on my mac the L shift is constantly pressed sorry for my english skill pls suggest submitted by /u/Aromatic_Ad6134 [link] [comments]

  • My iPhone keep disconnecting from my Mac when trying to download the pictures. It keeps asking for trust the device but then disappears before I can click trust
    by /u/freebutpriceless (Mac) on September 25, 2022 at 6:09 am

    submitted by /u/freebutpriceless [link] [comments]

  • IPhone 12 Pro Max IN 2022
    by Umer Ali (Apple on Medium) on September 25, 2022 at 5:50 am

    Product Details:Continue reading on Medium »

  • Is there a way to change wallpapers on mac like you can on IOS 16?
    by /u/TenthMarigold77 (Mac) on September 25, 2022 at 5:31 am

    The title says it all, I am wondering if there is any way to change my wallpaper on my Macbook Air as you can now do on IOS 16 where I can theme it depending on my mood or what I am watching. I never really thought I would care about this feature at all recently I have begone tinkering with it and love changing it to whatever my favorite tv show is at the moment or whenever I need to work or study changing it to something more peaceful. submitted by /u/TenthMarigold77 [link] [comments]

  • Battery on my MacBook Pro 15” 2015 is starting to bulge. Is it easy enough to replace myself? If so, any battery recommendations?
    by /u/Jessus_ (Mac) on September 25, 2022 at 5:06 am

    submitted by /u/Jessus_ [link] [comments]

  • Mozilla accuse Google, Apple, and Microsoft force users to use their respective platforms’ default…
    by Urban Tech Story (Apple on Medium) on September 25, 2022 at 4:46 am

    Continue reading on Medium »

  • Yeni iPhone’lar için kuyruğa girdiler
    by Deşifre Haberler (Apple on Medium) on September 25, 2022 at 4:34 am

    Continue reading on Medium »

  • What does the iPhone 14 look like
    by Sajjad Hussain (Apple on Medium) on September 25, 2022 at 4:30 am

    The design of the iPhone 14 series is no longer the same as its predecessors. The design of the iPhone 14 series is much more streamlined…Continue reading on God Hardware »

  • Fastest external drive option for imac?
    by /u/LogicalFig1759 (Mac) on September 25, 2022 at 4:10 am

    My 2011 27" imac does not detect any internal hard drives, no matter which one I put in. I am currently using an external hard drive with a sata to usb cable. It does work, but with it being usb 2.0 and a mechanical hard drive, it is incredibly slow, especially when booting up. What would be the fastest option for an external drive? Ideally I would want a thunderbolt 1 to sata cable, but afaik none exist. submitted by /u/LogicalFig1759 [link] [comments]

  • Whenever I restart or shut off my Mac, it removes my wallpaper. It’s done this every time and I’m getting annoyed. How do I fix this?
    by /u/Forward-Sock-1568 (Mac) on September 25, 2022 at 3:02 am

    submitted by /u/Forward-Sock-1568 [link] [comments]

  • Digitally Decluttering Your Phone
    by Mariana Itzel (Apple on Medium) on September 24, 2022 at 11:51 pm

    This is a step by step guide on what you can do in order to declutter your phone to make it functional and aesthetic 📱⚡Continue reading on ILLUMINATION »

  • What MacBook should I get?
    by /u/WTMCMaher (Mac) on September 24, 2022 at 11:29 pm

    I have an iPad and an iMac but I want a MacBook for desktop tasks and for some of my college programs needing to use Desktop Safari & Chrome. I do light gaming like Minecraft and light video editing along with Pixlr X/Photoshop. Im torn between a M1 Pro MacBook Pro for the 16” screen and active cooling. But I also heard the M2 MBA is a good choice too. I just want something fast for school and my gaming session of Minecraft (100+ FPS). Edit #1: Or should I wait for the M2 Pro and Max chips to come out (rumored October). submitted by /u/WTMCMaher [link] [comments]

  • Unconventional ecosystem setup
    by /u/D_Empire412 (Mac) on September 24, 2022 at 10:34 pm

    ​ https://preview.redd.it/db6bf1rqvvp91.jpg?width=4032&format=pjpg&auto=webp&s=f04d3f241f2924100d84785791807f8b7dd58c66 submitted by /u/D_Empire412 [link] [comments]

  • Shantaram & Me
    by Errol Marks (Apple on Medium) on September 24, 2022 at 8:29 pm

    The trailer for Apple TV’s Shantaram was released a few days back. Watching it was a bittersweet experience for me. I was a part of it for…Continue reading on Medium »

  • Five Tips to increase the responsiveness and autonomy of your MacBook
    by Louis-Christophe THIRION (MacBook on Medium) on September 24, 2022 at 8:09 pm

    If you are the happy owner of a MacBook for a few years now, you have certainly realized the loss of energy capacity and power. Between…Continue reading on Medium »

  • “Fixing”?
    by Shivam (Apple on Medium) on September 24, 2022 at 7:53 pm

    Nothing needs fixing bruhContinue reading on Doing Me A Think »

  • help?
    by /u/saltbae999 (Mac) on September 24, 2022 at 5:59 pm

    submitted by /u/saltbae999 [link] [comments]

  • Should I Know Anything Before Buying An External Monitor For MacBook Air?
    by /u/anon-5461281 (Mac) on September 24, 2022 at 5:49 pm

    I want to buy an inexpensive monitor that way I have a bigger screen. Anything I should know? submitted by /u/anon-5461281 [link] [comments]

  • my M2 MBP case horror story (nearly!)
    by /u/JDT33658 (Mac) on September 24, 2022 at 5:40 pm

    SO, if some of you remember me yes I did finally get my M2 MBP and I love it! I have had a hard plastic clear case on it since the day I got it and thought nothing of it, I ignored all of the case horror stories since I thought it was all blown out of proportion but boy was I wrong. ​ Today my MacBook had a lot of dirt under the case so I took it off to clean it and I couldn't believe it, the case actually done some damage! There are two identical dents at the bottom of the screen where the case was putting pressure on the display. I thought this would never happen to me since im super careful with my stuff! But the case is now in the trashcan. Ive seen this before and over time (if the case was left on) the dents would get way bigger and cause the display damage, it could crack it, cause stage light issues, cause lines or just kill it all together. Luckily I caught it now where no damage will happen but I just wanted to warn others. ​ TAKE YOUR CASES OF YALL!!! If your that paranoid about damage get a skin. https://preview.redd.it/5vi0oofoeup91.jpg?width=1575&format=pjpg&auto=webp&s=8c40cd2c7b8ce332239d75c930f1be1be18d97ba submitted by /u/JDT33658 [link] [comments]

  • How To Enable Cookies On Macbook
    by Sharafatofficial (MacBook on Medium) on September 24, 2022 at 5:18 pm

    How to Enable Cookies on Your MacbookContinue reading on Medium »

  • Is there any fix for this or am I screwed?
    by /u/BooksSmartt (Mac) on September 24, 2022 at 2:33 pm

    It’s a MacBook Pro 2017. No water damage, just occurred one day. Apple want £600 to send it in for repair so not really worth it. Seems to be a correlation between the tilt of the screen and the amount of glitchiness submitted by /u/BooksSmartt [link] [comments]

  • My Mac died overnight, it was at around 50ish% battery. I can see a wifi.log and system.log in the console. Could that be the cause and are those bad?
    by /u/lilferz (Mac) on September 24, 2022 at 1:53 pm

    Here is a screenshot of the batter usage https://preview.redd.it/fdd33lqt9tp91.png?width=1332&format=png&auto=webp&s=52913ce3bcb99a28e3ad05d7ca3858a387185425 A screenshot from the log names https://preview.redd.it/4n1zyvoy9tp91.png?width=1732&format=png&auto=webp&s=180cfdbaf90c9ad7f8da7b2e1c781e7dbfc1c798 ​ system.log ​ wifi.log Thank you for your time 🙂 submitted by /u/lilferz [link] [comments]

  • hashcat m1 not working ?
    by /u/gr4jek (Mac) on September 24, 2022 at 11:56 am

    submitted by /u/gr4jek [link] [comments]

  • Apple 13″ MacBook Air M2 Chip 8GB 256GB_  Midnight(2022)
    by Zeeshan Saleem (MacBook on Medium) on September 24, 2022 at 10:40 am

    Supercharged by the next-generation M2 chip, the redesigned Mac Book Air combines unimaginable performance and up to eighteen hours of…Continue reading on Medium »

  • 12 tính năng mới đầy hữu ích không thể bỏ qua của hệ điều hành MacOS 12.1 Monterey
    by Viện Di Động (MacBook on Medium) on September 23, 2022 at 4:50 am

    Continue reading on Medium »

  • How to Record Audio on a MacBook?
    by Spencer Thomason (MacBook on Medium) on September 23, 2022 at 3:57 am

    If you’re interested in recording audio on your MacBook, there are all kinds of ways to do it. There are a number of third-party apps that…Continue reading on Medium »

  • How to fix multiple monitors having issues on Mac
    by Pinky Roy (MacBook on Medium) on September 22, 2022 at 7:28 am

    Many Mac users prefer to use a second monitor or even two monitors when using their MacBook in clamshell mode. The Mac does not…Continue reading on Medium »

  • Hệ điều hành macOS là gì? Thiết bị nào chạy macOS? Có những phiên bản nào?
    by Viện Di Động (MacBook on Medium) on September 22, 2022 at 1:49 am

    Continue reading on Medium »

  • How to install MySQL in Your Macbook (M1)?
    by Mohamed Y (MacBook on Medium) on September 21, 2022 at 8:46 pm

    We are going to use homebrew package manager to install the mysql server in a Mac M1 model (which uses ARM64 architecture instead of x64).Continue reading on Medium »

  • Stop Buying Every New Gadget
    by Michael Swengel (MacBook on Medium) on September 21, 2022 at 8:03 pm

    You probably don’t need it.Continue reading on CodeX »

  • Why The 13 Inch MacBook Pro Is Secretly The Best MacBook
    by Andrew Zuo (MacBook on Medium) on September 21, 2022 at 3:32 pm

    Another day another article on Medium attacking the 13 inch MacBook Pro.Continue reading on Medium »

  • WWDC 2022 Discussion Thread - M2 Chip, MacBook Air and macOS Ventura
    by /u/ChampJamie153 (Mac) on June 6, 2022 at 6:55 pm

    The WWDC 2022 event is over. Here's what we got: A redesigned MacBook Air The MacBook Air has been redesigned for the first time since 2018 MacBook Air uses the new M2 chip with 8 CPU cores and up to 10 GPU cores Up to 24GB of memory is supported in the M2 Air, the largest amount in any Air The FaceTime HD camera is now 1080p, and it is located in a notch at the top of the new Liquid Retina display M2 Chip Supports up to 24GB of LPDDR5 memory 8-core CPU and up to 10-core GPU 100GB/s of memory bandwidth Based on second-generation 5 nm technology Updated 13" MacBook Pro The 13" MBP is still here, and it now features the new M2 chip Magic Keyboard and Touch Bar remains in this model making it the last with the Touch Bar Up to 24GB of memory available macOS Ventura The newest version of macOS introduces Stage Manager for grouping windows together System Settings has been improved, and Passkeys are designed to replace passwords on the web Continuity Camera allows your iPhone to be used as a camera for your Mac wirelessly, and Belkin will be introducing mounts to attach your iPhone to your Mac Mail has gotten some improvements including scheduling messages and "Undo Send" FaceTime Handoff allows you to switch from one device to another in the middle of a FaceTime session, and Live Captions have been brought to FaceTime as well submitted by /u/ChampJamie153 [link] [comments]

  • r/Mac Discord Server
    by /u/Stuttero (Mac) on February 26, 2020 at 8:38 pm

    submitted by /u/Stuttero [link] [comments]

How to pipe grep on command line on windows and Linux

You can translate the content of this page by selecting a language in the select box.

Let’s find how to pipe grep or find a specific string after running a command using shell, batch and powershell (windows and Linux)

  • On Linux via shell

    ls -al | grep filename

  • On Windows via powershell

    GetChildItem | Select-Object “filename”
    or
    GetChildItem | where-Object {$_ -match “filename”}

  • On Windows via batch

    Dir | findstr “filename”

reverse a string on Linux and Windows

You can translate the content of this page by selecting a language in the select box.

How to reverse a string on Linux and Windows

Via shell script on Linux

reverse a string on Linux and Windows

sh-3.2# vi reverse.sh
#### Start Script #####
#!/bin/bash
input_string=”$1″
reverse_string=””

input_string_length=${#input_string}
for (( i=$input_string_length-1; i>=0; i– ))
do
reverse_string=”$reverse_string${input_string:$i:1}”
done

echo “$reverse_string”
##### End Script #####

Let’s run it:

sh-3.2# chmod 775 reverse.sh
sh-3.2# ./reverse.sh Etienne
enneitE

Via powershell script on Windows

#Let’s use the script reverse.ps1 below.
######
$string=”Etienne”
$string_array=$string -split “”
[array]::Reverse($string_array)
$string_array -join ”

#####Output#####
PS C:\Users\etienne_noumen\Documents\Etienne\Scripting> .\reverse.ps1

E t i e n n e

enneitE

Via powershell script on Windows in one line

([regex]::Matches($String,’.’,’RightToLeft’) | ForEach {$_.value}) -join ”

Via batch script on Windows

::Note: ReverseStr also calls StrLen
::and string length is not greater than 80 chars
:: but can be changed.

If you are looking for an all-in-one solution to help you prepare for the AWS Cloud Practitioner Certification Exam, look no further than this AWS Cloud Practitioner CCP CLFC01 book below.


@echo off
SetLocal EnableDelayedExpansion
cls
set Str=Etienne
call :StrLen %Str%
echo Length=%Len%
call :ReverseStr %Str%
echo String=%Str%
echo Reverse Str=%Reverse%
exit /b

::—————-
:: Calc Var Length
::—————-
:: %*=Str to Check
:: Returns %Len%
:: —————
:StrLen %*
set Data=%*
for /L %%a in (0,1,80) do (
set Char=!Data:~%%a,1!
if not “!Char!”==”” (
set /a Len=%%a+1
) else (exit /b)
)
exit /b

Invest in your future today by enrolling in this Azure Fundamentals - Microsoft Azure Certification and Training ebook below. This Azure Fundamentals Exam Prep Book will prepare you for the Azure Fundamentals AZ900 Certification Exam.


::—————
:: Reverse String
::—————
:: %* Str to Reverse
:: Returns %Reverse%
::——————
:ReverseStr %*
set Data=%*
call :StrLen %Data%
for /L %%a in (!Len!,-1,0) do (
set Char=!Data:~%%a,1!
set Reverse=!Reverse!!Char!
)
exit /b

Via perl script on Windows or Linux

Via python script on Windows or Linux

def reverse_string(a_string)
return a_string[::-1]
reverse_string(“etienne”) returns “enneite”
Source:

  1. http://www.computing.net/answers/programming/reverse-a-string-in-dos/26004.html

Remove all empty lines in a file

You can translate the content of this page by selecting a language in the select box.

How to Remove all empty lines in a file on Linux and Windows?

Remove empty lines from file.txt via Linux command line

  • Option 1: sed -i ‘/^$/d’ file.txt
  • Option 2: awk ‘NF > 0’ file.txt > output.txt
  • Option 3: perl -i.backup -n -e “print if /\S/” file.txt
  • Option 4: grep . file.txt > output.txt

Remove empty lines from file.txt using Powershell script on Windows

  • (gc file.txt) | ? {$_.trim() -ne “” } | set-content file.txt
  • Windows Boot process

    You can translate the content of this page by selecting a language in the select box.

    What is involved in Windows Boot Process:

    Windows_Booting_Procedure

      • Power is turned on.
      • The first process starting when you turn on your computer is BIOS i.e, Basic Input Output System. BIOS has two functions, to conduct POST and read MBR.
        1. POST – POST stands for Power On Self Test. POST checks all the hardware devices connected to a computer like RAM, hard disk etc and make sure that the system can run smoothly with those hardware devices. If the POST is a failure the system halts with a beep sound.
        2. Now BIOS checks the boot priority. We can set the boot priority as CD drive, hard disk or floppy drive
        3. MBR – The next duty of BIOS is to read the MBR. MBR stands for Master Boot Record and its the first sector on a hard disk. MBR
          contains the partition table and boot loader.
      • Functions of Boot loader
        Now BIOS has passed the control to boot loader and boot loader is a small program which loads kernel to computers memory. Actually there are two stages of boot loaders, stage 1 boot loader and stage 2 boot loader. MBR contains the stage 1 boot loader and stage 1 boot loader is a link to the stage 2 boot loader. The stage 2 boot loader resides in the boot partition and it loads the kernel to memory.
      • Boot files and functions
        There are three boot files in a Windows operating system and they are NTLDR, NTDETECT.COM and Boot.ini. The boot files are found in the active partition of hard disk and its normally C drive in a Windows machine.

        1. NTLDR – NTLDR stands for NT Loader and its the second stage bootloader. The path of NTLDR is C:\Windows\i386\NTLDR.
        2. Boot.ini – Boot.ini contains the configuration files of NTLDR. When the operating system is loaded we cannot pass any arguments to kernel, so those arguments are passed through boot.ini. You can edit boot.ini by opening through notepad. The path of Boot.ini is C:\boot.ini.
        3. NTDETECT.COM – This file detect hardware’s and passes information to NTLDR. Using the collected information the NTLDR creates a hardware key and this key is used to detect hardware’s. A new hardware key is generated after each reboot of the operating system and that’s why system asks to reboot after installation of a new hardware. The hardware keys created by NTLDR can be found in Windows registry at
          HKEY_LOCAL_MACHINE -> HARDWARES.
      • Kernel and its functions
        After executing the functions of boot files the control is passed to Kernel. ntoskrnal.exe is the kernel file in a Windows machine and its path is C:\Windows\system 32\ntoskrnal.exe. Kernel acts as a layer between software and hardware. The library file hal.dll (C;\Windows\system32\hal.dll) helps Kernel to interact with hardware’s. HAL stands for Hardware Abstraction Layer and this hal.dll file is
        machine specific. Now the drivers for hardware’s are loaded from the file C:\Windows\system32\config\system and the Kernel is loaded to primary memory.
    • Services and log in procedure
      When kernel is loaded in the primary memory services for each process is started and the registry entry for those services can be found at HKEY_LOCAL_MACHINE – System – Current control set – Services.
      Winlogon.exe (C:\Windows\system32\winlogon.exe) is the last service started during this process.
      Winlogon.exe starts the log in procedures of windows machine. It first calls the library file msgina.dll (C:\Windows\system32\msgina.dll). MSGINA stands for Microsoft Graphics Identification and Authentication and it provides the log in window. Now msginal.dll passes the control to LSA (Local Security Authority), it verifies the username and password from the SAM file. SAM (Security Accounts Manager) contains the information about all users created in a Windows operating system.
      Now the booting procedure is over and we have reached the desktop of Windows operating system.

    Source:

    1. Windows Booting Process
    2. Understanding the boot process

    List only regular file names in a directory

    You can translate the content of this page by selecting a language in the select box.

    How to List only regular file names in a directory on Linux and Windows

    Listing regular files in a directory without including . and .. files.


    • On Linux

      Solution 1:$ ls -p | grep -v /
      Solution 2: $ ls -F | grep -v ‘[/@=|]’
      Solution 3: $for list in `ls` ; do ls -ld $list | grep -v ^d > /dev/null && echo $list ; done ;
      Solution4:$ for list in `ls` ; do ls -ld $list | grep ^d > /dev/null || echo $list ; done ;
      Solution5 (exclude sym links):$ for list in `ls` ; do ls -ld $list | grep -v ^l > /dev/null && echo $list ; done ;


    • On Windows

      Solution 1: dir /a-d /b >..\File_List.txt

    Set Date and time via command line

    You can translate the content of this page by selecting a language in the select box.

    Let’s find out how to set Date and time via command line on linux and windows:

    • On Linux via terminal

      System time (Must have sudo privilege)
      date -s ‘2015-07-28 15:27:30’
      Hardware time
      Let’s set the hardware clock to the current system time:
      hwclock –systohc

    • On Windows via command prompt terminal

      System time (Must have Administrator privilege)
      date
      The current date is: 07/28/2015
      Enter the new date: (mm-dd-yy)_
      time
      The current time is: 15:34:03.44
      Enter the new time: _

    List all processes holding a specific port

    You can translate the content of this page by selecting a language in the select box.

    How to list all processes holding a specific port on Linux and windows via command line

    Let’s find all processes pid using port 80 on linux and windows:

    • On Linux

      lsof -i:80

    • On Windows

      netstat -aon | findstr :80

    Replace all instances of a string in a file

    You can translate the content of this page by selecting a language in the select box.

    Shell script to replace all instances of a string in a file on Linux & Windows.

    • On Linux via bash script

      sed “s/$stringToReplace/$replaceWith/g” $File_Name > $File_Name

    • On Windows using Powershell

      ( get-content $File_Name ) | % { $_ -replace $stringToReplace, $replaceWith } | set-content $File_Name

    • On Windows using Batch

      set str=teh cat in teh hat
      echo.%str%
      set str=%str:teh=the%
      echo.%str%

      Script Output:
      teh cat in teh hat
      the cat in the hat

    • On Windows or Linux using Perl

      perl -pi.orig -e “s///g;”

    • On Windows or Linux using Python

    Source:

    1. http://stackoverflow.com/questions/60034/how-can-you-find-and-replace-text-in-a-file-using-the-windows-command-line-envir

    Search all files containing a specific string

    You can translate the content of this page by selecting a language in the select box.

    How to search all files containing a specific string on Linux and Windows?

    • On Linux

      grep -rnw ‘directory’ -e “pattern”
      grep –include=\*.{txt,log} -rnw ‘directory’ -e “pattern”
      This will only search for files with .txt or .log extension.
      grep –exclude=*.txt -rnw ‘directory’ -e “pattern”
      This will exclude files with .txt extensions.

    • On Windows

      CD Location
      FINDSTR /L /S /I /N /C:”pattern” *.log

    error: Content is protected !!