diff --git a/published/20170314 One Year Using Go.md b/published/20170314 One Year Using Go.md new file mode 100644 index 0000000000..6ddebb7f76 --- /dev/null +++ b/published/20170314 One Year Using Go.md @@ -0,0 +1,110 @@ +使用 Go 一年的体验 +============================================================ + +![](https://bugfender.com/wp-content/uploads/2017/03/one-year-using-go-social-1.jpg) + +我们公司 [Mobile Jazz][6] 从一个内部试验性项目开始使用 [Go][5]。如公司名暗示的那样,我们是开发移动应用的。 + +在发布一个应用给公众后,我们很快意识到我们缺失一个工具来检查用户实际发生的情况以及他们是如何与应用交互的 - 如果有任何问题或者 bug 的报告,这将会相当方便。 + +现在有几款工具声称能在这个方面帮助开发者,但是没有一个能完全满足要求,因此我们决定自己构建一个。我们开始创建一组基础的脚本,如今它很快进化成了完整的工具,称为 [Bugfender][7]! + +由于这最初是一个实验,我们决定使用一种新的趋势技术。对学习以及持续教育的热爱是 Mobile Jazz 的核心价值的之一,因此我们决定使用 Go 构建。这是一个由 Google 开发的相对较新的编程语言。它是编程世界的的新玩家,已经有许多受尊敬的开发者对它赞不绝口。 + +一年后,这个实验变成了一个初创项目,我们拥有了一个已经帮助了来自全世界的数以千计的开发者的令人难以置信的工具。我们的服务器每天处理来自 700 万台设备的超过 200GB 的数据。 + +在使用 Go 一年之后,我们想要分享我们将一个小小的实验变成处理百万日志的生产服务器的一些想法和经验。 + +### Go 生态系统 + +公司中没有人有使用 Go 的经验。Bugfender 是我们第一次深入这个语言。 + +学习基本上相当直接的。我们之前在 C/C++/Java/Objective-C/PHP 的经验让我们学习 Go 相当快,并且在几天内就开始开发了。当然会有一些新的和不常见的东西需要学习,包括 GOPATH 还有如何处理包,但这在我们的预期之内。 + +几天之内,我们意识到即使是一个以简化为设计目的的语言,Go 也是非常强大的。它能够做任何现代编程语言应该能做的事:能够处理 JSON、服务器之间通讯甚至访问数据库也没问题(并且只需要几行代码)。 + +在构建一个服务器时,你应该首先决定是否使用任何第三方库或者框架。对于 Bugfender,我们决定使用: + +#### Martini + +[Martini][8] 是一个强大的 Go 的 web 框架。我们开始这个实验时,它是一个很棒的解决方案,至今也是,我们还没遇到任何问题。然而如果我们今天再次开始这个实验的话,我们会选择一个不同的框架,因为 Martini 不在维护了。 + +我们还试验了 [Iris][9](我们目前的最爱)还有 [Gin][10]。Gin 是 Martini 继任者,并且迁移到这上能让我们重用已有的代码。 + +在过去的一年中,我们意识到 Go 的标准库是非常强大的,你不必依靠一个臃肿的 web 框架来构建一个服务器。最好在特定任务上使用专门的高性能库。 + +~~Iris 是我们目前最喜欢的,并且将来我们将使用它重写服务来替代 Martini/Gin,但这目前并不是优先的。~~ + +**修改:** 在讨论了 Iris 的各个方面之后,我们意识到 Iris 或许不是最好的选择。如果我们决定重写我们的 web 组件,我们或许会研究其他的选择,我们欢迎你的建议。 + +#### Gorm + +有些人喜欢 ORM,而有些人则不喜欢。我们决定使用 ORM,更确切地说是 [GORM][11]。我们的实现只针对 web 前端,对于日志提取 API 仍然继续使用手工优化的 SQL。在一开始,我们确实很喜欢它,但是随着时间的推移,我们开始发现问题,并且我们很快将它从代码中完全移除,并且使用 [sqlx][12] 这个标准 SQL 库。 + +GORM 的一个主要问题是 Go 的生态系统。作为一个新语言,自我们开始开发产品以来 Go 已经有很多新版本。在这些新版本中的一些改变并不向后兼容,因此要使用最新的库版本,我们要经常重写已有代码并检查我们为解决版本问题所做的 hack。 + +上述这两个库是大多数 web 服务的主要组件,因此做一个好的选择很重要,因为将来更改会很困难,并且会影响你服务器的性能。 + +### 第三方服务 + +在创建一个实际使用的产品的另外一个重要方面是考虑库、第三方服务和工具的可用性。在这方面,Go 还缺乏成熟度,大多数公司还没有提供 Go 库,因此你或许需要依赖其他人写的不能一直保证质量的库。 + +比如,对于使用 [Redis][13] 和 [ElasticSearch][14] 有很好的库,但是对于其他服务比如 Mixpanel 或者 Stripe 还没有好的。 + +我们建议在使用 Go 之前事先检查对于你需要的产品是否有好的库可用。 + +我们在 Go 的包管理系统上也遇到了很多问题。它处理版本的方式远没有达到最好,并且在过去的一年中,我们在不同的团队成员之间使用同一个库的不同版本上遇到了很多问题。然而,最近要归功于 Go 新支持的 vendor 包特性,除了 [gopkg.in][15] 服务外,这个问题基本被解决了。 + +### 开发者工具 + +![](https://bugfender.com/wp-content/uploads/2017/03/go-ide.jpg) + +由于 Go 是一门相对新的语言,你或许发现相比其他成熟的语言像 Java,它可用的开发工具并不很好。当我们开始 Bugfender 时,使用任何 IDE 都很困难,似乎没有 IDE 支持 Go。但是在过去的一年中,随着 [IntelliJ][16] 和 [Visual Studio Code Go][17] 插件的引入,这一切改善了很多。 + +最后看下其他的 Go 工具,调试器并不很好,而分析器甚至更糟,因此有时调试你的代码或者尝试优化它会很困难。 + +### 前往生产 + +这确实是 Go 最好的东西之一,如果你想要部署一些东西到生产环境中,你只需要构建你的二进制并发送到服务器中,没有依赖,不需要安装额外的软件,你只需要能在服务器中运行二进制文件就行。 + +如果你习惯于处理那些需要包管理器或者需要小心你使用的语言解释器的语言,用 Go 工作会感到很高兴。 + +我们对 Go 的稳定性也很满意,因为服务器似乎从没有崩溃过。我们在发送大量数据给 Go Routines 时遇到过一个问题,但是我们几乎没见到任何崩溃。注意:如果你需要发送大量数据给 Go Routine,你需要小心堆溢出。 + +如果你对性能感兴趣,我们没法与其他语言相比较,因为我们从零开始使用 Go,但是对于我们处理的数据量,我们感觉性能是非常好的,我们绝对不能如此轻松地使用 PHP 处理同等数量的请求。 + +### 总结 + +在过去的一年中,我们对 Go 的感觉起起伏伏。最初我们是兴奋的,但是在实验变成真实的产品后我们开始发现问题。我们几次考虑过用 Java 完全重写,但是目前为止,仍旧使用的是 Go,并且过去的一年中, Go 生态已经有了很大的提升,这简化了我们的工作。 + +如果你想要使用 Go 构建你的产品,你可以保证它可以工作,但是你确实需要小心一件事:可以雇佣的开发者。硅谷中只有很少的高级 Go 开发者,并且在其他地方寻找也是一件非常困难的任务。 + +-------------------------------------------------------------------------------- + +via: https://bugfender.com/one-year-using-go + +作者:[ALEIX VENTAYOL][a] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://bugfender.com/author/aleixventayol +[1]:https://bugfender.com/#facebook +[2]:https://bugfender.com/#twitter +[3]:https://bugfender.com/#google_plus +[4]:https://www.addtoany.com/share#url=https%3A%2F%2Fbugfender.com%2Fone-year-using-go&title=One%20Year%20Using%20Go +[5]:https://golang.org/ +[6]:http://mobilejazz.com/ +[7]:https://www.bugfender.com/ +[8]:https://github.com/go-martini/martini +[9]:https://github.com/kataras/iris +[10]:https://github.com/gin-gonic/gin +[11]:https://github.com/jinzhu/gorm +[12]:https://github.com/jmoiron/sqlx +[13]:https://github.com/go-redis/redis +[14]:https://github.com/olivere/elastic +[15]:http://labix.org/gopkg.in +[16]:https://plugins.jetbrains.com/plugin/5047-go +[17]:https://github.com/Microsoft/vscode-go +[18]:https://bugfender.com/one-year-using-go diff --git a/sources/talk/20170622 Linus Torvalds Explains How Linux Still Surprises and Motivates Him.md b/sources/talk/20170622 Linus Torvalds Explains How Linux Still Surprises and Motivates Him.md new file mode 100644 index 0000000000..6d2013d845 --- /dev/null +++ b/sources/talk/20170622 Linus Torvalds Explains How Linux Still Surprises and Motivates Him.md @@ -0,0 +1,58 @@ +Linus Torvalds Explains How Linux Still Surprises and Motivates Him +============================================================ + +![Linus Torvalds](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/linus-torvalds-lc3.jpg?itok=lzZupevU "Linus Torvalds") +Linux Torvalds spoke with Dirk Hohndel in one of their famous “fireside chats” this week at LinuxCon China.[The Linux Foundation][1] + +Linus Torvalds took to the stage in China for the first time Monday at [LinuxCon + ContainerCon + CloudOpen China in Beijing][3]. In front of a crowd of nearly 2,000, Torvalds spoke with VMware Head of Open Source Dirk Hohndel in one of their famous “fireside chats” about what motivates and surprises him and how aspiring open source developers can get started. Here are some highlights of their talk. + +**What’s surprising about Linux development** + +“What I find interesting is code that I thought was stable continually gets improved. There are things we haven’t touched for many years, then someone comes along and improves them or makes bug reports in something I thought no one used. We have new hardware, new features that are developed, but after 25 years, we still have old, very basic things that people care about and still improve.” + +**What motivates him** + +“I really like what I’m doing. I like waking up and having a job that is technically interesting and challenging without being too stressful so I can do it for long stretches; something where I feel I am making a real difference and doing something meaningful not just for me.” + +“I occasionally have taken breaks from my job. The 2-3 weeks I worked on Git to get that started for example. But every time I take a longer break, I get bored. When I go diving for a week, I look forward to getting back. I never had the feeling that I need to take a longer break.” + +**The future of Linux leadership** + +“Our processes have not only worked for 25 years, we still have a very strong maintainer group. We complain that we don’t have enough maintainers – which is true, we only have tens of top maintainers who do the daily work of merging stuff. That’s a strong team for an open source project. And as these maintainers get older and fatter, we have new people coming in. It takes years to go from a new developer to a top maintainer, so I don’t feel that we should necessarily worry about the process and Linux for the next 20 years.” + +**Will Linux be replaced** + +“Maybe some new aggressive project will come along and show they can do what we do better, but I don’t worry about that. There have been lots of very successful forks of Linux. What makes people not think of them as forks is that they are harmonious. If someone says they want to do this and change everything and make the kernel so much better, my feeling is do it, prove yourself. I may think it’s a bad idea, but you can prove me wrong.” + +**Thoughts on Git** + +“I’m very surprised about how widely Git has spread. I’m pleased obviously, and it validates my notion of doing distributed development. At the same time, looking at most source control versions, it tends to be a huge slog and difficult to introduce a new software control version. I expected it to be limited mostly to the kernel -- as it’s tailored to what we do.” + +“For the first 3 to 4 years, the complaint about Git was it was so different and hard to use. About 5 years ago something changed. Enough projects and developers had started using Git that it wasn’t different anymore; it was what people were used to. They started taking advantage of the development model and the feeling of security that using Git meant nothing would be corrupted or lost.” + +“In certain circles, Git is more well known than Linux. Linux is often hidden – on an Android phone you’re running Linux, but you don’t think about it. With Git, you know you are using Git.” + +**Forking Linux** + +“When I sat down and wrote Git, a prime principle was that you should be able to fork and go off on your own and do something on your own. If you have forks that are friendly -- the type that prove me wrong and do something interesting that improves the kernel -- in that situation, someone can come back and say they actually improved the kernel and there are no bad feelings. I’ll take your improved code and merge it back. That’s why you should encourage forks. You also want to make it easy to take back the good ones.” + +**How to get started as an open source developer** + +“For me, I was always self-motivated and knew what I wanted to do. I was never told what I should look at doing. I’m not sure my example is the right thing for people to follow. There are a ton of open source projects and, if you are a beginning programmer, find something you’re interested in that you can follow for more than just a few weeks. Get to know the code so well that you get to the point where you are an expert on a code piece. It doesn’t need to be the whole project. No one is an expert on the whole kernel, but you can know an area well.   + +If you can be part of a community and set up patches, it’s not just about the coding, but about the social aspect of open source. You make connections and improve yourself as a programmer. You are basically showing off – I made these improvements, I’m capable of going far in my community or job. You’ll have to spend a certain amount of time to learn a project, but there’s a huge upside -- not just from a career aspect, but having an amazing project in your life.” + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/event/lc3-china/20176/6/linus-torvalds-explains-how-linux-still-surprises-and-motivates-him + +作者:[ THE LINUX FOUNDATION][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/lfadmin +[1]:https://www.linux.com/licenses/category/linux-foundation +[2]:https://www.linux.com/files/images/linus-torvalds-lc3jpg +[3]:https://www.lfasiallc.com/linuxcon-containercon-cloudopen-china diff --git a/sources/tech/20170529 LFCS sed Command.md b/sources/tech/20170529 LFCS sed Command.md new file mode 100644 index 0000000000..acd63d5b12 --- /dev/null +++ b/sources/tech/20170529 LFCS sed Command.md @@ -0,0 +1,173 @@ +LFCS sed Command +===================== + +Another useful command for the Linux Foundation Certified SysAdmin (LFCS) is the 'sed' Command. The initials stand for 'Streaming EDitor'. + +The 'sed' Command is an editor that edits the file as a stream. To stream a file is to pass it from another command using pipes (> or |) or load it directly into 'sed'. + +The command works like any other editor except that the file is not displayed and allowed to be edited visually. Commands are passed to 'sed' to manipulate the stream. + +With 'sed' there are five basic things which can be done. Of course, with 'sed' being so powerful there are more advanced functions, but you only need to concentrate on the basic five. The five types of functionality are as follows: + +1. Search + +2. Replace + +3. Delete + +4. Adding + +5. Change/Transform + +Before getting into the command parameters we need to look over the basic syntax. + +**Syntax** + +The syntax for the 'sed' command is: + + _sed [options] commands [file-to-edit]_ + +The options will be covered in this article in the appropriate sections. The commands are the search and replacement patterns which can be Regex Expressions. Read on to see how 'sed' works and learn the basic commands. As I mentioned before, 'sed' is a very powerful tool and has more options available than I will cover in the article. + +**Example File** + +If you open a Terminal you can create a file to be used for the 'sed' examples. Perform the following commands: + + _cd ~ +grep --help >grephelp.txt_ + +You should now have a file named 'grephelp.txt' in your HOME folder. The contents of the file are the help instructions for the command 'grep'. + +**Search** + +Searching for specific strings is a common ability of editors and performing searches in 'sed' is no exception. + +Searches can be performed to find a string in a file. Let's look at a basic search. + +If we wanted to search through our example file for the word 'PATTERN' we would use the command and see the results in Figure 1: + + _sed -n 's/PATTERN/PATTERN/p' grephelp.txt_ + +**NOTE:** If you cut and paste the command make sure you replace the single quotes with that of a standard single quote on your keyboard. + +![Figure 01.jpg](https://www.linux.org/attachments/figure-01-jpg.684/) + +**FIGURE 1** + +The parameter '-n' is used to suppress the printing of each line automatically. These lines include lines which do not include the search pattern. By using the '-n' the lines with a matching result will be displayed. Every line which is streamed into 'sed' will be printed to the standard out (stdout). If you run the above command without the '-n' option you will have a line for every line in the original file as well as a duplicate line for each match. + +The file name to search is 'grephelp.txt' which we created in the 'Example File' section. + +The portion left is  _'s/PATTERN/PATTERN/p'_ . There are basically four sections to this section. The first section 's' specifies to perform a substitution, or a search and replace. + +The second and third part of the remaining portion are the patterns. The first is the pattern to search for and the last is the pattern to replace the matching string within the stream. In this case we are finding the string 'PATTERN' and replacing it with 'PATTERN'. By finding and replacing the same string we are not changing the file at all, even on the screen. + +The last command is 'p'. The 'p' command specifies to print the new line after the substitution is made. Of course, there is no change since the substitution is the same string. Since we are suppressing printing lines with ‘-n’ parameter only the changed lines will be printed with the ‘p’ command. + +The whole command allows us to perform a search and see the matching results. + +**Replace** + +When searching for specific strings you may want to replace the matching string with a new one. Replacing strings with another is very common. + +We can perform the same search with the following command and the results are shown in Figure 2: + + _sed -n 's/PATTERN/Pattern/p' grephelp.txt_ + +![Figure 02.jpg](https://www.linux.org/attachments/figure-02-jpg.685/) + +**FIGURE 2** + +In this instance, the string 'PATTERN' is changed to 'Pattern' and displayed. If you view the file with the command 'cat grephelp.txt' you will see that the file has not changed. The change was made only to the output on the screen. You could pipe the output to another file with the command: + + _sed 's/PATTERN/Pattern/' grephelp.txt > grephelp1.txt_ + +A new file called 'grephelp1.txt' would now exist which held the changed file. If the 'p' was left in as the fourth option then the problem is that each line that had a string substituted would exist twice in the file. We also drop the '-n' parameter to allow all the lines to print. + +Another way to replace the string with the same string is to use the ‘&’ symbol to represent the search string. For example, the command ‘s/PATTERN/&/p’ would be the same. We can add to the string, such as adding an ‘S’, with the command ‘s/PATTERN/&S/p’. + +What if we wish to replace only a certain pattern in each line? It is possible to specify the specific occurrence of a match to replace. Of course, the replacement will be a specific numbered occurrence on each line. For example, there are a lot of dashes on the sample file. Some lines have at least two dashes so we can replace the second dash in each line with another character. The command to replace the second dash (-) in each line with an asterisk (*) would be: + +sed 's/-/*/2' grephelp.txt + +Here, we are performing a substitution with the initial ‘s’. The character ‘-’ is replaced with the ‘*’. The ‘2’ shows we are wanting to replace the second instance of the ‘-’ on each line if it exists. A sample result is shown in Figure 3\. If we left out the command ‘2’ then the first occurrence of a dash is replaced. Not every dash of a line is replaced only the first one. + +![Figure 03.jpg](https://www.linux.org/attachments/figure-03-jpg.686/) + +**FIGURE 3** + +If you want to search and replace all dashes on a line with an asterisk, use the ‘g’ command: + + _sed 's/-/*/g' grephelp.txt_ + +Commands can also be combined. Let’s say you want to change all dashes starting at the second occurrence to the end, the command would be: + + _sed 's/-/*/2g' grephelp.txt_ + +Now every dash from the second to the last on every line is replaced with an asterisk. + +**Delete** + +Many times during a search you may want to remove the search string completely. + +For instance, if you wanted to remove all dashes from the file you could use the command: + + _sed ‘s/-//g’ grephelp.txt_ + +The replacement string is left as a blank so the matching string is removed or deleted. + +**Adding** + +When a match is found you can add a line of specific text to make the line stand out for viewing or printing. + +If you want the new line to be inserted after the match use the ‘a’ command followed by the string for the new line. Also include the string to match. For example, we can find a ‘--’ and add a line after the matched line. The string on the added line will be ‘double dash before this line’. + + _sed '/--/ a "double dash before this line"' grephelp.txt_ + +If you want to place the line before the line containing the matched string use the ‘i’ command as follows: + + _sed '/--/ i "double dash after this line"' grephelp.txt_ + +**Change/Transform** + +If a line needs to be changed or transformed you can use the command ‘c’. + +Let’s say we have a document which has some private information and we need to change any line which contains a specific string. The ‘c’ command will change the whole line and not just the search string. + +Let’s say in our example file we want to block out every line which contains the word ‘PATTERN’. The changed line will read ‘This line is Top Secret’. The command is: + + _sed ‘/PATTERN/ c This line is Top Secret’ grephelp.txt_ + +A Transformation can be performed to change case of specific letters. For instance, we can change all lower-case ‘a’ to uppercase ‘A’ with the command ‘y’ as follows: + + _sed ‘y/a/A/’ grephelp.txt_ + +Multiple letters can be specified such as ‘abdg’ as in the following command: + + _sed ‘y/abdg/ABDG/’ grephelp.txt_ + +Make sure the second set of letters are in the same order as the first or they can be replaced and transformed. For example, the string ‘y/a/D/’ would replace all lower-case ‘a’ with an upper-case ‘D’. + +**In-place change** + +If you actually want to make changes to the file you are using, use the ‘-i’ option. + +For example, to change the word ‘PATTERN’ to ‘Pattern’ and have the changes made to the file, the command would be: + +sed -i 's/PATTERN/Pattern/' grephelp.txt + +The file ‘grephelp.txt’ will now be changed. The ‘-i’ option can be used with any of the above commands to change the original file content. + +Practice with these commands and make sure you understand them. The ‘sed’ command is very powerful. + +-------------------------------------------------------------------------------- + +via: https://www.linux.org/threads/lfcs-sed-command.4561/ + +作者:[Jarret B ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.org/threads/lfcs-sed-command.4561/ diff --git a/sources/tech/20170529 NMAP OS Detection.md b/sources/tech/20170529 NMAP OS Detection.md new file mode 100644 index 0000000000..1f0de58514 --- /dev/null +++ b/sources/tech/20170529 NMAP OS Detection.md @@ -0,0 +1,186 @@ +NMAP OS Detection +=================== + +Sometimes on a network it is beneficial to know the Operating System (OS) of a machine. Accessing a system is easier when you know the OS because you can specifically search the Internet for known security holes in the OS. Granted, security holes are usually patched quickly, but you need to know when a security hole exists. + +Scanning your own network to detect the OS types can help you to see what a hacker will be able to see about your network. + +**OS Detection Database** + +NMAP has a database which is installed when you install NMAP. The database is used when doing OS detection, but it is not automatically updated. + +The database is located at ‘/usr/share/nmap/nmap-os-db’. The easiest way to manage an update is first to look at the database version number. Open the file in a text editor and the version number is usually listed on the second line. The second line of my database is ‘# $Id: nmap-os-db 35407 2015-11-10 04:26:26Z dmiller $’. The database version for this file is 35407. + +To look on the Internet for an updated version go to ‘[https://svn.nmap.org/nmap][1]’ as shown in Figure 1. + +![Figure 01.jpg](https://www.linux.org/attachments/figure-01-jpg.699/) + +**FIGURE 1** + +Here you can see that the version number is 36736\. This seems like quite an update compared to what is currently on my system. The database definitely needs to be updated for proper OS Detection of newer systems. + +It may be a good idea to keep the older database version. Since my current version is 35407 I will perform the following command in a Terminal: + + _sudo mv /usr/share/nmap/nmap-os-db /usr/share/nmap/nmap-os-db-35407_ + +The database is ‘moved’ or ‘renamed’ to include the version number. The next step is to download the new version from the website. Perform the following commands in a Terminal: + + _cd /usr/share/nmap +sudo su +wget _ [_https://svn.nmap.org/nmap/nmap-os-db_][2] + +The new database should be downloaded and ready to go, but you should add the version number. As you saw in Figure 1 the version number is 36736\. Use a text editor to open the database and on the second line add the version number. By adding the version number it will be easier to check later if the version number has changed. When the version number has changed you can update the database and add the version number so you are prepared when checking for updates again. + +**OS Detection Process** + +Before we get into the actual command and performing an OS Detection we should cover some details about what is happening during this scan. + +There are five separate probes being performed. Each probe may consist of one or more packets. The response to each packet by the target system helps to determine the OS type. + +The five different probes are: + +1. Sequence Generation + +2. ICMP Echo + +3. TCP Explicit Congestion Notification + +4. TCP + +5. UDP + +Now we can look at these individually to see what they are doing. + +**Sequence Generation** + +The Sequence Generation Probe consists of six packets. The six packets are sent 100 ms apart and are all TCP SYN packets. + +The result of each TCP SYN packet will help NMAP determine the OS type. + +**ICMP Echo** + +Two ICMP Request packets are sent to the target system with varying settings in the packet. + +The resulting responses will help verify the OS type by NMAP. + +**TCP Explicit Congestion Notification** + +When a lot of packets are being generated and passing through a router causing it to be burdened is known as congestion. The result is that systems slow down to reduce congestion so the router is not dropping packets. + +The packet being sent is only to get a response from the target system. Specific values returned are used to determine the specific OS since each OS handles the packets in different ways. + +**TCP** + +Six packets are sent during this probe. + +Some packets are sent to open or closed ports with specific packet settings. Again, the results will vary depending on the target OS. + +The TCP Packets are all sent with varying flags as follows: + +1. no flags + +2. SYN, FIN, URG and PSH + +3. ACK + +4. SYN + +5. ACK + +6. FIN, PSH, and URG + +**UDP** + +This probe consists of a single packet sent to a closed port. + +If the port used on the target system is closed and an ICMP Port Unreachable message is returned then there is no Firewall. + +**NMAP OS Detection Command** + +Now we need to run the actual command to perform an OS Detection. If you have read any of the other of my NMAP articles then it is best not to perform a PING. To skip the PING we use the parameter ‘-Pn’. To see the extra information we may require you should use the ‘-v’ parameter for adding verbosity. Specifically to get the OS Detection the parameter ‘-O’ is needed. + +For the command to complete properly and perform the TCP SYN Scan you need to perform the command as ROOT. In my case, I will perform the scan on one system only and not the whole network so the command would be: + + _sudo nmap -v -Pn -O 192.168.0.63_ + +The results of the scan are shown in Figure 2\. The scan shows that there are seven open ports using a SYN Stealth Scan. + +![Figure 02.jpg](https://www.linux.org/attachments/figure-02-jpg.700/) + +**FIGURE 2** + +The open ports are: + +1. 21/tcp ftp + +2. 22/tcp ssh + +3. 111/tcp rpcbind + +4. 139/tcp netbios-ssn + +5. 445/tcp microsoft-ds + +6. 2049/tcp nfs + +7. 54045/tcp unknown + +The MAC Address of the system is 00:1E:4F:9F +![:D](https://www.linux.org/styles/default/xenforo/clear.png "Big Grin :D") +F:7F. + +The final portion shows the OS type: + + _Device type: general purpose +Running: Linux 3.X|4.X +OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 +OS details: Linux 3.2 - 4.6 +Uptime guess: 0.324 days (since Sun Apr 23 08:43:32 2017)_ + +The system is running Ubuntu Server 16.10 and the Linux Kernel is 4.8\. The uptime is guessed correctly. + +I performed a second test against another system. The results are shown in Figure 3. + +![Figure 03.jpg](https://www.linux.org/attachments/figure-03-jpg.701/) + +**FIGURE 3** + +In this scan different ports are open. The system is guessed to be ‘Microsoft Windows 2000|XP’. It is Windows XP running SP3. + +**Port Sniffer Results.** + +Let’s look at what is going on in the background of the first scan shown in Figure 2. + +Initially NMAP is performing a TCP Stealth Scan. In this instance the OS Detection Probes start at Packet 2032 in Figure 4. + +![Figure 04.jpg](https://www.linux.org/attachments/figure-04-jpg.702/) + +**FIGURE 4** + +The Sequence Generation starts at Packet 2032/2033 and the sixth one is at Packet 2047/2048\. Notice that each one is sent twice and the next packet in the probe is sent 100 ms later. + +The ICMP Packets are sent at 2050-2053\. The two packets are duplicated making a total of four. + +Packets 2056-2057 are the TCP Explicit Congestion Notification packets. + +The six probes for the TCP are on lines 2059, 2060, 2061, 2063, 2065 and 2067. + +The last probe for UDP is line 2073. + +These are the probes that are used to determine the OS of the target system. + +I hope this helps you to understand how to update the NMAP OS Detection Database and perform a scan on systems. Be aware that you can run the scan on systems which are not on your network, so the scan can be performed on systems on the Internet. + +-------------------------------------------------------------------------------- + +via: https://www.linux.org/threads/nmap-os-detection.4564/ + +作者:[Jarret B ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.org/members/jarret-b.29858/ +[1]:https://svn.nmap.org/nmap +[2]:https://svn.nmap.org/nmap/nmap-os-db diff --git a/sources/tech/20170602 Linux Kernel Utilities A Set Of Shell Scripts To Compile, Install Update Latest Kernel In Ubuntu LinuxMint.md b/sources/tech/20170602 Linux Kernel Utilities A Set Of Shell Scripts To Compile, Install Update Latest Kernel In Ubuntu LinuxMint.md new file mode 100644 index 0000000000..58b63eb039 --- /dev/null +++ b/sources/tech/20170602 Linux Kernel Utilities A Set Of Shell Scripts To Compile, Install Update Latest Kernel In Ubuntu LinuxMint.md @@ -0,0 +1,349 @@ +Linux Kernel Utilities (LKU) – A Set Of Shell Scripts To Compile, Install & Update Latest Kernel In Ubuntu/LinuxMint +============================================================ + + +Installing & Upgrading latest Linux kernel in the manual way is not a small task for everyone, including experience guys. It requires depth knowledge on Linux core. We have already covered in the past about UKUU (Ubuntu Kernel Upgrade Utility) which automatically detect the latest mainline kernel from kernel.ubuntu.com and popup the nice GUI for installation. + +[Linux Kernel Utilities][2] (LKU) offers set of shell scripts (Three Shell Scripts) which help users to compile & install latest Linux kernel from kernel.org, also install precompiled latest Ubuntu kernel from kernel.ubuntu.com. Even it has an option to choose required kernel (manual kernel selection) based on our requirement. + +This script will also check the downloaded archive against the PGP signature file and possible to choose generic and lowlatency kernels. + +Suggested Read : [Ukuu – An Easy Way To Install/Upgrade Linux Kernel In Ubuntu based Systems][3] + +It remove/purge all inactive kernels and won’t leave backup kernel for safety purpose. It is highly recommended that a reboot be performed before executing this script. + +* compile_linux_kernel.sh : Users can able to compile & install required or latest kernel from kernel.org + +* update_ubuntu_kernel.sh : Users can able to install & update required or latest precompiled ubuntu kernel from kernel.ubuntu.com + +* remove_old_kernels.sh : This will remove/purge all inactive kernels and will keep only the currently loaded version + +Kernel.org has regular release cycle (every three months once) which comes with new features, Improved Hardware & System Performance. Most of the distributions doesn’t offer/include the latest kernel except rolling release distributions such as Arch Linux, openSUSE Tumbleweed, etc., since it has a standard release cycle. + +#### How to Install Linux Kernel Utilities (LKU) + +As we told in the beginning of the article, its set of shell script so just clone the developer github repository and run the appropriate shell file to perform the activity. + +``` +$ git clone https://github.com/mtompkins/linux-kernel-utilities.git && cd linux-kernel-utilities +``` + +#### Install Specific kernel + +For testing purpose we are going to install `Linux v4.4.10-xenial` kernel. Before proceeding the new kernel installation we need to check current installed kernel version with help of `uanme -a` command so that we can check whether the new kernel get installed or not? + +``` +$ uname -a +Linux magi-VirtualBox 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux +``` + +As per the above output, our system has `4.4.0-21-generic` kernel. + +Just run `update_ubuntu_kernel.sh` shell file. In the very first time script will check whether all dependencies are met or not? and will install missing dependencies automatically. It detect which distribution it is and retrieve Precompiled kernels available from kernel.ubuntu.com. Now, choose your desired kernel from the list and input the value, and hit `Enter` then sit-back because it’s going to download the kernel images (linux-headers-4.4.10, linux-headers-4.4.10-xxx-generic & linux-image-4.4.10-xxx-generic). + +Once the kernel images get downloaded, it will popup the `sudo` password to start the new kernel installation. + +``` +$ ./update_ubuntu_kernel.sh + +[+] Checking Distro + \_ Distro identified as LinuxMint. + +[+] Checking Dependencies + curl Found + dkms Found + git Found + sudo Found + wget Found + whiptail Found + lynx Not Found + +-- Installing Dependencies -- + +[!] The first time this script is run missing dependencies will be installed. + For compiling a kernel this may take a bit of time. Feedback will be provided. + +[+] Dependencies + \_Elevating permissions as necessary . . . +[%] Elevated + +[+] Testing for previous held packages and trying to correct any found. + \_Passed + +[+] Updating package cache . . . + \_Complete + +[+] Installing dependencies . . . + \_Complete + + curl Found + dkms Found + git Found + sudo Found + wget Found + whiptail Found + lynx Found + +[+] Changing to temporary directory to work in . . . + \_ Temporary directory access granted: /tmp/tmp.97eHDsmg2K + +[+] Removing any conflicting remnants . . . + \_ Done + +[+] Retrieving available kernel choices . . . + \_ Precompiled kernels available from kernel.ubuntu.com: + + 1) Linux v4.11 2) Linux v4.11.3 3) Linux v4.11.2 4) Linux v4.11.1 + 5) Linux v4.10 6) Linux v4.10.17 7) Linux v4.10.16 8) Linux v4.10.15 + 9) Linux v4.10.14 10) Linux v4.10.13 11) Linux v4.10.12 12) Linux v4.10.11 + 13) Linux v4.10.10 14) Linux v4.10.9 15) Linux v4.10.8 16) Linux v4.10.7 + 17) Linux v4.10.6 18) Linux v4.10.5 19) Linux v4.10.4 20) Linux v4.10.3 + 21) Linux v4.10.2 22) Linux v4.10.1 23) Linux v4.9 24) Linux v4.9.30 + 25) Linux v4.9.29 26) Linux v4.9.28 27) Linux v4.9.27 28) Linux v4.9.26 + 29) Linux v4.9.25 30) Linux v4.9.24 31) Linux v4.9.23 32) Linux v4.9.22 + 33) Linux v4.9.21 34) Linux v4.9.20 35) Linux v4.9.19 36) Linux v4.9.18 + 37) Linux v4.9.17 38) Linux v4.9.16 39) Linux v4.9.15 40) Linux v4.9.14 + 41) Linux v4.9.13 42) Linux v4.9.12 43) Linux v4.9.11 44) Linux v4.9.10 + 45) Linux v4.9.9 46) Linux v4.9.8 47) Linux v4.9.7 48) Linux v4.9.6 + 49) Linux v4.9.5 50) Linux v4.9.4 51) Linux v4.9.3 52) Linux v4.9.2 + 53) Linux v4.9.1 54) Linux v4.8 55) Linux v4.8.17 56) Linux v4.8.16 + 57) Linux v4.8.15 58) Linux v4.8.14 59) Linux v4.8.13 60) Linux v4.8.12 + 61) Linux v4.8.11 62) Linux v4.8.10 63) Linux v4.8.9 64) Linux v4.8.8 + 65) Linux v4.8.7 66) Linux v4.8.6 67) Linux v4.8.5 68) Linux v4.8.4 + 69) Linux v4.8.3 70) Linux v4.8.2 71) Linux v4.8.1 72) Linux v4.7 + 73) Linux v4.7.10 74) Linux v4.7.9 75) Linux v4.7.8 76) Linux v4.7.7 + 77) Linux v4.7.6 78) Linux v4.7.5 79) Linux v4.7.4 80) Linux v4.7.3 + 81) Linux v4.7.2 82) Linux v4.7.1 83) Linux v4.6.7 84) Linux v4.6.6 + 85) Linux v4.6.5 86) Linux v4.6.4 87) Linux v4.6.3-yakkety 88) Linux v4.6.2-yakkety + 89) Linux v4.6.1-yakkety 90) Linux v4.6-yakkety 91) Linux v4.5.7-yakkety 92) Linux v4.5.6-yakkety + 93) Linux v4.5.5-yakkety 94) Linux v4.5.4-yakkety 95) Linux v4.5.3-wily 96) Linux v4.5.2-wily + 97) Linux v4.5.1-wily 98) Linux v4.5-wily 99) Linux v4.4.70 100) Linux v4.4.69 + 101) Linux v4.4.68 102) Linux v4.4.67 103) Linux v4.4.66 104) Linux v4.4.65 + 105) Linux v4.4.64 106) Linux v4.4.63 107) Linux v4.4.62 108) Linux v4.4.61 + 109) Linux v4.4.60 110) Linux v4.4.59 111) Linux v4.4.58 112) Linux v4.4.57 + 113) Linux v4.4.56 114) Linux v4.4.55 115) Linux v4.4.54 116) Linux v4.4.53 + 117) Linux v4.4.52 118) Linux v4.4.51 119) Linux v4.4.50 120) Linux v4.4.49 + 121) Linux v4.4.48 122) Linux v4.4.47 123) Linux v4.4.46 124) Linux v4.4.45 + 125) Linux v4.4.44 126) Linux v4.4.43 127) Linux v4.4.42 128) Linux v4.4.41 + 129) Linux v4.4.40 130) Linux v4.4.39 131) Linux v4.4.38 132) Linux v4.4.37 + 133) Linux v4.4.36 134) Linux v4.4.35 135) Linux v4.4.34 136) Linux v4.4.33 + 137) Linux v4.4.32 138) Linux v4.4.31 139) Linux v4.4.30 140) Linux v4.4.29 + 141) Linux v4.4.28 142) Linux v4.4.27 143) Linux v4.4.26 144) Linux v4.4.25 + 145) Linux v4.4.24 146) Linux v4.4.23 147) Linux v4.4.22 148) Linux v4.4.21 + 149) Linux v4.4.20 150) Linux v4.4.19 151) Linux v4.4.17 152) Linux v4.4.16 + 153) Linux v4.4.15 154) Linux v4.4.14-xenial 155) Linux v4.4.13-xenial 156) Linux v4.4.12-xenial + 157) Linux v4.4.11-xenial 158) Linux v4.4.10-xenial 159) Linux v4.4.9-xenial 160) Linux v4.4.8-wily + 161) Linux v4.4.7-wily 162) Linux v4.4.6-wily 163) Linux v4.4.5-wily 164) Linux v4.4.4-wily + 165) Linux v4.4.3-wily 166) Linux v4.4.2-wily 167) Linux v4.4.1-wily 168) Linux v4.4-wily + 169) Linux v4.3.6-wily 170) Linux v4.3.5-wily 171) Linux v4.3.4-wily 172) Linux v4.3.3-wily + 173) Linux v4.3.2-wily 174) Linux v4.3.1-wily 175) Linux v4.3-wily 176) Linux v4.3-unstable + 177) Linux v4.2.8-wily 178) Linux v4.2.8-ckt13 179) Linux v4.2.8-ckt12-wily 180) Linux v4.2.8-ckt10-yakkety + 181) Linux v4.2.8-ckt9-wily 182) Linux v4.2.8-ckt8-wily 183) Linux v4.2.8-ckt7-wily 184) Linux v4.2.8-ckt6-wily + 185) Linux v4.2.8-ckt5-wily 186) Linux v4.2.8-ckt4-wily 187) Linux v4.2.8-ckt3-wily 188) Linux v4.2.8-ckt2-wily + 189) Linux v4.2.8-ckt1-wily 190) Linux v4.2.7-wily 191) Linux v4.2.6-wily 192) Linux v4.2.5-wily + 193) Linux v4.2.4-wily 194) Linux v4.2.4-unstable 195) Linux v4.2.3-unstable 196) Linux v4.2.2-unstable + 197) Linux v4.2.1-unstable 198) Linux v4.2-wily 199) Linux v4.2-unstable 200) Linux v4.1.40 + 201) Linux v4.1.39 202) Linux v4.1.38 203) Linux v4.1.37 204) Linux v4.1.36 + 205) Linux v4.1.35 206) Linux v4.1.34 207) Linux v4.1.33 208) Linux v4.1.32 + 209) Linux v4.1.31 210) Linux v4.1.30 211) Linux v4.1.29 212) Linux v4.1.28 + 213) Linux v4.1.27-wily 214) Linux v4.1.26-wily 215) Linux v4.1.25-wily 216) Linux v4.1.24-wily + 217) Linux v4.1.23-wily 218) Linux v4.1.22-wily 219) Linux v4.1.21-wily 220) Linux v4.1.20-wily + 221) Linux v4.1.19-wily 222) Linux v4.1.18-wily 223) Linux v4.1.17-wily 224) Linux v4.1.16-wily + 225) Linux v4.1.15-wily 226) Linux v4.1.14-wily 227) Linux v4.1.13-wily 228) Linux v4.1.12-wily + 229) Linux v4.1.11-wily 230) Linux v4.1.11-unstable 231) Linux v4.1.10-unstable 232) Linux v4.1.9-unstable + 233) Linux v4.1.8-unstable 234) Linux v4.1.7-unstable 235) Linux v4.1.6-unstable 236) Linux v4.1.5-unstable + 237) Linux v4.1.4-unstable 238) Linux v4.1.3-unstable 239) Linux v4.1.2-unstable 240) Linux v4.1.1-unstable + 241) Linux v4.1-wily 242) Linux v4.1-unstable 243) Linux v4.0.9-wily 244) Linux v4.0.8-wily + 245) Linux v4.0.7-wily 246) Linux v4.0.6-wily 247) Linux v4.0.5-wily 248) Linux v4.0.4-wily + 249) Linux v4.0.3-wily 250) Linux v4.0.2-wily 251) Linux v4.0.1-wily 252) Linux v4.0-vivid + +Select your desired kernel: 158 + +Do you want the lowlatency kernel? (y/[n]): + +[+] Processing selection + \_ Determining CPU type: amd64 + \_ Locating source of v4.4.10-xenial generic kernel packages. + \_ Done + +[+] Checking AntiVirus flag and disabling if necessary +[+] Installing kernel . . . +[sudo] password for magi: +Selecting previously unselected package linux-headers-4.4.10-040410. +(Reading database ... 230647 files and directories currently installed.) +Preparing to unpack linux-headers-4.4.10-040410_4.4.10-040410.201605110631_all.deb ... +Unpacking linux-headers-4.4.10-040410 (4.4.10-040410.201605110631) ... +Selecting previously unselected package linux-headers-4.4.10-040410-generic. +Preparing to unpack linux-headers-4.4.10-040410-generic_4.4.10-040410.201605110631_amd64.deb ... +Unpacking linux-headers-4.4.10-040410-generic (4.4.10-040410.201605110631) ... +Selecting previously unselected package linux-image-4.4.10-040410-generic. +Preparing to unpack linux-image-4.4.10-040410-generic_4.4.10-040410.201605110631_amd64.deb ... +Done. +Unpacking linux-image-4.4.10-040410-generic (4.4.10-040410.201605110631) ... +Setting up linux-headers-4.4.10-040410 (4.4.10-040410.201605110631) ... +Setting up linux-headers-4.4.10-040410-generic (4.4.10-040410.201605110631) ... +Examining /etc/kernel/header_postinst.d. +run-parts: executing /etc/kernel/header_postinst.d/dkms 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +Setting up linux-image-4.4.10-040410-generic (4.4.10-040410.201605110631) ... +Running depmod. +update-initramfs: deferring update (hook will be called later) +Examining /etc/kernel/postinst.d. +run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +run-parts: executing /etc/kernel/postinst.d/dkms 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +update-initramfs: Generating /boot/initrd.img-4.4.10-040410-generic +Warning: No support for locale: en_IN +run-parts: executing /etc/kernel/postinst.d/pm-utils 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.10-040410-generic /boot/vmlinuz-4.4.10-040410-generic +Generating grub configuration file ... +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.4.10-040410-generic +Found initrd image: /boot/initrd.img-4.4.10-040410-generic +Found linux image: /boot/vmlinuz-4.4.9-040409-lowlatency +Found initrd image: /boot/initrd.img-4.4.9-040409-lowlatency +Found linux image: /boot/vmlinuz-4.4.0-21-generic +Found initrd image: /boot/initrd.img-4.4.0-21-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done + \_ Done +``` + +Post installation do the reboot to use the newly installed kernel. + +``` +$ sudo reboot now +``` + +yes, we are using newly installed kernel `4.4.10-040410-generic` + +``` +$ uname -a +Linux magi-VirtualBox 4.4.10-040410-generic #201605110631 SMP Wed May 11 10:33:23 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux +``` + +#### Install Latest Kernel + +Its same as above but we don’t want to choose the descried one, its automatically install most recent latest kernel. + +``` +$ ./update_ubuntu_kernel.sh --latest + +[+] Checking Distro + \_ Distro identified as LinuxMint. + +[+] Checking Dependencies + curl Found + dkms Found + git Found + sudo Found + wget Found + whiptail Found + lynx Found + +[+] Changing to temporary directory to work in . . . + \_ Temporary directory access granted: /tmp/tmp.pLPYmCze6S + +[+] Removing any conflicting remnants . . . + \_ Done + +[+] Retrieving available kernel choices . . . + \_ Precompiled kernels available from kernel.ubuntu.com: +. +. +. +. +Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported. +Found linux image: /boot/vmlinuz-4.11.3-041103-generic +Found initrd image: /boot/initrd.img-4.11.3-041103-generic +Found linux image: /boot/vmlinuz-4.4.10-040410-generic +Found initrd image: /boot/initrd.img-4.4.10-040410-generic +Found linux image: /boot/vmlinuz-4.4.9-040409-lowlatency +Found initrd image: /boot/initrd.img-4.4.9-040409-lowlatency +Found linux image: /boot/vmlinuz-4.4.0-21-generic +Found initrd image: /boot/initrd.img-4.4.0-21-generic +Found memtest86+ image: /boot/memtest86+.elf +Found memtest86+ image: /boot/memtest86+.bin +done + \_ Done +``` + +Post installation do the reboot to use the newly installed kernel. + +``` +$ sudo reboot now +``` + +yes, we are using newly installed kernel `4.11.3-041103-generic`. + +``` +$ uname -a +Linux magi-VirtualBox 4.11.3-041103-generic #201705251233 SMP Thu May 25 16:34:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux +``` + +#### Remove/Purge Old Kernel + +Just run `remove_old_kernels.sh` shell file to remove/purge all inactive kernels. + +``` +$ ./remove_old_kernels.sh + + ++++++++++++++++++++++++++++++++ + +++ W A R N I N G +++ + ++++++++++++++++++++++++++++++++ + +A reboot is recommended before running this script to ensure the current kernel tagged +as the boot kernel is indeed registered and old kernels properly marked for removal. +If you have just installed or modified your existing kernel and do not reboot before +running this script it may render you system INOPERABLE and that would indeed suck. + +You have been warned. +~the Mgmt + +[?]Continue to automagically remove ALL old kernels? (y/N)y +\_ Removing ALL old kernels . . . +[sudo] password for magi: +Reading package lists... Done +Building dependency tree +Reading state information... Done +The following packages will be REMOVED: + linux-headers-4.4.0-21* linux-headers-4.4.0-21-generic* linux-headers-4.4.10-040410* + linux-headers-4.4.10-040410-generic* linux-headers-4.4.9-040409* linux-headers-4.4.9-040409-lowlatency* + linux-image-4.4.0-21-generic* linux-image-4.4.10-040410-generic* linux-image-4.4.9-040409-lowlatency* + linux-image-extra-4.4.0-21-generic* linux-kernel-generic* +0 upgraded, 0 newly installed, 11 to remove and 547 not upgraded. +After this operation, 864 MB disk space will be freed. +(Reading database ... 296860 files and directories currently installed.) +Removing linux-kernel-generic (4.4.0-21) ... +Removing linux-headers-4.4.0-21-generic (4.4.0-21.37) ... +Removing linux-headers-4.4.0-21 (4.4.0-21.37) ... +Removing linux-headers-4.4.10-040410-generic (4.4.10-040410.201605110631) ... +Removing linux-headers-4.4.10-040410 (4.4.10-040410.201605110631) ... +Removing linux-headers-4.4.9-040409-lowlatency (4.4.9-040409.201605041832) ... +Removing linux-headers-4.4.9-040409 (4.4.9-040409.201605041832) ... +Removing linux-image-extra-4.4.0-21-generic (4.4.0-21.37) ... +. +. +. +done +Purging configuration files for linux-image-4.4.9-040409-lowlatency (4.4.9-040409.201605041832) ... +Examining /etc/kernel/postrm.d . +run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.9-040409-lowlatency /boot/vmlinuz-4.4.9-040409-lowlatency +run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.9-040409-lowlatency /boot/vmlinuz-4.4.9-040409-lowlatency +``` + +-------------------------------------------------------------------------------- + +via: http://www.2daygeek.com/lku-linux-kernel-utilities-compile-install-update-latest-kernel-in-linux-mint-ubuntu/ + +作者:[ 2DAYGEEK ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.2daygeek.com/author/2daygeek/ +[1]:http://www.2daygeek.com/author/2daygeek/ +[2]:https://github.com/mtompkins/linux-kernel-utilities +[3]:http://www.2daygeek.com/ukuu-install-upgrade-linux-kernel-in-linux-mint-ubuntu-debian-elementary-os/ diff --git a/sources/tech/20170606 ps_mem – A Simple Python Script To Report Core Memory Usage Accurately In Linux.md b/sources/tech/20170606 ps_mem – A Simple Python Script To Report Core Memory Usage Accurately In Linux.md new file mode 100644 index 0000000000..70ac943307 --- /dev/null +++ b/sources/tech/20170606 ps_mem – A Simple Python Script To Report Core Memory Usage Accurately In Linux.md @@ -0,0 +1,256 @@ +ps_mem – A Simple Python Script To Report Core Memory Usage Accurately In Linux +============================================================ + +[ps_mem][2] is a simple python script which help us to get core memory usage accurately for a program in Linux. There are many utilities available in Linux to see memory usage such as free, vmstat, smem & top, etc,. but this utility bit different compare with others since its showing core memory usage accurately. + +It’s calculating the sum of private & sum of shared memory against a program and giving total used RAM in more appropriate way, definitely it will help everyone to understand which program eating more RAM in system. + +You can install the ps_mem utility in many ways, through package manager, pip and directly method (by running the ps_mem.py script). Make a note, it’s requires root privilege. + +Also read the below suggested memory utilities. + +Suggested Read : [free – A Standard Command to Check Memory Usage Statistics (Free & Used) in Linux][3] + +Suggested Read : [smem – Linux Memory Reporting/Statistics Tool][4] + +Suggested Read : [vmstat – A Standard Nifty Tool to Report Virtual Memory Statistics][5] + +#### Install ps_mem Via Package Manager + +RHEL based system has the ps_mem utility in default repository, so we can easily install it through package manager. + +For RHEL/CentOS, use [yum Package Manager][6] to install ps_mem package. + +``` +$ sudo yum install ps_mem +``` + +For Fedora, use [dnf Package Manager][7] to install ps_mem package. + +``` +$ sudo dnf install ps_mem +``` + +For Arch Linux, use [pacman Package Manager][8] to install ps_mem package. + +``` +$ sudo pacman -S ps_mem +``` + +#### Install ps_mem Via Pip + +pip is a recommended tool for installing Python packages in Linux. Use pip command instead of package manager to get latest build. Make sure you should have install pip package on your system in order to use the pip package. If no, use distribution package manager and install `python-pip` package. + +For Debian based systems. + +``` +$ sudo apt-get install python-pip +``` + +For RHEL/CentOS based systems. + +``` +$ sudo yum install python-pip +``` + +For Fedora + +``` +$ sudo dnf install python-pip +``` + +For openSUSE + +``` +$ sudo zypper install python-pip +``` + +For Arch Linux based systems + +``` +$ sudo pacman -S python-pip +``` + +Finally run the pip tool to install ps_mem on Linux. + +``` +$ sudo pip install ps_mem +``` + +#### Run ps_mem.py script directly + +Alternatively we can run the `ps_mem.ph` script directly by downloading the file from developer github page. + +``` +$ git clone https://github.com/pixelb/ps_mem.git && cd ps_mem +$ sudo python ps_mem.py +``` + +#### ps_mem Usage + +Just run the `ps_mem` without any option to get core memory usage accurately for per program. + +``` +$ sudo ps_mem + Private + Shared = RAM used Program + + 1.6 MiB + 438.5 KiB = 2.1 MiB packagekitd + 1.7 MiB + 498.0 KiB = 2.1 MiB indicator-application-service +912.0 KiB + 1.3 MiB = 2.2 MiB window-stack-bridge + 2.0 MiB + 350.5 KiB = 2.3 MiB gnome-keyring-daemon + 1.8 MiB + 575.0 KiB = 2.3 MiB whoopsie + 2.4 MiB + 304.5 KiB = 2.7 MiB systemd-journald + 2.7 MiB + 157.5 KiB = 2.8 MiB ibus-engine-simple + 2.7 MiB + 182.0 KiB = 2.9 MiB ibus-dconf + 2.7 MiB + 332.5 KiB = 3.0 MiB NetworkManager + 3.1 MiB + 169.5 KiB = 3.2 MiB polkitd + 1.9 MiB + 1.7 MiB = 3.6 MiB systemd (2) + 3.4 MiB + 172.5 KiB = 3.6 MiB deja-dup-monitor + 2.9 MiB + 685.0 KiB = 3.6 MiB zeitgeist-datahub + 2.9 MiB + 848.0 KiB = 3.7 MiB python2.7 + 3.5 MiB + 442.0 KiB = 4.0 MiB dbus-daemon (3) + 3.2 MiB + 951.0 KiB = 4.1 MiB evolution-addressbook-factory + 3.9 MiB + 435.0 KiB = 4.3 MiB lightdm (2) + 3.7 MiB + 826.5 KiB = 4.5 MiB polkit-gnome-authentication-agent-1 + 3.7 MiB + 853.0 KiB = 4.6 MiB unity-fallback-mount-helper + 3.7 MiB + 884.0 KiB = 4.6 MiB ibus-x11 + 4.1 MiB + 590.5 KiB = 4.6 MiB indicator-sound-service + 4.5 MiB + 167.0 KiB = 4.7 MiB udisksd + 4.3 MiB + 571.0 KiB = 4.9 MiB gnome-session-binary + 4.5 MiB + 519.0 KiB = 5.0 MiB zeitgeist-fts + 4.2 MiB + 900.5 KiB = 5.1 MiB indicator-printers-service + 4.1 MiB + 1.0 MiB = 5.1 MiB bash (2) + 3.9 MiB + 1.2 MiB = 5.2 MiB update-notifier + 4.8 MiB + 426.0 KiB = 5.2 MiB pulseaudio + 4.5 MiB + 1.5 MiB = 6.0 MiB url-dispatcher + 4.3 MiB + 1.7 MiB = 6.0 MiB python3.5 + 5.2 MiB + 856.5 KiB = 6.1 MiB evolution-addressbook-factory-subprocess + 5.6 MiB + 494.5 KiB = 6.1 MiB colord + 5.0 MiB + 1.2 MiB = 6.2 MiB bamfdaemon + 5.7 MiB + 1.1 MiB = 6.8 MiB evolution-source-registry + 5.6 MiB + 1.3 MiB = 6.9 MiB indicator-keyboard-service + 5.5 MiB + 1.5 MiB = 7.1 MiB ibus-ui-gtk3 + 5.4 MiB + 1.8 MiB = 7.2 MiB notify-osd + 6.3 MiB + 1.1 MiB = 7.4 MiB nm-applet + 6.4 MiB + 1.4 MiB = 7.8 MiB evolution-calendar-factory + 6.3 MiB + 1.5 MiB = 7.8 MiB hud-service + 6.5 MiB + 1.5 MiB = 8.0 MiB unity-panel-service + 8.2 MiB + 1.8 MiB = 10.0 MiB unity-settings-daemon + 11.1 MiB + 126.5 KiB = 11.2 MiB snapd + 8.2 MiB + 3.0 MiB = 11.2 MiB indicator-datetime-service + 10.3 MiB + 1.7 MiB = 12.0 MiB evolution-calendar-factory-subprocess (2) + 12.5 MiB + 2.8 MiB = 15.3 MiB redshift-gtk + 14.5 MiB + 1.8 MiB = 16.3 MiB fluxgui + 13.5 MiB + 2.9 MiB = 16.4 MiB gnome-terminal-server + 12.7 MiB + 7.6 MiB = 20.4 MiB apache2 (6) + 20.8 MiB + 503.0 KiB = 21.3 MiB fwupd + 22.8 MiB + 70.0 KiB = 22.9 MiB collectl + 22.2 MiB + 10.8 MiB = 33.0 MiB nautilus + 70.9 MiB + 1.5 MiB = 72.4 MiB gnome-software + 97.9 MiB + 24.8 MiB = 122.8 MiB Xorg +131.9 MiB + 168.0 KiB = 132.1 MiB mysqld +222.1 MiB + 9.4 MiB = 231.5 MiB compiz +286.2 MiB + 11.8 MiB = 298.0 MiB firefox +--------------------------------- + 1.3 GiB +================================= +``` + +To print an output with full path. + +``` +$ sudo ps_mem -s + Private + Shared = RAM used Program + + 3.2 MiB + 951.0 KiB = 4.1 MiB /usr/lib/evolution/evolution-addressbook-factory + 3.7 MiB + 826.5 KiB = 4.5 MiB /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 + 3.7 MiB + 853.0 KiB = 4.6 MiB /usr/lib/unity-settings-daemon/unity-fallback-mount-helper + 3.7 MiB + 884.0 KiB = 4.6 MiB /usr/lib/ibus/ibus-x11 --kill-daemon + 4.1 MiB + 590.5 KiB = 4.6 MiB /usr/lib/x86_64-linux-gnu/indicator-sound/indicator-sound-service + 4.5 MiB + 167.0 KiB = 4.7 MiB /usr/lib/udisks2/udisksd --no-debug + 4.3 MiB + 571.0 KiB = 4.9 MiB /usr/lib/gnome-session/gnome-session-binary --session=ubuntu + 4.5 MiB + 519.0 KiB = 5.0 MiB /usr/lib/x86_64-linux-gnu/zeitgeist-fts + 4.2 MiB + 900.5 KiB = 5.1 MiB /usr/lib/x86_64-linux-gnu/indicator-printers/indicator-printers-service + 4.1 MiB + 1.0 MiB = 5.1 MiB bash (2) + 3.9 MiB + 1.2 MiB = 5.2 MiB update-notifier + 4.8 MiB + 426.0 KiB = 5.2 MiB /usr/bin/pulseaudio --start --log-target=syslog + 5.0 MiB + 863.0 KiB = 5.9 MiB /usr/lib/evolution/evolution-calendar-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx2573x3 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/2573/3 + 4.5 MiB + 1.5 MiB = 6.0 MiB /usr/lib/x86_64-linux-gnu/url-dispatcher/url-dispatcher + 4.3 MiB + 1.7 MiB = 6.0 MiB python3 -v + 5.2 MiB + 856.5 KiB = 6.1 MiB /usr/lib/evolution/evolution-addressbook-factory-subprocess --factory local --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.AddressBookx2637x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/AddressBook/2637/2 + 5.6 MiB + 494.5 KiB = 6.1 MiB /usr/lib/colord/colord + 5.2 MiB + 913.0 KiB = 6.1 MiB /usr/lib/evolution/evolution-calendar-factory-subprocess --factory contacts --bus-name org.gnome.evolution.dataserver.Subprocess.Backend.Calendarx2573x2 --own-path /org/gnome/evolution/dataserver/Subprocess/Backend/Calendar/2573/2 + 5.0 MiB + 1.2 MiB = 6.2 MiB /usr/lib/x86_64-linux-gnu/bamf/bamfdaemon + 5.7 MiB + 1.1 MiB = 6.8 MiB /usr/lib/evolution/evolution-source-registry + 5.6 MiB + 1.3 MiB = 6.9 MiB /usr/lib/x86_64-linux-gnu/indicator-keyboard/indicator-keyboard-service --use-gtk + 5.5 MiB + 1.5 MiB = 7.1 MiB /usr/lib/ibus/ibus-ui-gtk3 + 5.4 MiB + 1.8 MiB = 7.2 MiB /usr/lib/x86_64-linux-gnu/notify-osd + 6.3 MiB + 1.1 MiB = 7.4 MiB nm-applet + 6.4 MiB + 1.4 MiB = 7.8 MiB /usr/lib/evolution/evolution-calendar-factory + 6.3 MiB + 1.5 MiB = 7.8 MiB /usr/lib/x86_64-linux-gnu/hud/hud-service + 6.5 MiB + 1.5 MiB = 8.0 MiB /usr/lib/x86_64-linux-gnu/unity/unity-panel-service + 8.2 MiB + 1.8 MiB = 10.0 MiB /usr/lib/unity-settings-daemon/unity-settings-daemon + 11.1 MiB + 126.5 KiB = 11.2 MiB /usr/lib/snapd/snapd + 8.2 MiB + 3.0 MiB = 11.2 MiB /usr/lib/x86_64-linux-gnu/indicator-datetime/indicator-datetime-service + 12.5 MiB + 2.8 MiB = 15.3 MiB /usr/bin/python3 /usr/bin/redshift-gtk + 14.5 MiB + 1.8 MiB = 16.3 MiB /usr/bin/python /usr/bin/fluxgui + 13.6 MiB + 2.9 MiB = 16.4 MiB /usr/lib/gnome-terminal/gnome-terminal-server + 12.7 MiB + 7.6 MiB = 20.4 MiB /usr/sbin/apache2 -k start (6) + 20.8 MiB + 503.0 KiB = 21.3 MiB /usr/lib/x86_64-linux-gnu/fwupd/fwupd + 22.8 MiB + 70.0 KiB = 22.9 MiB /usr/bin/perl -w /usr/bin/collectl -D + 22.2 MiB + 10.8 MiB = 33.0 MiB nautilus -n + 70.9 MiB + 1.5 MiB = 72.4 MiB /usr/bin/gnome-software --gapplication-service + 97.9 MiB + 24.8 MiB = 122.8 MiB /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch +131.9 MiB + 168.0 KiB = 132.1 MiB /usr/sbin/mysqld +222.1 MiB + 9.4 MiB = 231.5 MiB /usr/bin/compiz +286.2 MiB + 11.8 MiB = 298.1 MiB /usr/lib/firefox/firefox +--------------------------------- + 1.3 GiB +================================= +``` + +Only show memory usage PIDs in the specified list + +``` +$ sudo ps_mem -p 2886,4386 + Private + Shared = RAM used Program + + 13.5 MiB + 2.9 MiB = 16.4 MiB gnome-terminal-server +286.2 MiB + 11.8 MiB = 298.0 MiB firefox +--------------------------------- + 314.4 MiB +================================= +``` + +To print process memory in every N seconds. The following command reports memory usage in every 2 seconds. + +``` +$ sudo ps_mem w 2 +``` + +To show only total memory. + +``` +$ sudo ps_mem -t +1329884160 +``` + +-------------------------------------------------------------------------------- + +via: http://www.2daygeek.com/ps_mem-report-core-memory-usage-accurately-in-linux/ + +作者:[ 2DAYGEEK ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.2daygeek.com/author/2daygeek/ +[1]:http://www.2daygeek.com/author/2daygeek/ +[2]:https://github.com/pixelb/ps_mem +[3]:http://www.2daygeek.com/free-command-to-check-memory-usage-statistics-in-linux/ +[4]:http://www.2daygeek.com/smem-linux-memory-usage-statistics-reporting-tool/ +[5]:http://www.2daygeek.com/linux-vmstat-command-examples-tool-report-virtual-memory-statistics/ +[6]:http://www.2daygeek.com/yum-command-examples/ +[7]:http://www.2daygeek.com/dnf-command-examples/ +[8]:http://www.2daygeek.com/pacman-command-examples/ diff --git a/sources/tech/20170607 uCareSystem - All-In-One System Update And Maintenance Tool For UbuntuLinuxMint.md b/sources/tech/20170607 uCareSystem - All-In-One System Update And Maintenance Tool For UbuntuLinuxMint.md new file mode 100644 index 0000000000..5d471080d5 --- /dev/null +++ b/sources/tech/20170607 uCareSystem - All-In-One System Update And Maintenance Tool For UbuntuLinuxMint.md @@ -0,0 +1,147 @@ +uCareSystem – All-In-One System Update And Maintenance Tool For Ubuntu/LinuxMint +============================================================ + + +[uCareSystem Core][2] is a thin utility that automates the basic system maintenance activity, in other hand it will reduce system administrator task in many ways and save some good amount of time. It doesn’t have any GUI and offers purely command line interface to perform the activity. + +There are several utilities available in Ubuntu to perform system maintenance activity. Each tool has their own unique features and designed accordingly. You can automate this task by adding a cron-job. + +uCareSystem Core will automatically refresh distribution repository, Updates the list of available packages, uninstall packages (obsolete, orphaned & old Linux Kernels) & Clears the retrieved packages to save some disk space on system. + +Suggested Read : [Stacer – Linux System Optimizer and Monitoring Tool][3] + +Suggested Read : [BleachBit – A Quick And Best Way to Clean Up Your System In Linux][4] + +Suggested Read : [Free Up Some Space in Ubuntu/LinuxMint With Ubuntu Cleaner (Fork of Janitor Module)][5] + +#### uCareSystem Core Features + +* Update package lists (It will refresh package index) + +* Downloads and install updates + +* Update packages and system libraries to latest available version + +* Remove unneeded, obsolete & orphaned packages + +* Remove old kernels (It keeps the current and previous one for safety purpose) + +* Remove unused config files + +* Clean downloaded temporary packages + +#### Install uCareSystem Core In Ubuntu/LinuxMint + +We can easily install uCareSystem Core in Ubuntu/LinuxMint through PPA since developer offering the own PPA. + +``` +$ sudo add-apt-repository ppa:utappia/stable +$ sudo apt update +$ sudo apt install ucaresystem-core +``` + +We have successfully installed `uCareSystem Core` package and going to check current disk space utilization with help of `df -h`command before executing uCareSystem Core command to know whether it will save some disk space or not? + +``` +$ df -h +Filesystem Size Used Avail Use% Mounted on +udev 979M 0 979M 0% /dev +tmpfs 200M 6.4M 194M 4% /run +/dev/sda1 38G 19G 17G 54% / +tmpfs 999M 216K 999M 1% /dev/shm +tmpfs 5.0M 4.0K 5.0M 1% /run/lock +tmpfs 999M 0 999M 0% /sys/fs/cgroup +tmpfs 200M 112K 200M 1% /run/user/1000 +``` + +Just run an `ucaresystem-core` command in terminal and sitback reset it will take care automatically and no human interaction requires till the end. + +``` +$ sudo ucaresystem-core + +_______________________________________________________ + + uCareSystem Core v3.0 + ~ '' ~ + + Welcome to all-in-one System Update and maintenance + assistant app. + + This simple script will automatically + refresh your packagelist, download and + install updates (if there are any), remove any old + kernels, obsolete packages and configuration files + to free up disk space, without any need of user + interference. +_______________________________________________________ + + uCareSystem Core will start in 5 seconds... +######################### + Started +######################### + +Ign:1 https://wire-app.wire.com/linux/debian stable InRelease +Hit:2 https://wire-app.wire.com/linux/debian stable Release +Hit:4 https://deb.nodesource.com/node_6.x yakkety InRelease +Hit:5 https://repo.skype.com/deb stable InRelease +Hit:6 http://in.archive.ubuntu.com/ubuntu yakkety InRelease +Hit:7 http://archive.canonical.com/ubuntu yakkety InRelease +. +. +. +Removing linux-image-extra-4.8.0-34-generic (4.8.0-34.36) ... +Purging configuration files for linux-image-extra-4.8.0-34-generic (4.8.0-34.36) ... +Removing linux-image-extra-4.8.0-32-generic (4.8.0-32.34) ... +Purging configuration files for linux-image-extra-4.8.0-32-generic (4.8.0-32.34) ... + +##################################### +Finished removing unused config files +##################################### + +Reading package lists... Done +Building dependency tree +Reading state information... Done +Del tilix 1.5.6-1~webupd8~yakkety1 [449 kB] +Del tilix-common 1.5.6-1~webupd8~yakkety1 [174 kB] +Del libfreetype6 2.6.3-3ubuntu1.2 [336 kB] +Del terminix 1.5.6-1~webupd8~yakkety1 [13.7 kB] + +###################################### + Cleaned downloaded temporary packages +###################################### + +######################### + Done +######################### +``` + +I could see that, it does the job as expected. Also found it saved almost `2GB` in `/ partition`. + +``` +$ df -h +Filesystem Size Used Avail Use% Mounted on +udev 979M 0 979M 0% /dev +tmpfs 200M 6.4M 194M 4% /run +/dev/sda1 38G 18G 19G 49% / +tmpfs 999M 216K 999M 1% /dev/shm +tmpfs 5.0M 4.0K 5.0M 1% /run/lock +tmpfs 999M 0 999M 0% /sys/fs/cgroup +tmpfs 200M 112K 200M 1% /run/user/1000 +``` + +-------------------------------------------------------------------------------- + +via: http://www.2daygeek.com/ucaresystem-system-update-and-maintenance-tool-for-ubuntu-linuxmint/ + +作者:[2DAYGEEK ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.2daygeek.com/author/2daygeek/ +[1]:http://www.2daygeek.com/author/2daygeek/ +[2]:https://github.com/cerebrux/uCareSystem +[3]:http://www.2daygeek.com/stacer-linux-system-optimizer-and-monitoring-tool/ +[4]:http://www.2daygeek.com/bleachbit-system-cleaner-on-ubuntu-debian-fedora-opensuse-arch-linux-mint/ +[5]:http://www.2daygeek.com/ubuntu-cleaner-system-cleaner-ubuntu-tweak-alternative-janitor/ diff --git a/sources/tech/20170609 Powerline – A Powerful Statusline Plugin For Vim Bash Terminal.md b/sources/tech/20170609 Powerline – A Powerful Statusline Plugin For Vim Bash Terminal.md new file mode 100644 index 0000000000..2eaa1be131 --- /dev/null +++ b/sources/tech/20170609 Powerline – A Powerful Statusline Plugin For Vim Bash Terminal.md @@ -0,0 +1,145 @@ +Powerline – A Powerful Statusline Plugin For Vim & Bash Terminal +============================================================ + + +[Powerline][2] is a statusline plugin for vim, zsh, bash, tmux, IPython, Awesome, bar, fish, lemonbar, pdb, rc, shell, tcsh, wm, i3 and Qtil. It provides statuslines to applications and make all applications more beautiful. It’s written in Python. + +It’s Extensible and feature rich, written in Python which is very thin and doesn’t required any third-party dependencies other than a Python interpreter. + +Stable and testable code base which is throughly tested and works fine with Python 2.6+ and Python 3. + +Statuslines Originally created exclusively for vim, later the project has evolved to provide statuslines in many Linux applications such as zsh, bash, tmux, IPython, Awesome, i3 and Qtil. + +Configuration and colorschemes written in JSON. It’s a standard and easy file format that allows user to configure supported applications with Powerline’s. + +Fast and lightweight, with daemon support for even better performance. + +#### Install pre requisites + +Make sure your system should have below pre requisite packages. If no, install before proceeding powerline installation. + +For Debian users, use [APT Package Manager][3] or [Apt-Get Package Manager][4] to install Audit package. + +``` +$ sudo apt-get install python-pip git +``` + +For openSUSE users, use [Zypper Package Manager][5] to install Audit package. + +``` +$ sudo zypper install python-pip git +``` + +For Fedora users, use [dnf Package Manager][6] to install Audit package. + +``` +$ sudo dnf install python-pip git +``` + +For Arch Linux users, use [pacman Package Manager][7] to install Audit package. + +``` +$ sudo pacman -S python-pip git +``` + +For CentOS/RHEL user, use [yum Package Manager][8] to install Audit package. + +``` +$ sudo yum install python-pip git +``` + +#### How to install Powerline in Linux + +In this article, we are going to show you how to install Powerline. Also show you how to use with Bash, tumx & Vim in Debian and RHEL based systems. + +``` +$ sudo pip install git+git://github.com/Lokaltog/powerline +``` + +Find the powerline installed location in order to configure with applications. + +``` +$ pip show powerline-status +Name: powerline-status +Version: 2.6.dev9999+git.517f38c566456d65a2170f9bc310e6b4f8112282 +Summary: The ultimate statusline/prompt utility. +Home-page: https://github.com/powerline/powerline +Author: Kim Silkebaekken +Author-email: kim.silkebaekken+vim@gmail.com +License: MIT +Location: /usr/lib/python2.7/site-packages +Requires: +``` + +#### Add/Enable Powerline on Bash Shell + +Add following lines to your `.bashrc` file which will enable powerline to base shell by default. + +``` +if [ -f `which powerline-daemon` ]; then + powerline-daemon -q + POWERLINE_BASH_CONTINUATION=1 + POWERLINE_BASH_SELECT=1 + . /usr/local/lib/python2.7/site-packages/powerline/bindings/bash/powerline.sh +fi +``` + +Reload the `.bashrc` file to take immediate effect to get the powerline in the same window. + +``` +$ source ~/.bashrc +``` + + [![](http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-1.png)][9] + +#### Add/Enable Powerline on tmux + +Tmux is one of the best terminal emulator that offers multiple window and statusline but is not looks good compare with powerline statusline. Add following line to your `.tmux.conf` file which will enable powerline to tmux by default. If you don’t found `.tmux.conf` file then create a new one. + +``` +# vi ~/.tmuc.conf + +source "/usr/local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf" +``` + + [![](http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-2.png)][10] + +#### Add/Enable Powerline on Vim + +Vim is one of the favourite text editor for admins. Enable powerline to add more power to vim by adding below lines into `.vmrc`file. Make a note, in vim 7.x you may not found the .vmrc file in system so don’t worry create a new one and add below lines that’s it. + +``` +# vi ~/.vmrc + +set rtp+=/usr/local/lib/python2.7/site-packages/powerline/bindings/vim/ +set laststatus=2 +set t_Co=256 +``` + + [![](http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-3.png)][11] + + [![](http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-4.png)][12] + +-------------------------------------------------------------------------------- + +via: http://www.2daygeek.com/powerline-adds-powerful-statusline-to-vim-bash-tumx-in-ubuntu-fedora-debian-arch-linux-mint/ + +作者:[ 2DAYGEEK · ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.2daygeek.com/author/2daygeek/ +[1]:http://www.2daygeek.com/author/2daygeek/ +[2]:https://github.com/powerline/powerline +[3]:http://www.2daygeek.com/apt-command-examples/ +[4]:http://www.2daygeek.com/apt-get-apt-cache-command-examples/ +[5]:http://www.2daygeek.com/zypper-command-examples/ +[6]:http://www.2daygeek.com/dnf-command-examples/ +[7]:http://www.2daygeek.com/pacman-command-examples/ +[8]:http://www.2daygeek.com/yum-command-examples/ +[9]:http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-1.png +[10]:http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-2.png +[11]:http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-3.png +[12]:http://www.2daygeek.com/wp-content/uploads/2017/06/install-powerline-in-linux-4.png diff --git a/sources/tech/20170612 3 Easy Ways To Create Or Extend Swap Space In Linux.md b/sources/tech/20170612 3 Easy Ways To Create Or Extend Swap Space In Linux.md new file mode 100644 index 0000000000..02d3f4510d --- /dev/null +++ b/sources/tech/20170612 3 Easy Ways To Create Or Extend Swap Space In Linux.md @@ -0,0 +1,210 @@ +3 Easy Ways To Create Or Extend Swap Space In Linux +============================================================ + +Users can create swap space during installation of any Linux operating system and its necessary too. If you forget to create or later if you want increase, you can at any point of time. + +Sometimes it is necessary to add more swap space when you upgrade the RAM after installation, say for example, if you upgrade the RAM in your system from 1GB to 2GB then you have to upgrade swap too (From 2GB to 4GB) since it’s uses double amount of physical RAM. + +Swap is space on a disk that is reserved to be used as virtual memory when the amount of physical memory (RAM-random access memory) is full. If the system needs more memory resources when the RAM is full, inactive pages in memory are moved to the swap space which can help system to run the applications some more time but it should not be considered a replacement for more RAM. + +It’s recommended to create a dedicated swap partition but if you don’t have a free partition then use a swap file, or a combination of swap partitions and swap files. Swap space is generally recommended for user at least 4 GB, also users can create a swap space depends upon their requirement and environment. + +I have found most of the VM’s and Cloud servers comes without swap partition, so in such cases we can create, extend or increase swap space using below three methods. + +#### How to check current swap size + +Lets first check the size of existing swap space partition using **[free][1]** & `swapon` command. + +``` +$ free -h + total used free shared buff/cache available +Mem: 2.0G 1.3G 139M 45M 483M 426M +Swap: 2.0G 655M 1.4G + +$ swapon --show +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 655.2M -1 +``` + +The above output clearly shows `2GB` is current swap space. + +#### Method-1 : Create the swap file using fallocate + +fallocate program is a best way to create a file of a preallocated size instantly. + +The following command will create 1GB of `/swapfile`. + +``` +$ sudo fallocate -l 1G /swapfile +``` + +Check whether its created correct size of file or not. + +``` +$ ls -lh /swapfile +-rw-r--r-- 1 root root 1.0G Jun 7 09:49 /swapfile +``` + +Change the file permission to `600` to only accessible by root user. + +``` +$ sudo chmod 600 /swapfile +``` + +Convert the file as swap area by running below command. + +``` +$ sudo mkswap /swapfile +Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) +no label, UUID=cda50e0e-41f3-49c7-af61-b8cb4a33a464 +``` + +Enable the swap file by running below command. + +``` +$ sudo swapon /swapfile +``` + +Add newely created swap file into fstab file, so that swap space partition available even after the reboot. + +``` +$ vi /etc/fstab + +/swapfile swap swap defaults 0 0 +``` + +Check newly created swap file. + +``` +$ swapon --show +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 657.8M -1 +/swapfile file 1024M 0B -2 +``` + +Yes i can see the new `1GB swapfile`. Reboot the system to use the new swap file. + +#### Method-2 : Create the swap file using dd command + +dd command is another utility which help us to create a file of a preallocated size instantly. + +The following dd command will create 1GB of `/swapfile1`. + +``` +$ sudo dd if=/dev/zero of=/swapfile1 bs=1G count=1 +1+0 records in +1+0 records out +1073741824 bytes (1.1 GB, 1.0 GiB) copied, 16.6154 s, 64.6 MB/s +``` + +**Details :** + +* **if=/dev/zero** is a input file, /dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it. + +* **of=/swapfile1** is an output file + +* **bs=1G :** Read and write up to 1GB bytes at a time + +* **count=1 :** Copy only 1 BLOCKS input blocks. + +Check whether its created correct size of file or not. + +``` +$ ls -lh /swapfile1 +-rw-r--r-- 1 root root 1.0G Jun 7 09:58 /swapfile1 +``` + +Change the file permission to `600` to only accessible by root user. + +``` +$ sudo chmod 600 /swapfile1 +``` + +Convert the file as a swap file by running below command. + +``` +$ sudo mkswap /swapfile1 +Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) +no label, UUID=96def6d7-b2da-4954-aa72-aa32316ec993 +``` + +Enable the swap file by running below command. + +``` +$ sudo swapon /swapfile1 +``` + +Add newely created swap file into fstab file, so that swap space partition available even after the reboot. + +``` +$ vi /etc/fstab + +/swapfile1 swap swap defaults 0 0 +``` + +Check newly created swap file. + +``` +$ swapon --show +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 1.3G -1 +/swapfile file 1024M 0B -2 +/swapfile1 file 1024M 0B -3 +``` + +Yes i can see the new `1GB swapfile1`. Reboot the system to use the new swap file. + +#### Method-3 : Create the swap file using Hard drive partition + +Hard drive partition is recommended method to create a swap space. + +If you have an additional hard disk create the new partition using fdisk command. Let us assume that we have created the partition called /dev/sda4. + +Use mkswap command to convert the partition as swap area. + +``` +$ sudo mkswap /dev/sda4 +``` + +Enable the swap file by running below command. + +``` +$ sudo swapon /dev/sda4 +``` + +Add newely created swap file into fstab file, so that swap space partition available even after the reboot. + +``` +$ vi /etc/fstab + +/dev/sda4 swap swap defaults 0 0 +``` + +Check newly created swap file. + +``` +$ swapon --show +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 1.3G -1 +/swapfile file 1024M 0B -2 +/swapfile1 file 1024M 0B -3 +/dev/sda4 partition 1G 0B -4 +``` + +Yes i can see the new `1GB /dev/sda4` swap partition. Reboot the system to use the new swap partition. + + + +-------------------------------------------------------------------------------- + +via: http://www.2daygeek.com/add-extend-increase-swap-space-memory-file-partition-linux/ + +作者:[2DAYGEEK ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.2daygeek.com/author/2daygeek/ +[1]:http://www.2daygeek.com/free-command-to-check-memory-usage-statistics-in-linux/ +[2]:http://www.2daygeek.com/author/2daygeek/ diff --git a/sources/tech/20170614 Automatically Create Remove And Mount Swap File In Linux Using Shell Script.md b/sources/tech/20170614 Automatically Create Remove And Mount Swap File In Linux Using Shell Script.md new file mode 100644 index 0000000000..7d8159c1c4 --- /dev/null +++ b/sources/tech/20170614 Automatically Create Remove And Mount Swap File In Linux Using Shell Script.md @@ -0,0 +1,150 @@ +Automatically Create/Remove And Mount Swap File In Linux Using Shell Script +============================================================  + + +Few days ago we have covered an article about swap file creation in Linux using three ways which is the common method but it requires manual human effort. + +Today i have found a small shell script (Two shell script, one for swap file creation and another one for removing swap file) which was written by [Gary Stafford][3] that help us to create/remove & mount swap file automatically in Linux. + +By default the script create and mount `512MB` swapfile. If you want more swap space and different file name you have to modify the script accordingly. It’s not a big deal to modify the script since it’s very handy and small script, even though i have colored the line where you want to modify the script. + +**Suggested Read : **[3 Easy Ways To Create Or Extend Swap Space In Linux][4] + +#### How to check current swap size + +Lets first check the size of existing swap space partition using **[free][1]** & `swapon` command. + +``` +$ free -h + total used free shared buff/cache available +Mem: 2.0G 1.3G 139M 45M 483M 426M +Swap: 2.0G 655M 1.4G + +$ swapon --show +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 655.2M -1 +``` + +The above output clearly shows `2GB` is my current swap space. + +#### Create Swap File + +Create `create_swap.sh` file and add below script to automate the swap space creation and mounting. + +``` +$ nano create_swap.sh +#!/bin/sh + +# size of swapfile in megabytes +swapsize=1024 + +# does the swap file already exist? +grep -q "swapfile" /etc/fstab + +# if not then create it +if [ $? -ne 0 ]; then + echo 'swapfile not found. Adding swapfile.' + fallocate -l ${swapsize}M /swapfile + chmod 600 /swapfile + mkswap /swapfile + swapon /swapfile + echo '/swapfile none swap defaults 0 0' >> /etc/fstab +else + echo 'swapfile found. No changes made.' +fi + +echo '--------------------------------------------' +echo 'Check whether the swap space created or not?' +echo '--------------------------------------------' +swapon --show +``` + +Add execute permission to the file. + +``` +$ sudo +x create_swap.sh +``` + +Run the file to create and mount swap file. + +``` +$ sudo ./create_swap.sh + +swapfile not found. Adding swapfile. +Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) +no label, UUID=d9004261-396a-4321-a45f-9923e3e1328c +-------------------------------------------- +Check whether the swap space created or not? +-------------------------------------------- +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 954.1M -1 +/swapfile file 1024M 0B -2 +``` + +Yes i can see the new `1024M swapfile`. Reboot the system to use the new swap file. + +#### Remove Swap File + +If the swap file is no longer required, then create `remove_swap.sh` file and add below script to remove swap file and its mount point from /etc/fstab. + +``` +$ nano remove_swap.sh +#!/bin/sh + +# does the swap file exist? +grep -q "swapfile" /etc/fstab + +# if it does then remove it +if [ $? -eq 0 ]; then + echo 'swapfile found. Removing swapfile.' + sed -i '/swapfile/d' /etc/fstab + echo "3" > /proc/sys/vm/drop_caches + swapoff -a + rm -f /swapfile +else + echo 'No swapfile found. No changes made.' +fi + +echo '--------------------------------------------' +echo 'Check whether the swap space removed or not?' +echo '--------------------------------------------' +swapon --show +``` + +Add execute permission to the file. + +``` +$ sudo +x remove_swap.sh +``` + +Run the file to remve and unmount swap file. + +``` +$ sudo ./remove_swap.sh + +swapfile found. Removing swapfile. +swapoff: /dev/sda5: swapoff failed: Cannot allocate memory +-------------------------------------------- +Check whether the swap space removed or not? +-------------------------------------------- +NAME TYPE SIZE USED PRIO +/dev/sda5 partition 2G 951.8M -1 +``` + + + +-------------------------------------------------------------------------------- + +via: http://www.2daygeek.com/shell-script-create-add-extend-swap-space-linux/ + +作者:[2DAYGEEK ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.2daygeek.com/author/2daygeek/ +[1]:http://www.2daygeek.com/free-command-to-check-memory-usage-statistics-in-linux/ +[2]:http://www.2daygeek.com/author/2daygeek/ +[3]:https://programmaticponderings.com/2013/12/19/scripting-linux-swap-space/ +[4]:http://www.2daygeek.com/add-extend-increase-swap-space-memory-file-partition-linux/ diff --git a/sources/tech/20170617 Top 8 IDEs for Raspberry Pi.md b/sources/tech/20170617 Top 8 IDEs for Raspberry Pi.md new file mode 100644 index 0000000000..8091a1e04a --- /dev/null +++ b/sources/tech/20170617 Top 8 IDEs for Raspberry Pi.md @@ -0,0 +1,241 @@ +Top 8 IDEs for Raspberry Pi +============================================================ + + + _![](https://i2.wp.com/opensourceforu.com/wp-content/uploads/2017/05/LEGO_brick_robot_05.jpg?resize=700%2C479)_ + + _The Raspberry Pi, a tiny single-board computer, has revolutionised the way in which computer science is being taught in schools. It has also turned out to be a boon for software developers. Currently, it has gained popularity much beyond its target market and is being used in robotics projects._ + +Raspberry Pi, a small development board minicomputer that runs the Linux operating system, was developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools in the UK and in developing countries. Raspberry Pi has USB sockets, which support various peripheral plug-and-play devices like the keyboard, the mouse, the printer, etc. It contains ports like HDMI (High Definition Multimedia Interface) to provide users with video output. Its credit-card-like size makes it extremely portable and affordable. It requires just a 5V micro-USB power supply, similar to the one used to charge a mobile phone. + +Over the years, the Raspberry Pi Foundation has released a few different versions of the Pi board. The first version was Raspberry Pi 1 Model B, which was followed by a simple and cheap Model A. In 2014, the Foundation released a significant and improved version of the board —Raspberry Pi 1 Model B+. In 2015, the Foundation revolutionised the design of the board by releasing a small form factor edition costing US$ 5 (about ` 323) called Raspberry Pi Zero. + +In February 2016, Raspberry Pi 3 Model B was launched, which is currently the main product available. In 2017, the Foundation released the updated model of Raspberry Pi Zero named Raspberry Pi Zero W (W = wireless). + +In the near future, a model that has improved technical specifications will arrive, offering a robust platform for embedded systems enthusiasts, researchers, hobbyists and engineers to use it in multi-functional ways to develop real-time applications. + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-1-8.jpg?resize=350%2C198)][3] + +Figure 1: Raspberry Pi + +**Raspberry Pi as an efficient programming device** + +After getting the Pi powered up and the LXDE WM up and running, the user gets a full-fledged Linux box running a Debian based operating system, i.e., Raspbian. The Raspbian operating system comes with tons of free and open source utilities for users, covering programming, gaming, applications and even education. + +The official programming language of Raspberry Pi is Python, which comes preloaded with the Raspbian operating system. The combination of Raspberry Pi and IDLE3, a Python integrated development environment, enables programmers to develop all sorts of Python based programs. + +In addition to Python, various other languages are supported by Raspberry Pi. A number of IDEs (integrated development environments) that are free and open source are also available. These allow programmers, developers and application engineers to develop programs and applications on Pi. + + [![](https://i2.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-2-6.jpg?resize=350%2C230)][4] + +Figure 2: The BlueJ GUI interface + + [![](https://i2.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-3-3.jpg?resize=350%2C288)][5] + +Figure 3: The Geany IDE GUI interface + +**Best IDEs for Raspberry Pi** + +As a programmer and developer, the first thing you require is an IDE, which is regarded as a comprehensive software suite that integrates the basic tools that developers and programmers require to write, compile and test their software. An IDE contains a code editor, a compiler or interpreter and a debugger, which the developer can access via a graphical user interface (GUI). One of the main aims of an IDE is to reduce the configuration necessary to piece together multiple development utilities, and provide the same set of capabilities as a cohesive unit. + +An IDE’s user interface is similar to that of a word processor, for which tools in the toolbar support colour-coding, formatting of source code, error diagnostics, reporting and intelligent code completion. IDEs are designed to integrate with third-party version control libraries like GitHub or Apache Subversion. Some IDEs are dedicated to a particular programming language, allowing a feature set that matches the programming language, while some support multiple languages. + +Raspberry Pi has a wide range of IDEs that provide programmers with good interfaces to develop source code, applications and system programs. + +Let’s explore the top IDEs for Raspberry Pi. + + [![](https://i2.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-4-3.jpg?resize=350%2C216)][6] + +Figure 4: The Adafruit WebIDE GUI interface + +**BlueJ** + +BlueJ is an IDE that is dedicated to the Java Programming Language and was mainly developed for educational purposes. It also supports short software development projects. Michael Kolling and John Rosenburg at Monash University, Australia, started BlueJ development in 2000 as a powerful successor to the Blue system, and BlueJ became free and open source in March 2009. + +BlueJ provides an efficient way for learning object-oriented programming concepts and the GUI provides a class structure for applications like UML diagram. Every OOPS based concept, like class, objects and function calling, can be represented via interaction based design. + + _**Features**_ + +* _Simple and interactive interface:_  The user interface is simple and easy to learn as compared to other professional interfaces like NetBeans or Eclipse. Developers can focus mainly on programming rather than the environment. + +* _Portable:_  BlueJ supports multiple platforms like Windows, Linux and Mac OS X, and can even run without any installation. + +* _New innovations:_  BlueJ IDE is filled with innovations in terms of the object bench, code pad and scope colouring, which makes development fun even for newbies. + +* _Strong technical support:_  BlueJ has a hard-core functioning team that responds to queries and offers solutions to all sorts of developer problems within 24 hours. + +**Latest version:** 4.0.1 + +**Geany IDE** + +Geany IDE is regarded as a very lightweight GUI based text editor that uses Scintilla and GTK+ with IDE environment support. The unique thing about Geany is that it is designed to be independent of a special desktop environment and requires only a few dependencies on other packages. It only requires GTK2 runtime libraries for execution. Geany IDE supports tons of programming languages like C, C++, C#, Java, HTML, PHP, Python, Perl, Ruby, Erlang and even LaTeX. + + _**Features**_ + +* Auto-completion of code and simple code navigation. + +* Efficient syntax highlighting and code folding. + +* Supports embedded terminal emulator, and is highly extensible and feature-rich since lots of plugins are available for free download. + +* Simple project management and supports multiple file types, which include C, Java, PHP, HTML, Python, Perl, and many more. + +* Highly customised interface for adding or removing options, bars and windows. + +**Latest version:** 1.30.1 + + [![](https://i2.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-5-2.jpg?resize=350%2C252)][7] + +Figure 5: The AlgoIDE GUI interface + + [![](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-6-1.jpg?resize=350%2C378)][8] + +Figure 6: The Ninja IDE GUI interface + +**Adafruit WebIDE** + +Adafruit WebIDE provides a Web based interface for Raspberry Pi users to perform programming functions, and allows developers to compile the source code of various languages like Python, Ruby, JavaScript and many others. + +Adafruit IDE allows developers to put the code in a GIT repository, which can be accessed anywhere via GitHub. + + _**Features**_ + +* Can be accessed via Web browser on ports 8080 or 80. + +* Supports the easy compilation and running of source code. + +* Bundled with a debugger and visualiser for proper tracking, the navigation of code and to test source code. + +**AlgoIDE** + +AlgoIDE is a combination of a scripting language and an IDE environment, designed to function together to take programming to the next paradigm. It incorporates a powerful debugger, real-time scope explorer and executes the code, step by step. It is basically designed for all age groups to design programs and do extensive research on algorithms. +It supports various types of languages like C, C++, Python, Java, Smalltalk, Objective C, ActionScript, and many more. + + _**Features**_ + +* Automatic indentation and completion of source code. + +* Effective syntax highlighting and error management. + +* Contains a debugger, scope explorer and dynamic help system. + +* Supports GUI and traditional Logo programming language Turtle for the development of source code. + +**Latest version:** 2016-12-08 (when it was last updated) + +**Ninja IDE** + +Ninja IDE (Not Just Another IDE), which was designed by Diego Sarmentero, Horacio Duranm Gabriel Acosta, Pedro Mourelle and Jose Rostango, is written purely in Python and supports multiple platforms like Linux, Mac OS X and Windows, for execution. It is regarded as a cross-platform IDE software, especially designed to build Python based applications. + +Ninja IDE is very lightweight and performs various functions like file handling, code locating, going to lines, tabs, automatic indentation of code and editor zoom. Apart from Python, several other languages are supported by this IDE. + + _**Features**_ + +* _An efficient code editor:_  Ninja-IDE is regarded as the most efficient code editor as it performs various functions like code completion and code indentation, and functions as an assistant. + +* _Errors and PEP8 finder:_  It highlights static and PEP8 errors in the file. + +* _Code locator:_  With this feature, quick and direct access to a file can be made. The user can just make use of the ‘CTRL+K’ shortcut to type anything, and the IDE will locate the specific text. + +* Its unique project management features and tons of plugins make Ninja-IDE highly extensible. + +**Latest version:** 2.3 + + [![](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-7.jpg?resize=350%2C306)][9] + +Figure 7: The Lazarus IDE GUI interface + +**Lazarus IDE** + +Lazarus IDE was developed by Cliff Baeseman, Shane Miller and Michael A. Hess in February 1999\. It is regarded as a cross-platform GUI based IDE for rapid application development, and it uses the Free Pascal Compiler. It inherits three primary features—compilation speed, execution speed and cross-compilation. Applications can be cross-compiled from Windows to other operating systems like Linux, Mac OS X, etc. + +This IDE consists of the Lazarus component library, which provides varied facilities to developers in the form of a single and unified interface with different platform-specific implementations. It supports the principle of ‘Write once and compile anywhere’. + + _**Features**_ + +* Powerful and fast enough to handle any sort of source code, and supports performance testing. + +* Easy to use GUI, which supports drag-and-drop components. Additional components can be added to the IDE through Lazarus package files. + +* Makes use of Free Pascal, which is highly enhanced with new features and is even used in Android app development. + +* Highly extensible, open source and supports various frameworks to compile additional languages. + +**Latest version:** 1.6.4 + +**Codeblock IDE** + +Codeblock IDE was written in C++ using wxWidgets as a GUI toolkit and was released in 2005\. It is a free, open source and cross-platform IDE supporting multiple compilers like GCC, Clang and Visual C++. + +Codeblock IDE is highly intelligent and performs various functions like Syntax highlighting, code folding, code completion and indentation, and has a number of external plugins for varied customisations. It can run on Windows, Mac OS X and Linux operating systems. + + _**Features**_ + +* Supports multiple compilers like GCC, Visual C++, Borland C++, Watcom, Intel C++ and many more. Basically designed for C++, but today supports many languages. + +* Intelligent debugger, which allows users to debug programs via access to the local function symbol and argument display, user defined watches, call stack, custom memory dump, thread switching and GNU debugger interface. + +* Supports varied features for migrating code from Dev-C++, Visual C++ and others. + +* Makes use of custom-built systems and stores information in XML extension files. + +**Latest version:** 16.01 + + [![](https://i2.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-8.jpg?resize=350%2C289)][10] + +Figure 8: Codeblock IDE interface + + [![](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-9.jpg?resize=350%2C236)][11] + +Figure 9: Greenfoot IDE interface + +**Greenfoot IDE** + +Greenfoot IDE was designed by Michael Kolling at the University of Kent. It is a cross-platform Java based IDE basically designed for educational purposes for high schools and undergraduate students. The Greenfoot IDE features project management, automatic code completion and syntax highlighting, and has an easy GUI interface. + +Greenfoot IDE programming consists of sub-classing of two main classes — World and Actor. World represents the class where the main execution occurs. Actors are objects that exist and act in World. + + _**Features**_ + +* Simple and easy-to-use GUI, which is more interactive than BlueJ and other IDEs. + +* Easy to use even for newbies and beginners. + +* Highly powerful in executing Java code. + +* Supports GNOME/KDE/X11 graphical environments. + +* Other features include project management, auto-completion, syntax highlighting and auto-correction of errors. + +**Latest version:** 3.1.0 + +-------------------------------------------------------------------------------- + +作者简介: + +Anand Nayyar + +The author is assistant professor in Department of Computer Applications & IT at KCL Institute of Management and Technology, Jalandhar, Punjab. He loves to work on Open Source technologies, embedded systems, cloud computing, wireless sensor networks and simulators. He can be reached at anand_nayyar@yahoo.co.in. + +-------------------- + +via: http://opensourceforu.com/2017/06/top-ides-raspberry-pi/ + +作者:[Anand Nayyar ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://opensourceforu.com/author/anand-nayyar/ +[1]:http://opensourceforu.com/2017/06/top-ides-raspberry-pi/#disqus_thread +[2]:http://opensourceforu.com/author/anand-nayyar/ +[3]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-1-8.jpg +[4]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-2-6.jpg +[5]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-3-3.jpg +[6]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-4-3.jpg +[7]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-5-2.jpg +[8]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-6-1.jpg +[9]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-7.jpg +[10]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-8.jpg +[11]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-9.jpg diff --git a/sources/tech/20170617 What all you need to know about HTML5.md b/sources/tech/20170617 What all you need to know about HTML5.md new file mode 100644 index 0000000000..b5adee5fb2 --- /dev/null +++ b/sources/tech/20170617 What all you need to know about HTML5.md @@ -0,0 +1,272 @@ +What all you need to know about HTML5 +============================================================ + + + _![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/handwritten-html5-peter-booth-e-plus-getty-images-56a6faec5f9b58b7d0e5d1cf.jpg?resize=700%2C467)_ + + _HTML5, the fifth and current version of the HTML standard, is a markup language used to structure and present content on the World Wide Web. This article will help readers get acquainted with it._ + +HTML5 has evolved through the cooperation between the W3C and the Web Hypertext Application Technology Working Group. It is a higher version of HTML, and its many new elements make your pages more semantic and dynamic. It was developed to provide a greater Web experience for everyone. HTML5 offers great features that make the Web more dynamic and interactive. + +The new features of HTML5 are: + +* New sets of tags such as
and
+ +* element for 2D drawing + +* Local storage + +* New form controls like calendar, date and time + +* New media functionality + +* Geo-location + +HTML5 is not an official standard as yet; hence, not all browsers support it or some of its features. One of the most important reasons behind developing HTML5 was to prevent users from having to download and install multiple plugins like Silverlight and Flash. + +**New tags and elements** + +**Semantic elements:** Figure 1 displays a few useful semantic elements. +**Form elements:** The form elements present in HTML5 are shown in Figure 2. +**Graphic elements:** The graphic elements in HTML5 can be seen in Figure 3. +**Media elements:** The new media elements in HTML5 are listed in Figure 4. + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-1-7.jpg?resize=350%2C277)][3] + +Figure 1: Semantic elements + + [![](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-2-5.jpg?resize=350%2C108)][4] + +Figure 2: Form elements + +**Advanced features of HTML5** + +**Geo-location** + +It is an HTML5 API that is used to get the geographical location of a website’s user, who has to first permit the site to fetch his or her location. This usually happens via a button and/or browser popup. All the latest versions of Chrome, Firefox, IE, Safari and Opera can use the geo-location feature of HTML5. + +Some uses of geo-location are: + +* Public transportation websites + +* Taxi and other transportation websites + +* To calculate shipping costs on an e-commerce site + +* Travel agency websites + +* Real estate websites + +* Movie theatre websites can find movies playing nearby + +* Online gaming + +* For sites to feature local headlines and weather on their front page + +* Job postings can automatically include commute times + +**How it works:** Geo-location works by scanning common sources of location information, which include the following: + +* Global Positioning System (GPS), which is the most accurate + +* Network signals—IP address, RFID, Wi-Fi and Bluetooth MAC addresses + +* GSM/CDMA cell IDs + +* User inputs + +The API offers a very handy function to detect geo-location support in browsers: + +| `if` `(navigator.geolocation) {``//` `do` `stuff``}` | + +The  _getCurrentPosition_  API is the main method for using geo-location. It retrieves the current geographic location of the user’s device. The location is described as a set of geographic coordinates along with the heading and speed. The location information is returned as a position object. + +The syntax is: + +`getCurrentPosition(showLocation, ErrorHandler, options);` + +* _showLocation:_  This defines the callback method that retrieves location information. + +* _ErrorHandler(Optional):_  This defines the callback method that is invoked when an error occurs in processing the asynchronous call. + +* _options (Optional):_  This defines a set of options for retrieving the location information. + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-3-2.jpg?resize=350%2C72)][5] + +Figure 3: Graphic elements + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure-4-2.jpg?resize=350%2C144)][6] + +Figure 4: Media elements + +Figure 5 incorporates the set of properties returned by a position object. + +We can present location information to the user in two ways—geodetic and civil: + +1\. The geodetic way of describing a position refers directly to the latitude and longitude. +2\. The civic representation of location data is readable and easily understood by humans. + +As shown in Table 1, each attribute/parameter has both a geodetic representation and a civic representation. + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/table-1.jpg?resize=350%2C132)][7] + +**Web storage** + +In HTML, to store user data on a local machine, we were using JavaScript cookies. To avoid that, HTML5 has introduced Web storage, with which websites themselves store user data on a local machine. + +The advantages of Web storage, as compared to cookies, are: + +* More secure + +* Faster + +* Stores a larger amount of data + +* The stored data is not sent with every server request. It is only included when asked for. This is a big advantage of HTML5 Web storage over cookies. + +There are two types of Web storage objects: + +1) Local – this stores data with no expiration date. +2) Session – this stores data for one session only. + +**How it works:** The  _localStorage_  and  _sessionStorage_  objects create a  _key = value pair._ + +An example is: _ key=“Name”,_   _value=“Palak”_ + +These are stored as strings but can be converted, if required, by using JavaScript functions like  _parseInt()_  and  _parseFloat()_ . + +Given below is the syntax for using Web storage objects: + + `Storing a Value:``• localStorage.setItem(“key1”, “value1”);``• localStorage[“key1”] = “value1”;``Getting a Value:``• alert(localStorage.getItem(“key1”));``• alert(localStorage[“key1”]);``Remove a Value:``• removeItem(“key1”);``Remove All Values:``• localStorage.``clear``();` + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure5-1.jpg?resize=350%2C202)][8] + +Figure 5: Position object properties + +**Application Cache (AppCache)** + +Using HTML5 Apache, we can make a Web application work offline without an Internet connection. All browsers, besides IE, can use  _AppCache_  (at this point in time). + +The advantages of Application Cache are: + +* Enables browsing Web pages offline + +* Pages load faster + +* Results in less load for servers + +The  _cache manifest_  file is a simple text file that lists the resources the browser should cache for offline access. The  _manifest_  attribute can be included on the document’s HTML tag, as follows: + +```...``<``/html``>` + +It should be on all the pages that you want to cache. + +The application pages that are cached will remain unless: + +1\. The user clears them out. +2\. The manifest has been modified. +3\. The cache is updated. + +**Video** + +Until HTML5 was launched, there was no uniform standard for showing video on Web pages. Most of the videos were shown through different plugins like Flash. But HTML5 specifies a standard way to show the video on a Web page by using a video element. + +Currently, it supports three video formats for the video element, as shown in Table 2. + + [![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/table-2.jpg?resize=350%2C115)][9] +The example given below shows the use of this video element: + ```````