使用ubuntu PC开发ARM单板常用技巧总结

1、终端路径过长

最近一直在Ubuntu下用终端操作,看着他长长的路径名实在不爽, 动手来改改咯~

$: sudo vim ~/.bashrc

这个文件记录了用户终端配置

找到

if [ "$color_prompt " = yes ]; then
    PS1 ='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W \[\033[00m\]\$ '
else
    PS1 ='${debian_chroot:+($debian_chroot)}\u@\h:\W \$ '

将蓝色的w由小写改成大写,可以表示只显示当前目录名称.

安装Ubuntu的时候用户名起的很长,刚开始没怎么注意,命令行用的比较多的时候就发现这真是个失误。命令窗口就那么宽,前面很长都用了现在用户名和主机名了,后面如果再显示路径,剩余可以显示命令的空间就不够了。命令多行输入不方便也不直观,就想修改这个命令提示符。随便搜素了下,果然可以实现,而且非常简单。 
修改~/.bashrc文件中的PS1即可。 
PS1是主要的提示符设置,在ubuntu一般为: 
${debian_chroot:+($debian_chroot)}\u@\h:\w\$ 
具体的提示符,按分类含义如下: 
主要信息: 
\u 当前登录用户名 
\h 当前计算机名称(譬如ubuntu) 
\H 当前计算机的域名全程,譬如(ubuntu.ubuntu.com) 
\w 当前目录 
\W 当前目录的basename 
\$ 一般用户为$,root用户为> 
时间显示 
\t 当前时间(24小时制,HH:MM:SS 分别代表 小时:分钟:秒) 
\T 当前时间(12小时制) 
\@ 当前时间(AM/PM显示) 
\d 当前日期 
Shell信息: 
\v Bash版本 
\V Bash的发布版本号 
\S Shell名称 
\! Bash命令的历史编号 
\j job序号 
\l Shell的终端名称 
我是直接将用户名和主机写成固定的值,如shell@ubuntu 
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}shell@ubuntu: \w\a\]$PS1" 
要让改变立即生效source  ~/.bashrc即可 
完成后,命令提示符变成:shell@ubuntu:~$

2、修改hostname

直接用命令#hostname newname

修改/etc/hostname文件就可以了
  root@ubuntuServer:/etc#hostname “xxxx”
  但是这样一来在X下面,很多命令不正常,比如打开terminal出不来,原来还需要修改
  /etc/hosts文件,
  127.0.0.1 localhost.localdomain localhost newname

3、修改家目录下一些配置文件

# vim .bashrc 

alias ll='ls -alt'        (别名,对于部分命令的简化很方便,后面的PATH用于自己用户设置arm交叉编译工具路径)
alias la='ls -A'
alias l='ls -CF'

export PATH=$PATH:/home/yanghaibing/mmp3_q7/from_marvell/toolchain/armv7-marvell-linux-gnueabi-softfp_x86_64/bin

4、强大的图片和PDF互转换工具convert

# 转换所有jpg图片为pdf

$ find *.jpg -exec convert {} {}.pdf \\;

# 合并多个pdf

$ find *.jpg.pdf | xargs gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=test.pdf

linux下转换PDF为图片 

$ find *.pdf -exec convert {} {}.png \;

Introduce:

ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

The functionality of ImageMagick is typically utilized from the command line or you can use the features from programs written in your favorite language. Choose from these interfaces: G2F(Ada), MagickCore (C), MagickWand (C), ChMagick (Ch), ImageMagickObject (COM+), Magick++ (C++), JMagick (Java), L-Magick (Lisp), NMagick (Neko/haXe), MagickNet (.NET),PascalMagick (Pascal), PerlMagick (Perl), MagickWand for PHP (PHP), IMagick (PHP), PythonMagick (Python), RMagick (Ruby), or TclMagick (Tcl/TK). With a language interface, use ImageMagick to modify or create images dynamically and automagically.

convert logo: logo.gifidentify logo.gifdisplay logo.gif

official website:

http://www.imagemagick.org/script/index.php

5. covert mp3 to wav

convert wav to flac

http://flac.sourceforge.net/faq.html

Install mpg321 or mpg123

Type the following command under Debian / Ubuntu Linux, enter:

