Total Pageviews

Thursday, 28 February 2013

Linux的一些特殊命令

1、avi格式转mp4

[roowe@localhost tmp]$ ffmpeg -i Reflets3-3.avi -f mp4 -vcodec libxvid -maxrate 1000 -qmin 3 -qmax 5 -bufsize 4096 -g 300 -acodec aac -strict experimental -mbd 2 -s 320x240 -ab 128 -b 400 test.mp4

2、执行history的第1234条到第1238条命令命令

for x in {1234..1238}; do fc -s $x; done

3、在gnome3设置动态背景

git clone https://github.com/ametaireau/gnome-background-generator.git
cd gnome-background-generator/
./gnome-background-generator -p ../../Photos/wallpaper/ -o ../../Photos/wallpaper/background-1.xml
GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri 'file:///home/roowe/Dropbox/Photos/wallpaper/background-1.xml'
GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options 'zoom'
 ## Possible values: centered, none, scaled, spanned, stretched, wallpaper, zoom

4、sudo无需输入密码,在root下visudo之后,在root ALL=(ALL) ALL下一行添加yourusername ALL=(ALL) ALL,同时取消%wheel ALL=(ALL) NOPASSWD: ALL的注释,最后gpasswd -a YourUserName wheel就OK了。

5、远程关掉一台Windows机器

net rpc shutdown -I IP_ADDRESS -U username%password

刚刚就把师兄的机子给关了,喵哈哈

6、以HTTP方式共享当前文件夹的文件

python -m SimpleHTTPServer

7、在以普通用户打开的vim当中保存一个root用户文件

:w !sudo tee %

%是vim当中一个只读寄存器的名字,总保存着当前编辑文件的文件路径。

8、快速备份一个文件

 cp filename{,.bak}

9、免密码ssh登录主机,前提当前用户要有公钥,没有就执行ssh-keygen生成个吧。

ssh-copy-id host

然后以后ssh host的时候就不输入密码

10、wget下载

wget -c -r -np --restrict-file-names=nocontrol  --accept=pdf,chm,zip,ppt,rar,doc  url

简单解释下,-c是断点续传,-r是递归,-np不到父目录去,如果不想创建目录就加个-nd

11、画ascii码,详细见:http://search.cpan.org/~tels/Graph-Easy/

[roowe@localhost ~]$ echo "[ Bonn ] -> [ Berlin ] [ Freiburg ] -> [ Hamburg ]" | graph-easy
+----------+     +---------+
|   Bonn   | --> | Berlin  |
+----------+     +---------+
+----------+     +---------+
| Freiburg | --> | Hamburg |
+----------+     +---------+

12、用yum-utils的repoquery查询包中的所有文件。

repoquery –l packname

13、SDB:Clean the swap superblock
出错的提示大概内容如下。
“The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 “
解决方案见http://en.opensuse.org/SDB:Clean_the_swap_superblock
我的大概记录如下:

fdisk -l
dumpe2fs /dev/sda1
dumpe2fs /dev/sda3
e2fsck -c -f -v /dev/sda1
e2fsck -c -f -v /dev/sda3
swapoff -a /dev/sda2
mkswap /dev/sda2 -L swap

14、新建mysql访问的账户

mysql> grant all on db_name.* to 'db_name'@'ip' identified by 'passwd';
mysql> flush privileges;

15、简易计时器

[roowe@localhost ~]$ time read

16、lftp上传文件夹用mirror。

lftp jiaofeng@172.16.0.2:~> mirror -R /etc/openvpn/sj-vpn/
Total: 1 directory, 7 files, 0 symlinks
New: 7 files, 0 symlinks
286290 bytes transferred

17、ubuntu下看应用程序xxx安装路径

dpkg -L xxx

17、debugging NetworkManager-pptp

/usr/libexec/nm-pptp-service --debug

18、合并图片

montage *.jpg -geometry +0+0 -tile 1x6 a.png

19、查看命令输出变化

watch -d -n 1 cmd

20、清理最近使用的文件

echo "" > ~/.local/share/recently-used.xbel

21、查看系统网络端口暂用情况

sudo netstat -tulnp

22、关闭TAB的错误警告声音,修改文件/etc/inputrc,讲下面语句前的注释去掉

set bell-style none