Hidden Admin User On Mac

dscl . list /Users | grep -v '^_'
dscacheutil -q user | grep -A 3 -B 2 -e name:/ aRoot

echo -n 'Password: '
read -s password
sudo dscl . -create /Users/aRoot IsHidden 1
sudo dscl . -create /Users/aRoot UserShell /bin/bash
sudo dscl . -create /Users/aRoot NFSHomeDirectory /Local/Users/aRoot
sudo dscl . -create /Users/aRoot RealName 'ASB Admin'
sudo dscl . -create /Users/aRoot UniqueID 401
sudo dscl . -create /Users/aRoot PrimaryGroupID 400
sudo dscl . -passwd /Users/aRoot $password
sudo dscl . -append /groups/admin GroupMembership aRoot

dscl . -read /groups/admin GroupMembership

echo -n 'HostName: '
read hostname
sudo scutil --set HostName $hostname
sudo scutil --set LocalHostName $hostname
sudo scutil --set ComputerName $hostname

dscacheutil -flushcache
Remote PC

How to install NodeJs on Mac

Best way to install NodeJs is using NVM (Node Version Manager)

Installing NVM

Check bash_profile file exist

[ -f ~/.bash_profile ] && echo "File exist" || echo "File does not exist"

Apple has announced that in macOS 10.15 Catalina the default shell will be zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile.

The main change you will see is that the prompt character.

  • zsh uses the % character as the default prompt
  • bash uses the $ character as the default prompt

Basic syntax/commands

  • see all available shells in macOS Catalina => cat /etc/shells
  • to change to bash shell, run and relaunch Terminal => chsh -s /bin/bash
  • to change to bash shell, run and relaunch Terminal => chsh -s /bin/zsh

Resources

To install nvm run script, do:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

To verify that nvm has been installed, do:

command -v nvm

Some useful commands

% nvm list                      # list all installed node versions
% nvm install node              # "node" is an alias for the latest version
% nvm ls-remote                 # list available versions online

% nvm use node
% nvm run node --version
% nvm exec 4.2 node --version   # run any arbitrary command in a subshell with the desired version of node:

% nvm which current


% nvm current
% nvm -v

Install MacPorts

MacPorts initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac operating system. To Install MacPorts for your version of the Mac operating system, go to https://www.macports.org/install.php and select macOS Catalina v10.15

After installation run below command to check for the proper installation if MacPorts on your mac

sudo port selfupdate

Install Yarn using MacPorts

sudo port install yarn
yarn --version

Some information about Yarn installation

yarn stores data in:

~/.yarn
~/.yarnrc
~/.cache/yarn
~/.config/yarn

By default, these packages will be installed in ~/.config/yarn/global, and soft-linked to /opt/local/bin. 

To uninstall them all:

ls -1 $HOME/.config/yarn/global/node_modules/  | xargs sudo yarn > global remove

You may then remove the directories listed above and uninstall yarn. yarn is meant to replace NPM and may cause conflicts if you use both. You may override the default global installation directory by setting > the PREFIX environment variable, e.g.

mkdir -p $HOME/.config/yarn/bin # Or wherever you want
export PREFIX=$HOME/.config/yarn/bin
export PATH=$PREFIX:$PATH

Top npm modules

npm i http-server
npm i fs-extra
npm i moment
npm i async
npm i underscore underscore.string
npm i validator
npm i csv           # npm i csv-generate csv-parse stream-transform csv-stringify
npm i axios
npm i objection     # An SQL-friendly ORM for Node.js
npm i typescript

macOS Catalina moving to zsh

Apple has announced that in macOS 10.15 Catalina the default shell will be zsh.

In this series, I will document my experiences moving bash settings, configurations, and scripts over to zsh.

Continue reading “macOS Catalina moving to zsh”