mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
1ef54f5f51
@ -1,4 +1,4 @@
|
||||
Linux有问必答——如何检查Linux上的glibc版本
|
||||
Linux有问必答:如何检查Linux上的glibc版本
|
||||
================================================================================
|
||||
> **问题**:我需要找出我的Linux系统上的GNU C库(glibc)的版本,我怎样才能检查Linux上的glibc版本呢?
|
||||
|
||||
@ -20,7 +20,7 @@ GNU C库(glibc)是标准C库的GNU实现。glibc是GNU工具链的关键组
|
||||
|
||||
### 方法二 ###
|
||||
|
||||
另一个方法是在命令行“输入”**glibc library**(如,libc.so.6),就像命令一样。
|
||||
另一个方法是在命令行“输入”**glibc 库的名称**(如,libc.so.6),就像命令一样执行。
|
||||
|
||||
输出结果会显示更多关于**glibc库**的详细信息,包括glibc的版本以及使用的GNU编译器,也提供了glibc扩展的信息。glibc变量的位置取决于Linux版本和处理器架构。
|
||||
|
||||
@ -49,6 +49,6 @@ GNU C库(glibc)是标准C库的GNU实现。glibc是GNU工具链的关键组
|
||||
via: http://ask.xmodulo.com/check-glibc-version-linux.html
|
||||
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
84
published/20141127 How to install Docker on CentOS 7.md
Normal file
84
published/20141127 How to install Docker on CentOS 7.md
Normal file
@ -0,0 +1,84 @@
|
||||
如何在 CentOS 7 上安装 Docker
|
||||
================================================================================
|
||||
|
||||
Docker 是一个开源工具,它可以让创建和管理 **Linux 容器**变得简单。容器就像是轻量级的虚拟机,并且可以以毫秒级的速度来启动或停止。Docker 帮助系统管理员和程序员在容器中开发应用程序,并且可以扩展到成千上万的节点。
|
||||
|
||||
容器和 VM(虚拟机)的主要区别是,容器提供了**基于进程的隔离**,而虚拟机提供了资源的完全隔离。虚拟机可能需要一分钟来启动,而容器只需要一秒钟或更短。容器使用宿主操作系统的内核,而虚拟机使用独立的内核。
|
||||
|
||||
Docker 的局限性之一是,它只能用在 **64 位**的操作系统上。
|
||||
|
||||
在这篇文章中我们将讨论如何在 CentOS 7.x 中安装 docker。
|
||||
|
||||
### CentOS 7 中 Docker 的安装 ###
|
||||
|
||||
Docker 软件包已经包括在默认的 CentOS-Extras 软件源里。因此想要安装 docker,只需要运行下面的 yum 命令:
|
||||
|
||||
[root@localhost ~]# yum install docker
|
||||
|
||||
### 启动 Docker 服务 ###
|
||||
|
||||
安装完成后,使用下面的命令来启动 docker 服务,并将其设置为开机启动:
|
||||
|
||||
[root@localhost ~]# service docker start
|
||||
[root@localhost ~]# chkconfig docker on
|
||||
|
||||
(LCTT 译注:此处采用了旧式的 sysv 语法,如采用CentOS 7中支持的新式 systemd 语法,如下:
|
||||
|
||||
[root@localhost ~]# systemctl start docker.service
|
||||
[root@localhost ~]# systemctl enable docker.service
|
||||
|
||||
)
|
||||
|
||||
**下载官方的 CentOS 镜像到本地** (LCTT 译注:由于 Docker 被**墙** :-< ,所以请使用 http://docker.cn 的[镜像][1],感谢 @马全一 的镜像。 )
|
||||
|
||||
[root@localhost ~]# docker pull centos
|
||||
Pulling repository centos
|
||||
192178b11d36: Download complete
|
||||
70441cac1ed5: Download complete
|
||||
ae0c2d0bdc10: Download complete
|
||||
511136ea3c5a: Download complete
|
||||
5b12ef8fd570: Download complete
|
||||
|
||||
**确认 CentOS 镜像已经被获取:**
|
||||
|
||||
[root@localhost ~]# docker images centos
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
centos centos5 192178b11d36 2 weeks ago 466.9 MB
|
||||
centos centos6 70441cac1ed5 2 weeks ago 215.8 MB
|
||||
centos centos7 ae0c2d0bdc10 2 weeks ago 224 MB
|
||||
centos latest ae0c2d0bdc10 2 weeks ago 224 MB
|
||||
|
||||
**运行一个 Docker 容器:**
|
||||
|
||||
[root@localhost ~]# docker run -i -t centos /bin/bash
|
||||
[root@dbf66395436d /]#
|
||||
|
||||
我们可以看到,CentOS 容器已经被启动,并且我们得到了 bash 提示符。在 docker 命令中我们使用了 “-i 捕获标准输入输出”和 “-t 分配一个终端或控制台”选项。若要断开与容器的连接,输入 exit。
|
||||
|
||||
[root@cd05639b3f5c /]# cat /etc/redhat-release
|
||||
CentOS Linux release 7.0.1406 (Core)
|
||||
[root@cd05639b3f5c /]# exit
|
||||
exit
|
||||
[root@localhost ~]#
|
||||
|
||||
我们还可以搜索基于 Fedora 和 Ubuntu 操作系统的容器。
|
||||
|
||||
[root@localhost ~]# docker search ubuntu
|
||||
[root@localhost ~]# docker search fedora
|
||||
|
||||
**显示当前正在运行容器的列表**
|
||||
|
||||
![](http://www.linuxtechi.com/wp-content/uploads/2014/11/docker-ps.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxtechi.com/install-docker-on-centos-7/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
译者:[felixonmars](https://github.com/felixonmars)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxtechi.com/author/pradeep/
|
||||
[1]:https://docker.cn/h/how-to-use-docker-official-repositories
|
@ -0,0 +1,80 @@
|
||||
Systemd这个有争议的项目正在接管你身边的Linux发行版
|
||||
=========
|
||||
![](http://core4.staticworld.net/images/article/2014/10/linux-attack-100528169-gallery.jpg)
|
||||
|
||||
Systemd 是目前为止在Linux平台上最有争议的项目之一。它到底有多大的争议?它的争议大到systemd的开发者之一Lennart Poettering 声称有人使用[比特币][2]雇佣职业杀手要干掉他。但是还是有比较理智的做法的,有一个[抵制systemd网站][3]在技术角度上提出了抵制systemd的原因。
|
||||
|
||||
如此强烈的抵制也反映了systemd的成功。它已经被或将要被Fedroa、OpenSUSE、Ubuntu、Debian、Arch Linux等众多发行版采用。随着时间推移,GNOME越来越依赖它,Debian[回归GNOME][4]的原因之一就是它采用了systemd。systemd无处不在!
|
||||
|
||||
那么如此激烈的争论到底是关于什么呢?让我们近距离观察这场战争。
|
||||
|
||||
###Systemd是一个全新的init
|
||||
|
||||
[Systemd][5]的核心是取代老旧的[SysV init][6]。init用来初始化你的操作系统,当你启动系统时,init负责加载需要的驱动,激活你的网络链接,启动众多的系统服务,最后进入图形登陆界面。而SysV init 是一个老旧的系统,它基本上仅运行**/etc/init.d**目录下的一些脚本。
|
||||
|
||||
Systemd是一个现代技术,用以取代老旧以及粗糙的SysV init。它可以在接收到事件响应时启动相关服务;比如,当你接入了一个USB打印机,systemd可以在接收到设备接入响应时启动打印服务。当它接收到某个网络端口的连接请求时,它可以启动在此端口上监听的服务并且传递这个连接。
|
||||
|
||||
获取更多关于SysV init 与 systemd的信息,可以参考Jorgen Schäfer的 “[Why systemd?][9]”
|
||||
|
||||
###但是systemd远不止此###
|
||||
|
||||
systemd的反对者之中也有部分人认为SysV太老了,应该被取代掉。但是批评systemd的人发现Systemd是一个巨大的项目,其中包括了很多其他的功能。它是一个软件套件,而不仅仅是一个init。
|
||||
|
||||
![An illustration of systemd's structure.](https://cms-images.idgesg.net/images/article/2014/10/systemd-diagram-100528171-orig.png)
|
||||
|
||||
*[维基共享资源][10] systemd 结构图解*
|
||||
|
||||
Systemd包括用于管理用户登陆的守护进程logind,还包括journald,并且journald 颇有争议的使用了二进制形式保存系统日志而不是以文本形式。systemd也采用了[udev][11]的思想及代码,它对**/dev/**目录下的虚拟设备文件进行管理,并且处理设备接入或推出时所产生的事件。除了这些还有很多其他的,如:systemd还包括了[cron][12]风格的任务调度器与网络守护进程networkd等等。
|
||||
|
||||
###抨击者认为systemd不是类UNIX风格
|
||||
|
||||
多数的抱怨源于人们认为systemd项目太大以至于超出了它的工作范围,并且它从Linux系统接管的部分太多了。不要感到惊奇,systemd的抵制活动是以下面的抱怨开始的:
|
||||
|
||||
>"systemd文件是一大堆的复杂的高度耦合的二进制组成的,这违反了UNIX哲学:‘做一件事情,并把它做好’。它超出了一个init程序的职责范围,因为它还有电源管理,设备管理,挂载管理,cron(定时执行工具),磁盘加密,socket接口/inetd,syslog,网络配置,登陆/会话管理,文件预读,GPT分区发现,容器注册,hostname/locale/time管理,mDNS/DNS-SD等功能,它将Linux控制台以及其他的一些功能都包装在一个程序里面。
|
||||
|
||||
##那么,systemd是好是坏?
|
||||
|
||||
到这里,我判断一下,到底谁是正确的。
|
||||
|
||||
![](https://cms-images.idgesg.net/images/article/2013/09/linux-penguin-100055693-medium.png)
|
||||
|
||||
systemd最初的想法是非常好的。Linux需要一个新的东西来替换老的 SysV init 和沉重的 SysV init 脚本,这个新的程序应该是灵活的,现代化的系统守护进程,它可以响应更多类型,并且智能化的管理众多的守护进程。然而,事实上systemd好像成为了**一个仅依赖Linux核心的完全统一的系统层**。
|
||||
|
||||
*但是*,尽管Linux是一个社区开发项目,但它不是为PC世界的专栏作家或者是一群网络评论者提供的,这些人都不能决定它的进化与发展。只有那些亲手贡献代码以及全身心投入的人才有这个资格。巧的是,Linux发行版以及那些参与者好像大部分都倾向与systemd。
|
||||
|
||||
>'我对于systemd本身并没有很强烈的个人看法。我与核心开发人员争论过它的bug与兼容性,并且我认为它的一些设计是愚蠢的(比如二进制的日志),但这只是细节,不是大问题。
|
||||
|
||||
如果 Linux Torvald 对于systemd的设计没有什么反对意见,那么说明它可能还是不错的。如果你想平静的看下为什么Linux发行版要使用systemd的话,我推荐这篇文章,[Debian's systemd discussion document][13]。
|
||||
|
||||
你是如何看systemd的,可以在评论回复!但是请文明讨论。
|
||||
|
||||
*更新这篇文章以澄清之前的错误的消息,ubuntu 桌面版将在下一个版本中纳入systemd。之前我们错误的认为ubuntu已经使用了systemd*。
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.pcworld.com/article/2841873/meet-systemd-the-controversial-project-taking-over-a-linux-distro-near-you.html
|
||||
|
||||
作者:[Chris Hoffman][a]
|
||||
译者:[SPccman](https://github.com/SPccman)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.pcworld.com/article/2841873/meet-systemd-the-controversial-project-taking-over-a-linux-distro-near-you.html#chrishoffman
|
||||
[1]:https://plus.google.com/app/basic/stream/z13rdjryqyn1xlt3522sxpugoz3gujbhh04
|
||||
[2]:http://www.pcworld.com/article/2033715/7-things-you-need-to-know-about-bitcoin.html
|
||||
[3]:http://boycottsystemd.org/
|
||||
[4]:http://www.pcworld.com/article/2691192/how-gnome-3-14-is-winning-back-disillusioned-linux-users.html
|
||||
[5]:http://www.freedesktop.org/wiki/Software/systemd/
|
||||
[6]:http://en.wikipedia.org/wiki/Init#SysV-style
|
||||
[7]:http://www.pcworld.com/column/world-beyond-windows/
|
||||
[8]:http://www.pcworld.com/blog/world-beyond-windows/index.rss
|
||||
[9]:http://blog.jorgenschaefer.de/2014/07/why-systemd.html
|
||||
[10]:http://en.wikipedia.org/wiki/File:Systemd_components.svg
|
||||
[11]:http://en.wikipedia.org/wiki/Udev
|
||||
[12]:http://en.wikipedia.org/wiki/Cron
|
||||
[13]:http://www.markshuttleworth.com/archives/1295
|
||||
[14]:http://www.pcworld.com/article/2836984/why-ubuntu-1410-utopic-unicorns-humble-changes-are-the-calm-before-the-storm.html
|
||||
[15]:http://www.maximumpc.com/article/news/linus_torvalds_tosses_f-bombs_middle_fingers_and_general_disdain_nvidia
|
||||
[16]:http://www.zdnet.com/linus-torvalds-and-others-on-linuxs-systemd-7000033847/
|
||||
[17]:https://wiki.debian.org/Debate/initsystem/systemd
|
@ -1,32 +1,32 @@
|
||||
安卓编年史
|
||||
安卓编年史(4)
|
||||
================================================================================
|
||||
![安卓0.9显示着横屏的主屏幕——后续一些版本无法实现的一个特性。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/horizontal.png)
|
||||
安卓0.9显示着横屏的主屏幕——后续一些版本无法实现的一个特性。
|
||||
Ron Amadeo供图
|
||||
|
||||
尽管从功能上很难将模拟器和操作系统区分开,但安卓0.9是第一个支持横屏显示的版本。更让人惊讶的是,几乎所有东西都支持横屏模式,在某些方面安卓0.9甚至做的比KitKat更好。在Kiakat中,主屏幕和拨号被锁定为竖向并且无法旋转。但在安卓0.9这里,对任何一个应用横向显示都不是问题。(有谁知道怎么把Nexus 5从Kitkat升级到安卓0.9吗?)
|
||||
*安卓0.9显示着横屏的主屏幕——后续一些版本无法实现的一个特性* [Ron Amadeo供图]
|
||||
|
||||
尽管从功能上很难将模拟器和操作系统区分开,但安卓0.9是第一个支持横屏显示的版本。更让人惊讶的是,几乎所有东西都支持横屏模式,在某些方面安卓0.9甚至做的比KitKat更好。在Kiakat中,主屏幕和拨号被锁定为竖向并且无法旋转。但在安卓0.9这里,对任何一个应用横向显示都不是问题。(有谁知道怎么把Nexus 5从Kitkat升(降)级到安卓0.9吗?)
|
||||
|
||||
截图同样显示了安卓0.9中的新的音量显示设计。它抛弃了在Milestone 3中初次登场的旧铃铛式控制界面。那是一个巨大的,充满屏幕的界面。实际上,安卓4.0的重新设计中让它变得更小了,但它仍然是个问题。(你想增加音量却因此没法看到视频了这种情况特别烦人。)
|
||||
|
||||
![新通知面板,抛弃了应用快捷方式并添加了顶部部分。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/n09c2.png)
|
||||
新通知面板,抛弃了应用快捷方式并添加了顶部部分。
|
||||
Ron Amadeo供图
|
||||
|
||||
*新通知面板,抛弃了应用快捷方式并添加了顶部部分* [Ron Amadeo供图]
|
||||
|
||||
几乎每个安卓版本中的通知面板都有一定的调整,安卓0.9也不例外。电池电量图标进行了重绘,变成了黑底绿色图标,其它的状态栏图标变为黑色,白色以及灰色。状态栏左侧部分明智地选择在通知面板打开的时候显示日期。
|
||||
|
||||
通知面板加入了一个新的顶部部分,它能够显示运营商名称(在模拟器里显示“安卓”),以及一个巨大的写着“清除通知”的按钮,它能够让你不用打开应用而彻底清除通知。应用程序图标被取消了,替换为通知到达的时间,“最新事件”文字被更换为简单的“通知”。面板的空白部分现在是灰色的而不是之前的白色,底部的滑动条也进行了重新设计。上面两张图片的底部看起来并没有对齐,但这是因为Milestone 5的通知面板在面板底部有一圈空白。安卓0.9的通知面板是完全直达底部边缘的。
|
||||
|
||||
![安卓0.9和0.5的浏览器,展现出新的无色彩菜单。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/browser4c2.png)
|
||||
安卓0.9和0.5的浏览器,展现出新的无色彩菜单。
|
||||
Ron Amadeo供图
|
||||
|
||||
*安卓0.9和0.5的浏览器,展现出新的无色彩菜单* [Ron Amadeo供图]
|
||||
|
||||
浏览器主页现在是加载一个真正的网站,而不是像Milestone 5中那样的本地存储的假Google页面。Webkit的版本升至525.10,但是看起来它似乎没法正确渲染更现代的Google.com搜索按钮。纵观安卓0.9,Milestone 5中的菜单设计已经被抛弃,取而代之的是重新设计的灰色图标。这些截图的区别十分的明显,因为所有的颜色都被去除了。
|
||||
|
||||
“更趋向于”列表式的菜单变得更高了一点,并且只是一个没有图标的列表而已。安卓0.9已经获得了其它搜索方式,这次是在浏览器菜单里。和主屏幕小部件,主屏幕菜单按钮,以及浏览器主页,它们共同组成了四个搜索框。谷歌从未隐藏它的主要业务是什么,就连在它的操作系统中也是这样。
|
||||
|
||||
![从左到右:安卓0.9的浏览器缩放控件,页面内搜索界面,浏览器窗口,以及设置。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/b4.png)
|
||||
从左到右:安卓0.9的浏览器缩放控件,页面内搜索界面,浏览器窗口,以及设置。
|
||||
Ron Amadeo供图
|
||||
|
||||
*从左到右:安卓0.9的浏览器缩放控件,页面内搜索界面,浏览器窗口,以及设置* [Ron Amadeo供图]
|
||||
|
||||
安卓0.9带来了许多浏览器改进。谢天谢地缩放控件又能正常使用了,而且从疯狂的垂直控制变成了简单的加减按钮。谷歌做了个符合常识的决定,将缩放控制从屏幕中间移到了屏幕底部。在这些缩放控件中,安卓在一致性方面的努力显而易见。这些看起来是系统中唯一的圆形按钮。
|
||||
|
||||
@ -35,20 +35,20 @@ Ron Amadeo供图
|
||||
这个版本的系统没有设置界面,但是浏览器最终还是有了自己的设置界面。它会有个桌面式选项的弹窗,Javascript,隐私和cookie,保存的密码以及表单数据。甚至还有Google Gears整合(还记得Google Gears吗?)。
|
||||
|
||||
![拨号盘以及打开菜单的正在通话界面。](http://cdn.arstechnica.net/wp-content/uploads/2014/04/revisedcalls.jpg)
|
||||
拨号盘以及打开菜单的正在通话界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
*拨号盘以及打开菜单的正在通话界面* [Ron Amadeo供图]
|
||||
|
||||
拨号和联系人在安卓0.9中实际上是同一个应用——两个图标只是打开不同的标签而已。将联系人像这样附到拨号盘表明了智能手机联系人的第一目的还是通话,不是短信,电子邮件,即时通讯或查找地址。最终谷歌还是会完全接受非传统的智能手机沟通,将联系人和拨号分为两个独立的应用程序。
|
||||
|
||||
Milestone 5中大多数拨号盘的缺陷在安卓0.9中得到了修复。“最小化”标签被一组正常的亮/暗标签替代。对话气泡式的退格键被替换为正常的退格图标并集成到了拨号数字显示界面。数字键变成了圆形,尽管这个系统的其它东西是圆角矩形的(至少这次文本是垂直对齐的)。谷歌还修复了Milestone 5中“一”键,“星”键和“井”键不平衡的问题。
|
||||
Milestone 5中大多数拨号盘的缺陷在安卓0.9中得到了修复。“最小化”标签被一组正常的亮/暗标签替代。对话气泡式的退格键被替换为正常的退格图标并集成到了拨号数字显示界面。数字键变成了圆形,尽管这个系统的其它东西是圆角矩形的(至少这次文本是垂直对齐的)。谷歌还修复了Milestone 5中“-”键,“*”键和“#”键不平衡的问题。
|
||||
|
||||
在安卓0.9中点击显示的号码会开始一个通话。这是十分重要的,因为这是摆脱安卓设备硬件实体“拨号”和“结束”键的一大步。另一方面,来电界面却走的是完全相反的道路,去除了在安卓0.5中显示于屏幕之上的“接听”和“拒绝”按键。谷歌会花上接下来几个版本的时间去摸索在特定的显示之下是否需要硬件实体拨号键。但是直到安卓2.0和摩托罗拉Droid面世,实体拨号按钮才最终变成了可选选项。
|
||||
|
||||
来电界面的所有选项隐藏在目录按钮之后。Milestone 5不支持距离传感器,所以它采取了简单粗暴的路线,在通话过程中禁用触摸屏。安卓0.9为G1开发,它有个距离传感器。最终谷歌没有在通话的时候禁用触摸传感器。
|
||||
|
||||
![安卓0.9和0.5中独立的联系人界面和联系人编缉界面。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/CONTACTS.png)
|
||||
安卓0.9和0.5中独立的联系人界面和联系人编缉界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
*安卓0.9和0.5中独立的联系人界面和联系人编缉界面* [Ron Amadeo供图]
|
||||
|
||||
Milestone 5的一些联系人信息有令人困惑的标签,像电子邮件只被打上“主要的”标签而不是“主电子邮箱”标签。安卓0.9用各部分的水平标题纠正了这个错误。而且现在左侧的每个联系人类型都有了手形图标(Action icons)。
|
||||
|
||||
@ -66,7 +66,7 @@ Milestone 5的一些联系人信息有令人困惑的标签,像电子邮件只
|
||||
|
||||
via: http://arstechnica.com/gadgets/2014/06/building-android-a-40000-word-history-of-googles-mobile-os/4/
|
||||
|
||||
译者:[alim0x](https://github.com/alim0x) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
译者:[alim0x](https://github.com/alim0x) 校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
@ -1,94 +0,0 @@
|
||||
UbuTricks – Script to install the latest versions of several games and applications in Ubuntu
|
||||
================================================================================
|
||||
UbuTricks is a program that helps you install the latest versions of several games and applications in Ubuntu.
|
||||
|
||||
UbuTricks is a Zenity-based, graphical script with a simple interface. Although early in development, its aim is to create a simple, graphical way of installing updated applications in Ubuntu 14.04 and future releases.
|
||||
|
||||
Apps will be downloaded and installed automatically. Some will require a PPA to be added to the repositories. Others will be compiled from source if no PPA is available. The compilation process can take a long time, while installing from a PPA or DEB file should be quick, depending on your download speed.
|
||||
|
||||
### The install methods are as follows: ###
|
||||
|
||||
- PPA – the program will be downloaded and installed from a PPA
|
||||
- DEB – the program will be installed from a DEB package
|
||||
- Source – the program will be compiled (may take a long time)
|
||||
- Script – the program will be installed using a script provided by the developer
|
||||
- Archive – the program will be installed from a compressed archive
|
||||
- Repository – the program will be installed from a repository (not PPA)
|
||||
|
||||
### List of applications you can install ###
|
||||
|
||||
The latest versions of the following applications can be installed via UbuTricks:
|
||||
|
||||
### Games ###
|
||||
|
||||
- 0 A.D.
|
||||
- Battle for Wesnoth (Dev)
|
||||
- VCMI (Heroes III Engine)
|
||||
|
||||
### File Managers ###
|
||||
|
||||
- PCManFM
|
||||
|
||||
### Internet ###
|
||||
|
||||
- Geary
|
||||
- HexChat
|
||||
- QupZilla
|
||||
- QuiteRSS
|
||||
|
||||
### Multimedia ###
|
||||
|
||||
- SMPlayer
|
||||
- Transmageddon
|
||||
- Kdenlive
|
||||
- Fotoxx
|
||||
- jAlbum
|
||||
- GIMP
|
||||
- Shutter
|
||||
- Qmmp
|
||||
- XBMC
|
||||
|
||||
### Office/Ebooks/Documents ###
|
||||
|
||||
- Calibre
|
||||
- LibreOffice
|
||||
|
||||
### Tools ###
|
||||
|
||||
- Ubuntu Tweak
|
||||
|
||||
### Desktop Environments ###
|
||||
|
||||
- Cinnamon
|
||||
|
||||
### Other ###
|
||||
|
||||
- Google Earth
|
||||
- Wine
|
||||
|
||||
### Download and install Ubuntutricks script ###
|
||||
|
||||
You can download ubuntutricks script from [here][1] Once downloaded, make it executable and either double-click the script or run it from the terminal.
|
||||
|
||||
### Screenshots ###
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/116.png)
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/213.png)
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/35.png)
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/45.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.ubuntugeek.com/ubutricks-script-to-install-the-latest-versions-of-several-games-and-applications-in-ubuntu.html
|
||||
|
||||
作者:[ruchi][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.ubuntugeek.com/author/ubuntufix
|
||||
[1]:http://www.tuxarena.com/intro/files/ubutricks.sh
|
@ -1,66 +0,0 @@
|
||||
[Translating by Stevearzh]
|
||||
When hackers grow old
|
||||
================================================================================
|
||||
Lately I’ve been wrestling with various members of an ancient and venerable open-source development group which I am not going to name, though people who regularly follow my adventures will probably guess which one it is by the time I’m done venting.
|
||||
|
||||
Why it so freaking hard to drag some people into the 21st century? Sigh…
|
||||
|
||||
I’m almost 56, an age at which a lot of younger people expect me to issue semi-regular salvos of get-off-my-lawn ranting at them. But no – I find, that, especially in technical contexts, I am far more likely to become impatient with my age peers.
|
||||
|
||||
A lot of them really have become grouchy, hidebound old farts. And, alas, it not infrequently falls to me to be the person who barges in and points out that practices well-adapted for 1995 (or, in the particular case I’m thinking of, 1985) are … not good things to hold on to decades later.
|
||||
|
||||
Why me? Because the kids have little or no cred with a lot of my age peers. If anyone’s going to get them to change, it has to be someone who is their peer in their own perception. Even so, I spend a lot more time than seems just or right fighting inertia.
|
||||
|
||||
Young people can be forgiven for lacking a clue. They’re young. Young means little experience, which often leads to unsound judgment. It’s more difficult for me to forgive people who have been around the track often enough that they should have a clue, but are so attached to The Way It’s Always Been Done that they can’t see what is in front of their freaking noses.
|
||||
|
||||
(News flash: I really don’t have a conservative temperament. I find it wryly amusing how often both conservatives and non-conservatives who argue politics with me fail to notice this.)
|
||||
|
||||
OK, now let’s talk about GNU ChangeLog files. They were a fine idea, a necessary one even, in 1985. The idea was to use a single ChangeLog entry to document a group of related changes to multiple files. This was a reasonable adaptation to absent or extremely primitive version control. I know this because I was there.
|
||||
|
||||
Even in 1995, or as late as the early 2000s, many version control systems didn’t have changesets. That is, there was no or only weak support for grouping multiple file modifications into a single retrievable object with a comment attached to the object rather than to individual file modifications. CVS, the system in widest use then, only faked changesets – and did it so badly that many people felt they couldn’t rely on that feature. ChangeLog files still made some functional sense.
|
||||
|
||||
But then Subversion – with real changesets – achieved wide acceptance through its beta releases around 2003 and its 1.0 in 2004. It should have been obvious then, even before the new wave of DVCSes that began a year later, that there was a culture clash a comin’. Because if your project both has a DVCS and uses the ChangeLog convention, they’re fighting for control of the same metadata.
|
||||
|
||||
There are different ways you can adapt. One is to continue to treat the ChangeLogs as the authoritative record of the evolution of the code. In that case, you tend to get stubby or pro-forma commit comments.
|
||||
|
||||
Another is to treat the commit comment log as authoritative. If you do that, you soon begin to wonder why you’re still writing ChangeLog entries at all. The commit metadata has better coherence with the code changes, after all – that’s what it’s designed for.
|
||||
|
||||
(Now imagine a project in which, with the best of intentions, different people are making opposite choices out of these two. Now you have to read both the ChangeLogs and the commit logs to know what’s going on. Friction costs are rising…)
|
||||
|
||||
A third is to try to have it both ways – duplicating commit comment data in a slightly different format in a ChangeLog entry that’s part of the commit. This has all the problems you’d expect with a representation in which there is no single point of truth; one copy gets garbled, or the ChangeLog entry gets modified so that it’s no longer in sync with the allegedly matching commit data, and life gets very confusing for anyone who comes along later and tries to figure out what people were thinking.
|
||||
|
||||
Or, as a senior dev on a Certain Project I Won’t Name just did in email, declaring that commits can include multiple ChangeLog entries and the commit metadata is irrelevant to the Changelogs. Which we still have to write.
|
||||
|
||||
My eyes crossed and my gorge rose when I read that. What kind of fool fails to realize that this is begging for trouble – that, actually, the whole edifice of custom around ChangeLog files is just dead weight and friction drag in a DVCS world with good browsing tools for reliable commit logs?
|
||||
|
||||
Alas, it’s a very particular kind of fool: a hacker who has grown old and rigid. All the rationalizations he will ever utter fail to hide this. He’s attached to tactics that made sense a decade ago but have become counterproductive ceremonies now. If you tried to explain not just about git summary lines but that the correct adaptation for current toolsets is to scrap ChangeLogs entirely … well, that would be insupportable, inconceivable, and just crazy talk.
|
||||
|
||||
Functionally this infuriates me. It is substantially harder to work on that project because of this and related nonsense. And, as badly as it happens to need young developers, that’s a real problem. It has a G+ community well into 4 digits, they’re mostly kids, and they’re not stepping up. Evidently the message has been received on the outside; the devs on this project are ancient mossbacks with inexplicable tribal fixations, and best admired from a good long distance.
|
||||
|
||||
What gives this extra emotional edge for me is that whenever I have to butt heads with a mossback, I keep wondering: will I be like this someday? Worse, am I looking in a mirror, already rigidified and not knowing it? I mean, I get the impression from his web presence that this particular specimen is younger than me. By a good fifteen years.
|
||||
|
||||
I feel mentally agile. I don’t get frustrated by people moving faster than I can handle, I get frustrated by people who can’t keep up with me, who can’t see the obvious. But this self-belief could be just a bad case of Dunning-Krueger effect biting me where I least understand it. Very few things terrify me; this possibility is high on the short list.
|
||||
|
||||
A separately disconcerting thing is that as I get older this sort of collision is happening more often rather than less. Somehow I expected my hacker peers to age more gracefully, to retain their neotenous flexibility even if they were physically aging. Some do indeed seem to be going that way; too many, alas, are not. It is a sadness.
|
||||
|
||||
I’m not sure I have a good finish for this. If I’ve escaped mentally rigidifying (and that’s an if) I think I know at least in part why, but I’m very unsure whether it can be generally replicated – you might need to have a wired-in brain chemistry that matches the strategy. Nevertheless, for whatever it’s worth, here is my advice to young hackers and indeed the young of all kinds.
|
||||
|
||||
You – yes, even you – cannot count on retaining your mental flexibility into middle and old unless you work at it. You have to practice busting out of comfortable mental grooves and regularly checking your assumptions when you’re young, and you have to develop a habit of it that sustains into old age.
|
||||
|
||||
It’s said that the best time for a middle-aged person to start (physically) exercising is thirty years ago. I think the same goes for the habits that might (might!) keep you mentally agile at 56, or 65. Push your envelope. Develop the regular practice of challenging yourself and exiting your comfort zone now so you’ll have it established when you really need it.
|
||||
|
||||
You have to be realistic about this; there’s an optimal-challenge level where you choose an attainable goal and work mentally hard for it. This month I’m going to learn go. Not the game, I already play that (though not very well); the programming language. Not because I really need to for a specific project, but because it’s time to stretch myself.
|
||||
|
||||
Develop that habit. And never let it go.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://esr.ibiblio.org/?p=6485
|
||||
|
||||
作者:[Eric Raymond][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://esr.ibiblio.org/?author=2
|
@ -1,91 +0,0 @@
|
||||
spccman translating
|
||||
Meet systemd, the controversial project taking over a Linux distro near you
|
||||
================================================================================
|
||||
![](http://core4.staticworld.net/images/article/2014/10/linux-attack-100528169-gallery.jpg)
|
||||
|
||||
Systemd is one of the most controversial projects in Linux-land right now. How controversial? So controversial that Lennart Poettering, one of systemd’s developers, even [claims][1] that horrible people have been pooling [Bitcoins][2] to hire a hitman on him. On a more reasonable level, there’s a [Boycott systemd website][3] that argues for a boycott of this software on various technical merits.
|
||||
|
||||
All this backlash is a reaction to systemd’s success. It has been—or is being—adopted by Linux distributions from Fedora and OpenSuSE to Ubuntu, Debian, and even Arch Linux. GNOME is becoming more dependent on it over time—one of Debian’s stated reasons for [switching back to GNOME][4] was because of its systemd integration. It’s everywhere.
|
||||
|
||||
So what’s all the hub-bub—and the fierce backlash—about? Let’s look a bit closer at this raging battle.
|
||||
|
||||
### Systemd is a new init system ###
|
||||
|
||||
At its core, [systemd][5] is a replacement for the old [SysV init][6] system. The init system is the software that initializes your system. When you boot up, init is responsible for loading the appropriate drivers, activating your network connection, launching various system services, and finally bringing up the graphical login screen where you log in. SysV init is an old system that basically just runs scripts located under **/etc/init.d**.
|
||||
|
||||
> Want to stay up to date on Linux, BSD, Chrome OS, and the rest of the World Beyond Windows? Bookmark the [World Beyond Windows column page][7] or follow [our RSS feed][8].
|
||||
|
||||
At its core, systemd is a modern replacement for the old and crufty SysV init. It can also launch services in response to events; for example, when you plug in a USB printer, it could launch the printing service in response to the device being plugged in. When it receives a connection on a specific network port, it could launch a network service configured to listen on that port and pass the connection along.
|
||||
|
||||
For more technical information about SysV init vs. systemd, read Jorgen Schäfer’s “[Why systemd?][9]”
|
||||
|
||||
### But systemd is more than that ###
|
||||
|
||||
Even systemd’s detractors largely agree that SysV is old and needs to be replaced. But critics correctly note that systemd is in fact more than that. It’s a large project containing many other bits of functionality. It’s a software suite, not just an init system.
|
||||
|
||||
![An illustration of systemd's structure.](https://cms-images.idgesg.net/images/article/2014/10/systemd-diagram-100528171-orig.png)
|
||||
|
||||
[Wikimedia Commons][10]
|
||||
|
||||
An illustration of systemd's structure.
|
||||
|
||||
The systemd project also contains logind, a daemon that manages user logins, and journald, an event-logging system that controversially writes to binary files and not text ones. Systemd has also absorbed [the udev project][11] and its code, which handles the management of virtual device files in the **/dev/** directory and events when devices are plugged in and unplugged. The list goes on and on: systemd also includes a [cron][12]-style task scheduler and networkd, a daemon for managing network connections.
|
||||
|
||||
More recently, systemd is gaining consoled, a user-mode console daemon that can be used when Linux’s virtual terminal code is stripped out of the kernel itself. The kernel developers seem happy to get this stuff out of the kernel and into user-space , but some people have to be thinking: Does systemd really have to take over this as well?
|
||||
|
||||
### Critics say it’s not Unix-like ###
|
||||
|
||||
Many of the complaints to systemd stem from a feeling that this huge project is increasing in scope and taking over too much of the Linux system. Not surprisingly, the Boycott systemd site starts with this exact complaint:
|
||||
|
||||
> “Systemd flies in the face of the Unix philosophy: ‘do one thing and do it well,’ representing a complex collection of dozens of tightly coupled binaries. Its responsibilities grossly exceed that of an init system, as it goes on to handle power management, device management, mount points, cron, disk encryption, socket API/inetd, syslog, network configuration, login/session management, readahead, GPT partition discovery, container registration, hostname/locale/time management, mDNS/DNS-SD, the Linux console and other things all wrapped into one.”
|
||||
|
||||
Ubuntu’s Mark Shuttleworth originally [called systemd][13] “hugely invasive and hardly justified” when Ubuntu was sticking with their own “upstart” init system. Ubuntu eventually gave up that fight and is switching to systemd. The change will show up [in the Ubuntu Desktop Next images][14] starting in the 15.04 update cycle.
|
||||
|
||||
### So, systemd: good or bad? ###
|
||||
|
||||
Oh boy, here we go. This is the part of the article where I have to wrap everything up with a nice bow and make a pronouncement about which side is right.
|
||||
|
||||
![](https://cms-images.idgesg.net/images/article/2013/09/linux-penguin-100055693-medium.png)
|
||||
|
||||
The original idea of systemd is definitely good. Linux needs a replacement for the old SysV init system and clunky SysV init scripts, and a sleek, modern system daemon that can respond to more types events and manage daemons more intelligently is a great idea. However, it’s true that systemd seems to be growing into a monolithic system layer that lives just above the Linux kernel.
|
||||
|
||||
*But*, although Linux is a community-developed project, it’s not for the peanut gallery—whether it’s a PCWorld columnist or a gaggle of Internet commenters—to decide how it evolves. It’s for the people actually getting their hands dirty with the code and involving themselves in these projects. And, interestingly enough, Linux distributions and the people involved in them seem mostly to be moving toward systemd integration.
|
||||
|
||||
Even Linux creator Linus Torvalds (who [isn’t afraid to say what he thinks][15]) doesn’t seem to mind systemd. As he told [ZDNet][16]:
|
||||
|
||||
> "I don't actually have any particularly strong opinions on systemd itself. I've had issues with some of the core developers that I think are much too cavalier about bugs and compatibility, and I think some of the design details are insane (I dislike the binary logs, for example), but those are details, not big issues."
|
||||
|
||||
If Linus Torvalds doesn’t have any big issues with the design of systemd, perhaps it’s not all bad. If you’d like a calm look at why a Linux distribution might want to go with systemd, [Debian’s systemd discussion document][17] is good reading.
|
||||
|
||||
What do you think of systemd? Sound off in the comments! Just try to keep it civil, folks—swaying opinions on contentious issues takes level-headed talk.
|
||||
|
||||
*This article has been updated to clarify when systemd is appearing in the Ubuntu Desktop Next images. It originally erroneously stated the change already took place. *
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.pcworld.com/article/2841873/meet-systemd-the-controversial-project-taking-over-a-linux-distro-near-you.html
|
||||
|
||||
作者:[Chris Hoffman][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.pcworld.com/article/2841873/meet-systemd-the-controversial-project-taking-over-a-linux-distro-near-you.html#chrishoffman
|
||||
[1]:https://plus.google.com/app/basic/stream/z13rdjryqyn1xlt3522sxpugoz3gujbhh04
|
||||
[2]:http://www.pcworld.com/article/2033715/7-things-you-need-to-know-about-bitcoin.html
|
||||
[3]:http://boycottsystemd.org/
|
||||
[4]:http://www.pcworld.com/article/2691192/how-gnome-3-14-is-winning-back-disillusioned-linux-users.html
|
||||
[5]:http://www.freedesktop.org/wiki/Software/systemd/
|
||||
[6]:http://en.wikipedia.org/wiki/Init#SysV-style
|
||||
[7]:http://www.pcworld.com/column/world-beyond-windows/
|
||||
[8]:http://www.pcworld.com/blog/world-beyond-windows/index.rss
|
||||
[9]:http://blog.jorgenschaefer.de/2014/07/why-systemd.html
|
||||
[10]:http://en.wikipedia.org/wiki/File:Systemd_components.svg
|
||||
[11]:http://en.wikipedia.org/wiki/Udev
|
||||
[12]:http://en.wikipedia.org/wiki/Cron
|
||||
[13]:http://www.markshuttleworth.com/archives/1295
|
||||
[14]:http://www.pcworld.com/article/2836984/why-ubuntu-1410-utopic-unicorns-humble-changes-are-the-calm-before-the-storm.html
|
||||
[15]:http://www.maximumpc.com/article/news/linus_torvalds_tosses_f-bombs_middle_fingers_and_general_disdain_nvidia
|
||||
[16]:http://www.zdnet.com/linus-torvalds-and-others-on-linuxs-systemd-7000033847/
|
||||
[17]:https://wiki.debian.org/Debate/initsystem/systemd
|
@ -1,3 +1,4 @@
|
||||
翻译中 by coloka
|
||||
Four ways Linux is headed for no-downtime kernel patching
|
||||
================================================================================
|
||||
![Credit: Shutterstock](http://images.techhive.com/images/article/2014/10/patch_f-100526950-primary.idge.jpeg)
|
||||
|
@ -1,62 +0,0 @@
|
||||
What Makes a Good Programmer?
|
||||
================================================================================
|
||||
What makes a good programmer? It’s an interesting question to ask yourself. It makes you reflect on the craft of software development. It is also a good question to ask your colleagues. It can trigger some interesting discussions on how you work together. Here are five skills I think are crucial to have in order to be a good programmer.
|
||||
|
||||
### 1. Problem Decomposition ###
|
||||
|
||||
Programming is about solving problems. But before you write any code, you need to be clear on how to solve the problem. One skill good programmers have is the ability to break the problem down in smaller and smaller parts, until each part can be easily solved. But it is not enough simply to find a way to solve the problem. A good programmer finds a way to model the problem in such a way that the resulting program is easy to reason about, easy to implement and easy to test.
|
||||
|
||||
Some of the most complicated programs I have worked on were complicated in part because the implementation did not fit the problem very well. This led to code that was hard to understand. When the problem is well modeled, I agree with Bernie Cosell (interviewed in the excellent [Coders at Work][1]):
|
||||
|
||||
> “…there are very few inherently hard programs. If you are looking at a piece of code and it looks very hard – if you can’t understand what this thing is supposed to be doing – that’s almost always an indication that it was poorly thought through. At that point you don’t roll up your sleeves and try to fix the code; you take a step back and think it through again. When you’ve thought it through enough, you’ll find out that it’s easy“.
|
||||
|
||||
### 2. Scenario Analysis ###
|
||||
|
||||
Good developers have the ability to consider many different scenarios for the program. This applies both to the logic in the program, and to the internal and external events that can occur. To consider the different paths in the logic, they ask questions like: What happens if this argument is null? What if none of these conditions are true? Is this method thread-safe? To discover what types of events the software needs to handle, they will ask questions like: What if this queue becomes full? What if there is no response to this request? What if the other server restarts while this server is restarting?
|
||||
|
||||
The good programmers ask themselves: How can this break? In other words, they have the ability to think like testers. In contrast, inexperienced programmers mostly only consider the “happy path” – the normal flow of control when everything goes as expected (which it does most of the time). But of course, the unexpected inevitably happens, and the program needs to be able to cope with that.
|
||||
|
||||
### 3. Naming ###
|
||||
|
||||
Programming consists to a large degree of naming things: classes, methods and variables. When done well, the program becomes largely self-documenting, meaning that the function of the program is quite clear just from reading the source code. One effect of self-documenting code is that it naturally leads to many smaller methods, rather than a few large ones, simply because then you have more places to put meaningful names (there are [other reasons][2] why many small methods are good too).
|
||||
|
||||
Coming up with good names is much harder than it sounds. I like this quote (from Phil Karlton): “There are only two hard things in Computer Science: cache invalidation and naming things.” Partly naming is hard because it needs to be clear in your mind what each name represents. Sometimes that is not immediately clear, but only becomes apparent as the development proceeds. Therefore, renaming is just as important as naming.
|
||||
|
||||
Naming things well also includes coming up with concepts to be used, and what these concepts should be called. By having well-thought out, distinctly named concepts that are used consistently (in the program, and when discussing the domain with programmers and non-programmers), writing the program becomes much easier.
|
||||
|
||||
### 4. Consistency ###
|
||||
|
||||
Perhaps the biggest challenge in programming is managing complexity. Consistency is one way to combat complexity. It reduces some of the complexity by allowing us to see patterns and infer how things are named, used and handled. With consistency, we don’t need to use brain power to remember exceptions and random variations. Instead we can concentrate on [essential complexity, not accidental complexity][3].
|
||||
|
||||
Consistency is important across the board. It applies to variable names and grouping, method naming, the division into modules, the directory structure, the GUI, error handling, logging, documentation etc. For example, if some variables are related and appear together (in declarations, method calls or as columns in the database) then always use them in the same order. Then it becomes easier to see if one is missing, or if they have been mixed up. For an operation, if it is called delete in one place, don’t call it remove in another place – stick with the same name. Steve McConnell also has some good advice on using opposites precisely in [Code Complete][4]. For example, begin/end are opposites, as are start/stop. Don’t mix names from different pairs (for example using begin/stop) when dealing with opposites.
|
||||
|
||||
Inconsistencies can get introduced when modifying a program. Sloppy programmers don’t pay attention to if what they add is consistent with the existing code or not. Good programmers are relentless in ensuring that seemingly small details are just right. They know how important consistency is in the overall fight against complexity.
|
||||
|
||||
### 5. Learning ###
|
||||
|
||||
As a software developer, you are constantly learning. Before adding a new feature, you have to understand what it is supposed to do. Before adding code to an existing program, you usually have to learn what the existing code does, in order fit the new functionality in properly. You also have to learn about the surrounding systems, in order to interface with them correctly. The ability to learn fast therefore makes you a much more effective developer.
|
||||
|
||||
Furthermore, because the pace of development in the software engineering field is so high, there is a steady stream of new languages, tools, techniques and frameworks to learn about. You can view this as good or bad. Fred Brooks lists learning as [one of the joys of the craft][5], and I agree. Learning new things is satisfying in itself. It also means that life as a developer never is boring.
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
All of the above skills are generic – none of them are specific to any one language, framework or technology. If you have them, you can quickly learn a new language or tool, and write good software in that environment. Furthermore, because they are general in nature, they will not become obsolete in a couple of years.
|
||||
|
||||
These are my answers for what makes a good programmer. What do you think makes a good programmer? Let me know in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://henrikwarne.com/2014/06/30/what-makes-a-good-programmer/
|
||||
|
||||
作者:[Henrik Warne][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://henrikwarne.com/about/
|
||||
[1]:http://www.amazon.com/review/R2OV0TG7MJGXGL
|
||||
[2]:http://henrikwarne.com/2013/08/31/7-ways-more-methods-can-improve-your-program/
|
||||
[3]:http://faculty.salisbury.edu/~xswang/Research/Papers/SERelated/no-silver-bullet.pdf
|
||||
[4]:http://www.amazon.com/review/R269BBARXH1V6R/
|
||||
[5]:http://henrikwarne.com/2012/06/02/why-i-love-coding/
|
@ -1,65 +0,0 @@
|
||||
disylee来翻译
|
||||
How to Remove Music Players from Ubuntu Sound Menu
|
||||
================================================================================
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/11/music-players.jpg)
|
||||
|
||||
**Since its introduction back in 2010, the Ubuntu Sound Menu has proven to be one of the most popular and unique features of the Unity desktop.**
|
||||
|
||||
Allowing music players to integrate with the volume applet – i.e., where one would expect to find sound-related tomfoolery – through a standard interface is inspired. One wonders why other operating systems haven’t followed suit!
|
||||
|
||||
#### Overstuffed ####
|
||||
|
||||
Handy though it may be there is a “problem” with the applet as it currently exists: pretty much anything that so much as looks at an MP3 can, should it want, lodge itself inside. While useful, an omnipresent listing for apps you have installed but don’t use that often is annoying and unsightly.
|
||||
|
||||
I’m going to wager that the screenshot above looks familiar to a great many of you reading this! Never fear, **dconf-editor** is here.
|
||||
|
||||
### Remove Players from Ubuntu Sound Menu ###
|
||||
|
||||
#### Part One: Basics ####
|
||||
|
||||
The quickest and easiest way to remove entries from the Sound Menu is to uninstall the apps afflicting it. But that’s extreme; as I said, you may want the app, just not the integration.
|
||||
|
||||
To remove players without ditching the apps we need to use a scary looking tool called dconf-editor.
|
||||
|
||||
You may have it installed already, but if you don’t you’ll find it in the Ubuntu Software Center waiting.
|
||||
|
||||
- [Click to Install Dconf-Editor in Ubuntu][1]
|
||||
|
||||
Once installed, head to the Unity Dash to open it. Don’t panic when it opens; you’ve not been shunted back to the 2002, it’s supposed to look like that.
|
||||
|
||||
Using the left-hand sidebar you need to navigate to com > canonical > indicator > sound. The following pane will appear.
|
||||
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/11/dconf-editor.jpg)
|
||||
|
||||
Double click on the closed brackets next to interested-media-players and delete the players you wish to remove from the Sound Menu, but leave in the square brackets and don’t delete any commas or apostrophes from items you wish to keep.
|
||||
|
||||
For example, I removed ‘**rhythmbox.desktop**’, ‘**pithos.desktop**’, ‘**clementine.desktop**’, to leave a line that reads:
|
||||
|
||||
['tomahawk.desktop']
|
||||
|
||||
Now, when I open the Sound menu I only see Tomahawk:
|
||||
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/11/music-players-2.jpg)
|
||||
|
||||
#### Part Two: Blacklisting ####
|
||||
|
||||
Wait! Don’t close dconf-editor yet. While the steps above makes things look nice and tidy some players will instantly re-add themselves to the sound menu when opened. To avoid having to repeat the process add them to the **blacklisted-media-player** section.
|
||||
|
||||
Remember to enclose each player in apostrophes with a comma separating multiple entries. They must also be inside the square brackets — so double check before exiting.
|
||||
|
||||
The net result:
|
||||
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/from-to-.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.omgubuntu.co.uk/2014/11/remove-players-ubuntu-sound-menu
|
||||
|
||||
作者:[Joey-Elijah Sneddon][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117485690627814051450/?rel=author
|
||||
[1]:apt://dconf-editor
|
@ -1,200 +0,0 @@
|
||||
翻译中 by coloka
|
||||
Restricting process CPU usage using nice, cpulimit, and cgroups
|
||||
================================================================================
|
||||
注:本文中的图片似乎都需要翻墙后才能看到,发布的时候注意
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/juggle.jpg)
|
||||
|
||||
The Linux kernel is an incredible circus performer, carefully juggling many processes and their resource needs to keep your server humming along. The kernel is also all about equity: when there is competition for resources, the kernel tries to distribute those resources fairly.
|
||||
|
||||
However, what if you've got an important process that needs priority? What about a low-priority process? Or what about limiting resources for a group of a processes?
|
||||
|
||||
**The kernel can't determine what CPU processes are important without your help. **
|
||||
|
||||
Most processes are started at the same priority level and the Linux kernel schedules time for each task evenly on the processor. Have a CPU intensive process that can be run at a lower priority? Then you need to tell the scheduler about it!
|
||||
|
||||
There are at least three ways in which you can control how much CPU time a process gets:
|
||||
|
||||
- Use the nice command to manually lower the task's priority.
|
||||
- Use the cpulimit command to repeatedly pause the process so that it doesn’t exceed a certain limit.
|
||||
- Use Linux’s built-in **control groups**, a mechanism which tells the scheduler to limit the amount of resources available to the process.
|
||||
|
||||
Let's look at how these work and the pros and cons of each.
|
||||
|
||||
### Simulating high CPU usage ###
|
||||
|
||||
Before looking at these three techniques, we need to find a tool that will simulate high CPU usage on a system. We will be using CentOS as our base system, and to artificially load the processor we can use the prime number generator from the [Mathomatic toolkit][1].
|
||||
|
||||
There isn’t a prebuilt package for CentOS so you will need to build it yourself. Download the source code from http://mathomatic.orgserve.de/mathomatic-16.0.5.tar.bz2 and then unpack the archive file. Change directory into **mathomatic-16.0.5/primes**. Run **make** and **sudo make install** to build and install the binaries. You will now have the **matho-primes** binary in **/usr/local/bin**.
|
||||
|
||||
Run the command like this:
|
||||
|
||||
/usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
This will generate a list of prime numbers from zero to nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine. Since we don’t really want to keep the list, the output is redirected to /dev/null.
|
||||
|
||||
Now run top and you will see that the matho-primes process is using all the available CPU.
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image00.jpg)
|
||||
|
||||
Exit top (press the q key) and kill the matho-primes process (fg to bring the process to the foreground and press CTRL+C).
|
||||
|
||||
### nice ###
|
||||
|
||||
The nice command tweaks the priority level of a process so that it runs less frequently. **This is useful when you need to run a CPU intensive task as a background or batch job**. The niceness level ranges from -20 (most favorable scheduling) to 19 (least favorable). Processes on Linux are started with a niceness of 0 by default. The nice command (without any additional parameters) will start a process with a niceness of 10. At that level the scheduler will see it as a lower priority task and give it less CPU resources.
|
||||
|
||||
Start two **matho-primes** tasks, one with nice and one without:
|
||||
|
||||
nice matho-primes 0 9999999999 > /dev/null &
|
||||
matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
Now run top.
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image05.jpg)
|
||||
|
||||
Observe that the process started without nice (at niceness level 0) gets more processor time, whereas the process with a niceness level of 10 gets less.
|
||||
|
||||
What this means in real terms is that if you want to run a CPU intensive task you can start it using nice and the scheduler will always ensure that other tasks have priority over it. This means that the server (or desktop) will remain responsive even when under heavy load.
|
||||
|
||||
Nice has an associated command called renice. It changes the niceness level of an already running process. To use it, find out the PID of process hogging all the CPU time (using ps) and then run renice:
|
||||
|
||||
renice +10 1234
|
||||
|
||||
Where 1234 is the PID.
|
||||
|
||||
Don’t forget to kill the **matho-primes** processes once you have finished experimenting with the **nice** and **renice** commands.
|
||||
|
||||
### cpulimit ###
|
||||
|
||||
The **cpulimit** tool curbs the CPU usage of a process by pausing the process at different intervals to keep it under the defined ceiling. It does this by sending SIGSTOP and SIGCONT signals to the process. It does not change the **nice** value of the process, instead it monitors and controls the real-world CPU usage.
|
||||
|
||||
cpulimit **is useful when you want to ensure that a process doesn't use more than a certain portion of the CPU**. The disadvantage over nice is that the process can't use all of the available CPU time when the system is idle.
|
||||
|
||||
To install it on CentOS type:
|
||||
|
||||
wget -O cpulimit.zip https://github.com/opsengine/cpulimit/archive/master.zip
|
||||
unzip cpulimit.zip
|
||||
cd cpulimit-master
|
||||
make
|
||||
sudo cp src/cpulimit /usr/bin
|
||||
|
||||
The commands above will download the source code from GitHub, unpack the archive file, build the binary, and copy it to /usr/bin.
|
||||
|
||||
cpulimit is used in a similar way to nice, however you need to explicitly define the maximum CPU limit for the process using the ‘-l’ parameter. For example:
|
||||
|
||||
cpulimit -l 50 matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image03.jpg)
|
||||
|
||||
Note how the matho-primes process is now only using 50% of the available CPU time. On my example system the rest of the time is spent in idle.
|
||||
|
||||
You can also limit a currently running process by specifying its PID using the ‘-p’ parameter. For example
|
||||
|
||||
cpulimit -l 50 -p 1234
|
||||
|
||||
Where 1234 is the PID of the process.
|
||||
|
||||
### cgroups ###
|
||||
|
||||
Control groups (cgroups) are a Linux kernel feature that allows you to specify how the kernel should allocate specific resources to a group of processes. With cgroups you can specify how much CPU time, system memory, network bandwidth, or combinations of these resources can be used by the processes residing in a certain group.
|
||||
|
||||
**The advantage of control groups over** nice **or** cpulimit **is that the limits are applied to a set of processes, rather than to just one**. Also, nice or cpulimit only limit the CPU usage of a process, whereas cgroups can limit other process resources.
|
||||
|
||||
By judiciously using cgroups the resources of entire subsystems of a server can be controlled. For example in CoreOS, the minimal Linux distribution designed for massive server deployments, the upgrade processes are controlled by a cgroup. This means the downloading and installing of system updates doesn’t affect system performance.
|
||||
|
||||
To demonstrate cgroups, we will create two groups with different CPU resources allocated to each group. The groups will be called ‘cpulimited’ and ‘lesscpulimited’.
|
||||
|
||||
The groups are created with the cgcreate command like this:
|
||||
|
||||
sudo cgcreate -g cpu:/cpulimited
|
||||
sudo cgcreate -g cpu:/lesscpulimited
|
||||
|
||||
The “-g cpu” part of the command tell cgroups that the groups can place limits on the amount of CPU resources given to the processes in the group. Other contollers include cpuset, memory, and blkio. The cpuset controller is related to the cpu controller in that it allows the processes in a group to be bound to a specific CPU, or set of cores in a CPU.
|
||||
|
||||
The cpu controller has a property known as cpu.shares. It is used by the kernel to determine the share of CPU resources available to each process across the cgroups. The default value is 1024. By leaving one group (lesscpulimited) at the default of 1024 and setting the other (cpulimited) to 512, we are telling the kernel to split the CPU resources using a 2:1 ratio.
|
||||
|
||||
To set the cpu.shares to 512 in the cpulimited group, type:
|
||||
|
||||
sudo cgset -r cpu.shares=512 cpulimited
|
||||
|
||||
To start a task in a particular cgroup you can use the cgexec command. To test the two cgroups, start matho-primes in the cpulimited group, like this:
|
||||
|
||||
sudo cgexec -g cpu:cpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
If you run top you will see that the process is taking all of the available CPU time.
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image01.jpg)
|
||||
|
||||
This is because when a single process is running, it uses as much CPU as necessary, regardless of which cgroup it is placed in. The CPU limitation only comes into effect when two or more processes compete for CPU resources.
|
||||
|
||||
Now start a second matho-primes process, this time in the lesscpulimited group:
|
||||
|
||||
sudo cgexec -g cpu:lesscpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
The top command shows us that the process in the cgroup with the greater cpu.shares value is getting more CPU time.
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image02.jpg)
|
||||
|
||||
Now start another matho-primes process in the cpulimited group:
|
||||
|
||||
sudo cgexec -g cpu:cpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image04.jpg)
|
||||
|
||||
Observe how the CPU is still being proportioned in a 2:1 ratio. Now the two matho-primes tasks in the cpulimited group are sharing the CPU equally, while the process in the other group still gets more processor time.
|
||||
|
||||
You can [read the full control groups documentation from Red Hat][2] (which applies equally to CentOS 7).
|
||||
|
||||
### Monitoring process CPU usage with Scout ###
|
||||
|
||||
What's the easiest way to monitor process CPU usage? [Scout][3] automatically tracks track process CPU + memory usage when our monitoring agent is installed on your servers.
|
||||
|
||||
### Monitoring process CPU usage with Scout ###
|
||||
|
||||
What's the easiest way to monitor process CPU usage? Scout automatically tracks track process CPU + memory usage when our monitoring agent is installed on your servers.
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/server_view/processes.png)
|
||||
|
||||
You can then create triggers to alert you when processes exceed specific CPU + memory usage thresholds.
|
||||
|
||||
[Signup for a free trial of Scout][4] to try process CPU monitoring.
|
||||
|
||||
### TL;DR ###
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/overview.png)
|
||||
|
||||
The finite resources of any server or desktop are a valuable commodity. The tools described above help you manage those resources, especially the CPU resource:
|
||||
|
||||
- **nice** is a great tool for 'one off' tweaks to a system.
|
||||
- **cpulimit** is useful when you need to run a CPU intensive job and having free CPU time is essential for the responsiveness of a system.
|
||||
- **cgroups** are the Swiss army knife of process limiting and offer the greatest flexibility.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://blog.scoutapp.com/articles/2014/11/04/restricting-process-cpu-usage-using-nice-cpulimit-and-cgroups
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.mathomatic.org/
|
||||
[2]:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Resource_Management_and_Linux_Containers_Guide/chap-Introduction_to_Control_Groups.html
|
||||
[3]:https://scoutapp.com/
|
||||
[4]:https://scoutapp.com/
|
||||
[5]:
|
||||
[6]:
|
||||
[7]:
|
||||
[8]:
|
||||
[9]:
|
||||
[10]:
|
||||
[11]:
|
||||
[12]:
|
||||
[13]:
|
||||
[14]:
|
||||
[15]:
|
||||
[16]:
|
||||
[17]:
|
||||
[18]:
|
||||
[19]:
|
||||
[20]:
|
@ -1,180 +0,0 @@
|
||||
Translating by ZTinoZ
|
||||
Linux FAQs with Answers--How to install phpMyAdmin on CentOS
|
||||
================================================================================
|
||||
> **Question**: I am running a MySQL/MariaDB server on CentOS, and I would like to manage its databases via web-based interface using phpMyAdmin. What is a proper way to install phpMyAdmin on CentOS?
|
||||
|
||||
phpMyAdmin is an open-source PHP application designed as a web-based MySQL/MariaDB database administration tool. While there exist lightweight database management tools such as [Adminer][1], phpMyAdmin is more popularly used among webmasters to conduct various MySQL/MariaDB administration tasks. It supports pretty much all MySQL database/table related operations such as browse, create, copy, drop, rename, alter, as well as MySQL user/privilege management, and database import/export. Here is **how to install phpMyAdmin on CentOS 6 or 7**.
|
||||
|
||||
### Prerequisites ###
|
||||
|
||||
To install phpMyAdmin on CentOS, you first need to set up a web server (e.g., Apache or nginx), MySQL/MariaDB and PHP. Depending on your preference or requirement, you can choose to install either [LAMP stack][2] or [LEMP stack][3].
|
||||
|
||||
Another requirement is to enable EPEL repository on your CentOS. Follow [this guide][4] to set up EPEL repository if you haven't done so.
|
||||
|
||||
### Install phpMyAdmin on CentOS 6 or 7 ###
|
||||
|
||||
Once you set up EPEL repository, you can install phpMyAdmin easily with yum command as follows.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo yum install phpmyadmin
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo yum install phpmyadmin php-mcrypt
|
||||
|
||||
### Configure phpMyAdmin on CentOS 7 ###
|
||||
|
||||
By default, phpMyAdmin on CentOS 7 allows access only from loopback address (127.0.0.1). To enable remote access, you will need to update its configuration.
|
||||
|
||||
Open phpMyAdmin's configuration (/etc/httpd/conf.d/phpMyAdmin.conf) with a text editor. Find and comment out every line that says "Require ip XXXX". There will be four such lines. Add "Require all granted" instead. The updated configuration file will look like the following.
|
||||
|
||||
$ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf
|
||||
|
||||
----------
|
||||
|
||||
. . . . .
|
||||
<Directory /usr/share/phpMyAdmin/>
|
||||
AddDefaultCharset UTF-8
|
||||
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
<RequireAny>
|
||||
#Require ip 127.0.0.1
|
||||
#Require ip ::1
|
||||
Require all granted
|
||||
</RequireAny>
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
Allow from 127.0.0.1
|
||||
Allow from ::1
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/phpMyAdmin/setup/>
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
<RequireAny>
|
||||
#Require ip 127.0.0.1
|
||||
#Require ip ::1
|
||||
Require all granted
|
||||
</RequireAny>
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
Allow from 127.0.0.1
|
||||
Allow from ::1
|
||||
</IfModule>
|
||||
</Directory>
|
||||
. . . . .
|
||||
|
||||
Finally, restart httpd to activate the change.
|
||||
|
||||
$ sudo systemctl restart httpd
|
||||
|
||||
### Configure phpMyAdmin on CentOS 6 ###
|
||||
|
||||
By default, phpMyAdmin on CentOS 6 blocks access from every IP address. To enable remote access, you will need to update its configuration.
|
||||
|
||||
Open phpMyAdmin's configuration (/etc/httpd/conf.d/phpmyadmin.conf) with a text editor. Find a line that says "Deny from all", and comment it out. Then change the line that says "Allow from 127.0.0.1" to "Allow from 0.0.0.0". The updated configuration will look like the following.
|
||||
|
||||
$ sudo vi /etc/httpd/conf.d/phpmyadmin.conf
|
||||
|
||||
----------
|
||||
|
||||
<Directory "/usr/share/phpmyadmin">
|
||||
Order Deny,Allow
|
||||
# Deny from all
|
||||
Allow from 0.0.0.0
|
||||
</Directory>
|
||||
|
||||
The next step is to add a blowfish password to the phpMyAdmin's configuration. This step is needed to encrypt password in cookie as part of cookie-based authentication.
|
||||
|
||||
Open the following file with a text editor, and set a random blowfish password as follows.
|
||||
|
||||
$ sudo vi /usr/share/phpmyadmin/config.inc.php
|
||||
|
||||
----------
|
||||
|
||||
$cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
|
||||
|
||||
Finally, restart httpd to activate the change.
|
||||
|
||||
$ sudo service httpd restart
|
||||
|
||||
### Test phpMyAdmin ###
|
||||
|
||||
To test if phpMyAdmin is successfully set up, go to http://<web-server-ip-addresss>/phpmyadmin
|
||||
|
||||
![](https://farm6.staticflickr.com/5606/15550758749_0f7ab66b5b_z.jpg)
|
||||
|
||||
You should be able to log with any MySQL user (e.g., root), and manage MySQL/MariaDB databases/tables via a web-based interface.
|
||||
|
||||
![](https://farm8.staticflickr.com/7505/15551187008_86ac7e7db1_z.jpg)
|
||||
|
||||
### Troubleshooting ###
|
||||
|
||||
Here are a few troubleshooting tips during phpMyAdmin installation on CentOS.
|
||||
|
||||
1. When you are trying to access phpMyAdmin page in web browser, you are getting "403 Forbidding" error with:
|
||||
|
||||
You don't have permission to access /phpMyAdmin on this server.
|
||||
|
||||
This error is happening because the default setting of phpMyAdmin blocks access from a remote IP address. To fix this error, you need to edit its configuration to allow remote access. See the above for more detail.
|
||||
|
||||
2. When you access phpMyAdmin page, you are seeing "The configuration file now needs a secret passphrase (blowfish_secret)." message, and you cannot login.
|
||||
|
||||
To fix this error, you need to edit /usr/share/phpmyadmin/config.inc.php to add a random blowfish password as follows, and restart httpd.
|
||||
|
||||
$cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
|
||||
|
||||
----------
|
||||
|
||||
$ sudo service httpd restart (CentOS 6)
|
||||
$ sudo systemctl restart httpd (CentOS 7)
|
||||
|
||||
3. When you access phpMyAdmin page, you are getting "Cannot load mcrypt extension. Please check your PHP configuration" error message.
|
||||
|
||||
To solve this error, install the following package:
|
||||
|
||||
$ sudo yum install php-mcrypt
|
||||
|
||||
and restart httpd:
|
||||
|
||||
$ sudo service httpd restart (CentOS 6)
|
||||
$ sudo systemctl restart httpd (CentOS 7)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-phpmyadmin-centos.html
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://xmodulo.com/set-web-based-database-management-system-adminer.html
|
||||
[2]:http://xmodulo.com/install-lamp-stack-centos.html
|
||||
[3]:http://xmodulo.com/install-lemp-stack-centos.html
|
||||
[4]:http://xmodulo.com/how-to-set-up-epel-repository-on-centos.html
|
||||
[5]:
|
||||
[6]:
|
||||
[7]:
|
||||
[8]:
|
||||
[9]:
|
||||
[10]:
|
||||
[11]:
|
||||
[12]:
|
||||
[13]:
|
||||
[14]:
|
||||
[15]:
|
||||
[16]:
|
||||
[17]:
|
||||
[18]:
|
||||
[19]:
|
||||
[20]:
|
@ -1,67 +0,0 @@
|
||||
Linux FAQs with Answers--How to access a NAT guest from host with VirtualBox
|
||||
================================================================================
|
||||
> **Question**: I have a guest VM running on VirtualBox, which uses NAT networking. So the guest VM is getting a private IP address (10.x.x.x) assigned by VirtualBox. If I want to SSH to the guest VM from the host machine, how can I do that?
|
||||
|
||||
VirtualBox supports several networking options for guest VMs, one of them being NAT networking. When NAT networking is enabled for a guest VM, VirtualBox automatically performs network address translation between the guest VM and host's network stack, so that you do not have to configure anything on the host machine and local network for the guest VM's networking to work. The implication of such NAT, however, is that the guest VM is not reachable or visible from external networks as well as from the local host itself. This is a problem if you want to access the guest VM from the host machine for some reason (e.g., SSH).
|
||||
|
||||
If you want to access a NAT guest from the host on VirtualBox, you can enable port forwarding for VirtualBox NAT, either from the GUI or from the command line. This tutorial demonstrates **how to SSH a NAT guest from the host** by enabling port forwarding for port 22. If you want to access HTTP of a NAT guest instead, replace port 22 with port 80.
|
||||
|
||||
### Configure VirtualBox Port Forwarding from the GUI ###
|
||||
|
||||
On VirtualBox, choose the guest VM you want to access, and open "Settings" window of the VM. Click on "Network" menu on the left, click on "Advanced" to show additional network adapter options.
|
||||
|
||||
![](https://farm8.staticflickr.com/7583/15797904856_2753dc785e_z.jpg)
|
||||
|
||||
Click on a button labeled "Port Forwarding."
|
||||
|
||||
![](https://farm8.staticflickr.com/7527/15636152708_cf2be7c7e8_z.jpg)
|
||||
|
||||
You will see a window where you can configure port forwarding rules. Click on "Add" icon in the upper right corner.
|
||||
|
||||
![](https://farm8.staticflickr.com/7489/15636391217_48a9954480_z.jpg)
|
||||
|
||||
Add a new port forwarding rule with the following detail.
|
||||
|
||||
- **Name**: SSH (any arbitrary unique name)
|
||||
- **Protocol**: TCP
|
||||
- **Host IP**: 127.0.0.1
|
||||
- **Host Port**: 2222 (any unused port higher than 1024)
|
||||
- **Guest IP**: IP address of the guest VM
|
||||
- **Guest Port**: 22 (SSH port)
|
||||
|
||||
![](https://farm6.staticflickr.com/5603/15202135853_02a07c3212_o.png)
|
||||
|
||||
Port forwarding configured for the guest VM will be enabled automatically when you power on the guest VM. For verification, check that port 2222 is opened by VirtualBox after you launch the guest VM:
|
||||
|
||||
$ sudo netstat -nap | grep 2222
|
||||
|
||||
![](https://farm8.staticflickr.com/7461/15819682411_6bb9707f8a_z.jpg)
|
||||
|
||||
Now that port forwarding is in place, you can SSH to the guest VM bs follows.
|
||||
|
||||
$ ssh -p 2222 <login>@127.0.0.1
|
||||
|
||||
An SSH login request sent to 127.0.0.1:2222 will automatically be translated into 10.0.2.15:22 by VirtualBox, allowing you to SSH to the guest VM.
|
||||
|
||||
### Configure VirtualBox Port Forwarding from the Command Line ###
|
||||
|
||||
VirtualBox comes with a command-line management interface called VBoxManage. Using this command-line tool, you can also set up port forwarding for your guest VM.
|
||||
|
||||
The following command creates a port forwarding rule for guest VM named "centos7" with IP address 10.0.2.15 and SSH port 22, mapped to local host at port 2222. The name of the rule ("SSH" in this example) must be unique.
|
||||
|
||||
$ VBoxManage modifyvm "centos7" --natpf1 "SSH,tcp,127.0.0.1,2222,10.0.2.15,22"
|
||||
|
||||
Once the rule is created, you can verify that by using the command below.
|
||||
|
||||
$ VBoxManage showvminfo "centos7" | grep NIC
|
||||
|
||||
![](https://farm8.staticflickr.com/7559/15636458427_7a0959900c_z.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/access-nat-guest-from-host-virtualbox.html
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -1,103 +0,0 @@
|
||||
How To Create A Multiboot USB From Ubuntu Using MultiSystem
|
||||
================================================================================
|
||||
### Introduction ###
|
||||
|
||||
For those who don’t know, **MultiSystem** is a small, Open Source freeware to create a multiboot usb drives from Linux systems. Using this utility, we can create any number of bootable Linux distributions in a USB drive. All you need is an Internet connection(at the time of MultiSystem installation only), and a sufficient size of a USB drive depending upon the number of distributions you want to include in that USB drive.
|
||||
|
||||
### Install MultiSystem On Ubuntu 14.10/14.04 ###
|
||||
|
||||
#### Manual Installation: ####
|
||||
|
||||
[Download MultiSystem][1] script, and extract it anywhere of your choice. Go to the extracted location, and run the script as shown below.
|
||||
|
||||
sudo ./install-depot-multisystem.sh
|
||||
|
||||
#### Installation Using PPA: ####
|
||||
|
||||
Alternatively, you can install MultiSystem more easily using PPA as shown below.
|
||||
|
||||
sudo apt-add-repository 'deb http://liveusb.info/multisystem/depot all main'
|
||||
wget -q -O - http://liveusb.info/multisystem/depot/multisystem.asc | sudo apt-key add -
|
||||
sudo apt-get update
|
||||
sudo apt-get install multisystem
|
||||
|
||||
After installation, It will automatically open. Just click Close button to exit.
|
||||
|
||||
### Post Installation ###
|
||||
|
||||
Once installed, plug-in your USB key, and launch MultiSystem either from Unity Dash or Menu.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/Menu_0012.png)
|
||||
|
||||
At first time, the MultiSystem interface will look like below.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_002.png)
|
||||
|
||||
Select the USB drive, and click **Confirm** button. You may get the following error dialog box. Don’t worry, It says our USB drive has no label. Click Ok to set label by MultiSystem itself.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/Error_003.png)
|
||||
|
||||
Then, unplug/replug the USB key, and launch MultiSystem again. Select the USB key, and click Confirm again. Now, you’ll be asked to confirm Grub2 installation in your USB key. Click Ok to continue.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/gtkdialog_004.png)
|
||||
|
||||
Finally, you’ll be pleased with MultiSystem interface. Now’ it’s time to create multiboot usb key.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_005.png)
|
||||
|
||||
### Usage ###
|
||||
|
||||
MultiSystem is very simple to use. Drag the ISO of your choice into the MultiSystem window. If it doesn’t work, click on the **cd icon** on the bottom and select the ISO’s.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_006.png)
|
||||
|
||||
Now, MultiSystem will copy the files from the ISO, and make the USB key as bootable.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_007.png)
|
||||
|
||||
Likewise, you can add as many distributions as you want in your USB key. In my case, I have added two Linux distributions: CentOS 6.5 and Android.
|
||||
|
||||
After adding all ISO’s, you will now see the list of bootable distributions in the MultiSystem main window.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_008.png)
|
||||
|
||||
That’s it. Our multiboot USB key is ready to use. Reboot your system, and set the first boot device as USB in your Bios. Select the distribution you want to install, and start installing the OS from the multiboot USB key.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/QEMU_009.png)
|
||||
|
||||
Additionally, MultiSystem includes some extra options such as:
|
||||
|
||||
- Grub Settings;
|
||||
- Grub & Burg bootloaders Update;
|
||||
- Download Live Cds;
|
||||
- VirtualBox installation;
|
||||
- Format USB key;
|
||||
- and many.
|
||||
|
||||
To view the list of additional options, navigate to the **Menus** tab of the MultiSystem.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_010.png)
|
||||
|
||||
Also, you can test the multiboot USB key within your Ubuntu desktop itself using QEMU or Oracle VirtualBox.
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_011.png)
|
||||
|
||||
MultiSystem tool is one of the best and useful tool ever I have tested. This tool will definitely useful for those who wants to install multiple different operating systems on their systems. You don’t have to carry your CD/DVD pouch wherever you go. Just buy a 16GB 0r 32GB USB, and dumb all Operating systems you want to install in it. and install OS like a boss.
|
||||
|
||||
And, the good news for Windows OS users is it supports some Windows os too. I tested Windows 7, and it’s working!
|
||||
|
||||
Enjoy!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.unixmen.com/create-multiboot-usb-ubuntu-using-multisystem/
|
||||
|
||||
作者:[SK][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.unixmen.com/author/sk/
|
||||
[1]:http://liveusb.info/multisystem/install-depot-multisystem.sh.tar.bz2
|
||||
[2]:http://liveusb.info/dotclear/
|
@ -1,76 +0,0 @@
|
||||
[translating by KayGuoWhu]
|
||||
How to install Docker on CentOS 7
|
||||
================================================================================
|
||||
Docker is an open-source tool that makes creating & managing **Linux containers(LXC)** easy. Containers are like lightweight VMs which can be started & stopped in milliseconds. Dockers help the system admin & coders to develop their application in a container and can further scale up to 1000 of nodes.
|
||||
|
||||
The main difference between container and VM(Virtual machine) is that dockers provide **process based isolation** , whereas VM provides full isolation of resources. Virtual machine takes a minute to start where as container can be started in a second or less than a second. Container uses the Kernel of host OS , whereas VM uses the separate Kernel.
|
||||
|
||||
One of the limitation of Docker is that it can be used only on **64bit hosts** OS.
|
||||
|
||||
In this post we will discuss how to install docker in CentOS 7.x
|
||||
|
||||
### Installation of Docker on CentOS 7 ###
|
||||
|
||||
Docker package is included in the default CentOS-Extras repository. So to install docker , simply run below yum command :
|
||||
|
||||
[root@localhost ~]# yum install docker
|
||||
|
||||
### Start the Docker Service ###
|
||||
|
||||
Once the Installation is finished , start docker service and enable it at boot using below commands
|
||||
|
||||
[root@localhost ~]# service docker start
|
||||
[root@localhost ~]# chkconfig docker on
|
||||
|
||||
**Download the official Centos images Locally**
|
||||
|
||||
[root@localhost ~]# docker pull centos
|
||||
Pulling repository centos
|
||||
192178b11d36: Download complete
|
||||
70441cac1ed5: Download complete
|
||||
ae0c2d0bdc10: Download complete
|
||||
511136ea3c5a: Download complete
|
||||
5b12ef8fd570: Download complete
|
||||
|
||||
**Verify CentOS images that have been fetched :**
|
||||
|
||||
[root@localhost ~]# docker images centos
|
||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||
centos centos5 192178b11d36 2 weeks ago 466.9 MB
|
||||
centos centos6 70441cac1ed5 2 weeks ago 215.8 MB
|
||||
centos centos7 ae0c2d0bdc10 2 weeks ago 224 MB
|
||||
centos latest ae0c2d0bdc10 2 weeks ago 224 MB
|
||||
|
||||
**Run a Docker Container :**
|
||||
|
||||
[root@localhost ~]# docker run -i -t centos /bin/bash
|
||||
[root@dbf66395436d /]#
|
||||
|
||||
As we can see centos container has been started and we got the bash shell. In docker command we have used options like ‘-i attaches stdin and stdout’ and ‘-t allocates a terminal or console’ . To disconnect from container type exit .
|
||||
|
||||
[root@cd05639b3f5c /]# cat /etc/redhat-release
|
||||
CentOS Linux release 7.0.1406 (Core)
|
||||
[root@cd05639b3f5c /]# exit
|
||||
exit
|
||||
[root@localhost ~]#
|
||||
|
||||
We can also search Containers based on fedora & ubuntu OS.
|
||||
|
||||
[root@localhost ~]# docker search ubuntu
|
||||
[root@localhost ~]# docker search fedora
|
||||
|
||||
**Display the list of running containers **
|
||||
|
||||
![](http://www.linuxtechi.com/wp-content/uploads/2014/11/docker-ps.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxtechi.com/install-docker-on-centos-7/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxtechi.com/author/pradeep/
|
@ -1,164 +0,0 @@
|
||||
[a598799539 translating...]
|
||||
Some Sentences about Java
|
||||
================================================================================
|
||||
There is nothing new in this article. I just collected some trivial statements which may not be trivial for some of the junior programmers programmers. Boring old stuff.
|
||||
|
||||
If you happen all of these things you know more about Java than the average house wife. I do not know if there is point to know all of these. You can be a fairly good Java programmer if you do not know some of these features. However a lot of new information in this article probably indicates you have room to develop.
|
||||
|
||||
### There are 4 different protection types ###
|
||||
|
||||
in Java (not three). These are `private`, package private, `protected` and `public`. If you do not specify any protection modifier when you define an element in a class it will be package private (and not public and not protected).
|
||||
|
||||
![There are four levels of protection in Java.](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/four-levels-of-protection.png)
|
||||
|
||||
There are four levels of protection in Java.
|
||||
|
||||
On the other hand if you do not specify protection modifier in front of a method declaration in an interface: it will be public. You may specify it to be explicitly public but it does not have effect on Java and SONAR will not like you doing so.
|
||||
|
||||
![Protection is Transitive](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/protection-is-transitive.png)
|
||||
|
||||
Protection is Transitive
|
||||
|
||||
> My opinion about Java allowing you to optionally write `public` in front of a method in an interface is that this is a technology mistake.
|
||||
|
||||
Similarly you can write `final` in front of a field in an interface, or even `static`. It may imply that they could be non-static or non-final: not true. Fields of an interface are final and static. Always.
|
||||
|
||||
### Protected and package private are not the same ###
|
||||
|
||||
Package private (or default) protection will let other classes of the same package access to the method or field. Protected methods and fields can be used from classes in the same package (so far the same as package private) and in addition to that it can be used from other classes that extend the class containing the protected field or method.
|
||||
|
||||
### Protected is transitive ###
|
||||
|
||||
If there are three packages `a`, `b` and `c`, each containing a class named `A`, `B` and `C` so that `B` extends `A` and `C` extends `B` then the class `C` can access the protected fields and methods of `A`.
|
||||
|
||||
package a;
|
||||
|
||||
public class A {
|
||||
protected void a() {
|
||||
|
||||
}
|
||||
}
|
||||
package b;
|
||||
|
||||
import a.A;
|
||||
|
||||
public class B extends A {
|
||||
protected void b() {
|
||||
a();
|
||||
}
|
||||
}
|
||||
package c;
|
||||
|
||||
import b.B;
|
||||
|
||||
public class C extends B {
|
||||
protected void c() {
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
### Interface can not define protected methods ###
|
||||
|
||||
Many thinks that you can also define `protected` methods in an interface. When programming the compiler makes it obvious fast and brutally: you can not. Btw: this is why I think that allowing the `public` keyword in an interface is a technology mistake: it makes people think that it could also be something else as well.
|
||||
|
||||
![Private is the new public](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/private-is-the-new-public.png)
|
||||
|
||||
Private is the new public
|
||||
|
||||
If you want to declare a `protected` method in an interface, you probably did not understand encapsulation.
|
||||
|
||||
### Private is not that private ###
|
||||
|
||||
Private variables and methods are visible inside the compilation unit. If that sounds too cryptic: in the same Java file (almost). This is a bit more than “in the class where they are defined”. They can also be seen from classes and interfaces that are in the same compilation unit. Inner and nested classes can see private fields and methods of the class enclosing them. However enclosing classes can also see the private methods and fields of the classes they enclose down to any depth.
|
||||
|
||||
package a;
|
||||
|
||||
class Private {
|
||||
private class PrivateInPrivate {
|
||||
private Object object;
|
||||
}
|
||||
|
||||
Object m() {
|
||||
return new PrivateInPrivate().object;
|
||||
}
|
||||
}
|
||||
|
||||
This latter is not widely known. As a matter of fact it is rarely useful.
|
||||
|
||||
### Private is class level not object ###
|
||||
|
||||
If you can access a variable or method you can access it no matter which object it belongs to. If `this.a` is accessible then `another.a` is also accessible assumed that `another` is an instance of the same class. Objects that are instances of the same class can fool around with each others variables or methods. Rarely makes sense to have such a code though. A real life exception is `equals()` (as generated by Eclipse, lines 15 and 18):
|
||||
|
||||
package a;
|
||||
|
||||
public class PrivateIsClass {
|
||||
private Object object;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PrivateIsClass other = (PrivateIsClass) obj;
|
||||
if (object == null) {
|
||||
if (other.object != null)
|
||||
return false;
|
||||
} else if (!object.equals(other.object))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
### Static classes may have many instances ###
|
||||
|
||||
![Protection is not object level. It is class level.](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/protection-is-class-feature.png)
|
||||
|
||||
Protection is not object level. It is class level.
|
||||
|
||||
Classes that are not supposed to have any instances are usually called utility classes. They contain only static fields and static methods and the only constructor is private, not invoked from any of the static methods of the class. In Java 8 you can have such a beasts implemented in interfaces, since Java 8 interfaces can have static methods in it. I am not convinced that we should use that feature instead of utility classes. I am not absolutely convinced that we should use utility classes at all.
|
||||
|
||||
Static classes are always inside in another class (or interface). They are nested classes. They are static and just as static methods can not access instance methods and fields of the class similarly a static nested class can not access the instance methods and fields of the embedding class. That is because nested classes do not have a reference (pointer if you like) to an instance of the embedding class. Inner classes, as opposed to nested classes are non static and can not be created without an instance of the embedding class. Each instance of an inner class has a reference to exactly one instance of the embedding class and thus an inner class can access instance methods and fields of the embedding class.
|
||||
|
||||
Because of this you can not create an inner class without an instance of the surrounding class. You need not specify it though if this is the current object, a.k.a `this`. In that case you can write `new`, which is, in this case, just a short form for `this.new`. In a static environment, for example from a static method you have to specify which instance of the enclosing class should the inner class created with. See the line 10:
|
||||
|
||||
package a;
|
||||
|
||||
class Nesting {
|
||||
static class Nested {}
|
||||
class Inner {}
|
||||
void method(){
|
||||
Inner inner = new Inner();
|
||||
}
|
||||
static void staticMethod(){
|
||||
Inner inner = new Nesting().new Inner();
|
||||
}
|
||||
}
|
||||
|
||||
### Anonymous classes can access only final variables ###
|
||||
|
||||
![Variable has to be effective final](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/effective-final.png)
|
||||
|
||||
Variable has to be effective final
|
||||
|
||||
When an anonymous class is defined inside a method, it can access local variables if they are final. But saying that is vague. They have to be declared final and they also have to be effective final. This is what is released a bit in Java 8. You need not declare such variables as final but they still have to be effective final.
|
||||
|
||||
![Java 8 does not require final, only effective final](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/java_ee_-_javabeantester_src_main_java_com_javax0_jbt_blog_java_-_eclipse_-__users_verhasp_github_javax_blog.png)
|
||||
|
||||
Java 8 does not require final, only effective final
|
||||
|
||||
Why do you need to declare something final, when it has to checked to be like that anyway. Like method arguments. They also have to be final. You say that this is not a requirement of Java? Well, you are right. It is a requirement of programming in good style.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.javacodegeeks.com/2014/11/some-sentences-about-java.html
|
||||
|
||||
作者:[Peter Verhas][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.javacodegeeks.com/author/peter-verhas/
|
@ -0,0 +1,94 @@
|
||||
UbuTricks - 在ubuntu上安装几个最新游戏和应用的脚本
|
||||
===
|
||||
UbuTricks是一个可以帮助你在ubuntu上安装几个最新版本的游戏和应用的程序。
|
||||
|
||||
UbuTricks是一个有简单界面,基于Zenity的图形脚本。虽然早期开发中,它的目标是通过简单的界面操作来安装Ubuntu14.04 及以后发行版上应用程序的更新。
|
||||
|
||||
应用程序会自动下载安装。一些更新可能会需要ppa。其它的将会通过编译源代码安装。编译过程可能会需要一些时间,当从ppa或者deb文件安装应该会快一点,取决于你的下载速度。
|
||||
|
||||
###一共有以下几种安装方式:
|
||||
|
||||
- PPA - 程序将会从PPA下载安装
|
||||
- DEB - 程序将会从DEB文件进行安装
|
||||
- Source - 程序会进行编译安装 (可能需要一点时间)
|
||||
- Script - 程序会通过开发者提供的脚本进行安装
|
||||
- Archive - 程序会通过压缩文件安装
|
||||
- Repository - 程序从仓库安装 (不是PPA)
|
||||
|
||||
###你可以安装的应用程序列表
|
||||
|
||||
通过UbuTricks可以安装下面应用的最新版本:
|
||||
|
||||
###游戏
|
||||
|
||||
- 0 A.D.
|
||||
- Battle for Wesnoth (Dev)
|
||||
- VCMI (Heroes III Engine)
|
||||
|
||||
###文件管理
|
||||
|
||||
- PCManFM
|
||||
|
||||
###互联网
|
||||
|
||||
- Geary
|
||||
- HexChat
|
||||
- QupZilla
|
||||
- QuiteRSS
|
||||
|
||||
###多媒体
|
||||
|
||||
- SMPlayer
|
||||
- Transmageddon
|
||||
- Kdenlive
|
||||
- Fotoxx
|
||||
- jAlbum
|
||||
- GIMP
|
||||
- Shutter
|
||||
- Qmmp
|
||||
- XBMC
|
||||
|
||||
###办公/电子书/文档
|
||||
|
||||
- Calibre
|
||||
- LibreOffice
|
||||
|
||||
###工具
|
||||
|
||||
- Ubuntu Tweak
|
||||
|
||||
###桌面环境
|
||||
|
||||
- Cinnamon
|
||||
|
||||
###其他
|
||||
|
||||
- Google Earth
|
||||
- Wine
|
||||
|
||||
###下载,安装Ubuntutricks
|
||||
|
||||
你可以从[这里][1]下载ubuntutricks,让它可执行然后双击脚本或者从终端里运行它。
|
||||
|
||||
###截图
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/116.png)
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/213.png)
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/35.png)
|
||||
|
||||
![](http://www.ubuntugeek.com/wp-content/uploads/2014/10/45.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.ubuntugeek.com/ubutricks-script-to-install-the-latest-versions-of-several-games-and-applications-in-ubuntu.html
|
||||
|
||||
作者:[ruchi][a]
|
||||
译者:[DoubleShit](https://github.com/DoubleShit)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.ubuntugeek.com/author/ubuntufix
|
||||
[1]:http://www.tuxarena.com/intro/files/ubutricks.sh
|
65
translated/talk/20141108 When hackers grow old.md
Normal file
65
translated/talk/20141108 When hackers grow old.md
Normal file
@ -0,0 +1,65 @@
|
||||
黑客年暮
|
||||
================================================================================
|
||||
近来我一直在与某资深开源组织的各成员进行争斗,尽管密切关注我的人们会在读完本文后猜到是哪个组织,但我不会在这里说出这个组织的名字。
|
||||
|
||||
怎么让某些人进入 21 世纪就这么难呢?真是的...
|
||||
|
||||
我快56 岁了,也就是大部分年轻人会以为的我将时不时朝他们发出诸如“滚出我的草坪”之类歇斯底里咆哮的年龄。但事实并非如此 —— 我发现,尤其是在技术背景之下,我变得与我的年龄非常不相称。
|
||||
|
||||
在我这个年龄的大部分人确实变成了爱发牢骚、墨守成规的老顽固。并且,尴尬的是,偶尔我会成为那个打断谈话的人,然后提出在 1995 年(或者在某些特殊情况下,1985 年)时很适合的方法... 但十年后就不是个好方法了。
|
||||
|
||||
为什么是我?因为我的同龄人里大部分人在孩童时期都没有什么名气。任何想要改变自己的人,就必须成为他们中具有较高思想觉悟的佼佼者。即便如此,在与习惯做斗争的过程中,我也比实际上花费了更多的时间。
|
||||
|
||||
年轻人犯下无知的错误是可以被原谅的。他们还年轻。年轻意味着缺乏经验,缺乏经验通常会导致片面的判断。我很难原谅那些经历了足够多本该有经验的人,却被<em>长期的固化思维</em>蒙蔽,无法发觉近在咫尺的东西。
|
||||
|
||||
(补充一下:我真的不是老顽固。那些和我争论政治的,无论保守派还是非保守派都没有注意到这点,我觉得这颇有点嘲讽的意味。)
|
||||
|
||||
那么,现在我们来讨论下 GNU 更新日志文件这件事。在 1985 年的时候,这是一个不错的主意,甚至可以说是必须的。当时的想法是用单独的更新日志文件来记录相关文件的变更情况。用这种方式来对那些存在版本缺失或者非常原始的版本进行版本控制确实不错。当时我也在场,所以我知道这些。
|
||||
|
||||
不过即使到了 1995 年,甚至 21 世纪早期,许多版本控制系统仍然没有太大改进。也就是说,这些版本控制系统并非对批量文件的变化进行分组再保存到一条记录上,而是对每个变化的文件分别进行记录并保存到不同的地方。CVS,当时被广泛使用的版本控制系统,仅仅是模拟日志变更 —— 并且在这方面表现得很糟糕,导致大多数人不再依赖这个功能。即便如此,更新日志文件的出现依然是必要的。
|
||||
|
||||
但随后,版本控制系统 Subversion 于 2003 年发布 beta 版,并于 2004 年发布 1.0 正式版,Subversion 真正实现了更新日志记录功能,得到了人们的广泛认可。它与一年后兴起的分散式版本控制系统(Distributed Version Control System,DVCS)共同引发了主流世界的激烈争论。因为如果你在项目上同时使用了分散式版本控制与更新日志文件记录的功能,它们将会因为争夺相同元数据的控制权而产生不可预料的冲突。
|
||||
|
||||
另一种方法是对提交的评论日志进行授权。如果你这样做了,不久后你就会开始思忖为什么自己仍然对所有的日志更新条目进行记录。提交的元数据与变化的代码具有更好的相容性,毕竟这就是它当初设计的目的。
|
||||
|
||||
(现在,试想有这样一个项目,同样本着把项目做得最好的想法,但两拨人却做出了完全不同的选择。因此你必须同时阅读更新日志和评论日志以了解到底发生了什么。最好在矛盾激化前把问题解决....)
|
||||
|
||||
第三种办法是尝试同时使用两种方法 —— 以另一种格式再次提交评论数据,作为更新日志提交的一部分。这解决了所有你期待的有代表性的问题,并且没有任何缺陷遗留下来;只要其中有拷贝文件损坏,日志文件就会修改,因此这不再是同步时数据匹配的问题,而且导致在其后参与进来的人试图搞清人们是怎么想的时候将会变得非常困惑。
|
||||
|
||||
或者,如某个<em>我就不说出具体名字的特定项目</em>的高层开发只是通过电子邮件来完成这些,声明提交可以包含多个更新日志,以及提交的元数据与更新日志是无关的。这导致我们直到现在还得不断进行记录。
|
||||
|
||||
当我读到那条的时候我的眼光停在了那个地方。什么样的傻瓜才会没有意识到这是在自找麻烦 —— 事实上,针对更新日志文件采取的定制措施完全是不必要的,尤其是在分散式版本控制系统中
|
||||
有很好的浏览工具来阅读可靠的提交日志的时候。
|
||||
|
||||
唉,这是比较特殊的笨蛋:变老的并且思维僵化了的黑客。所有的合理化改革他都会极力反对。他所遵循的行事方法在十年前是有效的,但现在只能使得其反了。如果你试图解释不只是git的总摘要,还得正确掌握当前的各种工具才能完全弃用更新日志... 呵呵,准备好迎接无法忍受、无法想象的疯狂对话吧。
|
||||
|
||||
幸运的是这激怒了我。因为这点还有其他相关的胡言乱语使这个项目变成了很难完成的工作。而且,这类糟糕的事时常发生在年轻的开发者身上,这才是问题所在。相关 G+ 社群的数量已经达到了 4 位数,他们大部分都是孩子,他们也没有紧张起来。显然消息已经传到了外面;这个项目的开发者都是被莫名关注者的老牌黑客,同时还有很多对他们崇拜的人。
|
||||
|
||||
这件事给我的最大触动就是每当我要和这些老牌黑客较量时,我都会想:有一天我也会这样吗?或者更糟的是,我看到的只是如同镜子一般对我自己的真实写照,而我自己却浑然不觉吗?我的意思是,我的印象来自于他的网站,这个特殊的样本要比我年轻。通过十五年的仔细观察得出的结论。
|
||||
|
||||
我觉得思路很清晰。当我和那些比我聪明的人打交道时我不会受挫,我只会因为那些不能跟上我的人而
|
||||
沮丧,这些人也不能看见事实。但这种自信也许只是邓宁·克鲁格效应的消极影响,至少我明白这点。很少有什么事情会让我感到害怕;而这件事在让我害怕的事情名单上是名列前茅的。
|
||||
|
||||
另一件让人不安的事是当我逐渐变老的时候,这样的矛盾发生得越来越频繁。不知怎的,我希望我的黑客同行们能以更加优雅的姿态老去,即使身体老去也应该保持一颗年轻的心灵。有些人确实是这样;但可是绝大多数人都不是。真令人悲哀。
|
||||
|
||||
我不确定我的职业生涯会不会完美收场。假如我最后成功避免了思维僵化(注意我说的是假如),我想我一定知道其中的部分原因,但我不确定这种模式是否可以被复制 —— 为了达成目的也许得在你的头脑中发生一些复杂的化学反应。尽管如此,无论对错,请听听我给年轻黑客以及其他有志青年的建议。
|
||||
|
||||
你们 —— 对的,也包括你 —— 一定无法在你中年老年的时候保持不错的心灵,除非你能很好的控制这点。你必须不断地去磨练你的内心、在你还年轻的时候完成自己的种种心愿,你必须把这些行为养成一种习惯直到你老去。
|
||||
|
||||
有种说法是中年人锻炼身体的最佳时机是他进入中年的 30 年前。我以为同样的方法,坚持我以上所说的习惯能让你在 56 岁,甚至 65 岁的时候仍然保持灵活的头脑。挑战你的极限,使不断地挑战自己成为一种习惯。立刻离开安乐窝,由此当你以后真正需要它的时候你可以建立起自己的安乐窝。
|
||||
|
||||
你必须要清楚的了解这点;还有一个可选择的挑战是你选择一个可以实现的目标并且为了这个目标不断努力。这个月我要学习 Go 语言。不是指游戏,我早就玩儿过了(虽然玩儿的不是太好)。并不是因为工作需要,而是因为我觉得是时候来扩展下我自己了。
|
||||
|
||||
保持这个习惯。永远不要放弃。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://esr.ibiblio.org/?p=6485
|
||||
|
||||
作者:[Eric Raymond][a]
|
||||
译者:[Stevearzh](https://github.com/Stevearzh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://esr.ibiblio.org/?author=2
|
66
translated/talk/20141127 What Makes a Good Programmer.md
Normal file
66
translated/talk/20141127 What Makes a Good Programmer.md
Normal file
@ -0,0 +1,66 @@
|
||||
什么造就一个优秀的程序员?
|
||||
|
||||
================================================================================
|
||||
是什么造成一个优秀的程序员?首先问问你自己吧,这会是个有趣的问题。它让你反思自己软件开发的能力。这个问题也适合问问你的同事。它可以带来一些关于如何协同工作的有趣讨论。下面是五个我认为成为一个优秀程序员必备的重要技能。
|
||||
|
||||
### 1. 分解问题 ###
|
||||
|
||||
编程是为了解决问题,但在你开始写代码前,需要明白如何解决问题。优秀程序员的一项技能是把大的问题逐层分解成一个个更小的部分,直到每一部分都可以很容易解决。但找到解决问题的方式往往并没有那么简单。优秀程序员能找到方法去建立问题模型,这种方法使得输出结果的程序容易解释、实现和测试。
|
||||
|
||||
我写过的某些最复杂的程序在局部上都是难懂的,因为代码实现并不能很好地描述问题,也就导致了编写的代码难以理解。当问题很好建模的时候,我赞同伯尼·科赛尔所说的话(取自著名的[程序员在工作][1]中的访谈记录):
|
||||
|
||||
> “……很少有本质上很难的程序。如果你盯着某一块代码,它看起来确实很难;如果你无法理解某件事情应该产生什么结果,这基本上就暗示这件事情很难思考清楚了。在这个时候,你不应该卷起袖子,尝试修复代码;你需要只是往回一步,再仔细考虑清楚。当你已经深思熟虑后,你会发现问题变得很简单”。
|
||||
|
||||
### 2. 场景分析 ###
|
||||
|
||||
优秀开发者能考虑到如何使程序适合多种不同的场景。这项能力既适用于处理程序本身的逻辑,又适用于处理发生的外部和内部事件。为了考虑逻辑上的不同思路,他们问自己这样的问题:如果这个参数为空会发生什么?如果所有条件都为假呢?这个方法在线程上是安全的吗?为了发现软件需要处理的各种类型的事件,他们问自己这样的问题:如果队列占满了会怎样?如果请求收不到响应会怎样?如果在这台服务器重启的同时另外一台服务器也重启了会怎样?
|
||||
|
||||
优秀程序员问他们自己:如何打破自己的程序?换句话说,他们有能力像测试人员一样思考。相反,缺少经验的程序员通常只考虑正确的路径——在一切都按照预期进行时正常的控制流(当然这也是程序在大部分时候做的事情)。当然,异常不可避免要发生,所以需要程序能处理这些情况。
|
||||
|
||||
### 3. 命名 ###
|
||||
|
||||
编程由大量的命名对象组成:类、方法和变量。当编码完成时,程序也具备了自我描述的能力,也就是说通过阅读源代码可以清楚地明白程序中函数的含义。自描述代码的一个好处就是很自然地产生许多体积更小的方法,而不是少数体积大的方法,因为你有更多空间去放置有意义的名字(还有[其它原因][2]解释为什么短小方法更好)。
|
||||
|
||||
想出好的名字比它听起来更困难一些。我喜欢这段引用(来自菲尔·卡尔顿):“在计算机科学领域只有两件困难的事情:缓存失效和命名对象。”命名在一定程度上很困难是因为你需要清楚地明白每一个名字究竟要代表什么。有时候命名不是清楚,只有随着软件开发进展才会慢慢显现。因此,重命名和命名一样重要。
|
||||
|
||||
命名对象也包含提出要用的概念和这些概念该如何称呼。通过深思熟虑,清楚命名所使用的惯用概念(在程序中和与程序员、非程序员讨论时使用),这使得编写程序变得更加容易。
|
||||
|
||||
### 4. 一致性 ###
|
||||
|
||||
也许编程中最大的挑战是管理复杂性。保持一致性是处理复杂性的一种方法。它通过允许我们看到对象命名、使用和处理所采用的模式和推理来降低了某些复杂性。有了一致性,我们就无需用脑袋去记住异常和随机变量。取而代之,我们可以更关注[程序本身的复杂性,而不是偶然产生的复杂性][3]。
|
||||
|
||||
保持一致性是很重要的。它应用在变量名字和分组、方法命名、模块划分、目录结构、GUI、错误处理、日志输出和文档等很多方面。比如,如果某些变量是的相关,并一起出现(在声明、方法调用或数据库中的列),而且总是以相同的顺序使用它们。那么当其中一个消失或者整体被打乱时,你就会很容易发现。对于一个操作,如果在一个地方叫delete,就不要在另一个地方叫remove:务必使用相同的名字。史蒂夫·麦克奈尔在[代码大全][4]中对于使用相反命名有相同的建议。比如,begin和end是相反的,就如同start和stop一样。当使用相反对时不要混用不同对的名字(比如使用begin和stop)。
|
||||
|
||||
当修改一段程序时可能会引入非一致性。粗心大意的程序员不会注意到他们添加的代码是否和已有的代码保持一致。优秀程序员会严苛地确保在这些看似很小的细节上都要做得恰到好处。他们知道保持一致性对于在软件开发的整个过程中处理复杂性是多么的重要。
|
||||
|
||||
### 5. 学习能力 ###
|
||||
|
||||
作为一名软件开发者,你需要持续学习。在为软件添加一项新功能前,你必须明白为什么要这么做。在给一个已有程序添加代码前,你通常必须学习已有代码在做什么,以便合适地嵌入新功能。你还需要学习相关系统,以便正确地与它们交互。因此,快速学习的能力使你成为一名更加高效的开发者。
|
||||
|
||||
而且,因为软件工程领域的开发速度是如此的快速,所以新的编程语言、工具、技术和框架需要学习层出不穷。这是好还是坏,就看你怎么看。佛瑞德·布鲁克斯把学习能力列为[技能的快乐之一][5],对此我深表赞同。学习新事物本身就是令人心满意足的,它也意味着开发者的生活从不无聊。
|
||||
|
||||
### 总结 ###
|
||||
|
||||
上面所有的技能都是通用的——它们中没有一项是针对某种语言、某个框架或某种技术。如果你拥有它们,你就能快速学习一门新的语言或工具,在新的环境下写出优秀的软件。而且,因为它们在本质上是通用的,所以不会在若干年以后变得不实用。
|
||||
|
||||
这就是我对什么因素造就一个优秀程序员的回答。你认为造就一个优秀程序员的因素是哪些?在评论里让我知道吧。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://henrikwarne.com/2014/06/30/what-makes-a-good-programmer/
|
||||
|
||||
作者:[Henrik Warne][a]
|
||||
译者:[KayGuoWhu](https://github.com/KayGuoWhu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://henrikwarne.com/about/
|
||||
[1]:http://www.amazon.com/review/R2OV0TG7MJGXGL
|
||||
[2]:http://henrikwarne.com/2013/08/31/7-ways-more-methods-can-improve-your-program/
|
||||
[3]:http://faculty.salisbury.edu/~xswang/Research/Papers/SERelated/no-silver-bullet.pdf
|
||||
[4]:http://www.amazon.com/review/R269BBARXH1V6R/
|
||||
[5]:http://henrikwarne.com/2012/06/02/why-i-love-coding/
|
||||
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
|
||||
如何从Ubuntu的声音菜单中移除音乐播放器
|
||||
================================================================================
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/11/music-players.jpg)
|
||||
|
||||
|
||||
**自从2010年的介绍一来,Ubuntu声音菜单已经被证明是最流行和个性的统一桌面之一.**
|
||||
|
||||
随着音乐播放器与音量程序合成小体积的应用程序-即集成,其中一个希望找到与声音相关的蠢事-通过标准接口的灵感。人们不禁要问,为什么其它操作系统没有效仿这种做法!
|
||||
|
||||
#### 冗长的 ####
|
||||
|
||||
|
||||
尽管它看起来很方便,但是这个小应用当前存在一个问题:相当多的东西集在一起看起来想一个MP3,是否真正的把想要的东西都放在里面了。虽然有用,但是一个无所不再的应用程序清单已经安装了,这让一些不经常适用的人看着很累赘和反感。
|
||||
|
||||
|
||||
我将要打赌上面的截图看起来一定很熟悉,你们中的很多人一定阅读过吧!不要害怕,**dconf-editor **就在这里。
|
||||
|
||||
|
||||
|
||||
### 从Ubuntu 声音菜单中移除播放器 ###
|
||||
|
||||
|
||||
#### 第一部分: 基础知识 ####
|
||||
|
||||
最快速和最简单地从声音菜单中移除播放器的方法就是卸载相关的应用程序。但这是极端的方式,我的意思是指你也许想要保留应用程序,但是不需要它集成。
|
||||
|
||||
只删除播放器但是保留我们需要的应用程序,我们用到一个看起来令人惊讶的工具叫“dconf-editor”.
|
||||
|
||||
你可能已经安装了,如果没有安装的话,那么你从Ubuntu软件中心找出。
|
||||
|
||||
|
||||
- [在Ubuntu中点击安装Dconf-Editor][1]
|
||||
|
||||
一旦安装完毕,找到Unity Dash并打开。打开的时候不要惊慌;你不会再回到2002年了,它确实是这样子的。
|
||||
|
||||
|
||||
使用右侧菜单栏,你需要从导航到 com > canonical > indicator > sound.下面的面板将会出现。
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/11/dconf-editor.jpg)
|
||||
|
||||
双击靠近interested-media-players的比括号并删除你希望从声音菜单里移除掉的播放器,但需要保留在方括号中,且不要删除任何你想保留逗号或者撇号。
|
||||
|
||||
|
||||
举个例子,我移除掉这些
|
||||
|
||||
‘**rhythmbox.desktop**’, ‘**pithos.desktop**’, ‘**clementine.desktop**’,
|
||||
|
||||
这样就好留了一行如下:
|
||||
|
||||
['tomahawk.desktop']
|
||||
|
||||
现在,当我再打开声音菜单时,我只看到Tomahawk:
|
||||
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/11/music-players-2.jpg)
|
||||
|
||||
#### 第二部分:黑名单 ####
|
||||
|
||||
等等!还不能关闭dconf-editor。尽管上面的步骤看起来把事情处理得干净利落,但是一些播放器在打开时会立即重新加载到声音菜单。为了避免重复这个过程,将它们添加到**媒体播放器黑名单**中。
|
||||
|
||||
记得每个在撇括号里的播放器都用逗号分隔多个条目。他们也必须在方括号内,所以在退出之前请务必仔细检查。
|
||||
|
||||
最终结果如下:
|
||||
|
||||
![](http://www.omgubuntu.co.uk/wp-content/uploads/2014/10/from-to-.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.omgubuntu.co.uk/2014/11/remove-players-ubuntu-sound-menu
|
||||
|
||||
作者:[Joey-Elijah Sneddon][a]
|
||||
译者:[disylee](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117485690627814051450/?rel=author
|
||||
[1]:apt://dconf-editor
|
@ -0,0 +1,196 @@
|
||||
使用nice、cpulimit和cgroups限制cpu占用率
|
||||
================================================================================
|
||||
注:本文中的图片似乎都需要翻墙后才能看到,发布的时候注意
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/juggle.jpg)
|
||||
|
||||
Linux内核是一名了不起的马戏表演者,它在进程和系统资源间小心地玩着杂耍,并保持系统的能够正常运转。 同时,内核也很公正:它将资源公平地分配给各个进程。
|
||||
|
||||
但是,如果你需要给一个重要进程提高优先级时,该怎么做呢? 或者是,如何降低一个进程的优先级? 又或者,如何限制一组进程所使用的资源呢?
|
||||
|
||||
**答案是需要由用户来为内核指定进程的优先级**
|
||||
|
||||
大部分进程启动时的优先级时相同的,因此Linux内核会公平地进行调度。 如果想让一个CPU密集型的进程运行在低优先级,那么你就得事先配置好调度器。
|
||||
|
||||
下面介绍3种控制进程运行时间的方法:
|
||||
|
||||
- 使用nice命令手动减低任务的优先级。
|
||||
- 使用cpulimit命令控制进程的运行时间上限。
|
||||
- 使用linux内建的**control groups**功能,它提供了限制进程资源消耗的机制。
|
||||
|
||||
我们来看一下这3个工具的工作原理和各自的优缺点。
|
||||
|
||||
### 模拟高cpu占用率 ###
|
||||
|
||||
在分析这3种技术前,我们要先安装一个工具来模拟高CPU占用率的场景。我们会用到CentOS作为测试系统,并使用[Mathomatic toolkit][1]中的质数生成器来模拟CPU负载。
|
||||
|
||||
很不幸,在CentOS上这个工具没有预编译好的版本,所以必须要从源码进行安装。先从http://mathomatic.orgserve.de/mathomatic-16.0.5.tar.bz2这个链接下载源码包并解压。然后进入**mathomatic-16.0.5/primes**文件夹,运行**make** 和 **sudo make install**进行编译和安装。这样,就把**matho-primes**程序安装到了**/usr/local/bin**目录中。
|
||||
|
||||
接下来,通过命令行运行:
|
||||
|
||||
/usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
程序运行后,将输出从0到9999999999之间的质数。因为我们并不需要这些输出结果,直接将输出重定向到/dev/null就好。
|
||||
|
||||
现在,使用top命令就可以看到matho-primes进程榨干了你所有的cpu资源。
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image00.jpg)
|
||||
|
||||
好了,接下来退出top(按q键)并杀掉matho-primes进程(使用fg命令将进程切换到前台,再按CTRL+C)
|
||||
|
||||
### nice命令 ###
|
||||
下来介绍一下nice命令的使用方法,nice命令可以修改进程的优先级,这样就可以让进程运行得不那么频繁。 **这个功能在运行cpu密集型的后台进程或批处理作业时尤为有用。** nice值的取值范围是[-20,19],-20表示最高优先级,而19表示最低优先级。 Linux进程的默认nice值为0。使用nice命令(不带任何参数时)可以将进程的nice值设置为10。这样调度器就会将此进程视为低优先级的进程,从而减少cpu资源的分配。
|
||||
|
||||
下面来看一个例子,我们同时运行两个**matho-primes**进程,一个使用nice命令来启动运行,而另一个正常启动运行:
|
||||
|
||||
nice matho-primes 0 9999999999 > /dev/null &
|
||||
matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
再运行top命令。
|
||||
|
||||
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image05.jpg)
|
||||
|
||||
看到没,正常运行的进程(nice值为0)获得了更多的cpu运行时间,相反的,用nice命令运行的进程占用的cpu时间会较少(nice值为10)。
|
||||
|
||||
在实际使用中,如果你要运行一个CPU密集型的程序,那么最好用nice命令来启动它,这样就可以保证其他进程获得更高的优先级。 也就是说,即使你的服务器或者台式机在重载的情况下,也可以快速响应。
|
||||
|
||||
nice还有一个关联命令叫做renice,它可以在运行时调整进程的nice值。使用renice命令时,要先找出进程的PID。下面是一个例子:
|
||||
|
||||
renice +10 1234
|
||||
|
||||
其中,1234是进程的PID。
|
||||
|
||||
测试完**nice** 和 **renice**命令后,记得要将**matho-primes**进程全部杀掉。
|
||||
|
||||
### cpulimit命令 ###
|
||||
|
||||
接下来介绍 **cpulimit** 命令的用法。 **cpulimit** 命令的工作原理是为进程预设一个cpu占用率门限,并实时监控进程是否超出此门限,若超出则让该进程暂停运行一段时间。cpulimit使用 SIGSTOP和SIGCONT这两个信号来控制进程。它不会修改进程的nice值,而是通过监控进程的cpu占用率来做出动态调整。
|
||||
|
||||
cpulimit的优势是可以控制进程的cpu使用率的上限值。但与nice相比也有缺点,那就是即使cpu是空闲的,进程也不能完全使用整个cpu资源。
|
||||
|
||||
在CentOS上,可以用下面的方法来安装:
|
||||
|
||||
wget -O cpulimit.zip https://github.com/opsengine/cpulimit/archive/master.zip
|
||||
unzip cpulimit.zip
|
||||
cd cpulimit-master
|
||||
make
|
||||
sudo cp src/cpulimit /usr/bin
|
||||
|
||||
上面的命令行,会先从从GitHub上将源码下载到本地,然后再解压、编译、并安装到/usr/bin目录下。
|
||||
|
||||
cpulimit的使用方式和nice命令类似,但是需要用户使用-l选项显式地定义进程的cpu使用率上限值。举例说明:
|
||||
|
||||
cpulimit -l 50 matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image03.jpg)
|
||||
|
||||
从上面的例子可以看出matho-primes只使用了50%的cpu资源,剩余的cpu时间都为idle。
|
||||
|
||||
You can also limit a currently running process by specifying its PID using the ‘-p’ parameter. For example
|
||||
cpulimit还可以在运行时对进程进行动态限制,使用-p选项来指定进程的PID,下面是一个实例:
|
||||
|
||||
cpulimit -l 50 -p 1234
|
||||
|
||||
其中,1234是进程的PID。
|
||||
|
||||
### cgroups命令集 ###
|
||||
|
||||
最后介绍,功能最为强大的控制组(cgroups)的用法。cgroups是Linux内核提供的一种机制,利用它可以指定一组进程的资源分配。 具体来说,使用cgroups,用户能够限定一组进程的cpu占用率、系统内存消耗、网络带宽,以及这几种资源的组合。
|
||||
|
||||
对比nice和cpulimit,**cgroups的优势**在于它可以控制一组进程,不像前者仅能控制单进程。同时,nice和cpulimit只能限制cpu使用率,而cgroups可以限制其他进程资源的使用。
|
||||
|
||||
对cgroups善加利用就可以控制好整个子系统的资源消耗。就拿CoreOS作为例子,这是一个专为大规模服务器部署而设计的最简化的Linux发行版本,它的upgrade进程就是使用cgroups来管控。这样,系统在下载和安装升级版本时也不会影响到系统的性能。
|
||||
|
||||
下面做一下演示,我们将创建两个控制组(cgroups),并对其分配不同的cpu资源。这两个控制组分别命名为“cpulimited”和“lesscpulimited”。
|
||||
|
||||
使用cgcreate命令来创建控制组,如下所示:
|
||||
|
||||
sudo cgcreate -g cpu:/cpulimited
|
||||
sudo cgcreate -g cpu:/lesscpulimited
|
||||
|
||||
其中“-g cpu”选项用于设定cpu的使用上限。除此cpu外,cgroups还提供cpuset、memory、blkio等控制器。cpuset控制器与cpu控制器的不同在于,cpu控制器只能限制一个cpu核的使用率,而cpuset可以控制多个cpu核。
|
||||
|
||||
cpu控制器中的cpu.shares属性用于控制cpu使用率。它的默认值是1024,我们将lesscpulimited控制组的cpu.shares设为1024(默认值),而cpulimited设为512,配置后内核就会按照2:1的比例为这两个控制组分配资源。
|
||||
|
||||
To set the cpu.shares to 512 in the cpulimited group, type:
|
||||
|
||||
sudo cgset -r cpu.shares=512 cpulimited
|
||||
|
||||
使用cgexec命令来启动控制组的运行,为了测试这两个控制组,我们先用cpulimited控制组来启动matho-primes进程,命令行如下:
|
||||
|
||||
sudo cgexec -g cpu:cpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
打开top可以看到,matho-primes进程占用了所有的cpu资源。
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image01.jpg)
|
||||
|
||||
因为只有一个进程在系统中运行,不管将其放到哪个控制组中启动,它都会尽可能多的使用cpu资源。cpu资源限制只有在两个进程争夺cpu资源时才会生效。
|
||||
|
||||
那么,现在我们就启动第二个matho-primes进程,这一次我们在lesscpulimited控制组中来启动它:
|
||||
|
||||
sudo cgexec -g cpu:lesscpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
再打开top就可以看到,cpu.shares值大的控制组会得到更多的cpu运行时间。
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image02.jpg)
|
||||
|
||||
现在,我们再在cpulimited控制组中增加一个matho-primes进程:
|
||||
|
||||
sudo cgexec -g cpu:cpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/image04.jpg)
|
||||
|
||||
看到没,两个控制组的cpu的占用率比例仍然为2:1。其中,cpulimited控制组中的两个matho-primes进程获得的cpu时间基本相当,而另一组中的matho-primes进程显然获得了更多的运行时间。
|
||||
|
||||
更多的使用方法,可以在Red Hat上查看详细的cgroups使用[说明][2]。(当然CentOS 7也有)
|
||||
|
||||
### 使用Scout来监控cpu占用率 ###
|
||||
|
||||
监控cpu占用率最为简单的方法是什么?[Scout][3]工具能够监控能够自动监控进程的cpu使用率和内存使用情况。
|
||||
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/server_view/processes.png)
|
||||
|
||||
[Scout][3]的触发器(trigger)功能还可以设定cpu和内存的使用门限,超出门限时会自动产生报警。
|
||||
|
||||
从这里可以获取[Scout][4]的试用版。
|
||||
|
||||
### 总结 ###
|
||||
![](https://dl.dropboxusercontent.com/u/468982/blog/cpu_usage_blog/overview.png)
|
||||
|
||||
计算机的系统资源是非常宝贵的。上面介绍的这3个工具能够帮助大家有效地管理系统资源,特别是cpu资源:
|
||||
|
||||
- **nice**可以一次性调整进程的优先级。
|
||||
- **cpulimit**在运行cpu密集型任务且要保持系统的响应性时会很有用。
|
||||
- **cgroups**是资源管理的瑞士军刀,同时在使用上也很灵活。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://blog.scoutapp.com/articles/2014/11/04/restricting-process-cpu-usage-using-nice-cpulimit-and-cgroups
|
||||
|
||||
译者:[coloka](https://github.com/coloka)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.mathomatic.org/
|
||||
[2]:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Resource_Management_and_Linux_Containers_Guide/chap-Introduction_to_Control_Groups.html
|
||||
[3]:https://scoutapp.com/
|
||||
[4]:https://scoutapp.com/
|
||||
[5]:
|
||||
[6]:
|
||||
[7]:
|
||||
[8]:
|
||||
[9]:
|
||||
[10]:
|
||||
[11]:
|
||||
[12]:
|
||||
[13]:
|
||||
[14]:
|
||||
[15]:
|
||||
[16]:
|
||||
[17]:
|
||||
[18]:
|
||||
[19]:
|
||||
[20]:
|
@ -0,0 +1,179 @@
|
||||
Linux问答时间--如何在CentOS上安装phpMyAdmin
|
||||
================================================================================
|
||||
> **问题**:我正在CentOS上运行一个MySQL/MariaDB服务,并且我想要通过网络接口来用phpMyAdmin来管理数据库。在CentOS上安装phpMyAdmin的最佳方法是什么?
|
||||
|
||||
phpMyAdmin是一款以PHP为基础,基于Web的MySQL/MariaDB数据库管理工具。虽然已经存在着一些诸如[Adminer][1]的轻量级数据库管理工具, 但是phpMyAdmin还是更加广泛应用于网站管理员之中来进行各种MySQL/MariaDB的管理任务。它支持几乎所有MySQL数据库/表的相关操作,比如浏览、创建、复制、删除、重命名、更改,还有MySQL用户/权限管理和数据库导入/导出。以下就是**如何在CentOS 6或7上安装phpMyAdmin**。
|
||||
|
||||
### 前提 ###
|
||||
|
||||
在CentOS上安装phpMyAdmin,你第一步需要架设一台Web服务器(如Apache或nginx),安装好MySQL/MariaDB数据库和PHP。根据你的偏好和需求,你可以从[LAMP][2]和[LEMP][3]中选择一种安装。
|
||||
|
||||
另一个要求是允许在你的CentOS上安装EPEL库。如果你还没设置过请[猛戳这里][4]。
|
||||
|
||||
### 在CentOS6或7上安装phpMyAdmin ###
|
||||
|
||||
一旦你设置了EPEL库,你就能轻松地用以下命令安装phpMyAdmin了。
|
||||
|
||||
在CentOS 7上:
|
||||
|
||||
$ sudo yum install phpmyadmin
|
||||
|
||||
在CentOS 7上:
|
||||
|
||||
$ sudo yum install phpmyadmin php-mcrypt
|
||||
|
||||
### 在CentOS 7上配置phpMyAdmin ###
|
||||
|
||||
默认情况下,CentOS 7上的phpMyAdmin只允许从回环地址(127.0.0.1)访问。为了能远程连接,你需要改动它的配置。
|
||||
|
||||
用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉带有"Require ip XXXX"字样的代码行。会有四处这样的代码行,用"Require all granted"取而代之。重新改动过的配置文件如下所示。
|
||||
|
||||
$ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf
|
||||
|
||||
----------
|
||||
|
||||
. . . . .
|
||||
<Directory /usr/share/phpMyAdmin/>
|
||||
AddDefaultCharset UTF-8
|
||||
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
<RequireAny>
|
||||
#Require ip 127.0.0.1
|
||||
#Require ip ::1
|
||||
Require all granted
|
||||
</RequireAny>
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
Allow from 127.0.0.1
|
||||
Allow from ::1
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/phpMyAdmin/setup/>
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
<RequireAny>
|
||||
#Require ip 127.0.0.1
|
||||
#Require ip ::1
|
||||
Require all granted
|
||||
</RequireAny>
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
Allow from 127.0.0.1
|
||||
Allow from ::1
|
||||
</IfModule>
|
||||
</Directory>
|
||||
. . . . .
|
||||
|
||||
最后,重启httpd使改动生效。
|
||||
|
||||
$ sudo systemctl restart httpd
|
||||
|
||||
### 在CentOS 6上配置phpMyAdmin ###
|
||||
|
||||
默认情况下,CentOS 6上的phpMyAdmin是禁止从每个IP地址访问的。为了能远程连接,你需要改动它的配置。
|
||||
|
||||
用文本编辑器打开phpMyAdmin的配置文件(路径:/etc/httpd/conf.d/phpMyAdmin.conf),找出并注释掉"Deny from all"字样的代码行。然后把"Allow from 127.0.0.1"字样的代码行改成"Allow from 0.0.0.0"。重新改动过的配置文件如下所示。
|
||||
|
||||
$ sudo vi /etc/httpd/conf.d/phpmyadmin.conf
|
||||
|
||||
----------
|
||||
|
||||
<Directory "/usr/share/phpmyadmin">
|
||||
Order Deny,Allow
|
||||
# Deny from all
|
||||
Allow from 0.0.0.0
|
||||
</Directory>
|
||||
|
||||
下一步是将phpMyAdmin的配置文件用blowfish加密工具加密。这一步需要加密cookie里的密码来作为基于cookie的部分认证。
|
||||
|
||||
用文本编辑器打开如下路径所示的文件并且用blowfish设置一个随机密码,如下所示。
|
||||
|
||||
$ sudo vi /usr/share/phpmyadmin/config.inc.php
|
||||
|
||||
----------
|
||||
|
||||
$cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
|
||||
|
||||
最后,重启httpd使改动生效。
|
||||
|
||||
$ sudo service httpd restart
|
||||
|
||||
### 测试phpMyAdmin ###
|
||||
|
||||
测试phpMyAdmin是否设置成功,访问这个页面:http://<web-server-ip-addresss>/phpmyadmin
|
||||
|
||||
![](https://farm6.staticflickr.com/5606/15550758749_0f7ab66b5b_z.jpg)
|
||||
|
||||
你应该能通过Web界面来记录下任何MySQL用户(比如root)和管理MySQL/MariaDB的数据库/表。
|
||||
|
||||
![](https://farm8.staticflickr.com/7505/15551187008_86ac7e7db1_z.jpg)
|
||||
|
||||
### 疑难解答 ###
|
||||
|
||||
这里有一些在CentOS上安装phpMyAdmin的过程中遇到的一些问题解决方法。
|
||||
|
||||
1. 当你在浏览器里尝试连接phpMyAdmin页面的时候,你看到"403 Forbidding"错误:
|
||||
|
||||
You don't have permission to access /phpMyAdmin on this server.
|
||||
|
||||
发生这种错误是因为phpMyAdmin默认阻止了IP地址远程连接。要修复这种错误,你需要编辑它的配置文件来允许远程连接。具体操作见上。
|
||||
|
||||
2. 当你连接phpMyAdmin页面时,你看见"The configuration file now needs a secret passphrase (blowfish_secret)."信息,并且你无法登录。
|
||||
|
||||
要修复这种错误,你需要编辑 /usr/share/phpmyadmin/config.inc.php 这个文件来添加一个随机的blowfish密码,然后重启httpd,如下所示。
|
||||
|
||||
$cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
|
||||
|
||||
----------
|
||||
|
||||
$ sudo service httpd restart (CentOS 6)
|
||||
$ sudo systemctl restart httpd (CentOS 7)
|
||||
|
||||
3. 当你连接phpMyAdmin页面时,你看见"Cannot load mcrypt extension. Please check your PHP configuration"错误信息。
|
||||
|
||||
要修复这种错误,要安装下面这个包:
|
||||
|
||||
$ sudo yum install php-mcrypt
|
||||
|
||||
然后重启httpd:
|
||||
|
||||
$ sudo service httpd restart (CentOS 6)
|
||||
$ sudo systemctl restart httpd (CentOS 7)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-phpmyadmin-centos.html
|
||||
|
||||
译者:[ZTinoZ](https://github.com/ZTinoZ)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://xmodulo.com/set-web-based-database-management-system-adminer.html
|
||||
[2]:http://xmodulo.com/install-lamp-stack-centos.html
|
||||
[3]:http://xmodulo.com/install-lemp-stack-centos.html
|
||||
[4]:http://xmodulo.com/how-to-set-up-epel-repository-on-centos.html
|
||||
[5]:
|
||||
[6]:
|
||||
[7]:
|
||||
[8]:
|
||||
[9]:
|
||||
[10]:
|
||||
[11]:
|
||||
[12]:
|
||||
[13]:
|
||||
[14]:
|
||||
[15]:
|
||||
[16]:
|
||||
[17]:
|
||||
[18]:
|
||||
[19]:
|
||||
[20]:
|
@ -1,51 +1,51 @@
|
||||
15 ‘pwd’ (Print Working Directory) Command Examples in Linux
|
||||
15条Linux下的‘pwd’命令(打印工作目录)示例
|
||||
================================================================================
|
||||
For those working with Linux command Line, command ‘**pwd**‘ is very helpful, which tells where you are – in which directory, starting from the root (**/**). Specially for Linux newbies, who may get lost amidst of directories in command Line Interface while navigation, command ‘**pwd**‘ comes to rescue.
|
||||
对于那些使用Linux命令行的人来说,‘**pwd**‘命令是非常有用的,它告诉你你现在在那个目录,从根目录(**/**)开始。特别对于或许会在目录的切换间容易糊涂的Linux新手而言,‘**pwd**‘ 可以拯救他们。
|
||||
|
||||
![15 pwd Command Examples](http://www.tecmint.com/wp-content/uploads/2014/11/pwd-command.png)
|
||||
|
||||
15 pwd Command Examples
|
||||
15 pwd 命令示例
|
||||
|
||||
### What is pwd? ###
|
||||
### 什么是pwd? ###
|
||||
|
||||
‘**pwd**‘ stands for ‘**Print Working Directory**‘. As the name states, command ‘**pwd**‘ prints the current working directory or simply the directory user is, at present. It prints the current directory name with the complete path starting from root (**/**). This command is built in shell command and is available on most of the shell – bash, Bourne shell, ksh,zsh, etc.
|
||||
‘**pwd**‘ 代表的是‘**Print Working Directory**’(打印当前目录)。如它的名字那样,‘**pwd**’会打印出当前工作目录或仅是目录用户。它会打印出以root (**/**)为起始的完整目录名。这条命令是一条shell内建命令,并且在大多数shell中都可以使用,如bash、Bourne shell,ksh、zsh等等。
|
||||
|
||||
#### Basic syntax of pwd: ####
|
||||
#### pwd的基本语法: ####
|
||||
|
||||
# pwd [OPTION]
|
||||
|
||||
#### Options used with pwd ####
|
||||
#### pwd的选项 ####
|
||||
|
||||
<table border="0" cellspacing="0">
|
||||
<colgroup width="126"></colgroup>
|
||||
<colgroup width="450"></colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td height="21" align="LEFT" style="border: 1px solid #000000;"><b><span style="font-size: small;"> Options</span></b></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><b><span style="font-size: small;"> Description</span></b></td>
|
||||
<td height="21" align="LEFT" style="border: 1px solid #000000;"><b><span style="font-size: small;"> 选项</span></b></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><b><span style="font-size: small;"> 描述</span></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> -L (logical)</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> Use PWD from environment, even if it contains symbolic links</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> 使用环境中的路径,即使包含了符号链接</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> -P (physical)</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> Avoid all symbolic links</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> 避免所有的符号链接</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> –help </span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> Display this help and exit</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> 显示帮助并退出</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> –version</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> Output version information and exit</span></td>
|
||||
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;"> 输出版本信息并退出</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
If both ‘**-L**‘ and ‘**-P**‘ options are used, option ‘**L**‘ is taken into priority. If no option is specified at the prompt, pwd will avoid all symlinks, i.e., take option ‘**-P**‘ into account.
|
||||
如果同时使用了‘**-L**‘和‘**-P**‘,‘**-L**‘会有更高的优先级。如果没有指定参数,pwd会避开所有的软链接,也就是说会使用‘**-P**‘参数。
|
||||
|
||||
Exit status of command pwd:
|
||||
pwd的退出状态:
|
||||
|
||||
<table border="0" cellspacing="0">
|
||||
<colgroup width="128"></colgroup>
|
||||
@ -53,18 +53,18 @@ Exit status of command pwd:
|
||||
<tbody>
|
||||
<tr>
|
||||
<td height="19" align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">0</span></td>
|
||||
<td align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">Success</span></td>
|
||||
<td align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">成功</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="19" align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">Non-zero</span></td>
|
||||
<td align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">Failure</span></td>
|
||||
<td align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">失败</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
This article aims at providing you a deep insight of Linux command ‘**pwd**‘ with practical examples.
|
||||
本篇的目的是采用例子让你对‘**pwd**‘有更深入的领悟。
|
||||
|
||||
**1.** Print your current working directory.
|
||||
**1.** 打印放钱工作目录.
|
||||
|
||||
avi@tecmint:~$ /bin/pwd
|
||||
|
||||
@ -72,20 +72,20 @@ This article aims at providing you a deep insight of Linux command ‘**pwd**‘
|
||||
|
||||
![Print Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/pwd.gif)
|
||||
|
||||
Print Working Directory
|
||||
打印工作目录
|
||||
|
||||
**2.** Create a symbolic link of a folder (say **/var/www/html** into your home directory as **htm**). Move to the newly created directory and print working directory with symbolic links and without symbolic links.
|
||||
**2.** 为文件夹创建一个符号链接(比如说在home目录下创建一个**htm**链接指向**/var/www/html**)。进入新创建的目录并打印出含有以及不含符号链接的目录。
|
||||
|
||||
Create a symbolic link of folder /var/www/html as htm in your home directory and move to it.
|
||||
在home目录下创建一个htm链接指向/var/www/html,并进入。
|
||||
|
||||
avi@tecmint:~$ ln -s /var/www/html/ htm
|
||||
avi@tecmint:~$ cd htm
|
||||
|
||||
![Create Symbolic Link](http://www.tecmint.com/wp-content/uploads/2014/11/Create-Symbolic-Link.gif)
|
||||
|
||||
Create Symbolic Link
|
||||
创建符号链接
|
||||
|
||||
**3.** Print working directory from environment even if it contains symlinks.
|
||||
**3.** 从当前环境中答应目录即使它含有符号链接。
|
||||
|
||||
avi@tecmint:~$ /bin/pwd -L
|
||||
|
||||
@ -93,9 +93,9 @@ Create Symbolic Link
|
||||
|
||||
![Print Current Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Print-Working-Directory.gif)
|
||||
|
||||
Print Current Working Directory
|
||||
打印工作目录
|
||||
|
||||
**4.** Print actual physical current working directory by resolving all symbolic links.
|
||||
**4.** 解析符号链接并打印出物理目录。
|
||||
|
||||
avi@tecmint:~$ /bin/pwd -P
|
||||
|
||||
@ -103,9 +103,9 @@ Print Current Working Directory
|
||||
|
||||
![Print Physical Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Print-Physical-Working-Directory.gif)
|
||||
|
||||
Print Physical Working Directory
|
||||
打印物理工作目录
|
||||
|
||||
**5.** Check if the output of command “**pwd**” and “**pwd -P**” are same or not i.e., if no options are given at run-time does “**pwd**” takes option **-P** into account or not, automatically.
|
||||
**5.** 查看一下“**pwd**”和“**pwd -P**”的输出是否一致,也就是说,如果没有跟上选项,“**pwd**”时候会自动采用**-P**选项。
|
||||
|
||||
avi@tecmint:~$ /bin/pwd
|
||||
|
||||
@ -113,11 +113,11 @@ Print Physical Working Directory
|
||||
|
||||
![Check pwd Output](http://www.tecmint.com/wp-content/uploads/2014/11/Check-pwd-Output.gif)
|
||||
|
||||
Check pwd Output
|
||||
检查pwd输出
|
||||
|
||||
**Result:** It’s clear from the above output of example 4 and 5 (both result are same) thus, when no options are specified with command “**pwd**”, it automatically takes option “**-P**” into account.
|
||||
**结论:** 上面例子4和5的输出很明显(结果相同),当你“**pwd**”后面不带参数时,pwd会使用“**-P**”选项。
|
||||
|
||||
**6.** Print version of your ‘pwd’ command.
|
||||
**6.** 打印pwd命令的版本。
|
||||
|
||||
avi@tecmint:~$ /bin/pwd --version
|
||||
|
||||
@ -131,15 +131,15 @@ Check pwd Output
|
||||
|
||||
![Check pwd Version](http://www.tecmint.com/wp-content/uploads/2014/11/Check-pwd-Version.gif)
|
||||
|
||||
Check pwd Version
|
||||
检查pwd命令版本
|
||||
|
||||
**Note:** A ‘pwd’ command is often used without options and never used with arguments.
|
||||
**注意:** ‘pwd’ 通常不带选项运行,且没有任何参数
|
||||
|
||||
**Important:** You might have noticed that we are executing the above command as “**/bin/pwd**” and not “**pwd**”.
|
||||
**重要:** 你可能注意到我们刚才运行的都是 “**/bin/pwd**” 而不是 “**pwd**”。
|
||||
|
||||
So what’s the difference? Well “**pwd**” alone means shell built-in pwd. Your shell may have different version of pwd. Please refer manual. When we are using **/bin/pwd**, we are calling the binary version of that command. Both the shell and the binary version of command Prints Current Working Directory, though the binary version have more options.
|
||||
这有什么区别呢?直接使用“**pwd**”意味着使用shell内置的pwd。你的shell可能有不同版本的pwd。具体请参考手册。当你使用的是**/bin/pwd**时,我们调用的是二进制版本的命令。虽然二进制的版本有更多的选项,但是它们两者都能打印当前的目录。
|
||||
|
||||
**7.** Print all the locations containing executable named pwd.
|
||||
**7.** 打印所有含有可执行pwd的路径
|
||||
|
||||
avi@tecmint:~$ type -a pwd
|
||||
|
||||
@ -148,9 +148,9 @@ So what’s the difference? Well “**pwd**” alone means shell built-in pwd. Y
|
||||
|
||||
![Print Executable Locations](http://www.tecmint.com/wp-content/uploads/2014/11/Print-Executable-Locations.gif)
|
||||
|
||||
Print Executable Locations
|
||||
打印可执行文件路径
|
||||
|
||||
**8.** Store the value of “**pwd**” command in variable (say **a**), and print its value from the variable (important for shell scripting perspective).
|
||||
**8.** 存储“**pwd**”命令的值到变量中(比如说:**a** ),并从中打印i变量的值(对于观察shell脚本很重要)。
|
||||
|
||||
avi@tecmint:~$ a=$(pwd)
|
||||
avi@tecmint:~$ echo "Current working directory is : $a"
|
||||
@ -159,11 +159,11 @@ Print Executable Locations
|
||||
|
||||
![Store Pwd Value in Variable](http://www.tecmint.com/wp-content/uploads/2014/11/Store-Pwd-Value-in-Variable.gif)
|
||||
|
||||
Store Pwd Value in Variable
|
||||
存储pwd的值到变量中。
|
||||
|
||||
Alternatively, we can use **printf**, in the above example.
|
||||
下面的例子中也可以用**printf**来替代。
|
||||
|
||||
**9.** Change current working directory to anything (say **/home**) and display it in command line prompt. Execute a command (say ‘**ls**‘) to verify is everything is **OK**.
|
||||
**9.** 将工作路径切换到其他地方(比如说 **/home**),并在命令行中显示。通过执行命令(比如说 ‘**ls**‘)来验证一切**OK**。
|
||||
|
||||
avi@tecmint:~$ cd /home
|
||||
avi@tecmint:~$ PS1='$pwd> ' [Notice single quotes in the example]
|
||||
@ -171,14 +171,14 @@ Alternatively, we can use **printf**, in the above example.
|
||||
|
||||
![Change Current Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Change-Current-Working-Directory.gif)
|
||||
|
||||
Change Current Working Directory
|
||||
改变当前工作路径
|
||||
|
||||
**10.** Set multi-line command line prompt (say something like below).
|
||||
**10.** 设置多行显示 (就像下面这样),
|
||||
|
||||
/home
|
||||
123#Hello#!
|
||||
|
||||
And then execute a command (say **ls**) to check is everything is **OK**.
|
||||
接着执行命令(比如说 **ls**)来检验一切**OK**。
|
||||
|
||||
avi@tecmint:~$ PS1='
|
||||
> $PWD
|
||||
@ -190,9 +190,9 @@ And then execute a command (say **ls**) to check is everything is **OK**.
|
||||
|
||||
![Set Multi Commandline Prompt](http://www.tecmint.com/wp-content/uploads/2014/11/Set-Multi-Commandline-Prompt.gif)
|
||||
|
||||
Set Multi Commandline Prompt
|
||||
设置多行显示
|
||||
|
||||
**11.** Check the current working directory and previous working directory in one GO!
|
||||
**11.** 一下子检查当前工作路径以及先前的工作路径。
|
||||
|
||||
avi@tecmint:~$ echo “$PWD $OLDPWD”
|
||||
|
||||
@ -201,28 +201,29 @@ Set Multi Commandline Prompt
|
||||
![Check Present Previous Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Check-Present-Previous-Working-Directory.gif)
|
||||
|
||||
Check Present Previous Working Directory
|
||||
检查当前工作路径
|
||||
|
||||
**12.** What is the absolute path (starting from **/**) of the pwd binary file.
|
||||
**12.** pwd文件的绝对路径(以**/**开始)。
|
||||
|
||||
/bin/pwd
|
||||
|
||||
**13.** What is the absolute path (starting from **/**) of the pwd source file.
|
||||
**13.** pwd源文件文件的绝对路径(以**/**开始)。
|
||||
|
||||
/usr/include/pwd.h
|
||||
|
||||
**14.** Print the absolute path (starting from **/**) of the pwd manual pages file.
|
||||
**13.** 打印pwd手册的绝对路径(以**/**开始)。
|
||||
|
||||
/usr/share/man/man1/pwd.1.gz
|
||||
|
||||
**15.** Write a shell script analyses current directory (say **tecmint**) in your home directory. If you are under directory **tecmint** it output “**Well! You are in tecmint directory**” and then print “**Good Bye**” else create a directory **tecmint** under your home directory and ask you to cd to it.
|
||||
**15.** 写一个shell脚本分析home目录下的一个目录(比如**tecmint**)。如果当前目录是**tecmint**就输出“**Well! You are in tecmint directory**”接着输出“**Good Bye**”,不然就在**tecmint**下面创建一个目录并提示你cd进入它。
|
||||
|
||||
Let’s first create a ‘tecmint’ directory, under it create a following shell script file with name ‘pwd.sh’.
|
||||
让我们首先创建一个‘tecmint’目录,在下面创建一个名为‘pwd.sh’的脚本文件。
|
||||
|
||||
avi@tecmint:~$ mkdir tecmint
|
||||
avi@tecmint:~$ cd tecmint
|
||||
avi@tecmint:~$ nano pwd.sh
|
||||
|
||||
Next, add the following script to the pwd.sh file.
|
||||
接下来在pwd.sh中加入下面的脚本。
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
@ -240,7 +241,7 @@ Next, add the following script to the pwd.sh file.
|
||||
}
|
||||
fi
|
||||
|
||||
Give execute permission and run it.
|
||||
给予他执行权限并运行。
|
||||
|
||||
avi@tecmint:~$ chmod 755 pwd.sh
|
||||
avi@tecmint:~$ ./pwd.sh
|
||||
@ -248,16 +249,16 @@ Give execute permission and run it.
|
||||
Well you are in tecmint directory
|
||||
Good Bye
|
||||
|
||||
#### Conclusion ####
|
||||
#### 总结 ####
|
||||
|
||||
**pwd** is one of the simplest yet most popular and most widely used command. A good command over pwd is basic to use Linux terminal. That’s all for now. I’ll be here again with another interesting article soon, till then stay tuned and connected to Tecmint.
|
||||
**pwd**是一个最简单且会广泛用到的命令。掌握好pwd是使用Linux终端的基础。就是这些了。我很快会再带来另外有趣的注意,请不要走开继续关注Tecmint。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/pwd-command-examples/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,67 @@
|
||||
Linux 有问必答 -- 如何从VirtualBox中从主机访问NAT客户机
|
||||
================================================================================
|
||||
> **提问**: 我有一台运行在VirtualBox上的使用NAT的虚拟机。因此虚拟机会被VirtualBox分配一个私有IP地址(10.x.x.x)。如果我想要从主机SSH到虚拟机中,我该怎么做?
|
||||
|
||||
VirtualBox对虚拟机支持几种不同的网络方式,其中一种是NAT网络。当虚拟机启用NAT后,VirtualBox会自动在虚拟机和主机之间进行网络翻译,因此你不于必在虚拟机和主机之间配置任何东西。这也意味着NAT中的虚拟机对于外部网络以及主机本身是不可见的。这会在你想要从主机访问虚拟机时会产生问题(比如SSH)。
|
||||
|
||||
如果你想从VirtualBox的NAT环境的虚拟机,你可以在GUI或者命令行下启用VirtualBox NAT的端口转发。本篇教程将会演示**如何通过启用22端口转发而从主机SSH连接到NAT环境的客户机**。如果你先想要从HTTP访问NAT的客户机,用80端口代替22端口即可。
|
||||
|
||||
### 通过GUI配置VirtualBox端口转发 ###
|
||||
|
||||
在VirtualBox中选择你想要访问的虚拟机,打开虚拟机的“设置”。点击左侧的“网络”菜单,点击网络适配选项的“高级”。
|
||||
|
||||
![](https://farm8.staticflickr.com/7583/15797904856_2753dc785e_z.jpg)
|
||||
|
||||
点击“端口转发”按钮
|
||||
|
||||
![](https://farm8.staticflickr.com/7527/15636152708_cf2be7c7e8_z.jpg)
|
||||
|
||||
你会看到一个配置端口转发规则的窗口。点击右上角的“添加”图标。
|
||||
|
||||
![](https://farm8.staticflickr.com/7489/15636391217_48a9954480_z.jpg)
|
||||
|
||||
就会看到像下面那样的转发规则。
|
||||
|
||||
- **Name**: SSH (可以是任意唯一名)
|
||||
- **Protocol**: TCP
|
||||
- **Host IP**: 127.0.0.1
|
||||
- **Host Port**: 2222 (任何大于1024未使用的端口)
|
||||
- **Guest IP**: 虚拟机IP
|
||||
- **Guest Port**: 22 (SSH 端口)
|
||||
|
||||
![](https://farm6.staticflickr.com/5603/15202135853_02a07c3212_o.png)
|
||||
|
||||
端口转发的规则会自动在你启动虚拟机的时候启用。为了验证。可以在你启用虚拟机后检查端口2222是否被VirtualBox开启了。
|
||||
|
||||
$ sudo netstat -nap | grep 2222
|
||||
|
||||
![](https://farm8.staticflickr.com/7461/15819682411_6bb9707f8a_z.jpg)
|
||||
|
||||
现在端口转发可以使用了,你可以用下面的命令SSH到虚拟机。
|
||||
|
||||
$ ssh -p 2222 <login>@127.0.0.1
|
||||
|
||||
发送到127.0.0.1:2222的登录请求会自动被VirtualBox翻译成10.0.2.15:22,这可以让你SSH到虚拟机中。
|
||||
|
||||
### 通过命令行配置VirtualBox端口转发 ###
|
||||
|
||||
VirtualBox有一个称为VBoxManage的命令行管理工具。使用命令行工具,你也可以为你的虚拟机设置端口转发。
|
||||
|
||||
下面的命令会为IP地址为10.0.2.15的虚拟机设置一个名字为"centos7"的端口转发规则,SSH的端口号为22,映射到本地主机的端口为2222。规则的名字(本例中是SSH)必须是唯一的。
|
||||
|
||||
$ VBoxManage modifyvm "centos7" --natpf1 "SSH,tcp,127.0.0.1,2222,10.0.2.15,22"
|
||||
|
||||
规则创建之后,你可以用下面的命令来验证。
|
||||
|
||||
$ VBoxManage showvminfo "centos7" | grep NIC
|
||||
|
||||
![](https://farm8.staticflickr.com/7559/15636458427_7a0959900c_z.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/access-nat-guest-from-host-virtualbox.html
|
||||
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,103 @@
|
||||
如何在Ubuntu上使用MultiSystem创建多启动USB
|
||||
================================================================================
|
||||
### 介绍 ###
|
||||
|
||||
一些人并不知道**MultiSystem**是一个小型的开源软件来在Linux系统中创建多启动usb盘。使用这个工具,我们可以在USB中创建任意多的可启动Linux发行版。你所要的只是网络链接(之在MultiSystem安装的时候需要),以及一个足够大的USB盘,这取决于你想在USB盘中放入发行版的数量。
|
||||
|
||||
### 在 Ubuntu 14.10/14.04 安装MultiSystem ###
|
||||
|
||||
#### 手动安装: ####
|
||||
|
||||
[下载 MultiSystem][1]脚本,并解压到任意地方。进入解压的地址,使用下面的命令运行脚本。
|
||||
|
||||
sudo ./install-depot-multisystem.sh
|
||||
|
||||
#### 使用 PPA 安装: ####
|
||||
|
||||
相应地,你可以用下面的命令来更简单地使用PPA来安装MultiSystem。
|
||||
|
||||
sudo apt-add-repository 'deb http://liveusb.info/multisystem/depot all main'
|
||||
wget -q -O - http://liveusb.info/multisystem/depot/multisystem.asc | sudo apt-key add -
|
||||
sudo apt-get update
|
||||
sudo apt-get install multisystem
|
||||
|
||||
安装玩之后,它会自动打开。只要点击关闭按钮退出。
|
||||
|
||||
### 安装之后 ###
|
||||
|
||||
安装完成后,插入你的USB,并通过Unity Dash或者菜单运行MultiSystem。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/Menu_0012.png)
|
||||
|
||||
第一次启动时,MultiSystem界面看起来会像下面这样。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_002.png)
|
||||
|
||||
选择USB设备,点击**确认**按钮。你可能会看到下面的错误窗口。不必担心,它说的是USB设备没有标签。点击OK让MultiSystem自动设置标签。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/Error_003.png)
|
||||
|
||||
那么,拔出/重新插入USB,再次运行MultiSystem。选择USB盘,再次点击确认。现在,你被要求确认在USB中安装Grub2.点击OK继续。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/gtkdialog_004.png)
|
||||
|
||||
最终,你会高兴地看到MultiSystem的界面。现在,时候创建多启动USB盘。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_005.png)
|
||||
|
||||
### 使用 ###
|
||||
|
||||
MultiSystem非常容易使用。将ISO文件拖入MultiSystem窗口中。如果这不能用,点击底部的**cd 按钮**来选择ISO文件。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_006.png)
|
||||
|
||||
现在,MultiSystem会从ISO中拷贝文件,并让USB可启动。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_007.png)
|
||||
|
||||
相似地,你可以在你的USB中加入任意多的发行版。我这次加入了两个Linux发行版:CentOS 6.5和Android。
|
||||
|
||||
加完ISO文件后,你会在MultiSystem的主窗口中看到可启动的发行版列表了。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_008.png)
|
||||
|
||||
就是这样。我们的多启动USB盘就可以使用了。重启系统,并在BIOS中设置USB优先启动。选择你想要安装的发行版并开始安装系统。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/QEMU_009.png)
|
||||
|
||||
额外地,MultiSystem含有一些额外的选项:
|
||||
|
||||
- Grub 设置;
|
||||
- Grub 和 Burg 的bootloader更新;
|
||||
- 下载 LiveCD;
|
||||
- VirtualBox 安装;
|
||||
- 格式化USB盘;
|
||||
- 还有更多选项。
|
||||
|
||||
要浏览额外的选项列表,进入MultiSystem的**菜单**标签。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_010.png)
|
||||
|
||||
同样,你可以在Ubuntu中使用QEMU或者Oracle VirtualBox测试多启动USB盘。
|
||||
|
||||
![](http://180016988.r.cdn77.net/wp-content/uploads/2014/11/MultiSystem_011.png)
|
||||
|
||||
MultiSystem工具是我测试到现在最棒和最有用的一款工具。这款工具对那些想要在他们的机器上安装多个系统的人是非常有用的。在你外出的时候,你不必再携带CD/DVD袋了。只要买一个16GB或者32GB的USB就行,并把所有你想要的系统都放在里面,就像老板一样安装系统。
|
||||
|
||||
并且,一个对于Windows系统用户的好消息是它也支持Windows系统。我在Windows 7上测试过,它可以工作!
|
||||
|
||||
享受吧!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.unixmen.com/create-multiboot-usb-ubuntu-using-multisystem/
|
||||
|
||||
作者:[SK][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.unixmen.com/author/sk/
|
||||
[1]:http://liveusb.info/multisystem/install-depot-multisystem.sh.tar.bz2
|
||||
[2]:http://liveusb.info/dotclear/
|
202
translated/tech/20141127 Some Sentences about Java.md
Normal file
202
translated/tech/20141127 Some Sentences about Java.md
Normal file
@ -0,0 +1,202 @@
|
||||
一些关于Java的句子
|
||||
================================================================================
|
||||
本文并没有什么新鲜的。我只是收集了一些不太重要的语句,
|
||||
但这些语句可能对初级程序员来说很重要。也就是些无聊的旧东西。
|
||||
|
||||
如果以下的这些你都知道的话,那么你比Java的了解已经超过了对一个平常的家庭主妇的了解。我不知
|
||||
道清楚所有的这些是否是有意义的。即使不知道其中的一些特性,你照样也可以成
|
||||
为一个相当不错的Java程序员。然而,本文中许多的新信息可能表明你还有很大
|
||||
的发展空间。
|
||||
|
||||
### Java中有四种不同的访问类型(而不是三种) ###
|
||||
|
||||
这四种类型包括:`private`, package private (包访问权限,无修饰符,又叫
|
||||
default, 译者注)。如果你在类中定义一个元素时并不加任何访问类型修饰符,
|
||||
它将被默认设置为包访问权限(package private),而不是`public`或者`protected`。
|
||||
|
||||
|
||||
![Java中有四种级别的访问类型](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/four-levels-of-protection.png)
|
||||
|
||||
Java有四个级别的访问类型。
|
||||
|
||||
从另一方面来说,如果在接口中,你不指定方法的访问修饰符,那么它将是
|
||||
`public`类型的。你也可以显式地指定它为`public`类型, 但这并不符合SONAR
|
||||
(一个开源代码质量管理平台,译者注)的代码质量管理思想。
|
||||
|
||||
![访问类型是传递的](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/protection-is-transitive.png)
|
||||
|
||||
访问类型是传递的
|
||||
|
||||
> 我的在Java中允许选择性的在接口的方法中写`public`的观点是一个技术错误。
|
||||
|
||||
同样你也可在接口的字段前写`final`,甚至是`static`。这说明这些字段可以
|
||||
是非静态或非final吗?不是的,接口中的字段中总是final和static的。
|
||||
|
||||
### Protected和package private是不一样的 ###
|
||||
|
||||
Package private(或者default)访问类型可以使得相同包(package)下其他类
|
||||
能够访问这些字段或方法。保护类型(`protected`)的方法和字段可以被相同包
|
||||
下的类使用(这和package private是一样的),同时它也可以被其他类使用,只
|
||||
要那个类继承了这个包含这些`protected`方法或字段的类。
|
||||
|
||||
### Protected是可传递的 ###
|
||||
|
||||
如果有三个包a、b、c,每个包都分别包含A、B、C类,而且B继承A,C继承B,那
|
||||
么C可以访问A中的protected字段和方法。
|
||||
|
||||
package a;
|
||||
|
||||
public class A {
|
||||
protected void a() {
|
||||
|
||||
}
|
||||
}
|
||||
package b;
|
||||
|
||||
import a.A;
|
||||
|
||||
public class B extends A {
|
||||
protected void b() {
|
||||
a();
|
||||
}
|
||||
}
|
||||
package c;
|
||||
|
||||
import b.B;
|
||||
|
||||
public class C extends B {
|
||||
protected void c() {
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
### 接口不能定义protected方法 ###
|
||||
|
||||
很多人认为可以在接口中定义`protected`方法。如果你这么做的话,编译器很
|
||||
快就会毫不留情地给你报错。顺便说下,这也就是我为什么认为允许`public`关键字在接口
|
||||
中是一个技术错误,它会让人觉得还可以写其他访问类型似的。
|
||||
|
||||
![Private is the new public](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/private-is-the-new-public.png)
|
||||
|
||||
private是一种新的public
|
||||
|
||||
如果你还想在一个接口的方法中声明protected方法,你可能还不理解封装的含义。
|
||||
### 此private非彼private ###
|
||||
|
||||
私有变量和方法在编译单元内是可见的。如果这听起来太神秘的话,换种说法:几
|
||||
乎就是在同一个Java文件中。这比“在它们被定义的类中”听起来好理解些。它们在
|
||||
同一编译单元的类和接口中也是可见的。嵌套类可以看到类中封装的私有字段和
|
||||
方法。然而,当前封闭类也可以看到该类下任何深度下类中的私有方法和字段。
|
||||
|
||||
package a;
|
||||
|
||||
class Private {
|
||||
private class PrivateInPrivate {
|
||||
private Object object;
|
||||
}
|
||||
|
||||
Object m() {
|
||||
return new PrivateInPrivate().object;
|
||||
}
|
||||
}
|
||||
|
||||
后者并不广为人知,事实上也很少有用到。
|
||||
|
||||
### Private是类的访问级别而不是对象 ###
|
||||
|
||||
如果你可以访问一个变量或方法,那么不管它属于哪个对象你都可以访问它。如
|
||||
果`this.a`可以访问到,那`another.a`也可以访问到,只要它们是同一个类的
|
||||
实例。同一个类的实例对象可以随意调用其他实例的变量或方法。不过这样的代
|
||||
码一般都没有意义。现实生活中异常是`equals()`(由Eclipse生成, 15 - 18行):
|
||||
|
||||
package a;
|
||||
|
||||
public class PrivateIsClass {
|
||||
private Object object;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PrivateIsClass other = (PrivateIsClass) obj;
|
||||
if (object == null) {
|
||||
if (other.object != null)
|
||||
return false;
|
||||
} else if (!object.equals(other.object))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
###静态(static)类可能有很多实例 ###
|
||||
|
||||
![Protection is not object level. It is class level.](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/protection-is-class-feature.png)
|
||||
|
||||
访问类型不是对象级别的而是类级别的。
|
||||
|
||||
那些不支持有任何实例的类,通常被称为实用工具类。它们只包含静态字段和静
|
||||
态方法以及唯一的不被该类的任何静态方法调用的私有构造函数。在Java 8中也
|
||||
可以有这样的一个野兽(这个词翻译不通,译者注)在接口中实现,因为Java 8的
|
||||
接口可以有静态方法。我不觉得我们应该使用这个特性而不是实用工具类。我也
|
||||
不完全确信我们应该使用实用工具类。
|
||||
|
||||
静态类总是在另一个类或接口中。它们是嵌套类。他们是静态的,就像静态方法
|
||||
不能访问类的实例方法和字段一样,静态内部类也不能访问嵌入类的实例方法和
|
||||
字段。这是因为内部类没有嵌入类实例的引用(或者说是指针,如果你喜欢这么
|
||||
叫的话)。内部类(内部类,也即非静态嵌套类, 译者注),而非静态嵌套类, 没
|
||||
有嵌入类的一个实例,它是无法被创建的。每个内部类的实例都具有嵌入类实例
|
||||
的一个引用,因此一个内部类可以访问嵌入类的实例方法和字段。
|
||||
|
||||
因为这个原因,要是没有外部类的一个实例,你就不能创建一个内部类。当然,
|
||||
如果是当前对象,也就是`this`的话,你就可以不需要指定它。在这种情况下你
|
||||
可以使用`new`, 在这种情况下,也就是`this.new`的简式。在一个静态的环境中
|
||||
,例如从一个静态方法,你必须指定内部类应该创建哪个封闭类的实例。见第10
|
||||
行:
|
||||
|
||||
package a;
|
||||
|
||||
class Nesting {
|
||||
static class Nested {}
|
||||
class Inner {}
|
||||
void method(){
|
||||
Inner inner = new Inner();
|
||||
}
|
||||
static void staticMethod(){
|
||||
Inner inner = new Nesting().new Inner();
|
||||
}
|
||||
}
|
||||
|
||||
### 匿名类只能访问final变量 ###
|
||||
|
||||
![Variable has to be effective final](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/effective-final.png)
|
||||
|
||||
变量必须是有效的final
|
||||
|
||||
当一个匿名类被定义在一个方法中,它可以访问局部变量如果该变量是`final`的
|
||||
。但这说的有点模糊。它们不得不声明成final,他们还必须是有效final。这也
|
||||
是Java 8中发布的一些特性。你不需要声明这些变量为`final`型,但它们仍然
|
||||
必须是有效的`final`。
|
||||
|
||||
![Java 8 does not require final, only effective final](http://a3ab771892fd198a96736e50.javacodegeeks.netdna-cdn.com/wp-content/uploads/2014/11/java_ee_-_javabeantester_src_main_java_com_javax0_jbt_blog_java_-_eclipse_-__users_verhasp_github_javax_blog.png)
|
||||
|
||||
Java 8并不要求`final`,只要求有效final.
|
||||
|
||||
为什么你需要对一些东西声明`final`,当它被检查必须是这样的。就像方法的参
|
||||
数。它们也必须是`final`的。你说这不是Java所必须的吗?嗯,你是对的。这只
|
||||
是一个良好的编程风格所必须的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.javacodegeeks.com/2014/11/some-sentences-about-java.html
|
||||
|
||||
作者:[Peter Verhas][a]
|
||||
译者:[a598799539](https://github.com/a598799539)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.javacodegeeks.com/author/peter-verhas/
|
Loading…
Reference in New Issue
Block a user