Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2111810
  • 博文数量: 438
  • 博客积分: 3871
  • 博客等级: 中校
  • 技术积分: 6075
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-10 00:11
个人简介

邮箱: wangcong02345@163.com

文章分类

全部博文(438)

文章存档

2017年(15)

2016年(119)

2015年(91)

2014年(62)

2013年(56)

2012年(79)

2011年(16)

分类: LINUX

2011-11-01 23:16:37

一.系统使用
1.1 硬盘安装ubuntu时
  1. ubuntu@ubuntu:~$ mount
  2.      /dev/sda1 on /isodevice type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
  3. ubuntu@ubuntu:~$ sudo umount -l /isodevice
1.2 进入系统之后
a.如果有双系统,需要重引更新一下引导
  1. cong@msi:~$ sudo update-grub2
  2. [sudo] password for cong:
  3. Sorry, try again.
  4. [sudo] password for cong:
  5. Generating grub configuration file ...
  6. Found linux image: /boot/vmlinuz-4.4.0-31-generic
  7. Found initrd image: /boot/initrd.img-4.4.0-31-generic
  8. Found memtest86+ image: /boot/memtest86+.elf
  9. Found memtest86+ image: /boot/memtest86+.bin
  10. Found Windows 7 (loader) on /dev/sda1
  11. done
b.更新源列表
  1. cong@msi:~$ sudo apt-get update   //更新源,这样apt-get install 才可以用
1.3 安装cario-dock
  1. cong@msi:~$ sudo apt-get install cairo-dock
  2. 重启,在登陆时
  3. Select desktop environment
  4. 切换到cario-dock,图标是一个CD
1.4 配置vim
  1. cong@msi:/work$ tar xf ./vim.tar.gz -~               #将以前的vim配置包解压

  2. cong@msi:/work$ sudo apt-get install vim               #如果不执行这一步打开vim时会有如下错误
  3. Error detected while processing /home/cong/.vimrc:
    line    2:
    E319: Sorry, the command is not available in this version: syn on                  " 打开语法高亮
    line    3:
    E319: Sorry, the command is not available in this version: syntax enable
    line   18:
    E185: Cannot find color scheme 'desert'

  4. cong@msi:/work$ sudo apt-get install exuberant-ctags   #安装ctags
1.5安装chrome浏览器
  1. 进入 http://www.chromeliulanqi.com/ 下载deb包
  2. cong@msi:~/Downloads$ sudo dpkg -i ./google-chrome-stable_current_amd64.deb
  3.  google-chrome-stable depends on libappindicator1; however: Package libappindicator1 is not installed.
  4.  dpkg: error processing package google-chrome-stable (--install):   #安装时会提示缺少一个依赖包
  5.  dependency problems - leaving unconfigured

  6. cong@msi:~/Downloads$ sudo apt-get -f install           #重新安装即可
1.6 fcitx的安装
  1. a. 安装
  2. cong@msi:~$ sudo apt-get install fcitx-table-wbpy    #这一条命令就会把fcitx及wbpy这两个都安装了
  3. #cong@msi:~$ sudo apt-get install fcitx-pinyin fcitx-table-wubi  #下面是备选的码表
  4. b.配置码表
  5. #只安装不行,还要把码表放在fcitx中
  6. cong@msi:~$ fcitx-configtool
  7. 如果里面只有一项 Keyboard-English(US)则需要添加码表
  8. 点左下方的+ --> 去掉 only Show Current Language前面的勾 -->选中WubiPinyin后点OK,这样就把WubiPinyin加到码表里面去了。
  9. c.将fcitx作为默认的输入法
  10. system_settings --> language Support--> Keyboard input method system -->fcitx
  11. d. 重启后生效
  12. cong@msi:~$ sudo reboot    #重启后用ctrl+space 切换
1.7 编译环境
a. ubuntu64位兼容32位
  1. cong@msi:/work$ sudo apt-get install gcc-multilib g++-multilib
b. 内核的menuconfig
  1. cong@msi:/tmp/minix$ sudo apt-get install libncurses5-dev
1.8 将ubuntu的中文环境为英文环境
  1. cong@msi:/work$ sudo vi /etc/default/locale
  2. :1,$s/zh_CN/en_US/g
