ar command

主要来自man page

语法:
ar [-X32_64] [-]p[mod] [--plugin name] [--target bfdname] [relpos] [count] archive [member...]

commonly used options

r Insert the files member... into archive (with replacement).
s Add an index to the archive, or update it if it already exists.
c Create the archive.

unix>ar rcs libvector.a mul.o add.o

GNU ar allows you to mix the operation code p and modifier flags mod in any order, within the first command-line argument. If you wish, you may begin the first command-line argument with a dash. so the following line is equivalent to the above:

unix>ar -rcs libvector.a mul.o add.o

useful parameters:

1. the above ones(rcs).
2. t: Display a table listing the contents of archive, or those of the files listed in member... that are present in the archivear.

[user@hostname arCommandLearn]$ar t libvector.a 
mulvec.o
addvec.o

3. x: Extract members (named member) from the archive.把归档文件里面的.o文件提取出来,生成相应的.o文件:

[user@hostname arCommandLearn]$ls *.o
ls: cannot access *.o: No such file or directory
[user@hostname arCommandLearn]$ar x libvector.a 
[user@hostname arCommandLearn]$ls *.o
addvec.o  mulvec.o

4. r: Insert the files member... into archive (with replacement).

[user@hostname arCommandLearn]$ar t libvector.a 
mulvec.o
addvec.o
[user@hostname arCommandLearn]$ar r subvec.o
ar: subvec.o: File format not recognized
[user@hostname arCommandLearn]$ar r libvector.a  subvec.o
[user@hostname arCommandLearn]$ar t libvector.a 
mulvec.o
addvec.o
subvec.o

5. d: Delete modules from the archive. Specify the names of modules to be deleted as member...; the archive is untouched if you specify no files to delete.

[user@hostname arCommandLearn]$ar t libvector.a 
mulvec.o
addvec.o
subvec.o
[user@hostname arCommandLearn]$ar d libvector.a  subvec.o
[user@hostname arCommandLearn]$ar t libvector.a 
mulvec.o
addvec.o

把所有有交互界面使用了readline library的程序设置为vi mode

Put *Everything* in vi Mode
put gdb into vi mode
If you're a vi user like me, try adding these two lines to your ~/.inputrc file:

set keymap vi # 实践证明,这不是必须的
set editing-mode vi #这个比较重要

对于gdb,可以有临时方法:
Over in this question about ndk-gdb I learned that C-M-j will cause gdb to enter vi mode. I tried that with gdb 7.4.1 and it worked, but I don't know about gdb 7.5. (Note: C-M-j means "Alt-Ctrl-j" for those not used to emacs nomenclature or "Esc Ctrl-j" if you don't have an Alt key.)

让一些服务在Linux开机就启动

比较通用的方法

编辑rc.local文件:#vim /etc/rc.d/rc.local
加上你想加的任何命令,比如让mysql开机启动:
/etc/init.d/mysqld start

CentOS等RedHat系列的系统特有方法

先用chkconfig list查询apache服务是否存在,不存在则需要手动添加

chkconfig -add httpd
chkconfig --level 2345 httpd on
这个方法就写这些多吧,毕竟仅限于RedHat血统的OS.想深入了解可以man一下。

xfce终端,vim编辑器中,当cursor的颜色与字符的颜色一样时,看不见字符了

编辑~/.config/xfce4/terminal/terminalrc,如果没有,手动touch一个:
[Configuration]
ColorCursor=white
MiscCursorBlinks=TRUE
# cursor设为下划线类型
MiscCursorShape=TERMINAL_CURSOR_SHAPE_UNDERLINE
# ColorCursor=
# MiscCursorShape=TERMINAL_CURSOR_SHAPE_IBEAM
# 参考: http://docs.xfce.org/apps/terminal/advanced

Linux 从dhcp服务器那里释放ip并重新获取

# dhclient -r //release ip 释放IP
# dhclient //获取IP

解决ps aux | grep COMMAND 时候把grep自己也打印的问题

场景假设,想找出当前所有进程中有mpv命令的进程。很容易想到这么做:

# 如果有mpv命令在运行:
D.Deb[dice@ dbscan]$ps aux | grep mpv
dice     10978  4.0  0.6 1338328 53284 pts/0   Sl+  10:23   0:00 mpv --no-audio-display /home/dice/Music/qitian.mp3
dice     10995  0.0  0.0  12784   908 pts/4    S+   10:23   0:00 grep --color mpv
# 如果没有mpv命令在运行:
D.Deb[dice@ dbscan]$ps aux | grep mpv
dice     10881  0.0  0.0  12784   936 pts/4    S+   10:19   0:00 grep --color mpv

ps aux | grep mpv 本身是一个包含mpv的命令,grep把自己也filt出来了,但这并不是我们想要的结果,我们想要的是没有grep本身的结果。解决方案:

# 如果有mpv命令在运行:
D.Deb[dice@ dbscan]$ps aux | grep [m]pv
dice     11038  4.0  0.6 1338328 53412 pts/0   Sl+  10:26   0:00 mpv --no-audio-display /home/dice/Music/qitian.mp3
# 如果没有mpv命令在运行:
D.Deb[dice@ dbscan]$ps aux | grep [m]pv

"mpv --no-audio-display /home/dice/Music/qitian.mp3"这个字符串可以和模式 [m]pv匹配, "grep [m]pv"和模式 [m]pv不匹配。