Category Archives: Linux

Ubuntu 过期版本更新

Ubuntu 如果某个版本的生命周期已经结束, 更新就没法进行了, 会出现类似下面的错误:

mohd-arafat-hossain@TUD:~$ sudo apt-get update
[sudo] password for mohd-arafat-hossain:
Ign http://bd.archive.ubuntu.com precise InRelease
Ign http://bd.archive.ubuntu.com precise-updates InRelease                     
Ign http://bd.archive.ubuntu.com precise-backports InRelease                   
Ign http://bd.archive.ubuntu.com precise Release.gpg                           
Ign http://bd.archive.ubuntu.com precise-updates Release.gpg                   
Ign http://bd.archive.ubuntu.com precise-backports Release.gpg                 
Ign http://bd.archive.ubuntu.com precise Release                               
Ign http://bd.archive.ubuntu.com precise-updates Release                       
Ign http://bd.archive.ubuntu.com precise-backports Release                     
Ign http://extras.ubuntu.com precise InRelease                                 
Ign http://ppa.launchpad.net precise InRelease                                 
Hit http://extras.ubuntu.com precise Release.gpg                     
Hit http://ppa.launchpad.net precise Release.gpg                     
Hit http://extras.ubuntu.com precise Release                         
Hit http://ppa.launchpad.net precise Release                                   
Hit http://extras.ubuntu.com precise/main Sources                              
Hit http://bd.archive.ubuntu.com precise/main TranslationIndex                 
Hit http://ppa.launchpad.net precise/main Sources                              
Hit http://bd.archive.ubuntu.com precise/multiverse TranslationIndex           
Hit http://bd.archive.ubuntu.com precise/restricted TranslationIndex           
Hit http://extras.ubuntu.com precise/main i386 Packages              
Ign http://extras.ubuntu.com precise/main TranslationIndex                     
Hit http://bd.archive.ubuntu.com precise/universe TranslationIndex             
Hit http://ppa.launchpad.net precise/main i386 Packages                        
Ign http://ppa.launchpad.net precise/main TranslationIndex                     
Ign http://security.ubuntu.com precise-security InRelease                      
Hit http://security.ubuntu.com precise-security Release.gpg                    
Hit http://bd.archive.ubuntu.com precise-updates/main TranslationIndex         
Hit http://security.ubuntu.com precise-security Release                        
Hit http://bd.archive.ubuntu.com precise-updates/multiverse TranslationIndex   
Hit http://bd.archive.ubuntu.com precise-updates/restricted TranslationIndex   
Hit http://bd.archive.ubuntu.com precise-updates/universe TranslationIndex
Hit http://security.ubuntu.com precise-security/main Sources         
Ign http://extras.ubuntu.com precise/main Translation-en_US                    
Ign http://ppa.launchpad.net precise/main Translation-en_US                    
Ign http://extras.ubuntu.com precise/main Translation-en             
Hit http://bd.archive.ubuntu.com precise-backports/main TranslationIndex
Hit http://bd.archive.ubuntu.com precise-backports/multiverse TranslationIndex
Hit http://bd.archive.ubuntu.com precise-backports/restricted TranslationIndex
Ign http://ppa.launchpad.net precise/main Translation-en
Hit http://bd.archive.ubuntu.com precise-backports/universe TranslationIndex   
Hit http://bd.archive.ubuntu.com precise/main Translation-en                   
Hit http://bd.archive.ubuntu.com precise/multiverse Translation-en             
Hit http://bd.archive.ubuntu.com precise/restricted Translation-en
Hit http://bd.archive.ubuntu.com precise/universe Translation-en
Hit http://security.ubuntu.com precise-security/restricted Sources             
Hit http://security.ubuntu.com precise-security/universe Sources               
Hit http://security.ubuntu.com precise-security/multiverse Sources             
Hit http://security.ubuntu.com precise-security/main i386 Packages             
Hit http://security.ubuntu.com precise-security/restricted i386 Packages
Hit http://bd.archive.ubuntu.com precise-updates/main Translation-en           
Hit http://bd.archive.ubuntu.com precise-updates/multiverse Translation-en     
Hit http://security.ubuntu.com precise-security/universe i386 Packages
Hit http://security.ubuntu.com precise-security/multiverse i386 Packages
Hit http://security.ubuntu.com precise-security/main TranslationIndex
Hit http://security.ubuntu.com precise-security/multiverse TranslationIndex    
Hit http://security.ubuntu.com precise-security/restricted TranslationIndex    
Hit http://security.ubuntu.com precise-security/universe TranslationIndex      
Hit http://bd.archive.ubuntu.com precise-updates/restricted Translation-en     
Hit http://bd.archive.ubuntu.com precise-updates/universe Translation-en       
Hit http://security.ubuntu.com precise-security/main Translation-en
Hit http://security.ubuntu.com precise-security/multiverse Translation-en      
Hit http://security.ubuntu.com precise-security/restricted Translation-en      
Hit http://security.ubuntu.com precise-security/universe Translation-en        
Hit http://bd.archive.ubuntu.com precise-backports/main Translation-en         
Hit http://bd.archive.ubuntu.com precise-backports/multiverse Translation-en
Hit http://bd.archive.ubuntu.com precise-backports/restricted Translation-en
Hit http://bd.archive.ubuntu.com precise-backports/universe Translation-en
Err http://bd.archive.ubuntu.com precise/main Sources     
  404  Not Found
