Ubuntu下文件关联

需要涉及到以下几个目录和文件
~/.local/share/applications
/etc/gnome/defaults.list
/usr/share/applications
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
去这几个目录看一下,就会发现很多以 desktop 为后缀的文件。
这些文件是多功能的,第一,它们是组成GNMOE的“开始”菜单的一部分,即“开始”
菜单里的一些应用程序项,在这里都能找到。你可以运行 alacarte , 这里会
列出整个菜单的结构,你可以编辑它,但是很多项你没法删除,因为没有权限,
你试着用root权限去运行 alacarte ,抱歉,你还是没有权限删除,要删除它们,
只有在/usr/share/applications下面找到对应的文件,直接删除这个文件即可。
从总体上讲
/etc/gnome/defaults.list 保存了全局的打开方式 
~/.local/share/applications/defaults.list 保存了个人的打开方式 
当两着不一致是,优先采用局部的个人设置。
~/.local/share/applications 
/usr/share/applications 
这两个分别是局部的desktop项和全局的desktop项 
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
这两个分别是全局的和局部的打开方式缓存
先看一下/etc/gnome/defaults.list的结构
[Default Applications]
application/csv=gnumeric.desktop
application/excel=ooo-calc.desktop
application/msexcel=ooo-calc.desktop
application/msword=ooo-writer.desktop
application/ogg=mplayer.desktop
application/pdf=evince.desktop
application/postscript=evince.desktop
.................
text/x-chdr=vim.desktop
text/x-csrc=vim.desktop
text/x-dtd=vim.desktop
text/x-java=vim.desktop
text/mathml=vim.desktop
text/x-python=vim.desktop
text/x-sql=vim.desktop
text/xml=firefox.desktop
video/dv=mplayer.desktop
video/mp4=mplayer.desktop
video/mpeg=mplayer.desktop
video/msvideo=mplayer.desktop
video/quicktime=mplayer.desktop
video/vnd.rn-realvideo=mplayer.desktop
video/x-anim=mplayer.desktop
video/x-avi=mplayer.desktop
video/x-flc=mplayer.desktop
......................
不难发现
是这样的一种形式
程序的类型/文件类型=打开这个文件的项[;项2]...[;项n]
候选打开方式可以有好几种
中间用;隔开,不留其余字符
要修改一个文件的打开方式,需要先确定这个文件的类型
以纯文本文件为例 类型是plain 打开方式默认为vim.desktop
候选的是firefox.desktop
text/plain=vim.desktop;firefox.desktop
可以直接编辑
~/.local/share/applications/defaults.list
/etc/gnome/defaults.list
编辑完之后,手工修改
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/mimeinfo.cache
这两个cache文件。
这样就立即生效了
下面看一下desktop文件的结构
[Desktop Entry]
Encoding=UTF-8 //字符编码
Name=vim  //现实的名字
MimeType=text/plain; //类型
Exec=vim %f //运行的程序 %f表示一个参数
Type=Application //类型
Terminal=true //是否使用终端
NoDisplay=true //是否显示在gnome菜单里
知道这些
就可以很方便的定制“开始”菜单和文件的打开方式了

Ubuntu 14.04使用内置指纹识别(Dell E5400内置AuthenTec AES2550/AES2810)

一、添加 PPA 软件源

打开 System(系统)> Administration(管理) > Software Sources(软件和更新),在 Other Software(其它软件)标签下添加:

ppa:fingerprint/fprint

然后按照提示重加载软件列表。

Software_Sources

Other_SoftwareInput_Ohter_Software

熟悉命令行操作的话,直接在命令行中执行

$ sudo add-apt-repository ppa:fingerprint/fprint

$ sudo apt-get update

二、安装并测试 FPrint 指纹识别软件

打开 Applications(应用程序)> Ubuntu Software Center(Ubuntu 软件中心),在搜索框搜索 fprint-demo,安装第一项。

完成后,打开 Applications(应用程序)> fprint project demo,检查是否能够找到设备,此时不用进行登记。

fprint-demo

fprint_project_demo

三、安装 PAM 模块

打开 Ubuntu Software Center,搜索并安装 libpam-fprintd 。并且安装.

这里请仔细回忆您有没有修改过 /etc/pam.d/common-auth,若没有,则不需要做别的操作,否则还请按 Ctrl-Alt-T 打开终端,运行

$ sudo pam-auth-update --force

四、登记指纹

打开 System(系统)> Preferences(首选项)> User Account(用户账户),点选“Fingerprint Login(指纹登录)”并按提示操作即可。

fprint_login

五、现在可以卸载 fprint project demo 了,这个只是我们测试用的,不再需要了.

Ubuntu 14 Remmina 远程桌面提示 “无法连接到RDP服务器”