1.9 界面设置
a. 取消边缘自动最大化
sudo apt-get install CompizConfig Settings Manager
SystemTools-->Preferrence-->CompizConfig Settings Manager-->WindowsManagement-->SnappingWindows去掉前面的勾
b.将按钮放在右边
  1. 按照以前的办法用gconf-editor不行了,因为在gconf-editor-->apps中没有metacity
  2. 用下面这个方法:
  3. cong@msi:~$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close
1.10 startdict词典的安装
  1. a. cong@msi:~$ sudo apt-get install stardict
  2. b. 下载词典: http://abloz.com/huzheng/stardict-dic/zh_CN/
  3. c. 将下载的词典解压到dict目录下即可
  4. cong@msi:~/Downloads$ sudo tar xf ./stardict-langdao-ce-gb-2.4.2.tar.bz2 -C /usr/share/stardict/dic/
  5. cong@msi:~/Downloads$ sudo tar xf ./stardict-langdao-ec-gb-2.4.2.tar.bz2 -C /usr/share/stardict/dic/
  6. cong@msi:~/Downloads$ sudo tar xf ./stardict-oxford-gb-2.4.2.tar.bz2 -C /usr/share/stardict/dic/
  7. d. 重启startdict,点右下方的小齿轮manage dictionaries就看到新添加的词典了
1.11 virtualbox的安装
  1. a. 到  去下载virtulbox
  2. b. cong@msi:~$ sudo dpkg -i ./Downloads/virtualbox-5.1_5.1.6-110634-Ubuntu-trusty_amd64.deb
  3. dpkg: dependency problems prevent configuration of virtualbox-5.1:
  4.  virtualbox-5.1 depends on libsdl1.2debian (>= 1.2.11); however:
  5.   Package libsdl1.2debian is not installed.                #缺少依赖包

  6. dpkg: error processing package virtualbox-5.1 (--install):
  7.  dependency problems - leaving unconfigured
  8. cong@msi:~$ sudo apt-get -f install                       #重新安装
a. virtualbox 增加IDE硬盘
  先按照步骤设置虚拟机,设置完成后不要启动,然后:
  settings-->Storage --> Controller:IDE --> 加号 Add Hard disk -->Create New disk
 同时删掉不需要的SCSI的硬盘即可
1.12 wine的安装
a. cong@msi:~$ sudo apt-get install wine
b. souce insight 在系统中的路径
  1. ~/.wine/drive_c/users/cong/My\ Documents/Source\ Insight/Settings/
c. 配置source insight的字体
  1. c.1 左侧边栏 -->右键Symbol Window Properties --> Font
  2. c.2 中间字体 --> Options--> Document Options(或者Alt+t)--> ScreenFonts
  3. c.3 右侧 右键-->Font
1.13 ssh的安装
  1. cong@msi:~$ sudo apt-get install openssh-server    -->安装ssh

  2. cong@msi:~$ sudo ps -ef | grep "ssh"
  3. root 11453 1 0 00:48 ? 00:00:00 /usr/sbin/sshd -D   -->有sshd说明ssh的server己启动
  4. cong@msi:~$ sudo service ssh start                -->如果没有启动,则start
  5. start: Job is already running: ssh
  6. cong@msi:~$ sudo service ssh restart            -->重启动ssh
  7. ssh stop/waiting
  8. ssh start/running, process 11546
1.14 nfs server的安装
  1. cong@msi:~$ sudo apt-get install nfs-common nfs-kernel-server
  2. cong@msi:~$ sudo vi /etc/exports  
  3. /work *(rw,sync,no_subtree_check,no_root_squash)    -->设置共享目录
  4. /tmp/ *(rw,sync,no_subtree_check,no_root_squash,insecure)
  5. 解释:
  6. sync-->  将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性;
    insecure-->  允许客户端从大于1024的tcp/ip端口连接服务器;
    no_root_squash-->  此时root用户的身份被压缩为NFS server上面的root
    no_subtree_check--> 即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;

  7. cong@msi:~$ sudo service nfs-kernel-server start 

  8. cong@redhat:~$ sudo mount -t nfs 192.168.1.101:/work/ ./work 
  9.                                 -->注意这儿不要和scp混了,路径前没有用户名
