translating

This commit is contained in:
Linux-pdz 2013-11-13 09:39:56 +08:00
commit 2ad098d39f
6 changed files with 131 additions and 134 deletions

View File

@ -4,9 +4,7 @@ Linux中grep命令的12个实践例子
![](http://www.tecmint.com/wp-content/uploads/2013/11/Grep-Command-Examples.png)
*12个grep命令的例子*
**grep**是每个**Linux**发行版都预装的一个强有力的文件样式搜索工具。无论何种原因,如果你的系统没有预装它的话,你可以很容易的通过系统的包管理器来安装它(**Debian/Ubuntu**系中的**apt-get**和**RHEl/CentOS/Fedora**系中的**yum**)。
**grep**是每个**Linux**发行版都预装的一个强有力的文件模式搜索工具。无论何种原因,如果你的系统没有预装它的话,你可以很容易的通过系统的包管理器来安装它(**Debian/Ubuntu**系中的**apt-get**和**RHEl/CentOS/Fedora**系中的**yum**)。
$ sudo apt-get install grep #Debian/Ubuntu
@ -16,7 +14,7 @@ Linux中grep命令的12个实践例子
###1.搜索和寻找文件
假设你已经在你的电脑上安装了一个全新的**Ubuntu**,你打算卸载**Python**。你浏览网页寻找教程,但是你发现存在两个不同版本的**Python**在使用,而你不知道你的**Ubuntu**安装器到底在你的系统中安装了哪个版本的Python也不知道它安装了哪些模块。解决这个烦恼只需简单的运行以下命令
假设你已经在你的电脑上安装了一个全新的**Ubuntu**然后你打算卸载**Python**。你浏览网页寻找教程,但是你发现存在两个不同版本的**Python**在使用,而你不知道你的**Ubuntu**安装器到底在你的系统中安装了哪个版本的Python也不知道它安装了哪些模块。解决这个烦恼只需简单的运行以下命令
$ sudo dpkg -l | grep -i python
@ -32,11 +30,11 @@ Linux中grep命令的12个实践例子
grep还可以在一个或多个文件里用于搜索和过滤。让我们来看一个这样的情景
你的**Apache网页服务器**出现了问题,你不得不从许多专业网站找一个发帖询问。好心回复你的人让你粘贴你的**/etc/apache2/sites-available/default-ssl**文件内容。假如你能移除掉所有的注释行,那么对你,对帮你的人,以及所有阅读该文件的人,不是更容易发现问题吗?你当然可以很容易的做到!只需这样做就可以了:
你的**Apache网页服务器**出现了问题,你不得不从许多专业网站找一个发帖询问。好心回复你的人让你粘贴上来你的**/etc/apache2/sites-available/default-ssl**文件内容。假如你能移除掉所有的注释行,那么对你,对帮你的人,以及所有阅读该文件的人,不是更容易发现问题吗?你当然可以很容易的做到!只需这样做就可以了:
$ sudo grep -v "#" /etc/apache2/sites-available/default-ssl
选项**-v**是告诉**grep**命令反转它的输出结果,意思就是不输出匹配的项,做相反的事,打印出所有不匹配的项。这个例子中,有**#**的是注释行。
选项**-v**是告诉**grep**命令反转它的输出结果,意思就是不输出匹配的项,做相反的事,打印出所有不匹配的项。这个例子中,有**#**的是注释行(译注:其实这个命令并不准确,包含“#”的行不全是注释行。关于如何精确匹配注释行,可以了解更多的关于正则表达式的内容。)
###3.找出所有的mp3文件
@ -50,21 +48,23 @@ grep还可以在一个或多个文件里用于搜索和过滤。让我们来看
###4.在搜索字符串前面或者后面显示行号
另外两个选项是-A和-B之间的切换是用以显示匹配的行以及行号分别控制在字符串前或字符串后显示。Man页给出了更加详细的解释我发现一个记忆的小窍门-A=after、-B=before。
另外两个选项是-A和-B之间的切换是用以显示匹配的行以及行号分别控制在字符串前或字符串后显示的行数。Man页给出了更加详细的解释我发现一个记忆的小窍门-A=after、-B=before。
$ sudo ifconfig | grep -A 4 etho
$ sudo ifconfig | grep -B 2 UP
###5.在匹配字符串周围打印出行号
grep命令的**-C**选项和例4中的很相似不过打印的并不是在匹配字符串的前面或后面的行而是打印出两个方向都匹配的行
grep命令的**-C**选项和例4中的很相似不过打印的并不是在匹配字符串的前面或后面的行而是打印出两个方向都匹配的行译注同上面的记忆窍门一样-C=center以此为中心
$ sudo ifconfig | grep -C 2 lo
###6.计算匹配项的数目
这个功能类似于将**grep**输出的结果用管道传送给计数器(**wc**程序grep内建的选项可以达到同样的目的
$ sudo ifconfig | grep -c inet6
###7.按给定字符串搜索文件
###7.按给定字符串搜索文件中匹配的行号
当你在编译出错时需要调试时,**grep**命令的**-n**选项是个非常有用的功能。它能告诉你所搜索的内容在文件的哪一行:
@ -75,9 +75,9 @@ grep命令的**-C**选项和例4中的很相似不过打印的并不是在匹
假若你要在当前文件夹里搜索一个字符串,而当前文件夹里又有很多子目录,你可以指定一个**-r**选项以便于递归的搜索:
$ sudo grep -r "function" *
###9.进行完全匹配搜索
###9.进行精确匹配搜索
传递**-w**选项给grep命令可以在字符串中进行完全匹配搜索。例如,像下面这样输入:
传递**-w**选项给grep命令可以在字符串中进行精确匹配搜索(译注:包含要搜索的单词,而不是通配)。例如,像下面这样输入:
$ sudo ifconfig | grep -w “RUNNING”
@ -105,11 +105,10 @@ grep命令的**-C**选项和例4中的很相似不过打印的并不是在匹
$ sudo fgrep -f file_full_of_patterns.txt file_to_search.txt
这仅仅是**grep**命令的开始,你可能已经注意到,它对于实现各种各样的需求简直是太有用了。除了这种我们实施的只有一行的命令,**grep**还可以写成**cron**任务或者自动的**shell脚本**去执行。保持好奇心,试验一下**man页**的各个选项,为实现你的目的写出一些**grep表达式**吧。
这仅仅是**grep**命令的开始,你可能已经注意到,它对于实现各种各样的需求简直是太有用了。除了这种我们运行的这种只有一行的命令,**grep**还可以写成**cron**任务或者自动的**shell脚本**去执行。保持好奇心,试验一下**man页**的各个选项,为实现你的目的写出一些**grep表达式**吧。
---
via: http://www.tecmint.com/12-practical-examples-of-linux-grep-command/
译者:[Linux-pdz](https://github.com/Linux-pdz) 校对:[jasminepeng](https://github.com/jasminepeng)

View File

@ -1,3 +1,4 @@
翻译中 by Linux-pdz
How to Install the Latest NVIDIA 331.20 Driver in Ubuntu 13.10
================================================================================
**The installation of new NVIDIA drivers can be a problem sometimes, especially if you are not accustomed with the way things usually work on a Linux operating system.**

View File

@ -1,4 +1,4 @@
翻译中 by Linux-pdz
NearTan占坑
SBackup: A Simple Backup Solution For Your Linux Desktop
================================================================================
**SBackup**, Simple Backup, is an Open Source, easy to use backup solution intended for desktop use. It can backup any subset of files and folders. All configuration is accessable via Gnome interface. File and paths can be included and excluded directly or by regex, It supports local and as well as remote backups. Though it looks simple, it has many features to meet the advanced backup functionality.

View File

@ -1,120 +0,0 @@
Translating------------geekpi
20 The Linux Kernel: Configuring the Kernel Part 16
================================================================================
![](http://www.linux.org/attachments/slide-jpg.587/)
Welcome to the next Linux kernel article. In this article, we will discuss the input/output ports.
First, the "i8042 PC Keyboard controller" driver is needed for PS/2 mice and AT keyboards. Before USB, mice and keyboards used PS/2 ports which are circular ports. The AT keyboard is an 84-key IBM keyboard that uses the AT port. The AT port has five pins while the PS/2 port has six pins.
Input devices that use the COM port (sometime called RS232 serial port) will need this diver (Serial port line discipline). The COM port is a serial port meaning that one bit at a time is transferred.
The TravelMate notebooks need this special driver to use a mouse attached to the QuickPort (ct82c710 Aux port controller).
Parallel port adapters for PS/2 mice, AT keyboards, and XT keyboards use this driver (Parallel port keyboard adapter).
The "PS/2 driver library" is for PS/2 mice and AT keyboards.
"Raw access to serio ports" can be enabled to allow device files to be used as character devices.
Next, there is a driver for the "Altera UP PS/2 controller".
The PS/2 multiplexer also needs a driver (TQC PS/2 multiplexer).
The ARC FPGA platform needs special driver for PS/2 controllers (ARC PS/2 support).
NOTE: I want to make it clear that the PS/2 controllers that are discussed in this article are not Sony's game controllers for their PlayStation. This article is discussing the 6-pin mouse/keyboard ports. The controller is the card that holds the PS/2 ports.
The "Gameport support" driver offers support for the 15-pin gameport. Gameport was the 15-pin port used by many input gaming devices until the invention of the USB port.
The next driver is for gameports on ISA and PnP bus cards (Classic ISA and PnP gameport support). ISA stands for Industry Standard Architecture and was a parallel bus standard before PCI. PnP stands for Plug-and-Play and was a common standard before ISA.
"PDPI Lightning 4 gamecard support" provides a driver for a proprietary gamecard with gameports.
The SoundBlaster Audigy card is a proprietary gameport card (SB Live and Audigy gameport support).
The ForteMedia FM801 PCI audio controller has a gameport on the card (ForteMedia FM801 gameport support). This driver only supports the gameport.
Next, we can move on to "Character devices". Character devices transfer data character by character.
First, TTY can be enabled or disabled (Enable TTY). Removing TTY will save a lot of space, but TTY is needed for terminals and such. Unless you know what you are doing, do not disabled TTY.
NOTE TO MY FANS: If you know of a reason for disabling TTY, could you post the answer below and share with us. Mahalo!
Next, support for "Virtual terminals" can be enabled/disabled. Again, a lot of space can be saved, but virtual terminals are very important.
This next driver supports font mapping and Unicode translation (Enable character translations in console). This can be used to convert ASCII to Unicode.
Virtual terminals can be used as system consoles with this driver (Support for console on virtual terminal). A system console manages the logins and kernel messages/warnings.
Virtual terminals must channel through a console driver to interact with the physical terminal (Support for binding and unbinding console drivers). Before the virtual terminal can do so, the console driver must be loaded. When the virtual terminal is closed, the console terminal must be unloaded.
The next driver provides support for Unix98 PTY (Unix98 PTY support). This is Unix98 pseudo terminal.
FUN FACT: The Linux kernel allows a filesystem to be mount many times in many places at once.
Next, "Support multiple instances of devpts" can be supported. The devpts filesystem is for pseudo-terminal slaves.
Legacy support for PTY can also be enabled (Legacy (BSD) PTY support).
The max amount of legacy PTYs in use can be set (Maximum number of legacy PTY in use).
The next driver can be used to offer support to serial boards that the other drivers fail to support (Non-standard serial port support).
Next, there are some drivers for specific boards and cards.
The GSM MUX protocol is supported with this driver (GSM MUX line discipline support (EXPERIMENTAL)).
The next driver enables the kmem device file (/dev/kmem virtual device support). kmem is usually used for kernel debugging. kmem can be used to read certain kernel variables and states.
The Stallion cards have many serial ports on them (Stallion multiport serial support). This driver specifically supports this card.
Next, we can move on to drivers for serial devices. As stated before, serial devices transfer one bit at a time.
The first driver is for standard serial port support (8250/16550 and compatible serial support).
Plug-and-Play also exists for serial ports with this driver (8250/16550 PNP device support).
The following driver allows the serial ports to be used for connecting a terminal to be used as a console (Console on 8250/16550 and compatible serial port).
Some UART controllers support Direct Memory Access (DMA support for 16550 compatible UART controllers). UART stands for Universal Asynchronous Receiver/Transmitter. UART controllers convert serial to parallel and vice versa.
Next, this driver offers support for standard PCI serial devices (8250/16550 PCI device support).
16-bit PCMCIA serial devices are supported by this driver (8250/16550 PCMCIA device support). Remember, PCMCIA is a PC-card that is usually used in laptops.
The maximum number of supported serial ports can be set (Maximum number of 8250/16550 serial ports) and then the maximum that are registered during boot-up (Number of 8250/16550 serial ports to register at runtime).
For extended serial abilities like HUB6 support, enable this driver (Extended 8250/16550 serial driver options).
A special driver is needed to support more than four legacy serial ports (Support more than 4 legacy serial ports).
Serial interrupts can be shared when this driver is used (Support for sharing serial interrupts).
Serial port IRQs can be autodetected using this driver (Autodetect IRQ on standard ports).
RSA serial ports are also supported by the Linux kernel (Support RSA serial ports). RSA stands for Remote Supervisor Adapter. RSA is an IBM-specific hardware.
Next, there are various vendor/device specific divers.
This is a TTY driver that uses printk to output user messages (TTY driver to output user messages via printk). Printk (print kernel) is a special piece of software that usually prints the boot-up messages. Any string that is displayed by printk is usually put in the /var/log/messages file. The shell command "dmesg" displays all strings that were used by printk.
Next, we can enable/disable support for parallel printers (Parallel printer support).
The next driver allows a printer to be used as a console (Support for console on line printer). This means kernel messages will be literally printed at the printer. Normally when the word "print" was used in this article series, it meant putting data on the screen. This time, this literally means putting the data on paper.
The following driver makes the device files at /dev/parport/ (Support for user-space parallel port device drivers). This allows some processes to access.
Again, the Linux kernel has many features and drivers, so we will discuss more drivers in the next article. Mahalo!
NOTE TO FANS: We are getting close to the end of the configuration process. I still have a list of all of the suggested Linux kernel topics that many of you wanted to know about. Some of the topics include installing the kernel, managing modules, adding 3rd-party drivers, and all of the other very interesting suggestions and requests.
--------------------------------------------------------------------------------
via: http://www.linux.org/threads/the-linux-kernel-configuring-the-kernel-part-16.4835/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -0,0 +1,117 @@
戴文的Linux内核专题20 配置内核 (16)
================================================================================
![](http://www.linux.org/attachments/slide-jpg.587/)
欢迎来到下一篇Linux内核文章。在本篇里我们将讨论输入/输出端口。
首先PS/2鼠标和AT键盘需要"i8042 PC Keyboard controller"驱动。在USB之前鼠标和键盘使用圆形端口的PS/2端口。AT键盘是一种84键使用AT端口的IBM键盘。AT端口有5针而PS/2口有六针。
使用COM口(有时也称RS232串口)的输入设备需要这个驱动(Serial port line discipline)。COM是一种串口意味着每次传输一位。
TravelMate笔记本需要这个特殊的驱动来使用连接到QuickPort的鼠标(ct82c710 Aux port controller)。
对于PS/2 mice、AT keyboards 和 XT keyboards的并口适配器使用这个驱动(Parallel port keyboard adapter)。
"PS/2 driver library"用于PS/2鼠标和AT键盘。
可以启用"Raw access to serio ports"来允许设备文件作为字符文件来使用。
下面,下面有一个用于"Altera UP PS/2 controller"的驱动。
PS/2复用同样需要一个驱动(TQC PS/2 multiplexer)。
ARC FPGA平台对于PS/2控制器需要特殊的驱动(ARC PS/2 support)。
注意我想要说清楚这篇文章中讨论的PS/2空孩子气并不是Sony的PlayStation上的游戏控制器。这篇文章讨论的是6针鼠标/键盘端口。控制器是一种有PS/2端口的卡。
"Gameport support"提供对15针gameport的支持。gameport是一种曾经被很多游戏设备使用直到USB端口的发明的15针口。
下一个驱动是在ISA或者PnP总线卡上的gameport驱动(Classic ISA and PnP gameport support)。ISA代表"Industry Standard Architecture"(工业标准架构)并且它是一种在PCI之前的并行总线标准。PnP代表"Plug-and-Play"(即插即用)并且他是一种在ISA之前的通用标准。
"PDPI Lightning 4 gamecard support"提供了一个有gameport的游戏卡的专有驱动。
SoundBlaster Audigy卡是一种专有gameport卡(SB Live and Audigy gameport support)。
ForteMedia FM801 PCI音频控制器在卡上有一个音频控制器(ForteMedia FM801 gameport support)。这个驱动只支持gameport。
下一步,我们可以进入"Character devices"。字符设备以字符传输数据。
首先,可以启用/禁用TTY(Enable TTY)。移除TTY会节约很多空间但是许多终端和这类设备需要TTY。除非你知道你在做什么否则不要禁用TTY。
致我的粉丝如果你知道一个禁用TTY的理由你能在下面发表你的答案并与我们共享么?谢谢!
下一步,可以启用/禁用"Virtual terminals"(虚拟终端)。再说一次,这个可以节约很多空间,但是虚拟终端很重要。
下一个驱动支持字体映射和Unicode转换(Enable character translations in console)。这用于转换ASCII到Unicode。
虚拟终端可以用这个驱动作为系统控制台(Support for console on virtual terminal)。系统控制台管理着登陆和内核信息/警告。
虚拟终端必须通过控制台驱动与物理终端交互(Support for binding and unbinding console drivers)。在虚拟终端可以这么做之前,控制台驱动必须被加载。当虚拟终端关闭后,控制台终端必须被卸载。
下一个驱动提供了对Unix98 PTY驱动的支持(Unix98 PTY support)。这是Unix98伪终端。
有趣的事实Linux内核允许某个文件系统一次在很多地方被多次挂载。
接下来,可以支持"Support multiple instances of devpts"(译注:允许多个"devpts"文件系统实例。devpts文件系统用于伪终端的slave。
过时的PTY同样可以启用(Legacy (BSD) PTY support)。
可以设置最大数量的使用中的过时PTS(Maximum number of legacy PTY in use)。
下面的驱动可以用于提供对其他驱动不支持的串口的支持 (Non-standard serial port support)。
下面有一些用于特定板和卡的驱动。
这个驱动支持GSM MUX协议(GSM多路复用)(GSM MUX line discipline support (EXPERIMENTAL))。
下一个驱动启用kmen设备文件(/dev/kmem virtual device support)。kmem通常用于内核调试。kmem可以用于读取某些内核变量和状态。
Stallion卡上面有许多串口Stallion multiport serial support)。这个驱动特别支持这块卡。
下面,我们可以进入到串行设备驱动了。如前所述,串行设备每次传输一位。
第一个驱动用于标准串口支持(8250/16550 and compatible serial support)。
在这个驱动下,即插即用(Plug-and-Play)同样存在于串口中(8250/16550 PNP device support)。
下面的驱动允许串口用于连接一个终端后作为控制台(Console on 8250/16550 and compatible serial port)。
一些UART控制器支持直接内存访问(DMA support for 16550 compatible UART controllers)。UART代表的是"Universal Asynchronous Receiver/Transmitter"(通用异步收发)。UART控制器转换串行到并行反之亦然。
下一步这个驱动提供了标准PCI串行设备支持(8250/16550 PCI device support)。
16位PCMCIA串行设备由这个驱动支持(8250/16550 PCMCIA device support)。记住PCMCIA是一种通常使用于笔记本的PC卡。
可以设置最大数量支持的串口(Maximum number of 8250/16550 serial ports),接着是在启动中注册的最大数量(Number of 8250/16550 serial ports to register at runtime)。
为了扩展像HUB6的串行能力启用这个驱动(Extended 8250/16550 serial driver options)。
一个特殊驱动用于支持多于4种的过时串口(Support more than 4 legacy serial ports)。
当启用这个驱动后,可以共享串口中断(Support for sharing serial interrupts)。
使用这个驱动可以自动检测串口中断请求(Autodetect IRQ on standard ports)。
RSA串口同样也在Linux内核中支持(Support RSA serial ports)。RSA代表的是"Remote Supervisor Adapter"(远程管理适配器)。RSA是一种IBM特定的硬件。
下面,有不同的供应商/设备特定驱动。
下面有一个使用printk输出用户信息的TTY驱动(TTY driver to output user messages via printk)。printk(print kernel)是一种通常打印启动信息的特殊软件。任何由printk显示的字符串通常在/var/log/messages文件里。shell命令"dmesg"显示所有被printk使用的字符串。
下面,我们可以启用/禁用并口打印机的支持(Parallel printer support)。
接下来的驱动允许打印机作为一个控制台(Parallel printer support)。这意味着内核消息会被逐字地由打印机打印。通常地在这个系列中使用"print"(打印)这个单词时,意味这将输出信息到屏幕上。而这次,字面上的意思是将数据输出在纸上。
以下的驱动使设备文件在/dev/parport/中(Support for user-space parallel port device drivers)。这使得一些进程可以访问。
再说一次Linux内核有许多特性和驱动所以我们还会在下一篇文章中继续讨论更多的驱动。谢谢
致粉丝:我们正在接近配置过程的终点。我有一张你们很多人想知道的内核话题列表。这些话题包含了安装内核、管理模块、加入第三方驱动、还有许多其他有趣的建议和要求。
--------------------------------------------------------------------------------
via: http://www.linux.org/threads/the-linux-kernel-configuring-the-kernel-part-16.4835/
译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出