Ubuntu 中用 Remmina 远程桌面来登陆管理远程的Windows 电脑还是非常方便的,但是有时候会发生莫名的报错  “无法连接到RDP服务器” ,此时在命令行下面调用 rdesktop 是可以正常连接到服务器的,但是 Remmina 就不行了,找了半天找到解决方法。

删除 ~/.freerdp/known_hosts 即可,貌似是被控端的证书变更了,或者失效了,系统没有及时更新,导致异常。

另外,如果不能正确的保存新建的连接信息,看看 ~/.remmina 目录是不是被删除了,貌似 Remmina 不会自动创建目录,这个需要手工创建一个就OK 了。

Linux基础:分析 Ubuntu 磁盘使用情况

在这篇文章中,我将指导你们如何在 Ubuntu 中对磁盘使用情况进行分析。为了确保系统的健康,运行的流畅,时常关心机器的硬盘,适当的运行一些分析是非常重要的,当然,运行这些分析是很容易的。为了完成分析,我们将使用一款非常棒的图形工具,名叫Baobab

在 下一步操作之前,我可以告诉你们,它的使用非常简单,功能齐全,我确定它能够满足你的需求。Baobab 是 gnome-utils 的一部分,但是自从Gnome3.4版本后,已经作为独立应用。通过使用这个磁盘分析工具,你可以轻松扫描文件夹,文件系统,不单是本地,远程目录一样可 以轻松分析。

只需轻轻点击,便可以搞定一切!想要停止扫描?简单,在 baobab 用户界面的顶部,轻点 Stop scanning 按钮,完成。

我喜欢这个工具的简单性并且可以图形化表示数据,像饼状图和树形图。那么,现在你们在自己的机子上安装使用如何呢?

据我所知,ubuntu已经默认安装,如果没有,打开一个新终端(CTRL+ALT+T),然后运行下列命令来安装它。

sudo apt-get install baobab

安装完毕后,会分类至应用程序, 系统工具, 磁盘分析器,或者,直接使用下列命令,在终端中运行baobab。

baobab

下列图片显示了当它在你的机器运行时的界面。baobab1 如需扫描 Home 目录,点击 Scan Home 或者 Analyzer->Scan Home Folder 选项。完成扫描后,工具会做很多分析,耐心等待分析结果吧!

baobab2

正如上图所见,baobab 扫描结果提供给我们很多信息,包括 Home 目录中每一个文件夹的使用情况、大小,以及所拥有文件数。右边有一个饼状示意图。如果你喜欢,选择上方的 View as Treemap Chart,你可以轻松地把它换成树状图。

下图显示的是,选择树状图代替默认的饼状图的界面。

baobab3

如需扫描文件系统,选择 Analyzer->Scan Filesystem ,如果你懒得去点击这些,有一个简单方法,快捷键CTRL+F

选择你喜欢的方式,两个方法都会起效并做同样的扫描。快捷键的确易用省时,但是如果不是天天用这个工具,也很难同时记住所有快捷键。

baobab4

如何扫描文件夹?简单!Analyzer-> Scan A Folder -> 选择你想要扫描的文件夹,快捷键是 CTRL+O 。是不是非常简单?是的!看见 Scan a Folder 按钮了吗?点击它扫描就开始了!

下图显示了扫描完 python-nmap-0.1.4 后的结果。我用简单的方法得到了有用的信息列表。

baobab5

你已经学会了如何扫描 Home 目录、文件系统和指定文件夹。有一个重要的功能,我还没有告诉你,但我确定你一定可以自己学会。是不是有远程文件夹需要扫描?好好发挥一下脑力吧!

引用 http://www.lupaworld.com/article-238081-1.html

Ubuntu 12.04 Server安装Bittorrent Transmission

Ubuntu Server 没有图形界面,如果作为BT 下载服务器的话,可以使用Bittorrent Transmission 来通过Web界面操作,类似http://192.168.1.X:9091这样的方式管理下载。

1.安装服务器端

sudo apt-get install transmission-daemon

2.配置文件修改

sudo vim /var/lib/transmission-daemon/info/settings.json

主要调整如下部分的内容

"rpc-enabled": true,
"rpc-password": "password",
"rpc-port": 9091,
"rpc-username": "transmission",
"rpc-whitelist": "127.0.0.1,*.*.*.*",
"rpc-whitelist-enabled": true,
 "download-dir": "/var/lib/transmission-daemon/downloads"

也就是调整白名单为所有地址都可以网络访问,同时修改用户名密码到自己熟悉的即可。其中  "download-dir" 用来调整文件下载到的地址,这个自己调整即可。

3.使得配置信息生效(注意,必须使用此命令,否则Bittorrent Transmission 会在重启的时候把数据写回磁盘,导致修改无效)

sudo service transmission-daemon reload

4.修改系统配置文件,开放对于UDP的访问限制

sudo vim /etc/sysctl.conf

增加如下语句

