Category Archives: OS

[Linux] use tee to write log

Source: stackoverflow: How do I write stderr to a file while using “tee” with a pipe? sh test.sh 2>&1 | tee “test.log”

Posted in Linux | Leave a comment

Getting around Active Directory search size limit via ldapsearch

ldapsearch -E pr=500/noprompt -v -x -LLL -h host:port -D account -w password -b “DC=base,DC=dn” -s sub “(objectClass=user)” -E pr=500/noprompt : 500 results per page, no prompt -E pr=1000/prompt : 1000 results per page, show prompt Source: Getting around Active Directory … Continue reading

Posted in LDAP, Linux | Leave a comment

Linux command to get time in milliseconds

src: Linux command to get time in milliseconds date +”%T.%N” returns the current time with nanoseconds. date +”%T.%6N” returns the current time with nanoseconds rounded to the first 6 digits, which is microseconds. date +”%T.%3N” returns the current time with … Continue reading

Posted in Linux | Leave a comment

open external program from java for mac os x

Posted in Java, Mac, Office | Leave a comment

Add git branch name to bash prompt

edit ~/.bash_profile

Posted in CentOS, Git, Linux, Mac, Ubuntu | Leave a comment

Install Hbase 5.9 in Mac OS X

Download hbase package tar.gz file from https://www.cloudera.com/documentation/enterprise/release-notes/topics/cdh_vd_cdh_package_tarball_59.html Untar tar.gz file edit conf/hbase-env.sh export JAVA_HOME={{JAVA_HOME Directory path}} edit conf/hbase-site.xml

start hbase service bin/start-hbase.sh run hbase shell bin/hbase shell stop hbase shell service bin/stop-hbase.sh

Posted in HBase, Mac | Leave a comment

Get timestamp in milliseconds

echo $(($(date +%s%N)/1000000)) in Mac OS X, the command date does not support the %N flag, we can install coreutils using homebrew. brew install coreutils Then use gdate to get which we want. echo $(($(gdate +%s%N)/1000000))

Posted in Linux, Mac | Leave a comment

find unused files and delete them

find /var/log/radius/radacct -type f -name “reply*” -mtime +60 -exec rm -rf {} \; -mtime N — more than N days without being edited -exec CMD {} \; — comands, {} means the files which be found.

Posted in Linux, Shell Script | Leave a comment

[Linux] sudo: sorry, you must have a tty to run sudo

edit /etc/sudoers find ‘requiretty’ add username like this Defaults:webuser requiretty

Posted in Linux | Leave a comment

Delete the specific files in all subdirectories

check the find result find . -name “*.bak” -type f delete it find . -name “*.bak” -type f -delete Ref. ask Ubuntu: How can I recursively delete all files of a specific extension in the current directory?

Posted in Linux | Leave a comment