mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
modify
This commit is contained in:
commit
4f02dd3b26
@ -1,16 +1,16 @@
|
||||
Linux有问必答——Linux上如何查看某个进程的线程
|
||||
Linux有问必答:Linux上如何查看某个进程的线程
|
||||
================================================================================
|
||||
> **问题**: 我的程序创建并在它里头执行了多个线程,我怎样才能在该程序创建线程后监控其中单个线程?我想要看到带有它们名称的单个线程详细情况(如,CPU/内存使用率)。
|
||||
> **问题**: 我的程序在其内部创建并执行了多个线程,我怎样才能在该程序创建线程后监控其中单个线程?我想要看到带有它们名称的单个线程详细情况(如,CPU/内存使用率)。
|
||||
|
||||
线程是现代操作系统上进行并行执行的一个流行的编程方面的抽象概念。当一个程序内有多个线程被叉分出用以执行多个流时,这些线程就会在它们之间共享特定的资源(如,内存地址空间、打开的文件),以使叉分开销最小化,并避免大量花销IPC(进程间通信)频道。这些功能让线程在并发执行时成为一个高效的机制。
|
||||
线程是现代操作系统上进行并行执行的一个流行的编程方面的抽象概念。当一个程序内有多个线程被叉分出用以执行多个流时,这些线程就会在它们之间共享特定的资源(如,内存地址空间、打开的文件),以使叉分开销最小化,并避免大量高成本的IPC(进程间通信)通道。这些功能让线程在并发执行时成为一个高效的机制。
|
||||
|
||||
在Linux中,程序中创建的线程(也称为轻量级进程,LWP)会具有和程序的PID相同的“线程组ID”。然后,各个线程会获得其自身的线程ID(TID)。对于Linux内核调度器而言,线程不过是恰好共享特定资源的标准的进程。经典的命令行工具,如ps或top,都可以用来显示线程级别的信息,默认情况下它们会显示进程级别的信息。
|
||||
在Linux中,程序中创建的线程(也称为轻量级进程,LWP)会具有和程序的PID相同的“线程组ID”。然后,各个线程会获得其自身的线程ID(TID)。对于Linux内核调度器而言,线程不过是恰好共享特定资源的标准的进程而已。经典的命令行工具,如ps或top,都可以用来显示线程级别的信息,只是默认情况下它们显示进程级别的信息。
|
||||
|
||||
这里提供了**在Linux上显示某个进程的线程**的几种方式。
|
||||
|
||||
### 方法一:PS ###
|
||||
|
||||
在ps命令中,“-T”选项可以开启线程查看。下面的命令列出了由进程号为<pid>的进程创建的所有线程。
|
||||
在ps命令中,“-T”选项可以开启线程查看。下面的命令列出了由进程号为\<pid>的进程创建的所有线程。
|
||||
|
||||
$ ps -T -p <pid>
|
||||
|
||||
@ -26,7 +26,7 @@ top命令可以实时显示各个线程情况。要在top输出中开启线程
|
||||
|
||||
![](https://farm9.staticflickr.com/8824/17350561070_3dfe447974_c.jpg)
|
||||
|
||||
要让top输出某个特定进程<pid>并检查该进程内运行的线程状况:
|
||||
要让top输出某个特定进程\<pid>并检查该进程内运行的线程状况:
|
||||
|
||||
$ top -H -p <pid>
|
||||
|
||||
@ -36,7 +36,7 @@ top命令可以实时显示各个线程情况。要在top输出中开启线程
|
||||
|
||||
一个对用户更加友好的方式是,通过htop查看单个进程的线程,它是一个基于ncurses的交互进程查看器。该程序允许你在树状视图中监控单个独立线程。
|
||||
|
||||
要在htop中启用线程查看,请开启htop,然后按<F2>来进入htop的设置菜单。选择“设置”栏下面的“显示选项”,然后开启“树状视图”和“显示自定义线程名”选项。按<F10>退出设置。
|
||||
要在htop中启用线程查看,请开启htop,然后按\<F2>来进入htop的设置菜单。选择“设置”栏下面的“显示选项”,然后开启“树状视图”和“显示自定义线程名”选项。按\<F10>退出设置。
|
||||
|
||||
![](https://farm6.staticflickr.com/5338/17350364568_59bce22e7b_b.jpg)
|
||||
|
||||
@ -50,7 +50,7 @@ via: http://ask.xmodulo.com/view-threads-process-linux.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,4 +1,4 @@
|
||||
Linux 有问必答--如何在桌面版 Ubuntu 中安装 Unity Tweak Tool
|
||||
Linux 有问必答:如何在桌面版 Ubuntu 中安装 Unity Tweak Tool
|
||||
================================================================================
|
||||
> **问题**: 我试着给刚安装的桌面版 Ubuntu 自定制桌面。我想使用 Unity Tweak Tool。我怎样才能在 Ubuntu 上安装 Unity Tweak Tool 呢?
|
||||
|
||||
@ -6,7 +6,7 @@ Linux 有问必答--如何在桌面版 Ubuntu 中安装 Unity Tweak Tool
|
||||
|
||||
![](https://farm6.staticflickr.com/5463/17684020389_25dc7f0db2_b.jpg)
|
||||
|
||||
尽管 Unity Tweak Tool 是桌面版 Ubuntu 的重要工具,并没有在桌面版 Ubuntu 中预安装。为了能自定制 Unity 桌面,下面介绍一下如何在桌面版 Ubuntu 中安装 Unity Tweak Tool。
|
||||
尽管 Unity Tweak Tool 是桌面版 Ubuntu 的重要工具,但并没有在桌面版 Ubuntu 中预安装。为了能自定制 Unity 桌面,下面介绍一下如何在桌面版 Ubuntu 中安装 Unity Tweak Tool。
|
||||
|
||||
### 在 Ubuntu 13.04 或更高版本中安装 Unity Tweak Tool ###
|
||||
|
||||
@ -34,7 +34,7 @@ via: http://ask.xmodulo.com/install-unity-tweak-tool-ubuntu-desktop.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,9 +1,10 @@
|
||||
每个Linux用户都应该知道的3个有用技巧
|
||||
Linux 用户的 3 个命令行小技巧
|
||||
================================================================================
|
||||
Linux世界充满了乐趣,我们越深入进去,就会发现越多有趣的事物。我们会努力给你提供一些小技巧,让你和其他人有所不同,下面就是我们准备的3个小技巧。
|
||||
|
||||
### 1. 如何在不使用Cron的情况调度Linux下的作业 ###
|
||||
在Linux下,调度一个作业/命令可以缩写为Cron。当我们需要调度一个作业时,我们会使用Cron,但你知道我们在不使用Cron的情况也可以调度一个在将来时间运行的作业吗?你可以按照如下建议操作……
|
||||
### 1. 如何在不使用Cron的情况调度Linux下的任务 ###
|
||||
|
||||
在Linux下,调度一个任务/命令称之为Cron。当我们需要调度一个任务时,我们会使用Cron,但你知道我们在不使用Cron的情况也可以调度一个在将来时间运行的任务吗?你可以按照如下建议操作……
|
||||
|
||||
每5秒钟运行一个命令(date)然后将结果写入到一个文件(data.txt)。为了实现这一点,我们可以直接在命令提示符运行如下单行脚本。
|
||||
|
||||
@ -21,13 +22,13 @@ Linux世界充满了乐趣,我们越深入进去,就会发现越多有趣的
|
||||
|
||||
类似地,我们可以这样运行任何脚本。下边的例子是每100秒运行一个名为`script_name.sh`的脚本。
|
||||
|
||||
另外值得一提的是上边的脚本文件必须处于当前目录中,否则需要使用完整路径(`/home/$USER/…/script_name.sh`)。实现如上功能的单行脚本如下:
|
||||
另外值得一提的是上面提到的脚本文件必须处于当前目录中,否则需要使用完整路径(`/home/$USER/…/script_name.sh`)。实现如上功能的单行脚本如下:
|
||||
|
||||
$ while true; do /bin/sh script_name.sh ; sleep 100 ; done &
|
||||
|
||||
**总结**:上述的单行脚本并不是Cron的替代品,因为Cron工具支持众多选项,更加灵活,可定制性也更高。然而如果我们想运行某些测试,比如I/O评测,上述的单行脚本也管用。
|
||||
|
||||
还可以参考:[11 Linux Cron Job Scheduling Examples][1]
|
||||
还可以参考:[Linux 下 11 个定时调度任务例子][1]
|
||||
|
||||
### 2. 如何不使用clear命令清空终端的内容 ###
|
||||
|
||||
@ -37,23 +38,23 @@ Linux世界充满了乐趣,我们越深入进去,就会发现越多有趣的
|
||||
|
||||
**总结**:因为`ctrl + l`是一个快捷键,我们不可以在脚本中使用。所以如果我们需要在脚本中清空屏幕内容,还是需要使用`clear`命令。但我能想到的所有其他情况,`ctrl + l`都更加有效。
|
||||
|
||||
### 3. 运行一个命令,然后自动回到当前的工作目录 ###
|
||||
### 3. 在其它目录运行一个命令,然后自动返回当前工作目录 ###
|
||||
|
||||
这是一个很多人可能不知道的令人吃惊的技巧。你可能想运行任何一个命令,然后再回到当前目录。你只需要将命令放在一个圆括号里。
|
||||
这是一个很多人可能不知道的令人吃惊的技巧。你可能想在其它目录运行任何一个命令,然后再回到当前目录。要实现这样的目的,你只需要将命令放在一个圆括号里。
|
||||
|
||||
我们来看一个例子:
|
||||
|
||||
avi@deb:~$ (cd /home/avi/Downloads/)
|
||||
|
||||
#### 示例输出 ####
|
||||
|
||||
avi@deb:~
|
||||
示例输出:
|
||||
|
||||
avi@deb:~
|
||||
|
||||
它首先会cd到Downloads目录,然后又回到了之前的家目录。也许你认为里边的命令根本没有执行,或者是出了某种错误,因为从命令提示符看不出任何变化。让我们简单修改一下这个命令:
|
||||
|
||||
avi@deb:~$ (cd /home/avi/Downloads/ && ls -l)
|
||||
|
||||
#### 示例输出 ####
|
||||
|
||||
示例输出:
|
||||
|
||||
-rw-r----- 1 avi avi 54272 May 3 18:37 text1.txt
|
||||
-rw-r----- 1 avi avi 54272 May 3 18:37 text2.txt
|
||||
@ -70,7 +71,7 @@ via: http://www.tecmint.com/useful-linux-hacks-commands/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[goreliu](https://github.com/goreliu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,4 +1,3 @@
|
||||
translating wi-cuckoo
|
||||
No reboot patching comes to Linux 4.0
|
||||
================================================================================
|
||||
> **Summary**:With the new Linux 4.0 kernel, you'll need to reboot Linux less often than ever.
|
||||
|
@ -0,0 +1,82 @@
|
||||
PHP at 20: From pet project to powerhouse
|
||||
================================================================================
|
||||
![](http://images.techhive.com/images/article/2015/06/13049862325_8c97a11878_z-100590275-primary.idge.jpg)
|
||||
|
||||
Credit: [Steve Jurvetson via Flickr][1]
|
||||
|
||||
> The one-time ‘silly little project’ has transformed into a Web powerhouse, thanks to flexibility, pragmatism, and a vibrant community of Web devs
|
||||
|
||||
When Rasmus Lerdorf released “[a set of small tight CGI binaries written in C][2],” he had no idea how much his creation would impact Web development. Delivering the opening keynote at this year’s SunshinePHP conference in Miami, Lerdorf quipped, “In 1995, I thought I had unleashed a C API upon the Web. Obviously, that’s not what happened, or we’d all be C programmers.”
|
||||
|
||||
In fact, when Lerdorf released version 1.0 of Personal Home Page Tools -- as PHP was then known -- the Web was very young. HTML 2.0 would not be published until November of that year, and HTTP/1.0 not until May the following year. NCSA HTTPd was the most widely deployed Web server, and Netscape Navigator was the most popular Web browser, with Internet Explorer 1.0 to arrive in August. In other words, PHP’s beginnings coincided with the eve of the browser wars.
|
||||
|
||||
Those early days speak volumes about PHP’s impact on Web development. Back then, our options were limited when it came to server-side processing for Web apps. PHP stepped in to fill our need for a tool that would enable us to do dynamic things on the Web. That practical flexibility captured our imaginations, and PHP has since grown up with the Web. Now powering [more than 80 percent of the Web][3], PHP has matured into a scripting language that is especially suited to solve the Web problem. Its unique pedigree tells a story of pragmatism over theory and problem solving over purity.
|
||||
|
||||
### The Web glue we got hooked on ###
|
||||
|
||||
PHP didn’t start out as a language, and this is clear from its design -- or lack thereof, as detractors point out. It began as an API to help Web developers access lower-level C libraries. The first version was a small CGI binary that provided form-processing functionality with access to request parameters and the mSQL database. And its facility with a Web app’s database would prove key in sparking our interest in PHP and PHP’s subsequent ascendancy.
|
||||
|
||||
By version 2 -- aka PHP/FI -- database support had expanded to include PostgreSQL, MySQL, Oracle, Sybase, and more. It supported these databases by wrapping their C libraries, making them a part of the PHP binary. PHP/FI could also wrap the GD library to create and manipulate GIF images. It could be run as an Apache module or compiled with FastCGI support, and it introduced the PHP script language with support for variables, arrays, language constructs, and functions. For many of us working on the Web at that time, PHP was the kind of glue we'd been looking for.
|
||||
|
||||
As PHP folded in more and more programming language features, morphing into version 3 and onward, it never lost this gluelike aspect. Through repositories like PECL (PHP Extension Community Library), PHP could tie together libraries and expose their functionality to the PHP layer. This capacity to bring together components became a significant facet of the beauty of PHP, though it was not limited to its source code.
|
||||
|
||||
### The Web as a community of coders ###
|
||||
|
||||
PHP’s lasting impact on Web development isn’t limited to what can be done with the language itself. How PHP work is done and who participates -- these too are important parts of PHP’s legacy.
|
||||
|
||||
As early as 1997, PHP user groups began forming. One of the earliest was the Midwest PHP User’s Group (later known as Chicago PHP), which held its [first meeting in February 1997][4]. This was the beginning of what would become a vibrant, energetic community of developers assembled over an affinity for a little tool that helped them solve problems on the Web. The ubiquity of PHP made it a natural choice for Web development. It became especially popular in the shared hosting world, and its low barrier to entry was attractive to many early Web developers.
|
||||
|
||||
With a growing community came an assortment of tools and resources for PHP developers. The year 2000 -- a watershed moment for PHP -- witnessed the first PHP Developers’ Meeting, a gathering of the core developers of the programming language, who met in Tel Aviv to discuss the forthcoming 4.0 release. PHP Extension and Application Repository (PEAR) also launched in 2000 to provide high-quality userland code packages following standards and best practices. The first PHP conference, PHP Kongress, was held in Germany soon after. [PHPDeveloper.org][5] came online, and to this day, it is the most authoritative news source in the PHP community.
|
||||
|
||||
This communal momentum proved vital to PHP’s growth in subsequent years, and as the Web development industry erupted, so did PHP. PHP began powering more and larger websites. More user groups formed around the world. Mailing lists; online forums; IRC; conferences; trade journals such as php[architect], the German PHP Magazin, and International PHP Magazine -- the vibrancy of the PHP community had a significant impact on the way Web work would be done: collectively and openly, with an emphasis on code sharing.
|
||||
|
||||
Then, 10 years ago, shortly after the release of PHP 5, an interesting thing happened in Web development that created a general shift in how the PHP community built libraries and applications: Ruby on Rails was released.
|
||||
|
||||
### The rise of frameworks ###
|
||||
|
||||
The Ruby on Rails framework for the Ruby programming language created an increased focus and attention on the MVC (model-view-controller) architectural pattern. The Mojavi PHP framework a few years prior had used this pattern, but the hype around Ruby on Rails is what firmly cemented MVC in the PHP frameworks that followed. Frameworks exploded in the PHP community, and frameworks have changed the way developers build PHP applications.
|
||||
|
||||
Many important projects and developments have arisen, thanks to the proliferation of frameworks in the PHP community. The PHP [Framework Interoperability Group][6] formed in 2009 to aid in establishing coding standards, naming conventions, and best practices among frameworks. Codifying these standards and practices helped provide more interoperable software for developers using member projects’ code. This interoperability meant that each framework could be split into components and stand-alone libraries could be used together with monolithic frameworks. With interoperability came another important milestone: The Composer project was born in 2011.
|
||||
|
||||
Inspired by Node.js’s NPM and Ruby’s Bundler, Composer has ushered in a new era of PHP application development, creating a PHP renaissance of sorts. It has encouraged interoperability between packages, standard naming conventions, adoption of coding standards, and increased test coverage. It is an essential tool in any modern PHP application.
|
||||
|
||||
### The need for speed and innovation ###
|
||||
|
||||
Today, the PHP community has a thriving ecosystem of applications and libraries. Some of the most widely installed PHP applications include WordPress, Drupal, Joomla, and MediaWiki. These applications power the Web presence of businesses of all sizes, from small mom-and-pop shops to sites like whitehouse.gov and Wikipedia. Six of the Alexa top 10 sites use PHP to serve billions of pages a day. As a result, PHP applications have been optimized for speed -- and much innovation has gone into PHP core to improve performance.
|
||||
|
||||
In 2010, Facebook unveiled its HipHop for PHP source-to-source compiler, which translates PHP code into C++ code and compiles it into a single executable binary application. Facebook’s size and growth necessitated the move away from standard interpreted PHP code to a faster, optimized executable. However, Facebook wanted to continue using PHP for its ease of use and rapid development cycles. HipHop for PHP evolved into HHVM, a JIT (just-in-time) compilation-based execution engine for PHP, which included a new language based on PHP: [Hack][7].
|
||||
|
||||
Facebook’s innovations, as well as other VM projects, created competition at the engine level, leading to discussions about the future of the Zend Engine that still powers PHP’s core, as well as the question of a language specification. In 2014, a language specification project was created “to provide a complete and concise definition of the syntax and semantics of the PHP language,” making it possible for compiler projects to create interoperable PHP implementations.
|
||||
|
||||
The next major version of PHP became a topic of intense debate, and a project known as phpng (next generation) was offered as an option to clean up, refactor, optimize, and improve the PHP code base, which also showed substantial improvements to the performance of real-world applications. After deciding to name the next major version “PHP 7,” due to a previous, unreleased PHP 6.0 version, the phpng branch was merged in, and plans were made to proceed with PHP 7, working in many of the language features offered by Hack, such as scalar and return type hinting.
|
||||
|
||||
With the [first PHP 7 alpha release due out today][8] and benchmarks showing [performance as good as or better than that of HHVM][9] in many cases, PHP is keeping up with the pace of modern Web development needs. Likewise, the PHP-FIG continues to innovate and push frameworks and libraries to collaborate and cooperate -- most recently with the adoption of [PSR-7][10], which will change the way PHP projects handle HTTP. User groups, conferences, publications, and initiatives like [PHPMentoring.org][11] continue to advocate best practices, coding standards, and testing to the PHP developer community.
|
||||
|
||||
PHP has seen the Web mature through various stages, and PHP has matured. Once a simple API wrapper around lower-level C libraries, PHP has become a full-fledged programming language in its own right. Its developer community is vibrant and helpful, priding themselves in pragmatism and welcoming newcomers. PHP has stood the test of time for 20 years, and current activity in the language and community is ensuring it will be a relevant and useful language for years to come.
|
||||
|
||||
During his SunshinePHP keynote, Rasmus Lerdorf reflected, “Did I think I’d be here 20 years later talking about this silly little project I did? No, I didn’t.”
|
||||
|
||||
Here’s to Lerdorf and the rest of the PHP community for transforming this “silly little project” into a lasting, powerful component of the Web today.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.infoworld.com/article/2933858/php/php-at-20-from-pet-project-to-powerhouse.html
|
||||
|
||||
作者:[Ben Ramsey][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.infoworld.com/author/Ben-Ramsey/
|
||||
[1]:https://www.flickr.com/photos/jurvetson/13049862325
|
||||
[2]:https://groups.google.com/d/msg/comp.infosystems.www.authoring.cgi/PyJ25gZ6z7A/M9FkTUVDfcwJ
|
||||
[3]:http://w3techs.com/technologies/overview/programming_language/all
|
||||
[4]:http://web.archive.org/web/20061215165756/http://chiphpug.php.net/mpug.htm
|
||||
[5]:http://www.phpdeveloper.org/
|
||||
[6]:http://www.php-fig.org/
|
||||
[7]:http://www.infoworld.com/article/2610885/facebook-q-a--hack-brings-static-typing-to-php-world.html
|
||||
[8]:https://wiki.php.net/todo/php70#timetable
|
||||
[9]:http://talks.php.net/velocity15
|
||||
[10]:http://www.php-fig.org/psr/psr-7/
|
||||
[11]:http://phpmentoring.org/
|
@ -0,0 +1,73 @@
|
||||
Extend Swap Space using Swap file in Linux
|
||||
================================================================================
|
||||
There are some scenarios where our Linux box is running out of swap space so in that case we can extend the swap space using swap partition but due to unavailability of free partitions on the disk, we are unable to extend it.
|
||||
|
||||
So in such cases we can extend or increase swap space using a swap file
|
||||
|
||||
### Below are the Steps to extend Swap Space using Swap File in Linux ###
|
||||
|
||||
Lets first check the size of existing swap space / partition using the command like ‘**free -m‘** and ‘**swapon -s**‘
|
||||
|
||||
![](http://www.linuxtechi.com/wp-content/uploads/2015/06/free-output-with-swap.jpg)
|
||||
free-output-with-swap
|
||||
|
||||
In my case size of swap partition is 2 GB. So we will be extending swap space by 1 GB.
|
||||
|
||||
#### Step:1 Create a swap file of size 1 GB using below dd Command ####
|
||||
|
||||
[root@linuxtechi ~]# dd if=/dev/zero of=/swap_file bs=1G count=1
|
||||
1+0 records in
|
||||
1+0 records out
|
||||
1073741824 bytes (1.1 GB) copied, 414.898 s, 2.6 MB/s
|
||||
[root@linuxtechi ~]#
|
||||
|
||||
Replace the value of ‘**bs**‘ and ‘**count**‘ according your requirement.
|
||||
|
||||
#### Step:2 Secure the swap file with permissions 644. ####
|
||||
|
||||
[root@linuxtechi ~]# chmod 600 /swap_file
|
||||
|
||||
#### Step:3 Enable the Swap Area on the file (swap_file) ####
|
||||
|
||||
Use mkswap command to enable swap area
|
||||
|
||||
[root@linuxtechi ~]# mkswap /swap_file
|
||||
Setting up swapspace version 1, size = 1048572 KiB
|
||||
no label, UUID=f7b3ae59-c09a-4dc2-ba4d-c02abb7db33b
|
||||
[root@linuxtechi ~]#
|
||||
|
||||
#### Step:4 Add the swap file entry in the fstab file ####
|
||||
|
||||
Add the below entry in the fstab file so that swap file become persistent across every reboot.
|
||||
|
||||
/swap_file swap swap defaults 0 0
|
||||
|
||||
![swap-file-fstab-entry](http://www.linuxtechi.com/wp-content/uploads/2015/06/swap-file-fstab-entry.jpg)
|
||||
|
||||
#### Step:5 Enable the swap file using ‘mkswap on’ command. ####
|
||||
|
||||
[root@linuxtechi ~]# swapon /swap_file
|
||||
[root@linuxtechi ~]#
|
||||
|
||||
#### Step:6 Now verify the swap space ####
|
||||
|
||||
![swap-space-after-extension](http://www.linuxtechi.com/wp-content/uploads/2015/06/swap-space-after-extension.jpg)
|
||||
|
||||
**Note**: To disable the swap file for any troubleshooting point of view, use swapoff command as shown below and to re-enable swap file then use swapon command as shown in step5.
|
||||
|
||||
[root@linuxtechi ~]# swapoff /swap_file
|
||||
[root@linuxtechi ~]#
|
||||
|
||||
Please share your valuable inputs and comments of this article.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxtechi.com/extend-swap-space-using-swap-file-in-linux/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.linuxtechi.com/author/pradeep/
|
@ -0,0 +1,191 @@
|
||||
Install Plex Media Server On Ubuntu / CentOS 7.1 / Fedora 22
|
||||
================================================================================
|
||||
In this article we will show you how easily you can setup Plex Home Media Server on major Linux distributions with their latest releases. After its successful installation of Plex you will be able to use your centralized home media playback system that streams its media to many Plex player Apps and the Plex Home will allows you to setup your environment by adding your devices and to setup a group of users that all can use Plex Together. So let’s start its installation first on Ubuntu 15.04.
|
||||
|
||||
### Basic System Resources ###
|
||||
|
||||
System resources mainly depend on the type and number of devices that you are planning to connect with the server. So according to our requirements we will be using as following system resources and software for a standalone server.
|
||||
|
||||
注:表格
|
||||
<table width="666" style="height: 181px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="670" colspan="2"><b>Plex Home Media Server</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="236"><b>Base Operating System</b></td>
|
||||
<td width="425">Ubuntu 15.04 / CentOS 7.1 / Fedora 22 Work Station</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="236"><b>Plex Media Server</b></td>
|
||||
<td width="425">Version 0.9.12.3.1173-937aac3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="236"><b>RAM and CPU</b></td>
|
||||
<td width="425">1 GB , 2.0 GHZ</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="236"><b>Hard Disk</b></td>
|
||||
<td width="425">30 GB</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Plex Media Server 0.9.12.3 on Ubuntu 15.04 ###
|
||||
|
||||
We are now ready to start the installations process of Plex Media Server on Ubuntu so let’s start with the following steps to get it ready.
|
||||
|
||||
#### Step 1: System Update ####
|
||||
|
||||
Login to your server with root privileges Make your that your system is upto date if not then do by using below command.
|
||||
|
||||
root@ubuntu-15:~#apt-get update
|
||||
|
||||
#### Step 2: Download the Latest Plex Media Server Package ####
|
||||
|
||||
Create a new directory and download .deb plex Media Package in it from the official website of Plex for Ubuntu using wget command.
|
||||
|
||||
root@ubuntu-15:~# cd /plex/
|
||||
root@ubuntu-15:/plex#
|
||||
root@ubuntu-15:/plex# wget https://downloads.plex.tv/plex-media-server/0.9.12.3.1173-937aac3/plexmediaserver_0.9.12.3.1173-937aac3_amd64.deb
|
||||
|
||||
#### Step 3: Install the Debian Package of Plex Media Server ####
|
||||
|
||||
Now within the same directory run following command to start installation of debian package and then check the status of plekmediaserver.
|
||||
|
||||
root@ubuntu-15:/plex# dpkg -i plexmediaserver_0.9.12.3.1173-937aac3_amd64.deb
|
||||
|
||||
----------
|
||||
|
||||
root@ubuntu-15:~# service plexmediaserver status
|
||||
|
||||
![Plexmediaserver Service](http://blog.linoxide.com/wp-content/uploads/2015/06/plex-status.png)
|
||||
|
||||
### Plex Home Media Web App Setup on Ubuntu 15.04 ###
|
||||
|
||||
Let's open your web browser within your localhost network and open the Web Interface with your localhost IP and port 32400 and do following steps to configure it:
|
||||
|
||||
http://172.25.10.179:32400/web
|
||||
http://localhost:32400/web
|
||||
|
||||
#### Step 1:Sign UP before Login ####
|
||||
|
||||
After you have access to the web interface of Plesk Media Server make sure to Sign Up and set your username email ID and Password to login as.
|
||||
|
||||
![Plex Sign In](http://blog.linoxide.com/wp-content/uploads/2015/06/PMS-Login.png)
|
||||
|
||||
#### Step 2: Enter Your Pin to Secure Your Plex Media Home User ####
|
||||
|
||||
![Plex User Pin](http://blog.linoxide.com/wp-content/uploads/2015/06/333.png)
|
||||
|
||||
Now you have successfully configured your user under Plex Home Media.
|
||||
|
||||
![Welcome To Plex](http://blog.linoxide.com/wp-content/uploads/2015/06/3333.png)
|
||||
|
||||
### Opening Plex Web App on Devices Other than Localhost Server ###
|
||||
|
||||
As we have seen in our Plex media home page that it indicates that "You do not have permissions to access this server". Its because of we are on a different network than the Server computer.
|
||||
|
||||
![Plex Server Permissions](http://blog.linoxide.com/wp-content/uploads/2015/06/33.png)
|
||||
|
||||
Now we need to resolve this permissions issue so that we can have access to server on the devices other than the hosted server by doing following setup.
|
||||
|
||||
### Setup SSH Tunnel for Windows System to access Linux Server ###
|
||||
|
||||
First we need to set up a SSH tunnel so that we can access things as if they were local. This is only necessary for the initial setup.
|
||||
|
||||
If you are using Windows as your local system and server on Linux then we can setup SSH-Tunneling using Putty as shown.
|
||||
|
||||
![Plex SSH Tunnel](http://blog.linoxide.com/wp-content/uploads/2015/06/ssh-tunnel.png)
|
||||
|
||||
**Once you have the SSH tunnel set up:**
|
||||
|
||||
Open your Web browser window and type following URL in the address bar.
|
||||
|
||||
http://localhost:8888/web
|
||||
|
||||
The browser will connect to the server and load the Plex Web App with same functionality as on local.
|
||||
Agree to the terms of Services and start
|
||||
|
||||
![Agree to Plex term](http://blog.linoxide.com/wp-content/uploads/2015/06/5.png)
|
||||
|
||||
Now a fully functional Plex Home Media Server is ready to add new media libraries, channels, playlists etc.
|
||||
|
||||
![PMS Settings](http://blog.linoxide.com/wp-content/uploads/2015/06/8.png)
|
||||
|
||||
### Plex Media Server 0.9.12.3 on CentOS 7.1 ###
|
||||
|
||||
We will follow the same steps on CentOS-7.1 that we did for the installation of Plex Home Media Server on Ubuntu 15.04.
|
||||
|
||||
So lets start with Plex Media Servers Package Installation.
|
||||
|
||||
#### Step 1: Plex Media Server Installation ####
|
||||
|
||||
To install Plex Media Server on centOS 7.1 we need to download the .rpm package from the official website of Plex. So we will use wget command to download .rpm package for this purpose in a new directory.
|
||||
|
||||
[root@linux-tutorials ~]# cd /plex
|
||||
[root@linux-tutorials plex]# wget https://downloads.plex.tv/plex-media-server/0.9.12.3.1173-937aac3/plexmediaserver-0.9.12.3.1173-937aac3.x86_64.rpm
|
||||
|
||||
#### Step 2: Install .RPM Package ####
|
||||
|
||||
After completion of complete download package we will install this package using rpm command within the same direcory where we installed the .rpm package.
|
||||
|
||||
[root@linux-tutorials plex]# ls
|
||||
plexmediaserver-0.9.12.3.1173-937aac3.x86_64.rpm
|
||||
[root@linux-tutorials plex]# rpm -i plexmediaserver-0.9.12.3.1173-937aac3.x86_64.rpm
|
||||
|
||||
#### Step 3: Start Plexmediaservice ####
|
||||
|
||||
We have successfully installed Plex Media Server Now we just need to restart its service and then enable it permanently.
|
||||
|
||||
[root@linux-tutorials plex]# systemctl start plexmediaserver.service
|
||||
[root@linux-tutorials plex]# systemctl enable plexmediaserver.service
|
||||
[root@linux-tutorials plex]# systemctl status plexmediaserver.service
|
||||
|
||||
### Plex Home Media Web App Setup on CentOS-7.1 ###
|
||||
|
||||
Now we just need to repeat all steps that we performed during the Web app setup of Ubuntu.
|
||||
So let's Open a new window in your web browser and access the Plex Media Server Web app using localhost or IP or your Plex server.
|
||||
|
||||
http://172.20.3.174:32400/web
|
||||
http://localhost:32400/web
|
||||
|
||||
Then to get full permissions on the server you need to repeat the steps to create the SSH-Tunnel.
|
||||
After signing up with new user account we will be able to access its all features and can add new users, add new libraries and setup it per our needs.
|
||||
|
||||
![Plex Device Centos](http://blog.linoxide.com/wp-content/uploads/2015/06/plex-devices-centos.png)
|
||||
|
||||
### Plex Media Server 0.9.12.3 on Fedora 22 Work Station ###
|
||||
|
||||
The Basic steps to download and install Plex Media Server are the same as its we did for in CentOS 7.1.
|
||||
We just need to download its .rpm package and then install it with rpm command.
|
||||
|
||||
![PMS Installation](http://blog.linoxide.com/wp-content/uploads/2015/06/plex-on-fedora.png)
|
||||
|
||||
### Plex Home Media Web App Setup on Fedora 22 Work Station ###
|
||||
|
||||
We had setup Plex Media Server on the same host so we don't need to setup SSH-Tunnel in this time scenario. Just open the web browser in your Fedora 22 Workstation with default port 32400 of Plex Home Media Server and accept the Plex Terms of Services Agreement.
|
||||
|
||||
![Plex Agreement](http://blog.linoxide.com/wp-content/uploads/2015/06/Plex-Terms.png)
|
||||
|
||||
**Welcome to Plex Home Media Server on Fedora 22 Workstation**
|
||||
|
||||
Lets login with your plex account and start with adding your libraries for your favorite movie channels , create your playlists, add your photos and enjoy with many other features of Plex Home Media Server.
|
||||
|
||||
![Plex Add Libraries](http://blog.linoxide.com/wp-content/uploads/2015/06/create-library.png)
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
We had successfully installed and configured Plex Media Server on Major Linux Distributions. So, Plex Home Media Server has always been a best choice for media management. Its so simple to setup on cross platform as we did for Ubuntu, CentOS and Fedora. It has simplifies the tasks of organizing your media content and streaming to other computers and devices then to share it with your friends.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/tools/install-plex-media-server-ubuntu-centos-7-1-fedora-22/
|
||||
|
||||
作者:[Kashif Siddique][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/kashifs/
|
@ -0,0 +1,176 @@
|
||||
Lolcat – A Command Line Tool to Output Rainbow Of Colors in Linux Terminal
|
||||
================================================================================
|
||||
For those who believe that Linux Command Line is boring and there isn’t any fun, then you’re wrong here are the articles on Linux, that shows how funny and naughty is Linux..
|
||||
|
||||
- [20 Funny Commands of Linux or Linux is Fun in Terminal][1]
|
||||
- [6 Interesting Funny Commands of Linux (Fun in Terminal)][2]
|
||||
- [Fun in Linux Terminal – Play with Word and Character Counts][3]
|
||||
|
||||
Here in this article, I will be discussing about a small utility called “lolcat” – Which produce rainbow of colors in terminal.
|
||||
|
||||
![Lolcat Command to Output Rainbow of Colors for Terminal](http://www.tecmint.com/wp-content/uploads/2015/06/Linux-Lolcat.png)
|
||||
|
||||
Lolcat Command to Output Rainbow of Colors for Terminal
|
||||
|
||||
#### What is lolcat? ####
|
||||
|
||||
Lolcat is an utility for Linux, BSD and OSX which concatenates like similar to [cat command][4] and adds rainbow coloring to it. Lolcat is primarily used for rainbow coloring of text in Linux Terminal.
|
||||
|
||||
### Installation of Lolcat in Linux ###
|
||||
|
||||
**1. Lolcat utility is available in the repository of lots of Linux distributions, but the available version bit older. Alternatively you can download and install latest version of lolcat from git repository.**
|
||||
|
||||
Lolcat is a ruby gem hence it is essential to have latest version of RUBY installed on your system.
|
||||
|
||||
# apt-get install ruby [On APT based Systems]
|
||||
# yum install ruby [On Yum based Systems]
|
||||
# dnf install ruby [On DNF based Systems]
|
||||
|
||||
Once ruby package has been installed, make sure to verify the version of ruby installed.
|
||||
|
||||
# ruby --version
|
||||
|
||||
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
|
||||
|
||||
**2. Next download and install the most recent version of lolcat from the git repository using following commands.**
|
||||
|
||||
# wget https://github.com/busyloop/lolcat/archive/master.zip
|
||||
# unzip master.zip
|
||||
# cd lolcat-master/bin
|
||||
# gem install lolcat
|
||||
|
||||
Once lolcat is installed, you can check the version.
|
||||
|
||||
# lolcat --version
|
||||
|
||||
lolcat 42.0.99 (c)2011 moe@busyloop.net
|
||||
|
||||
### Usage of Lolcat ###
|
||||
|
||||
**3. Before starting usage of lolcat, make sure to know the available options and help using following command.**
|
||||
|
||||
# lolcat -h
|
||||
|
||||
![Lolcat Help](http://www.tecmint.com/wp-content/uploads/2015/06/Lolcat-Help1.png)
|
||||
|
||||
Lolcat Help
|
||||
|
||||
**4. Next, pipeline lolcat with commads say ps, date and cal as:**
|
||||
|
||||
# ps | lolcat
|
||||
# date | lolcat
|
||||
# cal | lolcat
|
||||
|
||||
![ps Command Output](http://www.tecmint.com/wp-content/uploads/2015/06/ps-command-output.png)
|
||||
|
||||
ps Command Output
|
||||
|
||||
![Date Output](http://www.tecmint.com/wp-content/uploads/2015/06/Date.png)
|
||||
|
||||
Date Output
|
||||
|
||||
![Calendar Output](http://www.tecmint.com/wp-content/uploads/2015/06/Cal.png)
|
||||
|
||||
Calendar Output
|
||||
|
||||
**5. 3. Use lolcat to display codes of a script file as:**
|
||||
|
||||
# lolcat test.sh
|
||||
|
||||
![Display Codes with Lolcat](http://www.tecmint.com/wp-content/uploads/2015/06/Script-Output.png)
|
||||
|
||||
Display Codes with Lolcat
|
||||
|
||||
**6. Pipeline lolcat with figlet command. Figlet is a utility which displays large characters made up of ordinary screen characters. We can pipeline the output of figlet with lolcat to make the output colorful as:**
|
||||
|
||||
# echo I ❤ Tecmint | lolcat
|
||||
# figlet I Love Tecmint | lolcat
|
||||
|
||||
![Colorful Texts](http://www.tecmint.com/wp-content/uploads/2015/06/Colorful-Text.png)
|
||||
|
||||
Colorful Texts
|
||||
|
||||
**Note**: Not to mention that ❤ is an unicode character and to install figlet you have to yum and apt to get the required packages as:
|
||||
|
||||
# apt-get figlet
|
||||
# yum install figlet
|
||||
# dnf install figlet
|
||||
|
||||
**7. Animate a text in rainbow of colours, as:**
|
||||
|
||||
$ echo I ❤ Tecmit | lolcat -a -d 500
|
||||
|
||||
![Animated Text](http://www.tecmint.com/wp-content/uploads/2015/06/Animated-Text.gif)
|
||||
|
||||
Animated Text
|
||||
|
||||
Here the option -a is for Animation and -d is for duration. In the above example duration count is 500.
|
||||
|
||||
**8. Read a man page (say man ls) in rainbow of colors as:**
|
||||
|
||||
# man ls | lolcat
|
||||
|
||||
![List Files Colorfully](http://www.tecmint.com/wp-content/uploads/2015/06/List-Files-Colorfully.png)
|
||||
|
||||
List Files Colorfully
|
||||
|
||||
**9. Pipeline lolcat with cowsay. cowsay is a configurable thinking and/or speaking cow, which supports a lot of other animals as well.**
|
||||
|
||||
Install cowsay as:
|
||||
|
||||
# apt-get cowsay
|
||||
# yum install cowsay
|
||||
# dnf install cowsay
|
||||
|
||||
After install, print the list of all the animals in cowsay as:
|
||||
|
||||
# cowsay -l
|
||||
|
||||
**Sample Output**
|
||||
|
||||
Cow files in /usr/share/cowsay/cows:
|
||||
apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default
|
||||
dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
|
||||
ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala
|
||||
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep
|
||||
skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey
|
||||
turtle tux unipony unipony-smaller vader vader-koala www
|
||||
|
||||
Output of cowsay pipelined with lolcat and ‘gnu‘ cowfile is used.
|
||||
|
||||
# cowsay -f gnu ☛ Tecmint ☚ is the best Linux Resource Available online | lolcat
|
||||
|
||||
![Cowsay with Lolcat](http://www.tecmint.com/wp-content/uploads/2015/06/Cowsay-with-Lolcat.png)
|
||||
|
||||
Cowsay with Lolcat
|
||||
|
||||
**Note**: You can use lolcat with any other command in pipeline and get colored output in terminal.
|
||||
|
||||
**10. You may create alias for the most frequently used commands to get command output in rainbow of colors. You can alias ‘ls -l‘ command which is used for long list the contents of directory as below.**
|
||||
|
||||
# alias lolls="ls -l | lolcat"
|
||||
# lolls
|
||||
|
||||
![Alias Commands with Colorful](http://www.tecmint.com/wp-content/uploads/2015/06/Alias-Commands-with-Colorful.png)
|
||||
|
||||
Alias Commands with Colorful
|
||||
|
||||
You may create alias for any command as suggested above. To create permanent alias, you have to add the relevant code (above code for ls -l alias) to ~/.bashrc file and also make sure to logout and login back for the changes to be taken into effect.
|
||||
|
||||
That’s all for now. I would like to know if you were aware of lolcat previously? Did you like the post? And suggestion and feedback is welcome in the comment section below. Like and share us and help us get spread.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/lolcat-command-to-output-rainbow-of-colors-in-linux-terminal/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/avishek/
|
||||
[1]:http://www.tecmint.com/20-funny-commands-of-linux-or-linux-is-fun-in-terminal/
|
||||
[2]:http://www.tecmint.com/linux-funny-commands/
|
||||
[3]:http://www.tecmint.com/play-with-word-and-character-counts-in-linux/
|
||||
[4]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
@ -1,108 +0,0 @@
|
||||
Translating by goreliu ...
|
||||
|
||||
11 pointless but awesome Linux terminal tricks
|
||||
================================================================================
|
||||
Here are some great Linux terminal tips and tricks, each one as pointless as it is awesome.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_01-100587352-orig.png)
|
||||
|
||||
### All work and no play... ###
|
||||
|
||||
Linux is one of the most astoundingly functional and utilitarian Operating Systems around when it comes to working from the command line. Need to perform a particular task? Odds are there is an application or script you can use to get it done. Right from the terminal. But, as they say in the good book, "All work and no play make Jack really bored or something." So here is a collection of my favorite pointless, stupid, annoying or amusing things that you can do right in your Linux Terminal.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_02-100587353-orig.png)
|
||||
|
||||
### Give the terminal an attitude ###
|
||||
|
||||
Step 1) Type "sudo visudo".
|
||||
|
||||
Step 2) At the bottom of the "Defaults" (near the top of the file) add, on a new line, "Defaults insults".
|
||||
|
||||
Step 3) Save the file.
|
||||
|
||||
"What did I just do to my computer?" you may be asking yourself. Something wonderful. Now, whenever you issue a sudo command and misstype your password, your computer will call you names. My favorite: "Listen, burrito brains, I don't have time to listen to this trash."
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_03-100587354-orig.png)
|
||||
|
||||
### apt-get moo ###
|
||||
|
||||
That screenshot you see? That's what typing "apt-get moo" (on a Debian-based system) does. That's it. Don't go looking for this to do something fancy. It won't. That, I kid you not, is it. But it's one of the most commonly known little Easter eggs on Linux. So I include it here, right near the beginning, so I won't get 5,000 emails telling me I missed it in this list.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_04-100587355-orig.png)
|
||||
|
||||
### aptitude moo ###
|
||||
|
||||
A bit more entertaining is aptitude's take on "moo." Type "aptitude moo" (on Ubuntu and the like) and you'll be corrected about thinking "moo" would do anything. But you know better. Try the same command again, this time with an optional "-v" attribute. Don't stop there. Add v's, one at a time, until aptitude gives you what you want.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_05-100587356-orig.png)
|
||||
|
||||
### Arch: Put Pac-Man in pacman ###
|
||||
|
||||
This is one just for the Arch-lovers out there. The de facto package manager, pacman, is pretty fantastic already. Let's make it even better.
|
||||
|
||||
Step 1) Open "/etc/pacman.conf".
|
||||
|
||||
Step 2) In the "# Misc options", remove the "#" from in front of "Color".
|
||||
|
||||
Step 3) Add "ILoveCandy".
|
||||
|
||||
Now the progress for installing new packages, in pacman, will include a little tiny Pac-Man. Which should really just be the default anyway.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_06-100587358-orig.png)
|
||||
|
||||
### Cowsay! ###
|
||||
|
||||
Making aptitude moo is neat, I guess, but you really can't use it for much. Enter "cowsay." It does what you think. You make a cow say things. Anything you like. And it's not even limited to cows. Calvin, Beavis, and the Ghostbusters logo are all available in full ASCII art glory – type "cowsay -l" for a full list of what's available in this, Linux's most powerful tool. Remember that, like most great terminal applications, you can pipe the output from other applications straight into cowsay (ala "fortune | cowsay").
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_07-100587359-orig.png)
|
||||
|
||||
### Become an 3l33t h@x0r ###
|
||||
|
||||
Typing "nmap" isn't something one typically needs to do on a day-to-day basis. But when one does need to "whip out the nmap," one wants to look as l33t as humanly possible. Add a "-oS" to any nmap command (such as "nmap -oS - google.com"). Bam. You're now in what is officially known as "[Script Kiddie Mode][1]." Angelina Jolie and Keanu Reeves would be proud.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_08-100587360-orig.png)
|
||||
|
||||
### Getting all Discordian ddate ###
|
||||
|
||||
If you've ever been sitting around thinking, "Hey! I want today's date to be written in an essentially useless, but whimsical, way"…try typing "ddate". Results like "Today is Setting Orange, the 72nd day of Discord in the YOLD 3181," can really spice up your server logs.
|
||||
|
||||
Note: Technically, this is a real thing called the [Discordian Calendar][2], used (in theory) by the followers of [Discordianism][3]. Which means I probably offended somebody. Or maybe not. I'm not really sure. Either way, ddate is a handy tool in any office.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_09-100587361-orig.png)
|
||||
|
||||
### I See Colors Everywhere! ###
|
||||
|
||||
Tired of boring old text? Looking to spruce things up and show the world your true style? lolcat. Install it. Use it. Everywhere. It takes any text input and turns it into a rainbow of wonder and enchantment. Piping text into lolcat (ala "fortune | lolcat") is sure to liven up any party.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_10-100587362-orig.png)
|
||||
|
||||
### The Steam Locomotive ###
|
||||
|
||||
Animated ASCII art steam locomotive in your terminal. You want this. You need this. Install and run "sl". Use "sl -l" for a tiny version. Or, if you want to really spend some time on this, "sl-h". This is the full train, including passenger cars.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_11-100587364-orig.png)
|
||||
|
||||
### Reverse any text ###
|
||||
|
||||
Pipe the output of any text into "rev" and it will reverse the text. "fortune | rev" gives you a fortune. In reverse. Which is, as odd as it may seem, not a misfortune.
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_12-100587366-orig.png)
|
||||
|
||||
### The Matrix is still cool, right? ###
|
||||
|
||||
Want your terminal to do that scrolling text, l33t, Matrix-y thing? "cmatrix" is your friend. You can even have it output different colors, which is snazzy. Learn how by typing "man cmatrix". Or, better yet, "man cmatrix | lolcat". Which, really, is the most pointless (but wonderful) thing you can do in the Linux Terminal. So that's where I leave you.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.networkworld.com/article/2926630/linux/11-pointless-but-awesome-linux-terminal-tricks.html
|
||||
|
||||
作者:[Bryan Lunduke][a]
|
||||
译者:[goreliu](https://github.com/goreliu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.networkworld.com/author/Bryan-Lunduke/
|
||||
[1]:http://nmap.org/book/output-formats-script-kiddie.html
|
||||
[2]:http://en.wikipedia.org/wiki/Discordian_calendar
|
||||
[3]:http://en.wikipedia.org/wiki/Discordianism
|
@ -1,3 +1,4 @@
|
||||
zpl1025
|
||||
How to Manipulate Filenames Having Spaces and Special Characters in Linux
|
||||
================================================================================
|
||||
We come across files and folders name very regularly. In most of the cases file/folder name are related to the content of the file/folder and starts with number and characters. Alpha-Numeric file name are pretty common and very widely used, but this is not the case when we have to deal with file/folder name that has special characters in them.
|
||||
@ -432,4 +433,4 @@ via: http://www.tecmint.com/manage-linux-filenames-with-special-characters/
|
||||
|
||||
[a]:http://www.tecmint.com/author/avishek/
|
||||
[1]:http://www.tecmint.com/15-basic-ls-command-examples-in-linux/
|
||||
[2]:http://www.tecmint.com/8-pratical-examples-of-linux-touch-command/
|
||||
[2]:http://www.tecmint.com/8-pratical-examples-of-linux-touch-command/
|
||||
|
@ -1,3 +1,4 @@
|
||||
wyangsun 申领
|
||||
Inside NGINX: How We Designed for Performance & Scale
|
||||
================================================================================
|
||||
NGINX leads the pack in web performance, and it’s all due to the way the software is designed. Whereas many web servers and application servers use a simple threaded or process-based architecture, NGINX stands out with a sophisticated event-driven architecture that enables it to scale to hundreds of thousands of concurrent connections on modern hardware.
|
||||
@ -171,4 +172,4 @@ via: http://nginx.com/blog/inside-nginx-how-we-designed-for-performance-scale/
|
||||
[12]:https://speakerdeck.com/nginx/nginx-installation-and-tuning
|
||||
[13]:http://nginx.com/blog/tuning-nginx/
|
||||
[14]:http://www.aosabook.org/en/nginx.html
|
||||
[15]:http://nginx.com/blog/socket-sharding-nginx-release-1-9-1/
|
||||
[15]:http://nginx.com/blog/socket-sharding-nginx-release-1-9-1/
|
||||
|
91
sources/tech/20150615 How to combine two graphs on Cacti.md
Normal file
91
sources/tech/20150615 How to combine two graphs on Cacti.md
Normal file
@ -0,0 +1,91 @@
|
||||
How to combine two graphs on Cacti
|
||||
================================================================================
|
||||
[Cacti][1] a fantastic open source network monitoring system that is widely used to graph network elements like bandwidth, storage, processor and memory utilization. Using its web based interface, you can create and organize graphs easily. However, some advanced features like merging graphs, creating aggregate graphs using multiple sources, migration of Cacti to another server are not provided by default. You might need some experience with Cacti to pull these off. In this tutorial, we will see how we can merge two Cacti graphs into one.
|
||||
|
||||
Consider this example. Client-A has been connected to port 5 of switch-A for the last six months. Port 5 becomes faulty, and so the client is migrated to Port 6. As Cacti uses different graphs for each interface/element, the bandwidth history of the client would be split into port 5 and port 6. So we end up with two graphs for one client - one with six months' worth of old data, and the other that contains ongoing data.
|
||||
|
||||
In such cases, we can actually combine the two graphs so the old data is appended to the new graph, and we get to keep a single graph containing historic and new data for one customer. This tutorial will explain exactly how we can achieve that.
|
||||
|
||||
Cacti stores the data of each graph in its own RRD (round robin database) file. When a graph is requested, the values stored in a corresponding RRD file are used to generate the graph. RRD files are stored in `/var/lib/cacti/rra` in Ubuntu/Debian systems and in `/var/www/cacti/rra` in CentOS/RHEL systems.
|
||||
|
||||
The idea behind merging graphs is to alter these RRD files so the values from the old RRD file are appended to the new RRD file.
|
||||
|
||||
### Scenario ###
|
||||
|
||||
The services for a client is running on eth0 for over a year. Because of hardware failure, the client has been migrated to eth1 interface of another server. We want to graph the bandwidth of the new interface, while retaining the historic data for over a year. The client would see only one graph.
|
||||
|
||||
### Identifying the RRD for the Graph ###
|
||||
|
||||
The first step during graph merging is to identify the RRD file associated with a graph. We can check the file by opening the graph in debug mode. To do this, go to Cacti's menu: Console > Graph Management > Select Graph > Turn On Graph Debug Mode.
|
||||
|
||||
#### Old graph: ####
|
||||
|
||||
![](https://farm4.staticflickr.com/3853/18795518096_f50a78d082_c.jpg)
|
||||
|
||||
#### New graph: ####
|
||||
|
||||
![](https://farm4.staticflickr.com/3674/18634036918_5c4118c4b9_c.jpg)
|
||||
|
||||
From the example output (which is based on a Debian system), we can identify the RRD files for two graphs:
|
||||
|
||||
- **Old graph**: /var/lib/cacti/rra/old_graph_traffic_in_8.rrd
|
||||
- **New graph**: /var/lib/cacti/rra/new_graph_traffic_in_10.rrd
|
||||
|
||||
### Preparing a Script ###
|
||||
|
||||
We will merge two RRD files using a [RRD splice script][2]. Download this PHP script, and install it as /var/lib/cacti/rra/rrdsplice.php (for Debian/Ubuntu) or /var/www/cacti/rra/rrdsplice.php (for CentOS/RHEL).
|
||||
|
||||
Next, make sure that the file is owned by Apache user.
|
||||
|
||||
On Debian or Ubuntu, run the following command:
|
||||
|
||||
# chown www-data:www-data rrdsplice.php
|
||||
|
||||
and update rrdsplice.php accordingly. Look for the following line:
|
||||
|
||||
chown($finrrd, "apache");
|
||||
|
||||
and replace it with:
|
||||
|
||||
chown($finrrd, "www-data");
|
||||
|
||||
On CentOS or RHEL, run the following command:
|
||||
|
||||
# chown apache:apache rrdsplice.php
|
||||
|
||||
### Merging Two Graphs ###
|
||||
|
||||
The syntax usage of the script can easily be found by running it without any parameters.
|
||||
|
||||
# cd /path/to/rrdsplice.php
|
||||
# php rrdsplice.php
|
||||
|
||||
----------
|
||||
|
||||
USAGE: rrdsplice.php --oldrrd=file --newrrd=file --finrrd=file
|
||||
|
||||
Now we are ready to merge two RRD files. Simply supply the names of an old RRD file and a new RRD file. We will overwrite the merged result back to the new RRD file.
|
||||
|
||||
# php rrdsplice.php --oldrrd=old_graph_traffic_in_8.rrd --newrrd=new_graph_traffic_in_10.rrd --finrrd=new_graph_traffic_in_10.rrd
|
||||
|
||||
Now the data from the old RRD file should be appended to the new RRD. Any new data will continue to be written by Cacti to the new RRD file. If we click on the graph, we should be able to verify that the weekly, monthly and yearly records have also been added from the old graph. The second graph in the following diagram shows weekly records from the old graph.
|
||||
|
||||
![](https://farm6.staticflickr.com/5493/18821787015_6730164068_b.jpg)
|
||||
|
||||
To sum up, this tutorial showed how we can easily merge two Cacti graphs into one. This trick is useful when a service is migrated to another device/interface and we want to deal with only one graph instead of two. The script is very handy as it can join graphs regardless of the source device e.g., Cisco 1800 router and Cisco 2960 switch.
|
||||
|
||||
Hope this helps.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/combine-two-graphs-cacti.html
|
||||
|
||||
作者:[Sarmed Rahman][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/sarmed
|
||||
[1]:http://xmodulo.com/install-configure-cacti-linux.html
|
||||
[2]:http://svn.cacti.net/viewvc/developers/thewitness/rrdsplice/rrdsplice.php
|
@ -0,0 +1,104 @@
|
||||
11个让人惊叹的Linux终端彩蛋
|
||||
================================================================================
|
||||
这里有一些很酷的Linux终端彩蛋,其中的每一个看上去并没有实际用途,但很精彩。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_01-100587352-orig.png)
|
||||
|
||||
### 只工作不玩耍…… ###
|
||||
|
||||
当我们使用命令行工作时,Linux是功能和实用性最好的操作系统之一。想要执行一个特殊任务?可能一个程序或者脚本就可以帮你搞定。但就像一本书中说到的,只工作不玩耍聪明的孩子也会变傻。下边是我最喜欢的可以在终端做的没有实际用途的、傻傻的、恼人的、可笑的事情。
|
||||
|
||||
### 给终端一个态度 ###
|
||||
|
||||
* 第一步)敲入`sudo visudo`
|
||||
* 第二步)在“Defaults”末尾(文件的前半部分)添加一行“Defaults insults”。
|
||||
* 第三步)保存文件。
|
||||
|
||||
“我刚才对电脑做了什么?”你可能这样问自己。一定是美妙的事情吧。现在,在sudo命令提示提示下输出错误的口令,你的电脑就会呼唤你的名字。我最喜欢的一句:“听好了,煎饼一样的脑子,我没有时间听你胡说八道了。”
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_02-100587353-orig.png)
|
||||
|
||||
### apt-get moo ###
|
||||
|
||||
你看过这张截图?那就是运行`apt-get moo`(在基于Debian的系统)的结果。对,就是它了。不要对它抱太多幻想,你会失望的,我不骗你。但是这是Linux世界最被人熟知的彩蛋之一。所以我把它包含进来,并且放在前排,然后我也就不会收到5千封邮件,指责我把它遗漏了。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_03-100587354-orig.png)
|
||||
|
||||
### aptitude moo ###
|
||||
|
||||
更有趣的是将moo应用到aptitude上。敲入`aptitude moo`(在Ubuntu及其衍生版),你对`moo`可以做什么事情的看法会有所变化。你还还会知道更多事情,尝试重新输入这条命令,但这次添加一个`-v`参数。这还没有结束,试着添加更多`v`,一次添加一个,直到aptitude给了你想要的东西。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_04-100587355-orig.png)
|
||||
|
||||
### Arch: 将吃豆人放入pacman ###
|
||||
|
||||
这里有一个只为Arch爱好者准备的彩蛋。Pacman包管理工具已经很棒了,但我们可以让它变得更棒。
|
||||
|
||||
* 第一步)打开“/etc/pacman.conf”文件。
|
||||
* 第二步)在“# Misc options”部分,去掉“Color”前的“#”。
|
||||
* 第三步)添加“ILoveCandy”。
|
||||
|
||||
现在我们使用pacman安装新软件包时,进度条里会出现一个小吃豆人。真应该默认就是这样的。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_05-100587356-orig.png)
|
||||
|
||||
### Cowsay! ###
|
||||
|
||||
`aptitude moo`的输出格式很漂亮,但我想你苦于不能自由自在地使用。输入`cowsay`,它会做到你想做的事情。你可以让牛说任何你喜欢的东西。而且不只可以用牛,还可以用Calvin、Beavis和Ghostbusters的ASCII logo——输入`cowsay -l`可以得到所有可用的logo。它是Linux世界的强大工具。像很多其他命令一样,你可以使用管道把其他程序的输出输送给它,比如`fortune | cowsay`。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_06-100587358-orig.png)
|
||||
|
||||
### 变成3l33t h@x0r ###
|
||||
|
||||
`nmap`并不是我们平时经常使用的基本命令。但如果你想蹂躏`nmap`的话,可能想在它的输出中看到l33t。在任何`nmap`命令(比如`nmap -oS - google.com`)后添加`-oS`。现在你的`nmap`已经处于官方名称是“[Script Kiddie Mode][1]”的模式了。Angelina Jolie和Keanu Reeves会为此骄傲的。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_07-100587359-orig.png)
|
||||
|
||||
### 获得所有的Discordian日期 ###
|
||||
|
||||
如果你们曾经坐在一起思考,“嗨!我想使用无用但异想天开的方式来书写今天的日期……”试试运行`ddate`。结果类似于“Today is Setting Orange, the 72nd day of Discord in the YOLD 3181”,这会让你的服务树日志平添不少香料。
|
||||
|
||||
注意:在技术层面,确实有一个[Discordian Calendar][2],理论上被[Discordianism][3]追随者所使用。这意味着我可能得罪某些人。或者不会,我不确定。不管怎样,`ddate`是一个方便的工具。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_08-100587360-orig.png)
|
||||
|
||||
### 我可以在任何地方看到颜色!###
|
||||
|
||||
厌倦了老旧的文本?想向世界展示出自己的个性?使用`lolcat`。安装它,然后在任何地方使用。它可以接收任何文本,然后将其转换成美轮美奂的彩虹效果。可以使用`fortune | lolcat`体验。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_09-100587361-orig.png)
|
||||
|
||||
### 蒸汽机车 ###
|
||||
|
||||
在你的终端显示蒸汽机车的ASCII图形。如果你需要它,安装并运行`sl`命令。`sl -l`可以看到一个袖珍版本的。或者,如果你真想在上边花费更多时间,运行`sl -h`。这会显示一个完整的或者,还包括乘客车厢。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_10-100587362-orig.png)
|
||||
|
||||
### 将任何文本逆序输出 ###
|
||||
|
||||
将任何文本使用管道输送给`rev`命令,它就会将文本内容逆序输出。`fortune | rev`会给你好运。当然,这不意味着rev会将幸运转换成不幸。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_11-100587364-orig.png)
|
||||
|
||||
### Matrix依然很酷,不是吗? ###
|
||||
|
||||
想让你的终端显示滚动的文字、l33t和Matrix电影中的坠落数码?`cmatrix`是你的朋友。你甚至可以用它输出不同的颜色,非常华丽。使用`man cmatrix`学习使用方法。或者使用更好的方法,“man cmatrix | lolcat”。这确实是你在Linux终端可以做的最没实际用途却又精彩的事情了。
|
||||
|
||||
![](http://images.techhive.com/images/article/2015/05/slide_12-100587366-orig.png)
|
||||
|
||||
以上就是全部内容了。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.networkworld.com/article/2926630/linux/11-pointless-but-awesome-linux-terminal-tricks.html
|
||||
|
||||
作者:[Bryan Lunduke][a]
|
||||
译者:[goreliu](https://github.com/goreliu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.networkworld.com/author/Bryan-Lunduke/
|
||||
[1]:http://nmap.org/book/output-formats-script-kiddie.html
|
||||
[2]:http://en.wikipedia.org/wiki/Discordian_calendar
|
||||
[3]:http://en.wikipedia.org/wiki/Discordianism
|
Loading…
Reference in New Issue
Block a user