#udp set for Transmission
#UDP receive buffer size
net.core.rmem_max = 4194304
#UDP send buffer size
net.core.wmem_max = 1048576

然后重启服务器。

5.通过浏览器访问即可。

Ubuntu 12.04 安装socks5代理服务器dante-server

dante-server是一个很好的socks4/5代理服务器软件。

  • 使用apt-get安装
apt-get install dante-server
  • 添加一个用户
useradd proxyuser
passwd proxyuser
  • 禁止proxyuser用户登录系统(安全考虑)
sudo vim /etc/passwd

将proxyuser的shell改成 /bin/false

  • 配置danted.conf
sudo mv /etc/danted.conf /etc/danted.conf_old
sudo vim /etc/danted.conf

输入以下内容:

#
#logoutput: stderr
#logoutput: syslog
logoutput: /var/log/sockd/sockd.log

internal: 0.0.0.0 port = 10080

external: eth0

#method: username none
#method: pam
method: username

user.privileged: root

user.notprivileged: proxyuser

user.libwrap: nobody

compatibility: sameport
compatibility: reuseaddr
extension: bind

client pass {

        from: 0.0.0.0/0 to: 0.0.0.0/0

        log: connect disconnect error

}

pass {

        from: 0.0.0.0/0 to: 0.0.0.0/0

        command: bind

        log: connect disconnect error

}

pass {

                from: 0.0.0.0/0 to: 0.0.0.0/0

                command: bindreply udpreply

                log: connect error

}

pass {

                from: 0.0.0.0/0 to: 0.0.0.0/0 port 1-65535

                protocol: tcp udp

}

pass {

                from: 0.0.0.0/0 to: 0.0.0.0/0 port 1-65535

                command: udpassociate

}

#block {
#				from: 0.0.0.0/0 to: 0.0.0.0/0 port 1-65535
#				protocol: tcp udp
#				log: connect erro
#}
  • 创建log文件夹
mkdir /var/log/sockd
  • 启动dante-server
/etc/init.d/danted start
  • 查看是否监听成功:
netstat -anp | grep 10080

现在你就可以使用socks5了

Ubuntu 13.10 IDT 92HD71B7X 声卡插入耳机无声问题

DELL E5400 笔记本,安装Ubuntu 13.10 ,今天突然发现,插入外置音响,耳机的时候,没有声音了,而内置的喇叭是正常的,网上查询了一下得到解决方法,目前仅仅针对IDT 92HD71B7X  芯片组,其他芯片组不保证能用。

查看声卡芯片组

cat /proc/asound/card0/codec#0 | grep Codec

输出结果如果为

Codec: IDT 92HD71B7X

则尝试本方法

sudo vim /etc/modprobe.d/alsa-base.conf

如果文件存在,则在文件的最后增加

#for Codec: IDT 92HD71B7X
options snd-hda-intel model=auto position_fix=0

重启机器,如果不想重启机器,可以尝试

sudo alsa force-reload

注意,重启,或者强制声卡重新加载之后,可能声音被强制设置为静音了,因此,需要手动打开音量,这个要注意一下。

Ubuntu无法进入桌面报告 Could not update /home/$USER/.ICEauthority

使用Ubuntu和Fedora的用户经常会在进入GNOME时出现

Could not update /home/$USER/.ICEauthority

这样的提示。然后就不能正常进入GNOME了(之前在GNOME上的配置都消失了)

解决办法:以root的用户执行

chown $USER:$USER -R  /home/$USER/
chmod 644 /home/$USER/.ICEauthority

解决问题很简单,但为什么会出现这种情况呢?下面是我的一些个人理解

首先:先介绍下sudo和gksudo

sudo和gksudo都是使用root权限来执行应用,sudo执行程序时使用的是当前用户的配置和家目录,而gksudo使用的是root用户 的家目录和配置,一般情况下看不出什么区别,但是对于那些针对不同用户有不同的配置文件和表现形式的应用程序来说,这两种方式的结果区别就很明显了。比如 下面原文中举的firefox例子。在不通过终端运行程序时,sudo没有办法提供一个界面来输入管理员密码,比如在快捷方式中。还有些GUI程序只能用 gksudo。细心的朋友肯定发现了,在/root下并没有.ICEauthority。那么当用sudo运行程序之后,由于使用的是当前用户的配置和家 目录,

系统将整个家目录的所属者和所属组归属到root:root下,并将.ICEauthority的权限修改成600。故当再次以普通用户身份登入系统时,由于没有权限故无法读取用户的配置文件。根据上述分析,显然,当使用gksudo将能避免这种情况的发生。
一般情况下,可以这样,运行命令行程序时使用sudo,运行GUI程序时用gksudo。

下面是原文:

What’s the Issue?
Since most Ubuntu documentation asks you to use sudo even with graphical applications, I often get asked by Ubuntu users why I recommendgksudo or kdesu for graphical applications instead of sudo.

