bash에서 자동완성할 때 공백 문자 들어가는 문제

언제부터 였는지는 모르겠지만, ubuntu (12.04)의 bash shell에서 자동완성을 하려고 <tab> key를 누르면 공백문자가 하나씩 추가되는 문제가 생겼다. 여러 단계로 되어 있는 file에 접근하려고 할 때 매번 <tab> key를 누르고 <backspace>로 공백문자를 지워줘야 하기 때문에 무척 불편했는데 좀 찾아보니 bash_completion file을 수정해서 이 문제를 해결 할 수 있었다.

sudo vi /etc/bash_completion
# makeinfo and texi2dvi are defined elsewhere.
for i in a2ps awk bash bc bison cat colordiff cp csplit \
    curl cut date df diff dir du enscript env expand fmt fold gperf gprof \
    grep grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod \
    mv netstat nl nm objcopy objdump od paste patch pr ptx readelf rm rmdir \
    sed seq sha{,1,224,256,384,512}sum shar sort split strip tac tail tee \
    texindex touch tr uname unexpand uniq units vdir wc wget who; do
    have $i && complete -F _longopt -o default $i
done
unset i

1587 line의 ‘_longopt -o default‘ 부분을 다음과 같이’ _longopt -o filenames‘로 변경한 후 다시 shell을 다시 열고 사용하면 된다.

 have $i && complete -F _longopt -o filenames $i

(참조 링크)

분실한 mysql root password 재설정하기

Mysql을 처음 설치할 때 database root 계정으로 사용할 password를 설정한다. 하지만 시간이 오래 지나서 그때 설정한 password를 기억할 수 없다면 다음의 방법으로 재설정할 수 있다. (Ubuntu 12.04 기준)

Step 1. 실행중인 mysql service를 중지 시킨다.

# service mysql stop

Step 2. Password를 검사하지 않도록 mysql 환경설정 파일을 수정한다.
: /etc/mysql/my.conf file에 skip-grant-tables를 추가하면 password를 검사하지 않는다.

[mysqld]
#
# * Basic Settings
#
user         = mysql
pid-file     = /var/run/mysqld/mysqld.pid
socket       = /var/run/mysqld/mysqld.sock
port         = 3306
basedir      = /usr
datadir      = /var/lib/mysql
tmpdir       = /tmp
lc-messages-dir = /usr/share/mysql

skip-external-locking

skip-grant-tables

Step 3. 새로운 설정 값으로 mysql service를 실행한다.

# sudo service mysql start

Step 4. root 계정으로 mysql database를 연다.

$ mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.29-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Step 5. root password를 재설정한다.

mysql> UPDATE user SET password=PASSWORD('ROOT_비밀번호') WHERE user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

Step 6. my.conf를 복원하고 mysql service를 재실행 시킨다. 

Android NDK build architecture 변경하기

아무 설정 없이 ndk를 build 하면 다음과 같이 arm용 library가 만들어진다.

$ <NDK_PATH>/ndk-build 
Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile thumb  : hello-jni <= hello-jni.c
SharedLibrary  : libhello-jni.so
Install        : libhello-jni.so => libs/armeabi/libhello-jni.so
$ file obj/local/armeabi/libhello-jni.so 
obj/local/armeabi/libhello-jni.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

NDK에서 build되는 binary의 architecture를 변경하려면 APP_ABI를 선언해 주어야 하는데, Android.mk에 추가해서는 제대로 동작하지 않는다. JNI directory 아래에 Application.mk file을 만들고  APP_ABI값에 build할 architecture를 설정해 준다. 다음은 x86 바이너리를 생성하는 예제이다.

$ cat jni/Application.mk 
APP_ABI := x86
$ <NDK_PATH>/ndk-build 
Gdbserver      : [x86-4.6] libs/x86/gdbserver
Gdbsetup       : libs/x86/gdb.setup
Compile x86    : hello-jni <= hello-jni.c
SharedLibrary  : libhello-jni.so
Install        : libhello-jni.so => libs/x86/libhello-jni.so
$ file obj/local/x86/libhello-jni.so 
obj/local/x86/libhello-jni.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

* Build에 사용되는 toolchain은 <NDK_PATH>/toolchains/<architecture>-<version>의 형태로 위치한다.