Showing posts with label Terminal (OS X). Show all posts
Showing posts with label Terminal (OS X). Show all posts

Thursday, November 17, 2016

macOS Sierra: Opening the File Using Application in Application Folder: TextEdit

Command:

$ open -a TextEdit html5game_pong.html


Graphical result:

Opening a File with TextEdit from Terminal

Monday, July 18, 2016

CentOS: Quick Fixing the Locale Problem When Terminal.app Failed to Set Locale Environment Variables on Startup

Command:

$ locale

Result:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: LC_ALL??????????????????: ??????????????????????
LANG=ja_JP.utf8
LC_CTYPE=UTF-8
LC_NUMERIC="ja_JP.utf8"
LC_TIME="ja_JP.utf8"
LC_COLLATE="ja_JP.utf8"
LC_MONETARY="ja_JP.utf8"
LC_MESSAGES="ja_JP.utf8"
LC_PAPER="ja_JP.utf8"
LC_NAME="ja_JP.utf8"
LC_ADDRESS="ja_JP.utf8"
LC_TELEPHONE="ja_JP.utf8"
LC_MEASUREMENT="ja_JP.utf8"
LC_IDENTIFICATION="ja_JP.utf8"
LC_ALL=


Command:

$ LC_CTYPE=ja_JP.utf8
$ locale

Result:

LANG=ja_JP.utf8
LC_CTYPE=ja_JP.utf8
LC_NUMERIC="ja_JP.utf8"
LC_TIME="ja_JP.utf8"
LC_COLLATE="ja_JP.utf8"
LC_MONETARY="ja_JP.utf8"
LC_MESSAGES="ja_JP.utf8"
LC_PAPER="ja_JP.utf8"
LC_NAME="ja_JP.utf8"
LC_ADDRESS="ja_JP.utf8"
LC_TELEPHONE="ja_JP.utf8"
LC_MEASUREMENT="ja_JP.utf8"
LC_IDENTIFICATION="ja_JP.utf8"
LC_ALL=


Command:

$ date

Result:

2016年  5月 18日 水曜日 03:47:01 JST

Friday, June 10, 2016

Nmap (Network Mapper): Scanning for Open Ports of Remote Server from Local Machine (OS X)

Command (Scanning open ports of a LAN server):

$ sudo nmap -sT -P0 -p 1-65535 192.168.0.6
Password:

Result:

Starting Nmap 7.12 ( https://nmap.org ) at 2016-07-16 16:34 JST
Nmap scan report for 192.168.0.6
Host is up (0.0064s latency).
Not shown: 65534 closed ports
PORT   STATE SERVICE
22/tcp open  ssh

Nmap done: 1 IP address (1 host up) scanned in 34.09 seconds


Command (Scanning open ports of a remote server):

$ sudo nmap -sT -P0 -p 1-65535 remote.servername.com

Result:

Starting Nmap 7.12 ( https://nmap.org ) at 2016-07-16 16:36 JST
Nmap scan report for remote.servername.com (150.000.000.00)
Host is up (0.053s latency).
rDNS record for 150.000.000.00: ik1-000-00000.vs.hostingservice.ne.jp
Not shown: 65533 filtered ports
PORT   STATE  SERVICE
22/tcp open   ssh
80/tcp closed http

Nmap done: 1 IP address (1 host up) scanned in 436.18 seconds

Nmap (Network Mapper): Installing on OS X Using Brew

Command:

$ brew install nmap


Result:

==> Installing dependencies for nmap: openssl
==> Installing nmap dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2h.el_capitan.b
######################################################################## 100.0%
==> Pouring openssl-1.0.2h.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2h: 1,691 files, 12M
==> Installing nmap
==> Downloading https://homebrew.bintray.com/bottles/nmap-7.12.el_capitan.bottle
######################################################################## 100.0%
==> Pouring nmap-7.12.el_capitan.bottle.tar.gz
==> Caveats
Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
  mkdir -p /Users/username/Library/Python/2.7/lib/python/site-packages
  echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/username/Library/Python/2.7/lib/python/site-packages/homebrew.pth
==> Summary
🍺  /usr/local/Cellar/nmap/7.12: 727 files, 23M

Monday, May 16, 2016

OS X: Terminal: Setting Locale for Remote Ubuntu Servers

Command:

user@remote:~$ locale
LANG=C
LANGUAGE=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

user@remote:~$ date
Mon May 16 12:19:05 JST 2016

user@remote:~$ export LANG=ja_JP.UTF-8
user@remote:~$ locale
LANG=ja_JP.UTF-8
LANGUAGE=
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=

user@remote:~$ date
2016年  5月 16日 月曜日 12:19:52 JST

OS X: Terminal: Locale Error When Accessing Remote Linux Server

Error message:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory


Solution:

Terminal > Preferences... > Profiles > Basic > Advanced > International > Set locale environment variables on startup > UNCHECK


Thursday, April 21, 2016

OS X: Launchpad: Changing Grid Layout

Command:
$ defaults write com.apple.dock springboard-columns -int 12;defaults write com.apple.dock springboard-rows -int 4;defaults write com.apple.dock ResetLaunchPad -bool TRUE;killall Dock
Result:

Thursday, January 28, 2016

Generating Random Password

Generating 32-character random password

$ cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1

This is the same:

$ cat /dev/urandom | env LC_CTYPE=C tr -dc '[:alnum:]' | fold -w 32 | head -n 1

Generating Random 15-Character User Name

Generating random 15-character:
$ cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 15 | head -n 1
This is the same:
$ $ cat /dev/urandom | env LC_CTYPE=C tr -cd '[:lower:][:digit:]' | fold -w 15 | head -n 1

Friday, May 31, 2013

Dumping Login Keychain Data

security dump-keychain -d ~/Library/Keychains/login.keychain

Sunday, January 27, 2013

Activating AirDrop

Type and enter following code in Terminal.

defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1

Restart computer.

Monday, March 26, 2012

In House App Development Essential Videos - Getting Started with iPhone Web Applications

Simulating Network Latency

In Terminal...

sudo su
ipfw add pipe 1 src0port http
ipfw pipe 1 config delay 200 bw 700kbit/s


To reset...

ipfw flush