For example, a lot of guides (including the first book ever published about Ubuntu) will ask you to type this sort of command:

sudo gedit /etc/apt/sources.list

I will always recommend, however, that people use instead this sort of command:

gksudo gedit /etc/apt/sources.list

And reserve sudo for command-line applications, like so:

sudo nano /etc/apt/sources.list

Why is it an issue?
Well, to be perfectly honest, most of the time it isn’t. For a lot of applications, you can run them the improper way—using sudo for graphical applications and see no adverse side effects.

1. There are other times, though, when side effects can be as mild as Firefox extensions not sticking or as extreme as as not being able to log in any more because the permissions on your .ICEauthority changed. You can read a full discussion on the issue here.

These errors occur because sometimes when sudo launches an application, it launches with root privileges but uses the user’s configuration file.

5616035720110414233611022

For example, if you launch Firefox with the command

gksudo firefox

it uses root’s Firefox configuration file.
5616035720110414233935037
But if you launch Firefox with the command

sudo firefox

Change a few settings while launched as root, and you'll see if you dig into your Firefox profile that certain files are now owned by root.

56160357201104142343300785616035720110414233611022 (1)

it runs with root privileges but uses the user’s configuration file (in this case, you can see the homepage and theme are different).
2. Running graphical applications with sudo also has the downside of always having to be run from the terminal. If you don’t use the proper command—gksudo or kdesu, you will not be able to use the command as an icon launcher or keyboard shortcut because there will be no graphical dialogue box to enter your sudo password in.

3. There are also some graphical applications that simply will not run with the sudo command. Kate, for example, can be run as

kdesu kate

but cannot be run as

sudo kate

Why not make exceptions?
Bottom line: most of the time when you use sudo for graphical applications, it’s fine. Some of the time, though, it is not fine, and is, in fact, extremely bad.

If you made exceptions, you would have to give people a list of all the graphical applications that are okay to run as sudo and a list of all the graphical applications that must be run as gksudo or kdesu.

Why make a list that needs to be compiled and updated, that most people won’t refer to, and that is completely unnecessary? Just be consistent in suggesting good practice: gksudo and kdesu for graphical applications. sudo for command-line applications.

But gksudo sometimes gives me an error… even though it appears to work…

You may notice that even though gksudo is the proper way to launch graphical applications, if you launch a gksudo application it will sometimes give you what appears to be an error. This, for example:

(gedit:####): GnomeUI-WARNING **: While connecting to session manager:
Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed.

or these

Initializing nautilus-gdu extension
Nautilus-Share-Message: Called "net usershare info" but it failed: 'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error No such file or directory
Please ask your system administrator to enable user sharing.

That is not a real error, and there’s already been a bug report filed on the message appearing. The developers have seen the bug and labeled it a low priority. In the meantime, just ignore the message and keep encouraging people to not use sudo for graphical applications so they won’t potentially mess up their ~/.ICEauthority and other user configuration files.

参考:http://czmmiao.iteye.com/blog/1003810

Ubuntu apt-get upgrade 时候忽略某些安装包

最近使用Squid3 做代理服务器,但是Ubuntu 默认的Squid3 是不包含HTTPS支持功能的,因此只能自己重新编译(参见 Ubuntu 12.04 上使用 squid 架设Http正向代理服务器),但是,在执行

sudo apt-get upgrade

的时候遇到一个问题,那就是 Squid3 总是被默认还原成原来的包,每次程序升级完成之后都要重新编译设置 ,非常麻烦,网上查找了一下,找到可以忽略某些特定包升级的命令。

sudo apt-mark hold squid3 squid3-dbg

这样就不担心在升级时候误升级 Squid3 了。

如果需要恢复原来的设定的话,执行如下命令即可

sudo apt-mark unhold squid3 squid3-dbg

linux top命令的TIME/TIME+值

top命令的TIME/TIME+是指的进程所使用的CPU时间,不是进程启动到现在的时间,因此,如果一个进程使用的cpu很少,那即使这个进程已经存在N长时间,TIME/TIME+也是很小的数值。

此外,如果你的系统有多个CPU,或者是多核CPU的话,那么,进程占用多个cpu的时间是累加的。

top的manual page:http://linux.die.net/man/1/top
看看他的帮助说明:
l: TIME — CPU Time
Total CPU time the task has used since it started. When ‘Cumulative mode’ is On, each process is listed with the cpu time that it and its dead children has used. You toggle ‘Cumulative mode’ with ‘S’, which is a command-line option and an interactive command. See the ‘S’ interactive command for additional information regarding this mode.
m: TIME+ — CPU Time, hundredths
The same as ‘TIME’, but reflecting more granularity through hundredths of a second.

参考 http://1.guotie.sinaapp.com/?p=24