1.14.1 nfs mount出错
  1. cong@msi:/tmp$ sudo mount -t nfs 192.168.4.93:/work/os/ /mnt/
  2. mount: wrong fs type, bad option, bad superblock on 192.168.4.93:/work/os/,
  3.        missing codepage or helper program, or other error
  4.        (for several filesystems (e.g. nfs, cifs) you might
  5.        need a /sbin/mount.<type> helper program)
  6.        In some cases useful info is found in syslog - try
  7.        dmesg | tail or so
查看/sbin/mount*,发现的确没有mount.nfs
  1. cong@msi:/tmp$ ls /sbin/mount.*
  2. /sbin/mount.fuse /sbin/mount.ntfs /sbin/mount.ntfs-3g /sbin/mount.vboxsf
解决方法:
  1. cong@msi:/tmp$ sudo apt-get install nfs-common
1.15 samba的安装
  1. cong@msi:/work$ sudo apt-get install samba samba-common

  2. cong@msi:/work$ sudo mkdir /work

  3. cong@msi:/work$ sudo chown cong:cong /work/

  4. cong@msi:/work$ sudo vi /etc/samba/smb.conf    -->添加如下
  5. [share]
  6.       path = /work
  7.       available = yes 
  8.       browsealbe = yes 
  9.       public = yes 
  10.       writable = yes
  11. cong@msi:/work$ sudo /etc/init.d/smbd restart
如果windows下只有读没有写的权限,执行如下操作:
  1. 解决:smbd不能启动的问题:
  2. a. 将smbd的启动信息打印出来
  3. sudo /usr/sbin/smbd -F -d 10 -S
  4. b. 出现如下信息:
  5. doing parameter security = share
  6. WARNING: Ignoring invalid value 'share' for parameter 'security'
  7. pm_process() returned No
  8. lp_servicenumber: couldn't find homes
  9. error opening config file '/etc/samba/smb.conf'
  10. c. 修改/etc/samb/smb.conf
  11. 将 security = share 改为 security = user
  12. [参考]
1.16 常用配置
a. bashrc
  1. # some more ls aliases
  2. alias ll='ls -alF'
  3. alias la='ls -A'
  4. alias l='ls -CF'
  5. alias l='ls -CF'
  6. alias cd1='cd ../'
  7. alias cd2='cd ../../'
  8. alias cd3='cd ../../../'
  9. alias cd4='cd ../../../../'
  10. alias cd5='cd ../../../../../'
  11. alias cd6='cd ../../../../../../'
  12. alias cd7='cd ../../../../../../../'
  13. alias cd8='cd ../../../../../../../../'
  14. alias cd9='cd ../../../../../../../../../'
  15. alias cd10='cd ../../../../../../../../../../'
  16. alias r='reset
  17. alias grep='grep --color=auto'   -->这样grep就带颜色了
b. gp -->grep
  1. cong@msi:/usr/local/bin$ cat gp
  2. #!/bin/sh
  3. grep "$1" * -R --color=auto
c. si -->open source insight
  1. cong@msi:/usr/local/bin$ cat si
  2. #!/bin/sh
  3. wine "C:\Program Files (x86)\Source Insight 3\insight3.exe" 1>/dev/null 2>&1 &
d.foxit
  1. cong@msi:~/Downloads$ cat /usr/local/bin/foxit
  2. #!/bin/sh
  3. wine /work/bak/soft/FoxitReader/Foxit\ Reader.exe 1>/dev/null 2>&1 &
d. adbr
  1. cong@msi:/usr/local/bin$ cat adbr
  2. #!/bin/sh
  3. sudo /work/bak/android/androidSDK/platform-tools/adb kill-server
  4. sudo /work/bak/android/androidSDK/platform-tools/adb start-server
  5. adb devices
5. 打开eclipse会出现错误:
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: /opt/andorid/eclipse/jre/bin/java java in your current PATH 
  1. sun@ubuntu:/usr/share/applications$ sudo update-alternatives --install /usr/bin/java java /opt/andorid/jdk1.6.0_24/bin/java 300

  2. sun@ubuntu:/usr/share/applications$ sudo update-alternatives --install /usr/bin/javac javac /opt/andorid/jdk1.6.0_24/bin/javac 300
6. vmware 停在starting nfs kernel 中
ubuntu 无法启动,停在 starting nfs kernel daemon [ok]上面,就没有动静了。看到网上有人说“不用管等几十分钟就可以起来”,我了个去等了二十分钟还没有反应,是不是我上面装的软件多,又等了二个二十分钟,坑爹啊,还没有起来!

