一.系统使用
1.1 硬盘安装ubuntu时
-
ubuntu@ubuntu:~$ mount
-
/dev/sda1 on /isodevice type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
-
ubuntu@ubuntu:~$ sudo umount -l /isodevice
1.2 进入系统之后
a.如果有双系统,需要重引更新一下引导
-
cong@msi:~$ sudo update-grub2
-
[sudo] password for cong:
-
Sorry, try again.
-
[sudo] password for cong:
-
Generating grub configuration file ...
-
Found linux image: /boot/vmlinuz-4.4.0-31-generic
-
Found initrd image: /boot/initrd.img-4.4.0-31-generic
-
Found memtest86+ image: /boot/memtest86+.elf
-
Found memtest86+ image: /boot/memtest86+.bin
-
Found Windows 7 (loader) on /dev/sda1
-
done
b.更新源列表
-
cong@msi:~$ sudo apt-get update //更新源,这样apt-get install 才可以用
1.3 安装cario-dock
-
cong@msi:~$ sudo apt-get install cairo-dock
-
重启,在登陆时
-
Select desktop environment
-
切换到cario-dock,图标是一个CD
-
1.4 配置vim
-
cong@msi:/work$ tar xf ./vim.tar.gz -C ~ #将以前的vim配置包解压
-
-
cong@msi:/work$ sudo apt-get install vim #如果不执行这一步打开vim时会有如下错误
-
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'
-
cong@msi:/work$ sudo apt-get install exuberant-ctags #安装ctags
-
1.5安装chrome浏览器
-
进入 http://www.chromeliulanqi.com/ 下载deb包
-
cong@msi:~/Downloads$ sudo dpkg -i ./google-chrome-stable_current_amd64.deb
-
google-chrome-stable depends on libappindicator1; however: Package libappindicator1 is not installed.
-
dpkg: error processing package google-chrome-stable (--install): #安装时会提示缺少一个依赖包
-
dependency problems - leaving unconfigured
-
-
cong@msi:~/Downloads$ sudo apt-get -f install #重新安装即可
1.6 fcitx的安装
-
a. 安装
-
cong@msi:~$ sudo apt-get install fcitx-table-wbpy #这一条命令就会把fcitx及wbpy这两个都安装了
-
#cong@msi:~$ sudo apt-get install fcitx-pinyin fcitx-table-wubi #下面是备选的码表
-
b.配置码表
-
#只安装不行,还要把码表放在fcitx中
-
cong@msi:~$ fcitx-configtool
-
如果里面只有一项 Keyboard-English(US)则需要添加码表
-
点左下方的+ --> 去掉 only Show Current Language前面的勾 -->选中WubiPinyin后点OK,这样就把WubiPinyin加到码表里面去了。
-
c.将fcitx作为默认的输入法
-
system_settings --> language Support--> Keyboard input method system -->fcitx
-
d. 重启后生效
-
cong@msi:~$ sudo reboot #重启后用ctrl+space 切换
1.7 编译环境
a. ubuntu64位兼容32位
-
cong@msi:/work$ sudo apt-get install gcc-multilib g++-multilib
b. 内核的menuconfig
-
cong@msi:/tmp/minix$ sudo apt-get install libncurses5-dev
1.8 将ubuntu的中文环境为英文环境
-
cong@msi:/work$ sudo vi /etc/default/locale
-
: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.将按钮放在右边
-
按照以前的办法用gconf-editor不行了,因为在gconf-editor-->apps中没有metacity
-
用下面这个方法:
-
cong@msi:~$ gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close
1.10 startdict词典的安装
-
a. cong@msi:~$ sudo apt-get install stardict
-
b. 下载词典: http://abloz.com/huzheng/stardict-dic/zh_CN/
-
c. 将下载的词典解压到dict目录下即可
-
cong@msi:~/Downloads$ sudo tar xf ./stardict-langdao-ce-gb-2.4.2.tar.bz2 -C /usr/share/stardict/dic/
-
cong@msi:~/Downloads$ sudo tar xf ./stardict-langdao-ec-gb-2.4.2.tar.bz2 -C /usr/share/stardict/dic/
-
cong@msi:~/Downloads$ sudo tar xf ./stardict-oxford-gb-2.4.2.tar.bz2 -C /usr/share/stardict/dic/
-
d. 重启startdict,点右下方的小齿轮manage dictionaries就看到新添加的词典了
1.11 virtualbox的安装
-
a. 到 去下载virtulbox
-
b. cong@msi:~$ sudo dpkg -i ./Downloads/virtualbox-5.1_5.1.6-110634-Ubuntu-trusty_amd64.deb
-
dpkg: dependency problems prevent configuration of virtualbox-5.1:
-
virtualbox-5.1 depends on libsdl1.2debian (>= 1.2.11); however:
-
Package libsdl1.2debian is not installed. #缺少依赖包
-
-
dpkg: error processing package virtualbox-5.1 (--install):
-
dependency problems - leaving unconfigured
-
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 在系统中的路径
-
~/.wine/drive_c/users/cong/My\ Documents/Source\ Insight/Settings/
c. 配置source insight的字体
-
c.1 左侧边栏 -->右键Symbol Window Properties --> Font
-
c.2 中间字体 --> Options--> Document Options(或者Alt+t)--> ScreenFonts
-
c.3 右侧 右键-->Font
1.13 ssh的安装
-
cong@msi:~$ sudo apt-get install openssh-server -->安装ssh
-
-
cong@msi:~$ sudo ps -ef | grep "ssh"
-
root 11453 1 0 00:48 ? 00:00:00 /usr/sbin/sshd -D -->有sshd说明ssh的server己启动
-
cong@msi:~$ sudo service ssh start -->如果没有启动,则start
-
start: Job is already running: ssh
-
cong@msi:~$ sudo service ssh restart -->重启动ssh
-
ssh stop/waiting
-
ssh start/running, process 11546
1.14 nfs server的安装
-
cong@msi:~$ sudo apt-get install nfs-common nfs-kernel-server
-
cong@msi:~$ sudo vi /etc/exports
-
/work *(rw,sync,no_subtree_check,no_root_squash) -->设置共享目录
-
/tmp/ *(rw,sync,no_subtree_check,no_root_squash,insecure)
-
解释:
-
sync--> 将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性;
insecure--> 允许客户端从大于1024的tcp/ip端口连接服务器;
no_root_squash--> 此时root用户的身份被压缩为NFS server上面的root
no_subtree_check--> 即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;
-
cong@msi:~$ sudo service nfs-kernel-server start
-
-
cong@redhat:~$ sudo mount -t nfs 192.168.1.101:/work/ ./work
-
-->注意这儿不要和scp混了,路径前没有用户名
1.14.1 nfs mount出错
-
cong@msi:/tmp$ sudo mount -t nfs 192.168.4.93:/work/os/ /mnt/
-
mount: wrong fs type, bad option, bad superblock on 192.168.4.93:/work/os/,
-
missing codepage or helper program, or other error
-
(for several filesystems (e.g. nfs, cifs) you might
-
need a /sbin/mount.<type> helper program)
-
In some cases useful info is found in syslog - try
-
dmesg | tail or so
查看/sbin/mount*,发现的确没有mount.nfs
-
cong@msi:/tmp$ ls /sbin/mount.*
-
/sbin/mount.fuse /sbin/mount.ntfs /sbin/mount.ntfs-3g /sbin/mount.vboxsf
解决方法:
-
cong@msi:/tmp$ sudo apt-get install nfs-common
1.15 samba的安装
-
cong@msi:/work$ sudo apt-get install samba samba-common
-
-
cong@msi:/work$ sudo mkdir /work
-
-
cong@msi:/work$ sudo chown cong:cong /work/
-
-
cong@msi:/work$ sudo vi /etc/samba/smb.conf -->添加如下
-
[share]
-
path = /work
-
available = yes
-
browsealbe = yes
-
public = yes
-
writable = yes
-
cong@msi:/work$ sudo /etc/init.d/smbd restart
如果windows下只有读没有写的权限,执行如下操作:
-
解决:smbd不能启动的问题:
-
a. 将smbd的启动信息打印出来
-
sudo /usr/sbin/smbd -F -d 10 -S
-
b. 出现如下信息:
-
doing parameter security = share
-
WARNING: Ignoring invalid value 'share' for parameter 'security'
-
pm_process() returned No
-
lp_servicenumber: couldn't find homes
-
error opening config file '/etc/samba/smb.conf'
-
c. 修改/etc/samb/smb.conf
-
将 security = share 改为 security = user
-
[参考]
1.16 常用配置
a. bashrc
-
# some more ls aliases
-
alias ll='ls -alF'
-
alias la='ls -A'
-
alias l='ls -CF'
-
alias l='ls -CF'
-
alias cd1='cd ../'
-
alias cd2='cd ../../'
-
alias cd3='cd ../../../'
-
alias cd4='cd ../../../../'
-
alias cd5='cd ../../../../../'
-
alias cd6='cd ../../../../../../'
-
alias cd7='cd ../../../../../../../'
-
alias cd8='cd ../../../../../../../../'
-
alias cd9='cd ../../../../../../../../../'
-
alias cd10='cd ../../../../../../../../../../'
-
alias r='reset
-
alias grep='grep --color=auto' -->这样grep就带颜色了
b. gp -->grep
-
cong@msi:/usr/local/bin$ cat gp
-
#!/bin/sh
-
grep "$1" * -R --color=auto
c. si -->open source insight
-
cong@msi:/usr/local/bin$ cat si
-
#!/bin/sh
-
wine "C:\Program Files (x86)\Source Insight 3\insight3.exe" 1>/dev/null 2>&1 &
d.foxit
-
cong@msi:~/Downloads$ cat /usr/local/bin/foxit
-
#!/bin/sh
-
wine /work/bak/soft/FoxitReader/Foxit\ Reader.exe 1>/dev/null 2>&1 &
d. adbr
-
cong@msi:/usr/local/bin$ cat adbr
-
#!/bin/sh
-
sudo /work/bak/android/androidSDK/platform-tools/adb kill-server
-
sudo /work/bak/android/androidSDK/platform-tools/adb start-server
-
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
-
sun@ubuntu:/usr/share/applications$ sudo update-alternatives --install /usr/bin/java java /opt/andorid/jdk1.6.0_24/bin/java 300
-
-
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
-
今天开机发现ubuntu分辨率不正常只有1024×768, Displays选项卡下面最大的分辨率是1024×768
-
a.
-
sun@ubuntu:~$ xrandr
-
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
-
VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
-
1024x768 60.0*
-
800x600 60.3 56.2
-
848x480 60.0
-
640x480 59.9
-
sun@ubuntu:~$ cvt 1440 900
-
# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
-
Modeline "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
-
sun@ubuntu:~$ xrandr
-
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
-
VGA1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
-
1024x768 60.0*
-
800x600 60.3 56.2
-
848x480 60.0
-
640x480 59.9
-
sun@ubuntu:~$ cvt 1440 900
-
# 1440x900 59.89 Hz (CVT 1.30MA) hsync: 55.93 kHz; pclk: 106.50 MHz
-
Modeline "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
-
sun@ubuntu:~$ xrandr --newmode "1440x900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync 中间的×与*容易混淆
-
sun@ubuntu:~$ xrandr --newmode "1440*900_60.00" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync
-
sun@ubuntu:~$ xrandr --addmode VGA1 1440*900_60.00
-
sun@ubuntu:~$ xrandr --output VAG1 --mode 1440*900_60.00
-
warning: output VAG1 not found; ignoring
-
sun@ubuntu:~$ xrandr --output VAG1 --mode 1440*900_60.00^C
-
sun@ubuntu:~$ sudo cp /etc/X11/xorg.conf.failsafe /etc/X11/xorg.conf
-
[sudo] password for sun:
-
sun@ubuntu:~$ vi /etc/X11/xorg.conf
-
sun@ubuntu:~$ sudo gedit /etc/X11/xorg.conf
-
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
-
出来了,终于可以将分辨率调高了!
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报错
-
[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无线配置
-
[root@localhost /]# ifconfig eth0 down ;首先关闭有线网卡
-
[root@localhost /]# wlanconfig ath0 create wlandev wifi0 wlanmode sta ;如果没有无线则创建
-
[root@localhost /]# ifconfig ath0 up ;启动无线网卡ath0
-
[root@localhost /]# ifconfig ;查看无线信息,出现HWaddr 00:12:34:56:78:90
-
[root@localhost /]# iwlist ath0 scan
-
ath0 Scan completed :
-
Cell 01 - Address: 00:1F:64:E1:96:51
-
ESSID:"test1"
-
Mode:Master
-
Frequency:2.412 GHz (Channel 1)
-
Quality=50/94 Signal level=-71 dBm Noise level=-121 dBm
-
Encryption key:off
-
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
-
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
-
48 Mb/s; 54 Mb/s
-
Extra:bcn_int=100
-
Extra:rsn_ie=30140100000fac020100000fac020100000fac020000
-
Extra:wme_ie=dd180050f2020101020003a4000027a4000042435e0062322f00
-
Extra:ath_ie=dd0900037f01010000ff7f
-
[root@localhost /]# iwconfig ath0 essid " test1" ;使用无线网络名称接入
-
[root@localhost /]# ifconfig ath0 192.168.22.196 ;不解释
-
[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
-
#!/bin/sh
-
for assfile in `find . -name "*.ass"`
-
do
-
echo $assfile
-
`iconv -f UTF-16LE -t UTF-8 $assfile -o $assfile.tmp`
-
mv $assfile.tmp $assfile
-
sed -i 's/PlayResX: 640/PlayResX: 1024/' $assfile
-
sed -i 's/PlayResY: 360/PlayResY: 576/' $assfile
-
done
2.批量改mp3的title
现在很多音频播放器都按mp3内部的tags显示文件名,但是很多音频文件只有一个文件名,没有tags的名字
所以用了ffmpeg来改mp3文件的tags
-
#!/bin/sh
-
FFMPEG_OUT=/work/ffmpeg/out
-
FFMPEG_LIB=$FFMPEG_OUT/lib
-
FFMPEG_BIN=$FFMPEG_OUT/bin
-
export LD_LIBRARY_PATH=$FFMPEG_LIB
-
#./ffmpeg -i /tmp/test/S1E07.mp3 -codec copy -metadata title="out1" -metadata album="" -metadata artist="" out1.mp3
-
for mp3file in `find . -name "*.mp3"`
-
do
-
echo "mp3file=$mp3file"
-
titlename=`echo "$mp3file" | sed 's/.mp3//'`
-
titlename=`echo "$titlename" | sed 's/.\///'`
-
echo "titlename=$titlename"
-
echo "$FFMPEG_BIN/ffmpeg -i $mp3file -codec copy -metadata title=\"$titlename\" -metadata album=\"\" -metadata artist=\"\" $mp3file.mp3"
-
$FFMPEG_BIN/ffmpeg -i $mp3file -codec copy -metadata title="$titlename" -metadata album="" -metadata artist="" $mp3file.mp3
-
mv $mp3file.mp3 $mp3file
-
done
注意: ffmpeg是按照输出文件的后缀来转换格式的,如果输出文件为S1E07.mp3.tmp时,则ffmpeg会报如下错误:
Unable to find a suitable output format for 'S1E07.mp3.tmp'
3.去掉文件名中的空格
-
#!/bin/sh
-
find . -type f | while read F
-
do
-
#echo "F=$F"
-
temp=`echo "$F" | sed 's/Friends //'`
-
#echo "temp=$temp"
-
echo "mv $F $temp"
-
mv "$F" $temp
-
done
三.命令使用
3.1 zip 避免符号链接丢失
zip -ry test.zip ./test/ -->加上y选项
3.2. pkg-config
-
查找路径:
-
/usr/lib/pkgconfig
-
/usr/lib/i386-linux-gnu/pkgconfig/
-
/usr/lib/x86_64-linux-gnu/pkgconfig
-
/usr/share/pkgconfig/
-
如果没有找到,则会查找 PKG_CONFIG_PATH 所定义的路径
-
使用自定义:
-
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/work/opencv/opencv-2.4.13/build/INSTALL/lib/pkgconfig/
-
$ pkg-config --cflags opencv
-
$ pkg-config --libs opencv
3.find使用
a. 把当前目录下面的*.zip,移动到/tmp下
find . -name "*.zip" -exec mv {} /tmp \;
阅读(7153) | 评论(0) | 转发(2) |