Category Archives: Linux

Add git branch name to bash prompt

edit ~/.bash_profile if [ -f $(xcode-select -p)/usr/share/git-core/git-completion.bash ]; then . $(xcode-select -p)/usr/share/git-core/git-completion.bash . $(xcode-select -p)/usr/share/git-core/git-prompt.sh fi #enables color in the terminal bash shell export CLICOLOR=1 #sets up the color scheme for list export LSCOLORS=ExFxCxDxBxegedabagacad #sets up the prompt color (currently … Continue reading

Posted in CentOS, Git, Linux, Mac, Ubuntu | 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

[Linux] Sort the disk usage

du -B M –max-depth=1 | sort -g Ref.: [ubuntu] 利用du搭配sort來查看磁碟使用空間]1

Posted in Linux | Leave a comment

Install aglio in Ubuntu 14.04

Install nodejs Ref. NodeSource Node.js Binary Distributions apt-get install -y nodejs nodejs-legacy Install python apt-get install python-dev Install aglio Ref. Github : aglio npm install -g aglio

Posted in Aglio, Ubuntu | Leave a comment

[Apache HBase] Install Apache HBase in Ubuntu 14.04

Java 1.7 add-apt-repository ppa:webupd8team/java apt-get update apt-get install oracle-java7-installer apt-get install oracle-java7-set-default Cloudera HBase Ref. installing-apache-hbase-on-ubuntu-for-standalone-mode Note. hbase tar file choose http://archive.apache.org/dist/hbase/hbase-0.98.5/hbase-0.98.5-hadoop1-bin.tar.gz (or http://ftp.mirror.tw/pub/apache/hbase/hbase-0.98.11/hbase-0.98.11-hadoop1-bin.tar.gz )

Posted in HBase, Ubuntu | Leave a comment

[Ubuntu] Enable exFAT support

All you need is install the exfat-* packages. sudo apt-get install exfat-fuse exfat-utils

Posted in Ubuntu | Leave a comment

[Ubuntu] Enable power saving in Lenovo X61

Ref: http://www.webupd8.org/2014/04/prevent-your-laptop-from-overheating.html Because I installed Ubuntu 14.04 in my Lenovo X61. Although it could switch into the sleep mode after closing the lid. It’s not really using the power saving mode. So we must edit the GRUB file. sudo vim … Continue reading

Posted in Ubuntu | Leave a comment