<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>sudo</strong></span> apt-get <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>install</strong></span> mpg321

OR

<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>sudo</strong></span> apt-get <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>install</strong></span> mpg123

I recommend using mpg123 as it is updated frequently.

Install mpg123 under CentOS / RHEL / Fedora Linux

Turn on rpmforge repo and type the following command:

yum <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>install</strong></span> mpg123

Convert an MP3 to WAV

The -w option will convert an .mp3 file to .wav file. The syntax is:

mpg123 -<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>w</strong></span> output.wav input.mp3

OR

mpg321 -<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>w</strong></span> output.wav input.mp3

A Sample Shell Script Helper Function

Add the following to your ~/.bashrc startup file (tested with bash v3.x+):

mp3towav<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>(</strong></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>)</strong></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>{</strong></span>
	<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>[</strong></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>[</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 120, 0); ">$#</span> -eq <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); ">0</span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>]</strong></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>]</strong></span> && <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>{</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>echo</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"mp3wav mp3file"</span>; <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>exit</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); ">1</span>; <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>}</strong></span>
	<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); "><strong>for</strong></span> i <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); "><strong>in</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"$@"</span>
	<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); "><strong>do</strong></span>
		<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(128, 128, 128); "><em># create .wav <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>file</strong></span> name</em></span>
		<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>local</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 120, 0); ">out=</span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"${i%/*}.wav"</span>
		<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>[</strong></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>[</strong></span> -f <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"$i"</span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>]</strong></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>]</strong></span> && <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>{</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>echo</strong></span> -n <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"Processing ${i}..."</span>; mpg123 -<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>w</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"${out}"</span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"$i"</span> &>/dev/null  && <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>echo</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"done."</span> || <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>echo</strong></span> <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"failed."</span>; <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>}</strong></span>
	<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); "><strong>done</strong></span>
<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(122, 8, 116); "><strong>}</strong></span>

Use it as follows:

mp3towav *.mp3
mp3towav <span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(255, 0, 0); ">"this is a test.mp3"</span>
<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(194, 12, 185); "><strong>ls</strong></span> *.wav

6. ADB server didn't ACK * failed to start daemon * 解决方案

   前几天请假了,回到公司后,打开电脑,插上手机,eclipse居然报ADB server didn't ACK * failed to start daemon *的错误,之前出这样的问题,都是:

  a. 查看任务管理器,关闭adb.exe进程,或者重新插一下手机,重启eclipse;

  b. 或者在eclipse里面的DDMS里面的devices区间右上角有个向下的箭头:


点击它,选择Reset adb;

  c. 或者就重启eclipse,再不行就重启电脑,基本上就能解决。

    但是,这次,都没用了,这次的情况是,adb启动了,但是立马就被杀掉了,有可能是被360给加入了屏蔽列表,这个好办,取消就行了;如果没有被屏蔽,就看看你的豌豆荚有没有开启,把豌豆荚关掉,再把手机重插一下,就行了,因为你在连手机的时候,如果豌豆荚开启了,则豌豆荚也会去开启adb,就会导致eclipse开启adb失败而连不上。

    其实豌豆荚只是用来装驱动的,没有它照样可以再eclipse中调试程序,建议在豌豆荚的设置中取消连接手机的时候自动开启豌豆荚的功能,这样,就没问题了。


7.  ctrl + H ubuntu show hidden files

8. ubuntu 绘图软件

sudo apt-get install dia

      Dia是一款和MS Visio类似的绘制流程图、UML图、电路图、网络、数据库等结构化图形的工具,可以读取和储存流程图到自定的档案格式和导出成postscript,并能够输出为EPS、SVG、XFIG、WMF、PNG等各种格式。这是个跨平台的开源软件,在Linux、Windows上都可以使用。

9. search a string from one file and copy to another file

# grep "aaa" 1.txt>> 2.txt
// search "aaa" from 1.txt and copy to 2.txt
# grep -i "aaa" -A 1 1.txt | grep -v -e "--" >>2.txt

# awk '/aaa/{getline var;print $1 "\n" var}' 1.txt >> 2.txt




你可能感兴趣的:(使用ubuntu PC开发ARM单板常用技巧总结)