xcrun: error: invalid active developer path MacOS

Again, I decided to come back and keep up with my path to become a full time Web Developer instead of an “IT handyman”. So, I brewed another cup of my favorite Caturra coffee varietal and poured it on my Caturra coffee varietal mug to get some code with coffee inspiration.

I opened my Terminal and wanted to check my git status:

git status

and got error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

I had no clue why. Then, I remembered the other day I applied an update to my macOS Mojave version. This seemed to mess things up. I found a solution somewhere. First you should try to reset you xcode install by issuing this command:

xcode-select --reset

The above did not resolve the xcrun: error: invalid active inactive issue. So, I have to re-install it by running the following on my Terminal:

xcode-select --install

It took about 5 minutes and I was able to run git commands again.

Contact me if you have any questions about this xcrun: error: invalid active or other issues with Technology. Remember I designed cool T-Shirts and coffee mugs inspired by tech and my trips. Check out my shop and let me know what you think. Thanks!

Find Command Examples Linux/MacOS

I wanted to put together some find command examples because I tend to forget this useful Linux command often. It is very important for Linux/MacOS administrators or DevOps to master the find command.

While having my favorite coffee varietal Caturra the other day I decided to put together this brief find command examples:

Syntax is simple:
find [where to start search from] [what to find] [-any options] [what to find at last]

1. Search a file with specific name.

$ find ./MyDirectory -name afile.txt

This find command will search for afile.txt in MyDirectory directory and display the results such as:

./MyDirectory/path/to/afile.txt

2. Find command examples to search for file patterns

For example if you want to find all files with a .txt extension inside the MyDirectory

find ./MyDirectory -name *.txt

If there are any .txt files you should get an output similar to:

./MyDirectory/some/path/afile.txt
./MyDirectory/some/path/bfile.txt

3. Search for empty files and directories.

This is a cool one. Let’s say you want to find those empty directories or file by just running a simple find command:

find ./MyDirectory -empty

If there are any empty files or directories you will get a list:

./MyDirectory/oneFile
./MyDirectory/twoFile

4. Find command examples to search for files with specific permissions

Another useful find command.

$ find ./MyDirectory -perm 644

The above find command example will search for files with permissions set to 644 under the /MyDirectory directory and will display a list.

Check the man pages for more useful options of the find command in Linux or MacOS. Contact me if you have any questions. Also grab one of my T-Shirt or coffee mugs designs on my shop. I design them myselft. Thanks!

Mirror a Website Using wget

The command is simple and to mirror a website using wget works fantastic. While I was crossing the Williamsburg Bridge in NYC I received a Slack chat from a customer. They wanted to backup some really old WordPress sites and just archive them as simple html files.

You can mirror a website using wget easily. Copy and paste the below into your terminal. If you’re on a mac you can install wget using brew or using your favorite method.

wget --mirror --convert-links --adjust-extension --page-requisites
--no-parent http://example.org

Explanation of the various flags:
• –mirror – Makes (among other things) the download recursive.
• –convert-links – convert all the links (also to stuff like CSS stylesheets) to relative, so it will be suitable for offline viewing.
• –adjust-extension – Adds suitable extensions to filenames (html or css) depending on their content-type.
• –page-requisites – Download things like CSS style-sheets and images required to properly display the page offline.
• –no-parent – When recursing do not ascend to the parent directory. It useful for restricting the download to only a portion of the site.
Alternatively, the command above may be shortened:
wget -mkEpnp http://example.org

wget will create a directory with the website’s name you’re mirroring. Enjoy and let me know if you have any questions by leaving a comment. You can also check out my shop for cool tech T-Shirts and Coffee mugs.

How to Change MacOS hostname using the Terminal

Hola! the other day I had a need to change a MacOS hostname using the Terminal. I did not have access to a GUI and had to do this remotely. Chagning the hostname using MacOS Terminal is quite simple and is my favorite method. This is why I decided to document this little how to.

To open your Terminal go to Applications/Utilities or just do a Spotlight Search and type Terminal.

Once in your Terminal type:

scutil --set ComputerName "name"

Replace “name” with the computer name you wish to assign and press return. Next, you need to set your local network to Bounjour-based services by typing this command:

scutil --set LocalHostName "name"

Again, replace “name” with the same name you used before.

One last one is to set the name when connecting via SSH and the name shown on your Terminal. Simple type:

scutil --set HostName "name"

Once again, replace “name” with the same name you used before. If you get an authentication window enter your password. This account must have admin rights to make the changes.

After you set all of the above to your desired computer name/MacOS hostname you can verify your MacOS hostname by typing this command:

scutil --get HostName

You should see the new MacOS hostname/computer name displayed on your terminal. Thank you and if you like to support me you can get my Code with Coffee T-Shirt design. I make all designs based in NYC.

The requested image’s platform (linux/arm64) does not match the detected host platform

When I was testing Docker’s initial tutorial when you download for the first time I got the error:

The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and nospecific platform was requested.

It sucks because I got a new MacBook Pro M1 and I did not know about these issues with arm64 chips and images. Trying to play with the tutorial while having great coffee from Latin America I got stuck when trying to run the MySQL image in my compose file.

Searching around I found two options to resolve this. See below:

Option 1: Add the flag –platform linux/arm64

This will tell your MacOS M1 what platform to use. Brief example:

docker run -d \
    --platform linux/amd64 \
    --network todo-app --network-alias mysql \
    -v todo-mysql-data:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=secret \
    -e MYSQL_DATABASE=todos \
    mysql:5.7

Option 2: Use MariaDB instead of MySQL

As of this post MariaDB offers official support for ARM64 architecture. Use this docker command instead as an example:

