Showing posts with label Terminal. Show all posts
Showing posts with label Terminal. Show all posts

Wednesday, August 19, 2015

How to stop disconnecting Wi-Fi when locking a MAC.

Hi All,

I've been experiencing an issue where the Wi-Fi keeps disconnecting when I lock my screen on my MacBook. I found the following solution to keep it up always.

Find the network interface for Wi-Fi.

Use the "ifconfig" command to find the network interface. It would most probably be "en0" or "en1".

Disable disconnecting.

Run the following commands. In the 2nd command, make sure you use the correct network interface found in the earlier step. Running the following commands may ask for the password. If so, please provide.

cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en1 prefs DisconnectOnLogout=NO

And thats all. Wi-Fi should be connected even if the screen is locked.

References...

[1] - http://apple.stackexchange.com/questions/71884/wi-fi-disconnects-when-i-lock-the-mac

Sunday, August 2, 2015

Unzip all zip files in a folder in terminal.

Hi,

With the following command you can unzip all the zip files in the current folder.

unzip \*.zip

Removing __MACOSX folder from a zip file/archive.

Hi All,

Recently I created a zip file in MAC OS X. But when I copied it from my MAC OS X to my Ubuntu machine and opened it, theres a folder named "__MACOSX" inside. I have no idea how it got there.

But you can delete that folder by running the following command in MAC OS X after compressing.

zip -d filename.zip __MACOSX/\*

Sunday, May 24, 2015

Creating a New User in Cassandra Database

Introduction...

Hi All,

Recently I was working on user authentication of DSE(DataStax Enterprise[1]) Cassandra and I noticed that any username and password allowed me to access the cassandra cluster. So I looked into the docs and saw that there are several authenticators[2].

By default the used authenticator is the "org.apache.cassandra.auth.AllowAllAuthorizer" authenticator which allowed access with any username and password. So to create a user and grant permissions, you can follow these steps...

Steps...

Shutdown the Cassandra cluster(can use kill -9) if it is already running and the modify the cassandra.yaml file. If you are using DSE cassandra, it will reside in "<DSE_HOME>/resources/cassandra/conf/cassandra.yaml". Else if you are using Apache Cassandra, it will reside in "<APACHE_CASSANDRA_HOME>/conf/cassandra.yaml".

Modify the file in a way that "org.apache.cassandra.auth.AllowAllAuthorizer" authenticator is commented and add "org.apache.cassandra.auth.PasswordAuthenticator" authenticator[3].
#authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator

By default, Cassandra has a user with username as "cassandra" and password as "cassandra" which can be used to create a new user using "cqlsh" tool[4]. Login using the "cqlsh" tool by executing the following command.

./cqlsh localhost -u cassandra -p cassandra

After the cqlsh console is opened, to get the current list of users run the following command.

list users;

To create a new user, run the following command. Here the username is "myUserName" and the password is "myPassword".

CREATE USER myUserName WITH PASSWORD 'myPassword' SUPERUSER;

The above user will get created with superuser privileges. The newly created user should be there when running the "list users;" command again.

Goodluck!!!

References...

[1] - http://www.datastax.com/products/products-index
[2] - http://docs.datastax.com/en/cassandra/1.2/cassandra/security/secure_config_native_authorize_t.html
[3] - http://www.datastax.com/dev/blog/a-quick-tour-of-internal-authentication-and-authorization-security-in-datastax-enterprise-and-apache-cassandra
[4] - http://docs.datastax.com/en/cassandra/1.2/cassandra/security/security_config_native_authenticate_t.html

Sunday, April 5, 2015

Open Sublime in Terminal for Mac OSX

Even though we install Sublime 2 or 3 using a DMG file in Mac OSX, we cannot open Sublime using the terminal. To fix this, run the following...

For Sublime Text 2

cd /usr/local/bin
ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" subl

For Sublime Text 3

cd /usr/local/bin
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" subl

To open Sublime in terminal, use the following command.

subl 
To see usages of subl command

subl --help

References

  • https://www.sublimetext.com/docs/3/osx_command_line.html
  • http://stackoverflow.com/questions/11889484/command-subl-from-terminal-dont-work
  • https://bensmann.no/open-folder-in-sublime/