a.    分析上面的打印感觉是跟网络有关,我的虚拟机上有两处与网络有关:

一个是网卡,另一个是与windows共享的文件夹,先把这两个都去掉试一下,

    vmware setting –> Network Adpator –> Devices status –> 去掉connected 和 connect at power on

   vmware setting –> Options –> Shared Folders –> Disabled

b. 重开机,正常启动。

c. 进一步排除,把网卡选上重启动,也是正常的;再把共享文件夹选上,不能启动



7. change resolution of unknown monitor
  1. 今天开机发现ubuntu分辨率不正常只有1024×768, Displays选项卡下面最大的分辨率是1024×768
  2. a.
  3. sun@ubuntu:~$ xrandr
  4. Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
  5. VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
  6.    1024x768 60.0*
  7.    800x600 60.3 56.2
  8.    848x480 60.0
  9.    640x480 59.9
  10. sun@ubuntu:~$ cvt 1440 900
  11. # 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
  12. Modeline "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
  13. sun@ubuntu:~$ xrandr
  14. Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
  15. VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
  16.    1024x768 60.0*
  17.    800x600 60.3 56.2
  18.    848x480 60.0
  19.    640x480 59.9
  20. sun@ubuntu:~$ cvt 1440 900
  21. # 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
  22. Modeline "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
  23. sun@ubuntu:~$ xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync 中间的×与*容易混淆
  24. sun@ubuntu:~$ xrandr --newmode "1440*900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
  25. sun@ubuntu:~$ xrandr --addmode VGA1 1440*900_60.00
  26. sun@ubuntu:~$ xrandr --output VAG1 --mode 1440*900_60.00
  27. warning: output VAG1 not found; ignoring
  28. sun@ubuntu:~$ xrandr --output VAG1 --mode 1440*900_60.00^C
  29. sun@ubuntu:~$ sudo cp /etc/X11/xorg.conf.failsafe /etc/X11/xorg.conf
  30. [sudo] password for sun:
  31. sun@ubuntu:~$ vi /etc/X11/xorg.conf
  32. sun@ubuntu:~$ sudo gedit /etc/X11/xorg.conf
  33. http://webcache.googleusercontent.com/search?q=cache:a3zWvZLNaT8J:anhe51.wordpress.com/2012/01/30/change-resolution-of-unknown-monitor-in-ubuntu-11-10/+ubuntu+unknown+displays&cd=1&hl=zh-TW&ct=clnk&gl=hk
  34. 出来了,终于可以将分辨率调高了!

8.uboot编译出问题
./scripts/dtc-version.sh: line 17: dtc: command not found
这说明dct工具没有安装
cong@msi:/code/ct/lichee/u-boot$ sudo apt-get install device-tree-compiler

9.chrome打开出错
命令行运行chrome报错
  1. [11191:11232:1009/232424:ERROR:connection.cc(1060)] Web sqlite error 5, errno 0: database is locked, sql: PRAGMA journal_mode = PERSIST
删除/home/cong/.config/google-chrome即可,删除之前记得备份书签等
11. wlan_11n无线配置
  1. [root@localhost /]# ifconfig eth0 down     ;首先关闭有线网卡
  2. [root@localhost /]# wlanconfig ath0 create wlandev wifi0 wlanmode sta ;如果没有无线则创建
  3. [root@localhost /]# ifconfig ath0 up          ;启动无线网卡ath0 
  4. [root@localhost /]# ifconfig             ;查看无线信息,出现HWaddr 00:12:34:56:78:90 
  5. [root@localhost /]# iwlist ath0 scan
  6. ath0 Scan completed :
  7.           Cell 01 - Address: 00:1F:64:E1:96:51
  8.                     ESSID:"test1"
  9.                     Mode:Master
  10.                     Frequency:2.412 GHz (Channel 1)
  11.                     Quality=50/94 Signal level=-71 dBm Noise level=-121 dBm
  12.                     Encryption key:off
  13.                     Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
  14.                               9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
  15.                               48 Mb/s; 54 Mb/s
  16.                     Extra:bcn_int=100
  17.                     Extra:rsn_ie=30140100000fac020100000fac020100000fac020000
  18.                     Extra:wme_ie=dd180050f2020101020003a4000027a4000042435e0062322f00
  19.                     Extra:ath_ie=dd0900037f01010000ff7f
  20. [root@localhost /]# iwconfig ath0 essid " test1" ;使用无线网络名称接入
  21. [root@localhost /]# ifconfig ath0 192.168.22.196 ;不解释
  22. [root@localhost /]# ping 192.168.22.1            ;验证一下

