安固途径

知识来源于感觉和经验

windows命令行下修改文件所有者

2016-04-28, 星期四|
windows软件

有些文件由于访问者不是所有者本身,所以即便是管理员也不能删除或重命名这种文件,这时就需要修改文件的权限和所有者。而通过文件属性中的安全设置文件的所有者比较麻烦,通过命令比较快捷易行。这里主要用到 icacls 这个程序,因为记不住,所以记录一下。

例如修改所有者为 system 的文件 test.dll 的所有者为 administrator:

> icacls test.dll /setowner administrator

参考http://bbs.pediy.com/archive/index.php?t-173687.html

...
阅读全文

linux下sed命令的经常用法

2016-04-26, 星期二|
linux软件

sed是linux下的一种文本流编辑器。

sed - stream editor for filtering and transforming text. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).

sed和vim的命令有着相似之处,例如删除d,插入i,增加a,匹配/regexp/,替换s/regexp/replacement/等。

一般来说sed有着如下经常用法。

删除行

假设文件名为test.txt

$ cat <<EOF >test.txt
> Can you feel my warm?
> How about having dinner with me?
> How am supposed to live without you?
> How many times you stand up for youself.
> EOF

$ grep
...
阅读全文

grep命令的一些高级用法

2016-04-25, 星期一|
linux软件

一般用 grep只作简单的匹配,或者用于管道输出信息。例如

# apt-cache search vim|grep enhanced

有时候也需要更复杂的操作,例如

显示行号

# wget //qiniu.imesu.co/doc/txt/the-end-of-the-world.txt
# grep -n 'goodbye' the-end-of-the-world.txt

输出

show-number

忽略大小写

# grep -n -i 'Goo.' the-end-of-the-world.txt

输出

ignore-case

反向选择

# grep -v 'pattern'

打出匹配行后几行

# grep -A 2 'goodbye' the-end-of-the-world.txt

输出

show-after-lines

打出匹配行前3行

# grep -B 3 'goodbye' the-end-of-the-world.txt

输出

show-before-lines

循环查找

这也是经常用的一种模式,例如查找本地的官方HTML文档快速获取帮助,快速定位开源软件的函数等等。

# mkdir lyric
# wget -O lyric/love-paradise.tx
...
阅读全文

VirtualBox与主机共享文件夹

2016-04-17, 星期日|
修复软件

Oracle的VM VirtualBox在安装增强功能后,可以使其中运行的Ubuntu挂载主机Windows的文件夹,从而实现文件夹共享。

VirtualBox设置主机共享文件夹

打开菜单

vmbox-folder-share

添加共享文件夹

add-folder-main

add-folder-dlg

VirtualBox的文件系统为vboxsf

$ su
# mkdir /mnt/win7share
# mount -t vboxsf ubuntushare /mnt/win7share

mount-vboxsf

好了吧,和主机共享文件夹这样做的好处是显而易见的。

和主机共享剪切板有时也是有必要的,至少VirtualBox提供这项功能。

...
阅读全文

利用adb工具快速将安卓手机照片备份到本地

2016-04-10, 星期日|
快捷键

首先需要准备好adb工具,并将adb的目录加入系统的path,然后电脑上安装好手机的驱动。

将手机和电脑USB连接完成后,打开手机的USB调试功能。

进入文件管理器,按shift+鼠标右键,在当前目录打开cmd。建一个文件夹camera,并将安卓手机中的照片备份到该文件夹。

>mkdir camera
>cd camera
>adb devices
>adb pull -p /storage/sdcard1/DCIM/camera/ .

adb pull camera

等待照片传输完成。

...
阅读全文