终端自动补全:

sudo apt-get install bash-completion

make: yacc: Command not found:

sudo apt-get install byacc

切换至超级用户:

sudo -s

build-essential程序包:

sudo apt-get install build-essential

更新软件:

sudo apt-get upgrade

Linux安全删除文件:

shred -u file
shred -u -z file
shred /dev/sdx

shred命令详细参数:

-f,--force,更改权限允许写入(如有必要);
-n,--iterations=N:重写N次,默认为3次;
--random-source=FILE:从指定文件读取数据;
-s,--size=N:将文件粉碎为固定大小 (可使用后缀如KMC等);
-u,--remove:重写后截短并移除文件;
-v,--verbose:显示进度;
-z,--zero-add:用0覆盖数据;
–help:显示帮助;
–version:显示版本信息。

gcc相关

-E 预处理(Only run the preprocessor)
-S 编译为汇编代码(Only run preprocess and compilation steps)
-c 生成目标文件(Only run preprocess, compile, and assemble steps)
-o 写到文件(Write output to <file>)

利用ffmpg转换图片格式

ffmpeg -f image2 -i ffc5948a99b0d622ce749c807073cb8b.png ffc5948a99b0d622ce749c807073cb8b.jpg

利用ffmpg提取图片

ffmpeg -i "video.avi" -r 12 -vf "transpose=2, transpose=2"  "out/%07d.jpg"

注:

-r 12 设置帧率为12fps
transpose=2 表示旋转90度

git添加submodule

git submodule add <url> <path>
git submodule add git://github.com/ejmr/php-mode.git .emacs.d/plugins/php-mode

将github中的submodule更新到最新revision

cd submodule_name
git checkout master && git pull
cd ..
git add submodule_name
git commit -m "updating submodule to latest"

Mac下压缩忽略一些文件,如“.DS_Store”

tar -c --exclude='._*' --exclude='.svn' --exclude='.git' --exclude='.DS_Store' --exclude='*.bak' --exclude='*~' -vjf "$@"

Emacs中转换文件编码(转为utf-8)

C-x C-m f utf-8-unix RET

也可另存为:C-x C-m c RET C-x C-w RET

利用pip更新服务端shadowsocks

pip install --upgrade shadowsocks

linux查看端口被哪个进程占用

lsof -i:<port number>

VPS上编译安装emacs 24.4

# wget http://ftp.gnu.org/gnu/emacs/emacs-24.4.tar.xz
# tar xJvf emacs-24.4.tar.xz
# ./configure --disable-largefile --with-x-toolkit=motif --without-toolkit-scroll-bars   --without-xaw3d --without-xim --without-sound --without-pop --without-xpm --without-tiff --without-rsvg --without-gconf   --without-gsettings --without-selinux --without-gpm --without-makeinfo --without-x

mosh在Linux下遇到的locale问题:

The locale requested by LANG=en_US.UTF-8 isn't available here.
Running `locale-gen en_US.UTF-8' may be necessary.

The locale requested by LANG=en_US.UTF-8 isn't available here.
Running `locale-gen en_US.UTF-8' may be necessary.

mosh-server needs a UTF-8 native locale to run.

Unfortunately, the local environment (LANG=en_US.UTF-8) specifies
the character set "US-ASCII",

The client-supplied environment (LANG=en_US.UTF-8) specifies
the character set "US-ASCII".

locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=zh_CN.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
LC_ALL=
Connection to onijiang closed.
/usr/bin/mosh: Did not find mosh server startup message. 

解决方法:

  1. 使用mosh时添加参数--server="LANG=$LANG mosh-server"
  2. 使用命令设置本地locate为`en_US:localedef -v -c -i en_US -f UTF-8 en_US.UTF-8`

博客自动备份脚本(使用ssmtp和mutt):

#!/bin/bash
now_date=$(date +"%F")

#Email recipient(s), separated by space
recipient="i@jiya.io"

#Email subject and message 
subject="jiya.io_$now_date"
echo $subject

message="此邮件为博客定期备份邮件,每周六00:00启动,此次备份时间:$(date +"%F %T")"

#Motion target files path
backpath="/tmp/"

#Motion target directory path
blogpath="/var/www/htdocs"

####################################
echo "Running backup_jiya.io.sh ..." `date`

# compress usr directory
destfile="$backpath$subject.tar.bz2"
echo $destfile
rm -rf $destfile

echo "Creating tar file... " `date`

pushd $blogpath
tar jcf $destfile jiya.io
popd

# send mail
echo "Sending mail to recipient... " `date`
echo $message | mutt -s $subject $recipient -a $destfile

iterm配置utf8编码,本地终端中文不乱码,ssh远程中文乱码,编辑~/.vimrc文件,加上如下几行:

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8