二.文本处理
1.文本文件的编码

a. 查看文本文件的编码
在Vim 中可以直接查看文件编码 --> :set fileencoding  
b.转换文本文件的编码
iconv 转换,iconv的命令格式如下:
iconv -f encoding -t encoding inputfile -o outputfile
比如将一个UTF-16LE 编码的文件转换成UTF-8编码
iconv -f UTF-16LE -t UTF-8 file1 -o file2
其中 -f 是指from       -t是指to
c. 一个小脚本
作用是将ass字幕文件的编码由utf-16le转为utf-8
然后替换其分辨率由640×360为1024×576
  1. #!/bin/sh
  2. for assfile in `find . -name "*.ass"`
  3. do
  4.     echo $assfile
  5.     `iconv -f UTF-16LE -t UTF-8 $assfile -o $assfile.tmp`
  6.     mv $assfile.tmp $assfile
  7.     sed -'s/PlayResX: 640/PlayResX: 1024/' $assfile
  8.     sed -'s/PlayResY: 360/PlayResY: 576/' $assfile
  9. done
2.批量改mp3的title
现在很多音频播放器都按mp3内部的tags显示文件名,但是很多音频文件只有一个文件名,没有tags的名字
所以用了ffmpeg来改mp3文件的tags
  1. #!/bin/sh
  2. FFMPEG_OUT=/work/ffmpeg/out
  3. FFMPEG_LIB=$FFMPEG_OUT/lib
  4. FFMPEG_BIN=$FFMPEG_OUT/bin
  5. export LD_LIBRARY_PATH=$FFMPEG_LIB
  6. #./ffmpeg -/tmp/test/S1E07.mp3 -codec copy -metadata title="out1" -metadata album="" -metadata artist="" out1.mp3
  7. for mp3file in `find . -name "*.mp3"`
  8. do
  9.     echo "mp3file=$mp3file"
  10.     titlename=`echo "$mp3file" | sed 's/.mp3//'`
  11.     titlename=`echo "$titlename" | sed 's/.\///'`
  12.     echo "titlename=$titlename"
  13.     echo "$FFMPEG_BIN/ffmpeg -i $mp3file -codec copy -metadata title=\"$titlename\" -metadata album=\"\" -metadata artist=\"\" $mp3file.mp3"
  14.     $FFMPEG_BIN/ffmpeg -i $mp3file -codec copy -metadata title="$titlename" -metadata album="" -metadata artist="" $mp3file.mp3
  15.     mv $mp3file.mp3 $mp3file
  16. done
注意: ffmpeg是按照输出文件的后缀来转换格式的,如果输出文件为S1E07.mp3.tmp时,则ffmpeg会报如下错误:
Unable to find a suitable output format for 'S1E07.mp3.tmp'
3.去掉文件名中的空格
  1. #!/bin/sh
  2. find . -type f | while read F 
  3. do 
  4.     #echo "F=$F"
  5.     temp=`echo "$F" | sed 's/Friends //'`
  6.     #echo "temp=$temp"
  7.     echo "mv $F $temp"
  8.     mv "$F" $temp
  9. done


三.命令使用
3.1 zip 避免符号链接丢失
zip -ry  test.zip ./test/    -->加上y选项
3.2. pkg-config
  1. 查找路径:
  2. /usr/lib/pkgconfig
  3. /usr/lib/i386-linux-gnu/pkgconfig/
  4. /usr/lib/x86_64-linux-gnu/pkgconfig
  5. /usr/share/pkgconfig/
  6. 如果没有找到,则会查找 PKG_CONFIG_PATH 所定义的路径
  7. 使用自定义:
  8. export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/work/opencv/opencv-2.4.13/build/INSTALL/lib/pkgconfig/
  9. $ pkg-config --cflags opencv
  10. $ pkg-config --libs opencv

3.find使用
a. 把当前目录下面的*.zip,移动到/tmp下
find  .  -name "*.zip"  -exec mv {}   /tmp   \;
阅读(7046) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~