Err http://bd.archive.ubuntu.com precise/restricted Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise/universe Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise/multiverse Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise/main i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise/restricted i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise/universe i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise/multiverse i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/main Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/restricted Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/universe Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/multiverse Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/main i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/restricted i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/universe i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-updates/multiverse i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/main Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/restricted Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/universe Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/multiverse Sources
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/main i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/restricted i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/universe i386 Packages
  404  Not Found
Err http://bd.archive.ubuntu.com precise-backports/multiverse i386 Packages
  404  Not Found
W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/main/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/restricted/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/universe/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/multiverse/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/restricted/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/universe/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise/multiverse/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/main/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/restricted/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/restricted/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/universe/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-updates/multiverse/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/main/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/restricted/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/universe/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/multiverse/source/Sources  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/main/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/restricted/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/universe/binary-i386/Packages  404  Not Found

W: Failed to fetch http://bd.archive.ubuntu.com/ubuntu/dists/precise-backports/multiverse/binary-i386/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

可以用如下的方法解决:

  • 备份先有的配置文件:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  • 替换源地址:
    sudo sed -i -e 's/ca.archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

    这里的 ca.archive.ubuntu.com 就是之前在更新时提示错误的 url 里的一部分, 根据实际情况替换.

  • 运行更新命令:
    sudo apt-get update

Ubuntu 15.04 上安装最新版本 mongodb

1

Import the public key used by the package management system.

The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
2

Create a list file for MongoDB.

Create the /etc/apt/sources.list.d/mongodb-org-3.0.list list file using the following command:

echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
3

Reload local package database.

Issue the following command to reload the local package database:

sudo apt-get update
4

Install the MongoDB packages.

You can install either the latest stable version of MongoDB or a specific version of MongoDB.

Install the latest stable version of MongoDB.

Issue the following command:

sudo apt-get install -y mongodb-org

Ubuntu 上安装最新版本的 ffmpeg

Install FFmpeg 2.7 Multimedia Framework and convert multimedia files on Linux Ubuntu Systems. Install FFmpeg 2.7 on Ubuntu 15.04, Ubuntu 14.04 and Derivatives. Below are the Terminal commands to upgrade to FFmpeg 2.7 on Linux.

FFmpeg 2.7 is a popular cross-platform solution to record, convert and stream audio and video. It includes libavcodec – the leading audio/video codec library.

FFmpeg 2.7 on Ubuntu 15.04

Run the following commands in Terminal to install FFmpeg 2.7 on Ubuntu 15.04, Ubuntu 14.04, Linux Mint 17.2, Linux Mint 17.1, Linux Mint 17 and Derivatives:

$ sudo apt-add-repository ppa:samrog131/ppa
$ sudo apt-get update
$ sudo apt-get install ffmpeg-real
$ sudo ln -sf /opt/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg

If you wish to uninstall and remove the FFmpeg 2.7 from Linux Ubuntu Systems, run the following command in Terminal:

