Using SQLPlus on MacOS

Once you have the client installed, go ahead and create tnsnames.oraΒ for your server connection under '/Applications/oracle/product/instantclient_64/network/admin'


ORACLE12C =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myoracle12c.senecacollege.ca)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracle12c)
)
)

view raw

tnsnames.ora

hosted with ❤ by GitHub

Modify your .bash_profileΒ to store environment variables:


export ORACLE_HOME="/Applications/oracle/product/instantclient_64"
export PATH=$ORACLE_HOME/bin:$PATH
export DYLD_LIBRARY_PATH=$ORACLE_HOME/lib
# Set ORACLE_PATH to the location where you store your custom "login.sql"
export ORACLE_PATH="/Applications/oracle/product/instantclient_64/sqlplus/admin"
alias sqlplus='rlwrap sqlplus'

view raw

.bash_profile

hosted with ❤ by GitHub

Then you can create your own startup script, e.g.


SET PAGESIZE 100;
SET LINESIZE 100;
define_editor='vi';
SET SERVEROUTPUT ON;
SET VERIFY OFF;

view raw

login.sql

hosted with ❤ by GitHub

Last, add the following command to your .bashrc to skip error command not found: sqlplus


# Add it to the end of your .bashrc as start-up command
source ~/.bash_profile

view raw

.bashrc

hosted with ❤ by GitHub

Note:
If you face Error ORA-21561: OID generation failed when connecting to Oracle with a Mac, edit your hosts file to append local computer name to the end of the 127.0.0.1 line.


##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost <local_computer_name>
255.255.255.255 broadcasthost

view raw

hosts

hosted with ❤ by GitHub

😌

Terminal Commands

Open the current directory in applications: open .Β / atom . / code .

Use curl to:

  • download:
    • curl -O ftp://ftp.example.com/file.zip
  • POST with multipart:
    • curl -v -F upload=@filename localhost:5000/api/upload
  • POST with json:
    • curl -d '{"Name":"John"}' -H "Content-Type: application/json" -X POST localhost:3000/api/names

Get your IPv4 address: ipconfig getifaddr en0

Reboot: sudo shutdown -r now

Clear command history: history -c

Unzip in quieter mode: unzip -qq

Check the size of the directory: du -sh ~/myFolder

List all IP sockets using port 5000: lsof -i :5000

Kill process: kill -9Β `pid`

Display local computer name: hostname

Start a simple HTTP server:
python -m SimpleHTTPServer 8000
ruby -run -e httpd . -p 9000

Give you your last command: !!

Copy content to your clipboard: pbcopy < file

Permanently save ssh key in your .bashrc:
(so you don’t need to enter passphrase all the time when using git over ssh)
echo "ssh-add -K ~/.ssh/id_rsa 2> /dev/null" >> ~/.bashrc

Use Git to:
  • Remove remote file:
    • git rm -r --cached file
  • Delete a local branch:
    • git branch -d branch
  • Remove remote branch:
    • git push origin --deleteΒ branch

Find all files containing specific string:
grep -rnwl -e 'string' dirname

Disable MacOs Gatekeeper:
sudo spctl --master-disable

Show package versions for pip3:
pip3 freeze

Show proxy settings:
scutil --proxy

Remove agent from launchd:
launchctl remove com.coppertino.VOXAgent

Find and remove VOX agent from VOX:
launchctl list | grep VOX
launchctl remove com.coppertino.VOXAgent

Check Xcode version:
xcodebuild -version