docker run -d \
  -v todo-mysql-data:/var/lib/mysql \
  -e MYSQL_ROOT_PASSWORD=secret \
  -e MYSQL_DATABASE=todos \
  mariadb:10.5

MacOS Restarts and a Message Shows

The other day after having my favorite Latin America coffee I went to take a walk around Seaport in New York City. When I came back my Macos restarted with error message saying that my MacOS restarted and if I wanted to send a report to Apple. I pressed ignore and put on my new Code with Coffee T-Shirt.

The most likely cause is faulty software. A kernel panic can also be caused by damaged or incompatible hardware, including external devices attached to your Mac. If the kernel panic is caused by a known problem, the faulty software is identified. To make sure that this software doesn’t continue to cause kernel panics, move it to the Trash.

If not a faulty software and your MacOS continues to reboot with kernel panics, try these:

  1. Restart your Mac in safe mode. If it successfully starts up in safe mode, choose Apple menu > App Store, click Updates, then install any available updates.
  2. Uninstall any plug-ins or other enhancement software from manufacturers other than Apple. If you recently updated macOS or an app, plug-ins and other software that worked in the past may no longer be compatible. Read the manufacturer’s documentation (including Read Me notes) to be sure the software is compatible with your version of macOS.
  3. Disconnect all devices except for an Apple keyboard and mouse. Remove hardware upgrades from other manufacturers, such as random-access memory (RAM) and Peripheral Component Interconnect (PCI) cards. Then try restarting your Mac.
  4. If this resolves the issue, reconnect one device at a time, restarting your Mac after reconnecting each one, until you determine which device is causing the problem.
  5. Use Apple Diagnostics to diagnose problems with your computer’s internal hardware, such as the logic board, memory, and wireless components.

You can also check MacOS Console to find out more details about why your MacOS restarted.

Find Public IP Address using Linux Command Line

The other day I had to ssh into a RedHat Linux server to help a friend. My friend wanted to find the public IP address using Linux command line. This is simpler than what I imaged.

After having one of my favorite Latin America coffee from Peru I was able to find the answer. Use these simple commands after opening your Terminal/Command line on Linux:

  • Using the dig command type:
    • dig +short myip.opendns.com @resolver1.opendns.com
  • or you can use this one:
    • dig TXT +short o-o.myaddr.l.google.com @ns1.google.com

You can now see your public IP address on your Linux terminal.

Find Public IP Address using Linux
Find Public IP Address using Linux

Create Desktop Shortcut Windows 10 For All Users

The other day a friend asked me to create a desktop shortcut in Windows 10 for all users. I have been using other operating systems for a while and have been trying to stay away from Windows.

After taking a walk in New York City I refreshed my mind and found a way to create this desktop shortcut for all users in Windows 10. These are the steps:

  • Login as Administrator in Windows 10 (Your local Admin account)
  • Go to your C drive > Users > Public > Public Desktop (“Public Desktop” is usually a hidden file, so you need to do this – in your File Explorer select ‘View’ and then select the checkbox ‘Hidden Items’
desktop shortcut Windows 10
Show hidden files Windows 10

Now just drag and drop your shortcuts into the Public Desktop and it will show for all your users in Windows 10.

Find Shutdown Log Windows 10

The other day while working at a client’s office I had to deploy an application update using a Thin Client management console. I pushed the update to all Thin Clients. Shutdown Log Windows 10

This was supposed to be a non-intrusive deployment of the application – meaning the Thin Clients were not supposed to reboot. One Thin Client rebooted and I needed to find out why.

In Windows 10 there are three events that gives you information about reboots and shutdown:

Event ID 1074 – Indicates that the shut down process was initiated by an app. For example, it can be Windows Update.

Event ID 6006 – The clean shut down event. This means Windows 10 was turned off correctly.

Event ID 6008 – Indicates a dirty/improper shutdown. Appears in the log when the previous shutdown was unexpected, e.g. due to power loss or etc.

To find these events simply do:

  • Press Windows key + R one the keyboard to open the Run dialog and then type eventvwr.msc followed by enter.
  • In Event Viewer, select Windows Logs and then System on the left.
  • On the right, click on the link Filter Current Log.
  • In the next dialog, type the line 1074, 6006, 6008 into the text box under Includes/Excludes Event IDs.
  • Click OK to filter the event log.

Now, the Event Viewer will display only events related to shut down and you can investigate reasons why. Hope this Find Shutdown Log Windows 10 brief tutorial helps.

Now, go see my sister website NYC Moments to see inspirational pictures of New York City.

How to Generate SSH Key Pair in Linux

The other day I got a new laptop and needed to generate ssh key pair. Sometimes you forget basic commands when you don’t run them on a daily basis. So, I took a short walk in Brooklyn, New York City before I started working on my new laptop setup.

To generate ssh key pair in Linux is quite simple. Use the ssh-keygen command. Open your Terminal and type:

ssh-keygen -t rsa

Next, you will need to specify the location of the file where you want to save the key such as for example:

Enter file in which to save the key (/home/youruser/.ssh/id_rsa):

Don’t type anything to leave your key at the default location with the default name /home/youruser/.ssh/id_rsa. If you want to you can specify a different name. I do this when I need to ssh to different servers, this helps me keep organized.

Finally, you will need to type a password if you like:

Enter passphrase (empty for no passphrase):

I usually leave it empty, but this is really up to you.

This will create a private key written to: /home/youruser/.ssh/id_rsa 

and a public key written /home/youruser/.ssh/id_rsa.pub

Copy the contents of your .pub file into your server’s .ssh/authorized_keys

You need to change your Linux permissions to:

chmod 700 .ssh/ 
chmod 600 .ssh/authorized_keys

Now you should be able to SSH to your server without using a password. Give it a try and Contact me if you have any questions.