$ sudo apt-get remove ffmpeg
$ sudo rm /opt/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg

Install FFmpeg on Debian 8.0 Jessie

Run the following commands in Terminal to install FFmpeg 2.7 on Debian 8.0 Jessie:

$ sudo sh -c 'echo "deb http://www.deb-multimedia.org jessie main" >> /etc/apt/sources.list'
$ sudo apt-get update
$ sudo apt-get install deb-multimedia-keyring
$ sudo apt-get install ffmpeg

If you wish to uninstall and remove the FFmpeg 2.7 from Debian 8.0 Jessie, run the following command:

$ sudo apt-get remove ffmpeg
$ sudo rm /opt/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg

Install FFmpeg on Fedora 22

Run the following command to install the latest FFmpeg version (FFmpeg 2.7 “Nash”) on Fedora 22:


$ sudo yum install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-22.noarch.rpm
$ sudo yum update
$ sudo yum install ffmpeg

Install FFmpeg on Fedora 21

Run the following command to install the latest FFmpeg version (FFmpeg 2.7 “Nash”) on Fedora 21:

$ sudo yum install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-21.noarch.rpm
$ sudo yum update
$ sudo yum install ffmpeg

If you wish to uninstall and remove the FFmpeg 2.7 from Fedora Systems, run the following command:

$ sudo yum remove ffmpeg

OpenGL学习-环境配置(Ubuntu+Eclipse)

前几天买了本《OpenGL超级宝典(第5版)》打算认真地学习点OpenGL的东西了,不过,首先遇上的麻烦事就是环境配置,在我的Thinkpad 510(Window8+VS2012)下我是怎么也没能配置好,按照书的上说明一步步来,好容易编译成功,但是只要有调用glxxx这样东西的地方立马报错,哎,之前没做过C++的程序,看到这种错误也不知如何解决,网上找了找,有说是因为显卡的问题,不支持OpenGL 3,实在找不到解决办法,就想到到其他系统中试了,我虚拟机里有Mac OS X 和 Ubuntu,不过我一直不喜欢Mac OS X, 只是工作所需才安装的,所以还是到Ubuntu下进行配置了。折腾了N久之后,终于算是配置成功了,大致步骤如下:
1. 下载安装Eclipse及C++的开发扩展CDT, 开始我是从 Ubuntu Soft Center 里直接下载的,不过似乎之后在安装C++扩展时打不开安装扩展的窗口,不知何故,后来直接去官网下了一个把这个给覆盖了就正常了。
2. 在Ubuntu Soft Center下安装如下几个包:libglu1-mesa-dev, freeglut3-dev, libglew1.6-dev.
3. 在Eclipse下打开书中的GLTools项目并编译,我是用了刚刚系统装的glew,所以就把这个项目里的与这个相关的文件给删除了。具体设置如图:

4. 在Eclipse下打开书中的Triangle项目并编译,具体设置如图:

终于,这个丑陋的三角形出现在我的面前了,啊哈哈。。。

关于Photoshop中图层的批量导出

最近又遇上了一个项目,需要把Photoshop中的各层全部导成相应的图片,并且要获取相应的图片在Photoshop中的实际位置的信息,用于在网页中重新生成与Photoshop中一样的整图的效果,于是整了一个JSX的脚本,似乎还挺有用处的,可以将photoshop中相应层中的图片先裁切掉多余的空白,之后将它们保存,并且最终生成一个xml文档或者是json的文档将相应的图像位置信息保存在其中。

不过还有几点问题:

1. PSD中不能有重名的层,重名的层中的图片会被相互覆盖。

2. PSD中不要有空层,有可能会引起错误。

时间紧,也没时间去完善,只能将就一下了。

另外直接用这个在图片出现重叠时会比较麻烦,好在有另一个强大的软件:TexturePacker(http://www.texturepacker.com),这个软件可以在Mac,Windows,Ubuntu等多个主流操作系统上运行, 可以从SWF或者直接将多张图合并成一张纹理图,同时可以生成相应格式的数据,包括JSON格式的,并且这个软件对于有技术类博客的网友,可以免费提供注册证书,无需花银子了,我的就是用的免费的,软件作者还很友好的,配合这个工具,再多的图也可以轻松排了。