Merge pull request #62 from LCTT/master

update 2017-06-25
This commit is contained in:
cinlen_0x05
2017-06-25 11:24:38 +08:00
committed by GitHub
25 changed files with 4254 additions and 110 deletions

View File

@@ -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

View File

@@ -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.
**Whats surprising about Linux development**
“What I find interesting is code that I thought was stable continually gets improved. There are things we havent 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 Im 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 dont have enough maintainers which is true, we only have tens of top maintainers who do the daily work of merging stuff. Thats 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 dont 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 dont 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 its a bad idea, but you can prove me wrong.”
**Thoughts on Git**
“Im very surprised about how widely Git has spread. Im 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 its 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 wasnt 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 youre running Linux, but you dont 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. Ill take your improved code and merge it back. Thats 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. Im 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 youre 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 doesnt 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, its 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, Im capable of going far in my community or job. Youll have to spend a certain amount of time to learn a project, but theres 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

View File

@@ -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. Lets 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.
Lets 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.
Lets 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/

View File

@@ -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.**
Lets 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

View File

@@ -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 wont 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 doesnt 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 its 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 dont 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/

View File

@@ -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.
Its 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, its 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/

View File

@@ -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 doesnt 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/

View File

@@ -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. Its written in Python.
Its Extensible and feature rich, written in Python which is very thin and doesnt 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. Its a standard and easy file format that allows user to configure supported applications with Powerlines.
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 dont 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 dont worry create a new one and add below lines thats 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

View File

@@ -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 its 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.
Its recommended to create a dedicated swap partition but if you dont 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 VMs 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/

View File

@@ -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. Its not a big deal to modify the script since its 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
```
<nav class="pagination group" style="display: block; margin: 0px 0px 15px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; font-family: inherit; vertical-align: baseline; zoom: 1;"></nav>
--------------------------------------------------------------------------------
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/

View File

@@ -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 IDEs 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.
Lets 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

View File

@@ -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 <header> and <section>
* <canvas> 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 websites 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 users 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 documents HTML tag, as follows:
`<html manifest=”``test``.appcache”>``...``<``/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:
`<! DOCTYPE HTML>``<html>``<body>``<video src=” vdeo.ogg” width=”320” height=”240” controls=”controls”>``This browser does not support the video element.``<``/video``>``<``/body``>``<``/html``>`
This example uses an Ogg file, and will work in Firefox, Opera and Chrome. To make the video work in Safari and future versions of Chrome, we must add an MPEG4 and WebM file.
The video element allows multiple source elements. Source elements can link to different video files. The browser will use the first recognised format, as follows:
`<video width=”320” height=”240” controls=”controls”>``<``source` `src=”vdeo.ogg” ``type``=”video``/ogg``” />``<``source` `src=” vdeo.mp4” ``type``=”video``/mp4``” />``<``source` `src=” vdeo.webm” ``type``=”video``/webm``” />``This browser does not support the video element.``<``/video``>`
[![](https://i0.wp.com/opensourceforu.com/wp-content/uploads/2017/05/Figure6-1.jpg?resize=350%2C253)][10]
Figure 6: Output of Canvas
**Audio**
With audio, the case is similar to video. Until HTML5 was launched, there wasnt any uniform standard for playing audio on Web pages. Most of the audio was also played through different plugins like Flash. But HTML5 specifies a standard way to play audio on a Web page by using an audio element. The audio element is used to play sound files and to stream audio.
Currently, HTML5 supports three audio formats for the audio element, as shown in Table 3.
[![](https://i1.wp.com/opensourceforu.com/wp-content/uploads/2017/05/table-3.jpg?resize=350%2C123)][11]
The use of the audio element is demonstrated below:
`<! DOCTYPE HTML>``<html>``<body>``<audio src=” song.ogg” controls=”controls”>``This browser does not support the audio element.``<``/video``>``<``/body``>``<``/html``>`
This example uses an Ogg file and will work in Firefox, Opera and Chrome. To make the audio work in Safari and future versions of Chrome, we must add an MP3 and Wav file.
The audio element allows multiple source elements, which can link to different audio files. The browser will use the first recognised format, as follows:
`<audio controls=”controls”>``<``source` `src=”song.ogg” ``type``=”audio``/ogg``” />``<``source` `src=”song.mp3” ``type``=”audio``/mpeg``” />``This browser does not support the audio element.``<``/audio``>`
**Canvas**
To create graphics on a Web page, HTML5 uses the Canvas API. We can draw anything with it and it uses JavaScript. This can improve the performance of our website by avoiding the need to download images off the network. With Canvas, we can draw shapes and lines, arcs and text, gradients and patterns. In addition, Canvas gives us the power to manipulate pixels in the images and even in video. You can add the Canvas element to an HTML page as shown below:
`<canvas ``id``=”myCanvas” width=”200” height=”100”><``/canvas``>`
The Canvas element doesnt have capabilities to draw elements. We can achieve this by using JavaScript. All drawings should be inside JavaScript.
`<script ``type``=”text``/javascript``”>``var c=document.getElementById(“myCanvas”);``var cxt=c.getContext(“2d”);``cxt.fillStyle=”blue”;``cxt.storkeStyle = “red”;``cxt.fillRect(10,10,100,100);``cxt.storkeRect(10,10,100,100);``<``/script``>`
The output of the above script is seen in Figure 6.
You can draw many objects like arcs, circles, linear/vertical gradients, etc.
**HTML5 tools**
To operate effectively, all skilled or amateur Web developers/designers should use HTML5 tools, which are a great help when one needs to set up workflows/websites or perform repetitive tasks. They improve the usability of Web designs.
Featured below are some essential tools which help in creating amazing websites.
_**HTML5 Maker:**_  This is used to interact with content in websites with the help of HTML, JavaScript and CSS. It is very easy to use. It also allows us to develop slide shows, sliders, HTML5 animation and more.
_**Liveweave:** _ This is used to test the code. It cuts down on the time spent on saving the code and loading it on screen. Pasting the code in the editor gives instant results. It is very easy to use and also provides the auto-complete feature for some of the code, which makes development and testing faster and easier.
_**Font dragr:**_  This previews the custom Web fonts in a browser. It loads the font instantly, so you get to know whether it looks good or not. It also offers a drag-and-drop interface, allowing you to drop your typefaces, Web open fonts and vector graphics to test all of them immediately.
_**HTML5 Please:**_  This allows us to find anything related to HTML5\. If you want to know how to use any feature, you can search for it on HTML Please. It provides lists of useful resources about supporting browsers and devices, syntax, general recommendations of how to use the element, etc.
_**Modernizr:** _ This is an open source tool which is used to provide the best experience possible, given the visitors browser. With this tool, you can detect whether the visitors browser supports HTML5 features, and load the scripts accordingly.
_**Adobe Edge Animate:**_  This is a useful tool for HTML5 developers who have to deal with interactive HTML animations. It is used in digital publishing, the Web and in the advertising fields. This tool allows users to create flawless animations, which run across multiple devices.
_**Video.js:**_  This is a HTML5 video player based on JavaScript. If you want to add videos to your website, you should use this tool. It makes videos look good and a part of the website.
_**The W3 Validator:**_  The W3 Validator tests the validity of the markup of websites in HTML, XHTML, SMIL, MathML, etc. To test the markup validity of any website, you have to choose the document type as HTML5 and enter your Web pages URL. By doing this, your code will get checked, and all errors and warnings will be mentioned.
_**HTML5 Reset:** _ This tool allows developers to rewrite the code of their old websites in HTML5.
You can use these tools to provide a great Web experience for visitors to your website.
--------------------------------------------------------------------------------
Palak Shah
The author is a senior software engineer. She loves to explore new technologies and learn innovative concepts. She is also fond of philosophy. She can be reached at palak311@gmail.com
--------------------
via: http://opensourceforu.com/2017/06/introduction-to-html5/
作者:[Palak Shah ][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/palak-shah/
[1]:http://opensourceforu.com/2017/06/introduction-to-html5/#disqus_thread
[2]:http://opensourceforu.com/author/palak-shah/
[3]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-1-7.jpg
[4]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-2-5.jpg
[5]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-3-2.jpg
[6]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure-4-2.jpg
[7]:http://opensourceforu.com/wp-content/uploads/2017/05/table-1.jpg
[8]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure5-1.jpg
[9]:http://opensourceforu.com/wp-content/uploads/2017/05/table-2.jpg
[10]:http://opensourceforu.com/wp-content/uploads/2017/05/Figure6-1.jpg
[11]:http://opensourceforu.com/wp-content/uploads/2017/05/table-3.jpg

View File

@@ -0,0 +1,178 @@
A beginner's guide to collecting and mapping Twitter data using R
============================================================
### Learn to use R's twitteR and leaflet packages, which allow you to map the location of tweets on any topic.
![A beginner's guide to collecting and mapping Twitter data using R](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/cloud-globe.png?itok=H4f-RAz_ "A beginner's guide to collecting and mapping Twitter data using R")
Image by : 
[Jason Baker][14]. [CC BY-SA 4.0][15]. Source: [Cloud][16], [Globe][17]. Both [CC0][18].
When I started learning R, I also needed to learn how to collect Twitter data and map it for research purposes. Despite the wealth of information on the internet about this topic, I found it difficult to understand what was involved in collecting and mapping Twitter data. Not only was I was a novice to R, but I was also unfamiliar with the technical terms in the various tutorials. Despite these barriers, I was successful! In this tutorial, I will break down how to collect Twitter data and display it on a map in a way that even novice coders can understand.
Programming and development
* [New Python content][1]
* [Our latest JavaScript articles][2]
* [Recent Perl posts][3]
* [Red Hat Developers Blog][4]
### Create the app
If you don't have a Twitter account, the first thing you need to do is to [create one][19]. After that, go to [apps.twitter.com][20] to create an app that allows you to collect Twitter data. Don't worry, creating the app is extremely easy. The app you create will connect to the Twitter application program interface (API). Think of an API as an electronic personal assistant of sorts. You will be using the API to ask another program to do something for you. In this case, you will be connecting to the Twitter API and asking it to collect data. Just make sure you don't ask too much, because there is a [limit][21] on how many times you can request Twitter data.
There are two APIs that you can use to collect tweets. If you want to do a one-time collection of tweets, then you'll use the **REST API**. If you want to do a continuous collection of tweets for a specific time period, you'll use the **streaming API**. In this tutorial, I'll focus on using the REST API.
After you create your app, go to the **Keys and Access Tokens** tab. You will need the Consumer Key (API key), Consumer Secret (API secret), Access Token, and Access Token Secret to access your app in R.
### Collect the Twitter data
The next step is to open R and get ready to write code. For beginners, I recommend using [RStudio][22], the integrated development environment (IDE) for R. I find using RStudio helpful when I am troubleshooting or testing code. R has a package to access the REST API called **[twitteR][8]**.
Open RStudio and create a new RScript. Once you have done this, you will need to install and load the **twitteR** package:
```
install.packages("twitteR")
#installs TwitteR
library (twitteR)
#loads TwitteR
```
Once you've installed and loaded the **twitteR** package, you will need to enter the your app's API information from the section above:
```
api_key <- ""
#in the quotes, put your API key
api_secret <- ""
#in the quotes, put your API secret token
token <- ""
#in the quotes, put your token
token_secret <- ""
#in the quotes, put your token secret
```
Next, connect to Twitter to access the API:
```
setup_twitter_oauth(api_key, api_secret, token, token_secret)
```
Let's try doing a Twitter search about community gardens and farmers markets:
```
tweets <- searchTwitter("community garden OR #communitygarden OR farmers market OR #farmersmarket", n = 200, lang = "en")
```
This code simply says to search for the first 200 tweets **(n = 200)** in English **(lang = "en")**, which contain the terms **community garden** or **farmers market**or any hashtag mentioning these terms.
After you have done your Twitter search, save your results in a data frame:
```
tweets.df <-twListToDF(tweets)
```
To create a map with your tweets, you will need to export what you collected into a **.csv** file:
```
write.csv(tweets.df, "C:\Users\YourName\Documents\ApptoMap\tweets.csv")
#an example of a file extension of the folder in which you want to save the .csv file.
```
Make sure you save your **R** code before running it and moving on to the next step.
### Create the map
Now that you have data, you can display it in a map. For this tutorial, we will make a basic app using the R package **[Leaflet][9]**, a popular JavaScript library for making interactive maps. Leaflet uses the [**magrittr**][23] pipe operator (**%>%**), which makes it easier to write code because the syntax is more natural. It might seem strange at first, but it does cut down on the amount of work you have to do when writing code.
For the sake of clarity, open a new R script in RStudio and install these packages:
```
install.packages("leaflet")
install.packages("maps")
library(leaflet)
library(maps)
```
Now you need a way for Leaflet to access your data:
```
read.csv("C:\Users\YourName\Documents\ApptoMap\tweets.csv", stringsAsFactors = FALSE)
```
**stringAsFactors = FALSE** means to keep the information as it is and not convert it into factors. (For information about factors, read the article ["stringsAsFactors: An unauthorized biography"][24], by Roger Peng.)
It's time to make your Leaflet map. You are going to use the **OpenStreetMap**base map for your map:
```
m <- leaflet(mymap) %>% addTiles()
```
Let's add circles to the base map. For **lng** and **lat**, enter the name of the columns that contain the latitude and longitude of your tweets followed by **~**. The **~longitude** and **~latitude** refer to the name of the columns in your **.csv** file:
```
m %>% addCircles(lng = ~longitude, lat = ~latitude, popup = mymap$type, weight = 8, radius = 40, color = "#fb3004", stroke = TRUE, fillOpacity = 0.8)
```
Run your code. A web browser should pop up and display your map. Here is a map of the tweets that I collected in the previous section:
### [leafletmap.jpg][6]
![Map of tweets by location](https://opensource.com/sites/default/files/leafletmap.jpg "Map of tweets by location")
Map of tweets by location, Leaflet and OpenStreetMap, [CC-BY-SA][5]
<add here="" leafletmap.jpg=""></add>
Although you might be surprised with the small number of tweets on the map, typically only 1% of tweets are geocoded. I collected a total of 366 tweets, but only 10 (around 3% of total tweets) were geocoded. If you are having trouble getting geocoded tweets, change your search terms to see if you get a better result.
### Wrapping up
For beginners, putting all the pieces together to create a Leaflet map from Twitter data can be overwhelming. This tutorial is based on my experiences doing this task, and I hope it makes the learning process easier for you.
_Dorris Scott will present this topic in a workshop, [From App to Map: Collecting and Mapping Social Media Data using R][10], at the [We Rise][11] Women in Tech Conference ([#WeRiseTech][12]) June 23-24 in Atlanta._
--------------------------------------------------------------------------------
作者简介:
Dorris Scott - Dorris Scott is a PhD student in geography at the University of Georgia. Her research emphases are in Geographic Information Systems (GIS), geographic data science, visualization, and public health. Her dissertation is on combining traditional and non-traditional data about Veterans Affairs hospitals in a GIS interface to help patients make more informed decisions regarding their healthcare.
-----------------
via: https://opensource.com/article/17/6/collecting-and-mapping-twitter-data-using-r
作者:[Dorris Scott ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/dorrisscott
[1]:https://opensource.com/tags/python?src=programming_resource_menu
[2]:https://opensource.com/tags/javascript?src=programming_resource_menu
[3]:https://opensource.com/tags/perl?src=programming_resource_menu
[4]:https://developers.redhat.com/?intcmp=7016000000127cYAAQ&src=programming_resource_menu
[5]:https://creativecommons.org/licenses/by-sa/2.0/
[6]:https://opensource.com/file/356071
[7]:https://opensource.com/article/17/6/collecting-and-mapping-twitter-data-using-r?rate=Rnu6Lf0Eqvepznw75VioNPWIaJQH39pZETBfu2ZI3P0
[8]:https://cran.r-project.org/web/packages/twitteR/twitteR.pdf
[9]:https://rstudio.github.io/leaflet
[10]:https://werise.tech/sessions/2017/4/16/from-app-to-map-collecting-and-mapping-social-media-data-using-r?rq=social%20mapping
[11]:https://werise.tech/
[12]:https://twitter.com/search?q=%23WeRiseTech&src=typd
[13]:https://opensource.com/user/145006/feed
[14]:https://opensource.com/users/jason-baker
[15]:https://creativecommons.org/licenses/by-sa/4.0/
[16]:https://pixabay.com/en/clouds-sky-cloud-dark-clouds-1473311/
[17]:https://pixabay.com/en/globe-planet-earth-world-1015311/
[18]:https://creativecommons.org/publicdomain/zero/1.0/
[19]:https://twitter.com/signup
[20]:https://apps.twitter.com/
[21]:https://dev.twitter.com/rest/public/rate-limiting
[22]:https://www.rstudio.com/
[23]:https://github.com/smbache/magrittr
[24]:http://simplystatistics.org/2015/07/24/stringsasfactors-an-unauthorized-biography/
[25]:https://opensource.com/users/dorrisscott

View File

@@ -0,0 +1,85 @@
# Debian armhf VM on arm64 server
At Collabora one of the many things we do is build [Debian][1] derivatives/overlays for customers on a variety of architectures including 32 bit and 64 bit ARM systems. And just as Debian does, our [OBS][2] system builds on native systems rather than emulators.
Luckily with the advent of ARM server systems some years ago building natively for those systems has been a lot less painful than it used to be. For 32 bit ARM we've been relying on [Calxeda][3] blade servers, however Calxeda unfortunately tanked ages ago and the hardware is starting to show its age (though luckily Debian Stretch does support it properly, so at least the software is still fresh).
On the 64 bit ARM side, we're running on Gigabyte MP30-AR1 based servers which can run 32 bit arm code (As opposed to e.g. ThunderX based servers which can only run 64 bit code). As such running armhf VMs on them to act as build slaves seems a good choice, but setting that up is a bit more involved than it might appear.
The first pitfall is that there is no standard bootloader or boot firmware available in Debian to boot on the "virt" machine emulated by qemu (I didn't want to use an emulation of a real machine). That also means there is nothing to pick the kernel inside the guest at boot nor something which can e.g. have the guest network boot, which means direct kernel booting needs to be used.
The second pitfall was that the current Debian Stretch armhf kernel isn't built with support for the generic PCI host controller which the qemu virtual machine exposes, which means no storage and no network shows up in the guest. Hopefully that will get solved soonish ([Debian bug 864726][4]) and can be in a Stretch update, until then a custom kernel package is required using the patch attach to the bug report is required but I won't go into that any further in this post.
So on the happy assumption that we have a kernel that works, the challenge left is to nicely manage direct kernel loading. Or more specifically, how to ensure the hosts boots the kernel the guest has installed via the standard apt tools without having to copy kernels around between guest/host, which essentially comes down to exposing /boot from the guest to the host. The solution we picked is to use qemu's 9pfs support to share a folder from the host and use that as /boot of the guest. For the 9p folder the "mapped" security mode seems needed as the "none" mode seems to get confused by dpkg ([Debian bug 864718][5]).
As we're using libvirt as our virtual machine manager the remainder of how to glue it all together will be mostly specific to that.
First step is to install the system, mostly as normal. One can directly boot into the vmlinuz and initrd.gz provided by normal Stretch armhf netboot installer (downloaded into e.g /tmp). The setup overall is straight-forward with a few small tweaks:
* /srv/armhf-vm-boot is setup to be the 9p shared folder (this should exist and owned by the libvirt-qemu user) that will be used for sharing /boot later
* the kernel args are setup to setup root= with root partition intended to be used in the VM, adjust for your usage.
* The image file to use the virtio bus, which doesn't seem the default.
Apart from those tweaks the resulting example command is similar to the one that can be found in the virt-install man-page:
```
virt-install --name armhf-vm --arch armv7l --memory 512 \
--disk /srv/armhf-vm.img,bus=virtio
--filesystem /srv/armhf-vm-boot,virtio-boot,mode=mapped \
--boot=kernel=/tmp/vmlinuz,initrd=/tmp/initrd.gz,kernel_args="console=ttyAMA0,root=/dev/vda1"
```
Run through the install as you'd normally would. Towards the end the installer will likely complain it can't figure out how to install a bootloader, which is fine. Just before ending the install/reboot, switch to the shell and copy the /boot/vmlinuz and /boot/initrd.img from the target system to the host in some fashion (e.g. chroot into /target and use scp from the installed system). This is required as the installer doesn't support 9p, but to boot the system an initramfs will be needed with the modules needed to mount the root fs, which is provided by the installed initramfs :). Once that's all moved around, the installer can be finished.
Next, booting the installed system. For that adjust the libvirt config (e.g. using virsh edit and tuning the xml) to use the kernel and initramfs copied from the installer rather then the installer ones. Spool up the VM again and it should happily boot into a freshly installed Debian system.
To finalize on the guest side /boot should be moved onto the shared 9pfs, the fstab entry for the new /boot should look something like:
```
virtio-boot /boot 9p trans=virtio,version=9p2000.L,x-systemd.automount 0 0
```
With that setup, it's just a matter of shuffling the files in /boot around to the new filesystem and the guest is done (make sure vmlinuz/initrd.img stay symlinks). Kernel upgrades will work as normal and visible to the host.
Now on the host side there is one extra hoop to jump through, as the guest uses the 9p mapped security model symlinks in the guest will be normal files on the host containing the symlink target. To resolve that one, we've used libvirt's qemu hook support to setup a proper symlink before the guest is started. Below is the script we ended up using as an example (/etc/libvirt/hooks/qemu):
```
vm=$1
action=$2
bootdir=/srv/${vm}-boot
if [ ${action} != "prepare" ] ; then
exit 0
fi
if [ ! -d ${bootdir} ] ; then
exit 0
fi
ln -sf $(basename $(cat ${bootdir}/vmlinuz)) ${bootdir}/virtio-vmlinuz
ln -sf $(basename $(cat ${bootdir}/initrd.img)) ${bootdir}/virtio-initrd.img
```
With that in place, we can simply point the libvirt definition to use /srv/${vm}-boot/virtio-{vmlinuz,initrd.img} as the kernel/initramfs for the machine and it'll automatically get the latest kernel/initramfs as installed by the guest when the VM is started.
Just one final rough edge remains, when doing reboot from the VM libvirt leaves qemu to handle that rather than restarting qemu. This unfortunately means a reboot won't pick up a new kernel if any, for now we've solved this by configuring libvirt to stop the VM on reboot instead. As we typically only reboot VMs on kernel (security) upgrades, while a bit tedious, this avoid rebooting with an older kernel/initramfs than intended
--------------------------------------------------------------------------------
via: https://www.collabora.com/news-and-blog/blog/2017/06/20/debian-armhf-vm-on-arm64-server/
作者:[ Sjoerd Simons][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.collabora.com/news-and-blog/blog/2017/06/20/debian-armhf-vm-on-arm64-server/
[1]:https://debian.org/
[2]:http://openbuildservice.org/
[3]:https://en.wikipedia.org/wiki/Calxeda
[4]:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864726
[5]:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864718

View File

@@ -0,0 +1,123 @@
How To kill An Inactive OR Idle SSH Sessions
============================================================
BY [MAGESH MARUTHAMUTHU][1] · PUBLISHED : JUNE 21, 2017 || LAST UPDATED: JUNE 21, 2017
Lets imagine that you are working in server through ssh, for some reason your session get disconnected like, internet issue or power failure or your Local PC get rebooted, etc,.
You may or maynt login to the server again to work but you have left the previous ssh session with out closing.
How to Kill an inactive ssh sessions ? Identify the Inactive or Idle ssh sessions with help of `w` command, then get the idle session PID by issuing `pstree` command, finally kill the sessions using `kill` command.
Suggested Read : [SSH Related Articles][2]
Suggested Read : [Mosh (Mobile Shell) Best Alternative for SSH to Connect Remote System][3]
#### How to Identify Inactive or Idle SSH Sessions
Login to the system and check how many users are currently logged in by issuing `w` command. If you identified your own session then note the Inactive or Idle ssh sessions to kill.
In my scenario, I can see two users are currently logged in, one is my new ssh session which am currently running `w` command and another one for my idle session.
```
# w
10:36:39 up 26 days, 20:29, 2 users, load average: 0.00, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 219.91.219.14 10:34 28.00s 0.00s 0.00s -bash
root pts/2 219.91.219.14 10:36 0.00s 0.00s 0.00s w
```
#### How to Get a SSH Session PID
To kill idle ssh session, we need a parent `PID` of the idle session. To get a parent pid, run the `pstree` command to see a tree diagram of all the processes.
You also get the similar kind of output like below. The pstree command output is much bigger so, i removed many things from the file for better understanding.
```
# pstree -p
init(1)-+-abrtd(2131)
|-acpid(1958)
|-httpd(32413)-+-httpd(32442)
|
|-mingetty(2198)
|-mysqld_safe(24298)---mysqld(24376)-+-{mysqld}(24378)
|
|-php(32456)-+-php(32457)
|
|-sshd(2023)-+-sshd(10132)---bash(10136)
| `-sshd(10199)---bash(10208)---pstree(10226)
|-udevd(774)-+-udevd(2191)
`-udevd(27282)
```
From the above output, you can see the tree of sshd processes and branchs. The main sshd process is `sshd(2023)` and two branchs, `sshd(10132)` and `sshd(10199)`.
As i told in the beginning of the article, one is my new session `sshd(10199)` because it shows the `pstree` command which is currently running by me, so the idle session is another one `sshd(10132)`.
Suggested Read : [How to Access Secure Shell (SSH) Servers Through Standard Web Browsers][4]
Suggested Read : [PSSH Execute Commands on Multiple Linux Servers in Parallel][5]
#### How to kill Idle SSH Sessions
We got all the information about idle session. Now, im going to kill the idle session, using the `kill` command. Make sure you have replace your PID instead of us.
```
# kill -9 10132
```
#### Recheck whether the idle session get killed or not
Again use `w` command to recheck whether the idle session get killed or not. Yes, its not there because i can see only one session which is owned by me.
```
# w
10:40:18 up 26 days, 20:33, 1 user, load average: 0.11, 0.04, 0.01
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/2 219.91.219.14 10:36 0.00s 0.00s 0.00s w
```
Suggested Read : [rtop A Nifty Tool to Monitor Remote Server Over SSH][6]
Suggested Read : [DSH Run/Execute Shell Commands On Multiple Linux Servers At Once][7]
#### Recheck with pstree Command
Recheck once again with `pstree` command to double confirm it. Yes, only one ssh session is live which is owned by me.
```
# pstree -p
init(1)-+-abrtd(2131)
|-acpid(1958)
|
|-httpd(32413)-+-httpd(32442)
|
|-mingetty(2198)
|-mysqld_safe(24298)---mysqld(24376)-+-{mysqld}(24378)
|
|-php(32456)-+-php(32457)
|
|-sshd(2023)---sshd(10199)---bash(10208)---pstree(10431)
|-udevd(774)-+-udevd(2191)
`-udevd(27282)
```
--------------------------------------------------------------------------------
via: http://www.2daygeek.com/kill-inactive-idle-ssh-sessions/
作者:[ Magesh Maruthamuthu][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/magesh/
[1]:http://www.2daygeek.com/author/magesh/
[2]:http://www.2daygeek.com/category/ssh-tutorials/
[3]:http://www.2daygeek.com/install-mosh-shell-ssh-client-in-linux-to-connect-remote-system/
[4]:http://www.2daygeek.com/shellinabox-web-based-ssh-terminal-to-access-remote-linux-servers/
[5]:http://www.2daygeek.com/pssh-parallel-ssh-run-execute-commands-on-multiple-linux-servers/
[6]:http://www.2daygeek.com/rtop-monitor-remote-linux-server-over-ssh/
[7]:http://www.2daygeek.com/dsh-run-execute-shell-commands-on-multiple-linux-servers-at-once/

View File

@@ -0,0 +1,313 @@
Using Kdump for examining Linux Kernel crashes
============================================================
### Let's examine the basics of kdump usage and look at the internals of kdump/kexec kernel implementation.
![Using Kdump for examining Linux Kernel crashes](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/linux_boot.png?itok=pSGmf8Ca "Using Kdump for examining Linux Kernel crashes")
Image by : 
[Penguin][13], [Boot][14]. Modified by Opensource.com. [CC BY-SA 4.0][15].
[Kdump][16] is a way to acquire a crashed Linux kernel dump, but finding documents that explain its usage and internals can be challenging. In this article, I'll examine the basics of kdump usage and look at the internals of kdump/kexec kernel implementation.
[Kexec][17] is a Linux kernel-to-kernel boot loader that helps to boot the second kernel from the context of first kernel. Kexec shuts down the first kernel, bypasses the BIOS or firmware stage, and jumps to second kernel. Thus, reboots become faster in absence of the BIOS stage.
Kdump can be used with the kexec application—for example, when the second kernel is booted when the first kernel panics, the second kernel is used to copy the memory dump of first kernel, which can be analyzed with tools such as gdb and crash to determine the panic reasons. (In this article, I'll use the terms  _first kernel_  for the currently running kernel,  _second kernel_  for the kernel run using kexec, and  _capture kernel_  for kernel run when current kernel panics.)
More Linux resources
* [What is Linux?][1]
* [What are Linux containers?][2]
* [Download Now: Linux commands cheat sheet][3]
* [Advanced Linux commands cheat sheet][4]
* [Our latest Linux articles][5]
The kexec mechanism has components in the kernel as well as in user space. The kernel provides few system calls for kexec reboot functionality. A user space tool called kexec-tools uses those calls and provides an executable to load and boot the second kernel. Sometimes a distribution also adds wrappers on top of kexec-tools, which helps capture and save the dump for various dump target configurations. In this article, I will use the name  _distro-kexec-tools_  to avoid confusion between upstream kexec-tools and distro-specific kexec-tools code. My example will use the Fedora Linux distribution.
### Fedora kexec-tools
**dnf install kexec-tools** installs fedora-kexec-tools on Fedora machines. The kdump service can be started by executing **systemctl start kdump** after installation of fedora-kexec-tools. When this service starts, it creates a root file system (initramfs) that contains resources to mount the target for saving vmcore, and a command to copy/dump vmcore to the target. This service then loads the kernel and initramfs at the suitable location within the crash kernel region so that they can be executed upon kernel panic.
Fedora wrapper provides two user configuration files:
1. **/etc/kdump.conf** specifies configuration parameters whose modification requires rebuild of the initramfs. For example, if you change the dump target from a local disk to an NFS-mounted disk, you will need NFS-related kernel modules to be loaded by the capture kernel.
2. **/etc/sysconfig/kdump** specifies configuration parameters whose modification do not require rebuild of the initramfs. For example, you do not need to rebuild the initramfs if you only need to modify command-line arguments passed to the capture kernel.
If the kernel panics after the kdump service starts, then the capture kernel is executed, which further executes the vmcore save process from initramfs and reboots to a stable kernel afterward.
### kexec-tools
Compilation of kexec-tools source code provides an executable called **kexec**. The same executable can be used to load and execute a second kernel or to load a capture kernel, which can be executed upon kernel panic.
A typical command to load a second kernel:
```
# kexec -l kernel.img --initrd=initramfs-image.img reuse-cmdline
```
**--reuse-command** line says to use the same command line as that of first kernel. Pass initramfs using **--initrd**. **-l** says that you are loading the second kernel, which can be executed by the kexec application itself (**kexec -e**). A kernel loaded using **-l** cannot be executed at kernel panic. You must pass **-p**instead of **-l** to load the capture kernel that can be executed upon kernel panic.
A typical command to load a capture kernel:
```
# kexec -p kernel.img --initrd=initramfs-image.img reuse-cmdline
```
**echo c > /pros/sysrq-trigger** can be used to crash the kernel for test purposes. See **man kexec** for detail about options provided by kexec-tools. Before moving to the next section, which focuses on internal implementation, watch this kexec_dump demo:
** 此处有iframe,请手动处理 **
### Kdump: End-to-end flow
Figure 1 shows a flow diagram. Crashkernel memory must be reserved for the capture kernel during booting of the first kernel. You can pass **crashkernel=Y@X** in the kernel command line, where **@X** is optional. **crashkernel=256M** works with most of the x86_64 systems; however, selecting a right amount of memory for the crash kernel is dependent on many factors, such as kernel size and initramfs, as well as runtime memory requirement of modules and applications included in initramfs. See the [kernel-parameters documentation][18] for more ways to pass crash kernel arguments.
![pratyush_f1.png](https://opensource.com/sites/default/files/images/life/pratyush_f1.png)
You can pass kernel and initramfs images to a **kexec** executable as shown in the typical command of section (**kexec-tools**). The capture kernel can be the same as the first kernel or can be different. Typically, keep it the same. Initramfs can be optional; for example, when the kernel is compiled with **CONFIG_INITRAMFS_SOURCE**, you do not need it. Typically, you keep a different capture initramfs from the first initramfs, because automating a copy of vmcore in capture initramfs is better. When **kexec** is executed, it also loads **elfcorehdr** data and the purgatory executable. **elfcorehdr** has information about the system RAM memory organization, and purgatory is a binary that executes before the capture kernel executes and verifies that the second stage binary/data have the correct SHA. Purgatory can be made optional as well.
When the first kernel panics, it does a minimal necessary exit process and switches to purgatory if it exists. Purgatory verifies SHA256 of loaded binaries and, if those are correct, then it passes control to the capture kernel. The capture kernel creates vmcore per the system RAM information received from **elfcorehdr**. Thus, you will see a dump of the first kernel in /proc/vmcore after the capture kernel boots. Depending on the initramfs you have used, you can now analyze the dump, copy it to any disk, or there can be an automated copy followed by reboot to a stable kernel.
### Kernel system calls
The kernel provides two system calls—**kexec_load()** and **kexec_file_load()**, which can be used to load the second kernel when **kexec -l** is executed. It also provides an extra flag for the **reboot()** system call, which can be used to boot into second kernel using **kexec -e**.
**kexec_load()**: The **kexec_load()** system call loads a new kernel that can be executed later by **reboot()**. Its prototype is defined as follows:
```
long kexec_load(unsigned long entry, unsigned long nr_segments,
struct kexec_segment *segments, unsigned long flags);
```
User space needs to pass segments for different components, such as kernel, initramfs, etc. Thus, the **kexec** executable helps in preparing these segments. The structure of **kexec_segment** looks like as follows:
```
struct kexec_segment {
void *buf;
/* Buffer in user space */
size_t bufsz;
/* Buffer length in user space */
void *mem;
/* Physical address of kernel */
size_t memsz;
/* Physical address length */
};
```
When **reboot()** is called with **LINUX_REBOOT_CMD_KEXEC**, it boots into a kernel loaded by **kexec_load()**. If a flag **KEXEC_ON_CRASH** is passed to **kexec_load()**, then the loaded kernel will not be executed with **reboot(LINUX_REBOOT_CMD_KEXEC)**; rather, that will be executed on kernel panic. **CONFIG_KEXEC** must be defined to use kexec and **CONFIG_CRASH_DUMP** should be defined for kdump.
**kexec_file_load()**: As a user you pass only two arguments (i.e., kernel and initramfs) to the **kexec** executable. **kexec** then reads data from sysfs or other kernel information source and creates all segments. So, **kexec_file_load()**gives you simplification in user space, where you pass only file descriptors of kernel and initramfs. The rest of the all segment preparation is done by the kernel itself. **CONFIG_KEXEC_FILE** should be enabled to use this system call. Its prototype looks like:
```
long kexec_file_load(int kernel_fd, int initrd_fd, unsigned long
cmdline_len, const char __user * cmdline_ptr, unsigned long
flags);
```
Notice that **kexec_file_load()** also accepts the command line, whereas **kexec_load()** did not. The kernel has different architecture-specific ways to accept the command line. Therefore, **kexec-tools** passes the command-line through one of the segments (like in **dtb** or **ELF boot notes**, etc.) in case of **kexec_load()**.
Currently, **kexec_file_load()** is supported for x86 and PowerPC only.
### What happens when the kernel crashes
When the first kernel panics, before control is passed to the purgatory or capture kernel it does the following:
* prepares CPU registers (see **crash_setup_regs()** in kernel code);
* updates vmcoreinfo note (see **crash_save_vmcoreinfo()**);
* shuts down non-crashing CPUs and saves the prepared registers (see **machine_crash_shutdown()** and **crash_save_cpu()**);
* you also might need to disable the interrupt controller here;
* and at the end, it performs the kexec reboot (see **machine_kexec()**), which loads/flushes kexec segments to memory and passes control to the execution of entry segment. Entry segment could be purgatory or start address of next kernel.
### ELF program headers
Most of the dump cores involved in kdump are in ELF format. Thus, understanding ELF Program headers is important, especially if you want to find issues with vmcore preparation. Each ELF file has a program header that:
* is read by the system loader,
* describes how the program should be loaded into memory,
* and one can use **Objdump -p elf_file** to look into program headers.
An example of ELF program headers of a vmcore:
```
# objdump -p vmcore
vmcore:
file format elf64-littleaarch64
Program Header:
NOTE off 0x0000000000010000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**0 filesz
0x00000000000013e8 memsz 0x00000000000013e8 flags ---
LOAD off 0x0000000000020000 vaddr 0xffff000008080000 paddr 0x0000004000280000 align 2**0 filesz
0x0000000001460000 memsz 0x0000000001460000 flags rwx
LOAD off 0x0000000001480000 vaddr 0xffff800000200000 paddr 0x0000004000200000 align 2**0 filesz
0x000000007fc00000 memsz 0x000000007fc00000 flags rwx
LOAD off 0x0000000081080000 vaddr 0xffff8000ffe00000 paddr 0x00000040ffe00000 align 2**0 filesz
0x00000002fa7a0000 memsz 0x00000002fa7a0000 flags rwx
LOAD off 0x000000037b820000 vaddr 0xffff8003fa9e0000 paddr 0x00000043fa9e0000 align 2**0 filesz
0x0000000004fc0000 memsz 0x0000000004fc0000 flags rwx
LOAD off 0x00000003807e0000 vaddr 0xffff8003ff9b0000 paddr 0x00000043ff9b0000 align 2**0 filesz
0x0000000000010000 memsz 0x0000000000010000 flags rwx
LOAD off 0x00000003807f0000 vaddr 0xffff8003ff9f0000 paddr 0x00000043ff9f0000 align 2**0 filesz
0x0000000000610000 memsz 0x0000000000610000 flags rwx
```
In this example, there is one note section and the rest are load sections. The note section has information about CPU notes and load sections have information about copied system RAM components.
Vmcore starts with **elfcorehdr**, which has the same structure as that of a an ELF program header. See the representation of **elfcorehdr** in Figure 2:
![pratyush_f2.png](https://opensource.com/sites/default/files/images/life/pratyush_f2.png)
**kexec-tools** reads /sys/devices/system/cpu/cpu%d/crash_notes and prepares headers for **CPU PT_NOTE**. Similarly, it reads **/sys/kernel/vmcoreinfo** and prepares headers for **vmcoreinfo PT_NOTE**, and reads system RAM values from **/proc/iomem** and prepares memory **PT_LOAD** headers. When the capture kernel receives **elfcorehdr**, it appends data from addresses mentioned in the header and prepares vmcore.
### Crash notes
Crash notes is a per-CPU area for storing CPU states in case of a system crash; it has information about current PID and CPU registers.
### vmcoreinfo
This note section has various kernel debug information, such as struct size, symbol values, page size, etc. Values are parsed by capture kernel and embedded into **/proc/vmcore**. **vmcoreinfo** is used mainly by the **makedumpfile** application. **include/linux/kexec.h** in the Linux kernel has macros to define a new **vmcoreinfo**. Some of the example macros are like these:
* **VMCOREINFO_PAGESIZE()**
* **VMCOREINFO_SYMBOL()**
* **VMCOREINFO_SIZE()**
* **VMCOREINFO_STRUCT_SIZE()**
### makedumpfile
Much information (such as free pages) in a vmcore is not useful. Makedumpfile is an application that excludes unnecessary pages, such as:
* pages filled with zeroes,
* cache pages without private flag (non-private cache);
* cache pages with private flag (private cache);
* user process data pages;
* free pages.
Additionally, makedumpfile compresses **/proc/vmcore** data while copying. It can also erase sensitive symbol information from dump; however, it first needs kernel's debug information to do that. This debug information comes from either **VMLINUX** or **vmcoreinfo**, and its output either can be in ELF format or kdump-compressed format.
Typical usage:
```
# makedumpfile -l --message-level 1 -d 31 /proc/vmcore makedumpfilecore
```
See **man makedumpfile** for detail.
### Debugging kdump issues
Issues that new kdump users might have:
### _Kexec -p kernel_image_  did not succeed
* Check whether crash memory is allocated.
* **cat /sys/kernel/kexec_crash_size** should have no zero value.
* **cat /proc/iomem | grep "Crash kernel"** should have an allocated range.
* If not allocated, then pass the proper **crashkernel=** argument in the command line.
* If nothing shows up, then pass **-d** in the **kexec** command and share the debug output with the kexec-tools mailing list.
### Do not see anything on console after last message from first kernel (such as "bye")
* Check whether **kexec -l kernel_image** followed by **kexec -e** works.
* Might be missing architecture- or machine-specific options.
* Might have purgatory SHA verification failed. If your architecture does not support a console in purgatory, then it is difficult to debug.
* Might have second kernel crashed early.
* Pass **earlycon**/**earlyprintk** option for your system to the second kernel command line.
* Share **dmesg** log of both the first and capture kernel with kexec-tools mailing list.
### Resources
#### fedora-kexec-tools
* Repository: **git://pkgs.fedoraproject.org/kexec-tools**
* Mailing list: [kexec@lists.fedoraproject.org][7]
* Description: Specs file and scripts to provide user-friendly command/services so that **kexec-tools** can be automated in different user scenarios.
#### kexec-tools
* Repository: git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
* Mailing list: [kexec@lists.infradead.org][8]
* Description: Uses kernel system calls and provides a user command **kexec**.
#### Linux kernel
* Repository: **git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git**
* Mailing list: [kexec@lists.infradead.org][9]
* Description: Implements **kexec_load()**, **kexec_file_load()**, and **reboot()**system call and architecture-specific code, such as **machine_kexec()** and **machine_crash_shutdown()**, etc.
#### Makedumpfile
* Repository: **git://git.code.sf.net/p/makedumpfile/code**
* Mailing list: [kexec@lists.infradead.org][10]
* Description: Compresses and filters unnecessary component from the dumpfile.
_Learn more in Pratyush Anand's [KDUMP: Usage and Internals][11] talk at LinuxCon ContainerCon CloudOpen China on June 20, 2017._
--------------------------------------------------------------------------------
作者简介:
Pratyush Anand - Pratyush is working with Red Hat as a Linux Kernel Generalist. Primarily, he takes care of several kexec/kdump issues being faced by Red Hat product and upstream. He also handles other kernel debugging/tracing/performance issues around Red Hat supported ARM64 platforms. Apart from Linux Kernel, he has also contributed in upstream kexec-tools and makedumpfile project. He is an open source enthusiast and delivers volunteer lectures in educational institutes for the promotion of FOSS.
-------
via: https://opensource.com/article/17/6/kdump-usage-and-internals
作者:[Pratyush Anand ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/pratyushanand
[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu
[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu
[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ
[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ
[5]:https://opensource.com/tags/linux?src=linux_resource_menu
[6]:https://opensource.com/article/17/6/kdump-usage-and-internals?rate=7i_-TnAGi8Q9GR7fhULKlQUNJw8KWgzadgMY9TDuiAY
[7]:mailto:kexec@lists.fedoraproject.org
[8]:mailto:kexec@lists.infradead.org
[9]:mailto:kexec@lists.infradead.org
[10]:mailto:kexec@lists.infradead.org
[11]:http://sched.co/AVB4
[12]:https://opensource.com/user/143191/feed
[13]:https://pixabay.com/en/penguins-emperor-antarctic-life-429136/
[14]:https://pixabay.com/en/shoe-boots-home-boots-house-1519804/
[15]:https://creativecommons.org/licenses/by-sa/4.0/
[16]:https://www.kernel.org/doc/Documentation/kdump/kdump.txt
[17]:https://linux.die.net/man/8/kexec
[18]:https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/kernel-parameters.txt
[19]:https://opensource.com/users/pratyushanand

View File

@@ -0,0 +1,95 @@
8 ways to contribute to open source when you have no time
============================================================
### Find the time in your busy life to give back to the projects you care about.
![8 ways to contribute to open source when you have no time](https://opensource.com/sites/default/files/styles/image-full-size/public/images/law/LAW-patent_reform_520x292_10136657_1012_dc.png?itok=zLMswcrw "8 ways to contribute to open source when you have no time")
Image by : opensource.com
One of the [most common reasons][3] people give for not contributing (or not contributing more) to open source is a lack of time. I get it; life is challenging, and there are so many priorities vying for your limited attention. So how can you find the time in your busy life to contribute to the open source projects you care about?
In the interest of full disclosure, I should warn you that I was late getting this article to the editors because I couldn't find the time to work on it. Take my advice at your own risk.
### Figure out what you care about
The first step in contributing is to figure out what exactly you're making time for. Do you have a project of your own that you want to work on? Is there a specific project that you use that you want to help with? Do you just want to do  _something_ ? Figuring out what you're making time for will help you decide where in your life's priorities it belongs.
### Find alternate ways to contribute
Writing a new feature can take many hours of design, coding, and testing. It's not always easy to work on that for a few minutes, step away, and then pick up where you left off. If you never get more than 30 minutes of uninterrupted effort, you might find yourself pretty frustrated if you try to take on a big task.
But there are other ways to contribute that might satisfy your need to give back within the time you have available. Some of them can be done in quick spurts from a smartphone, which means you can take the time you used to spend avoiding people on your commute and put it toward your open source contributions. Here's a list of some things that can be done in small chunks:
* **Bug triage:** Do all of the bug reports have the information necessary to diagnose and resolve them? Are they properly filed (to the right area, with the right severity, etc.)?
* **Mailing list support:** Are users or other contributors asking questions on the mailing list? Maybe you can help.
* **Documentation patches:** Documentation can often (but not always) be worked on in smaller chunks than code. Maybe there are a few places you can fill in. Or maybe it's time to run through the docs and make sure they're still accurate.
* **Marketing:** Talk about your project or community on social media. Write a quick blog post. Vote and comment on news aggregators.
### Talk to your boss
You might think you can't work on open source projects during the workday, but have you  _asked_ ? Particularly if the project somehow relates to your day job, you might be able to sell your boss on letting you make contributions while at work. Note that there may be some intellectual property issues (e.g., who owns the rights to the code you contribute during working hours), so do your research first and get the conditions in writing.
### Set deadlines
The best time management advice I ever received can be summarized with two rules:
1. If it's going to get done, it has to have a deadline
2. It's okay to change a deadline
This article had a deadline. There's no particular time sensitivity to it, but a deadline meant that I defined when I wanted to get it done and gave the editors a sense of when it might be submitted. And yes, as I said above, I missed the deadline. You know what happened? I set a new deadline (second time's a charm!).
If something  _is_  time-sensitive, set the deadline well ahead to give yourself some space if you need to push it back a time or two.
### Put it on your calendar
If you use a calendar to schedule the rest of your life, scheduling some time to work on your open source project may be the only way to get it done. How much time you schedule is up to you, but even if you block off only one hour once a week as open source time, that still gives you an hour a week of open source time.
And here's a secret: It's okay to cancel on yourself sometimes if you need the time to do something else—or do nothing at all.
### Reclaim unused time
Are you bored on your commute? Are you having trouble falling asleep at night? Maybe you can use that time to contribute. Now I happen to think the "work 169 hours a week at full tilt" lifestyle is a terrible, terrible thing. That said, some nights you just can't fall asleep. Instead of lying in bed, seeing what your Twitter friends on the other side of the world are up to (which I do), maybe you can work on that contribution you've been meaning to get around to. Just don't make a habit out of forgoing sleep.
### Stop
Sometimes the best way to contribute is to not contribute for a little bit. You're a busy person and no matter how awesome you are, you can't avoid your physiological and psychological needs. They will catch up to you. Taking a little time to refresh yourself might improve your productivity enough that you get stuff done faster, and suddenly there's time for you to make those open source contributions you've been meaning to get around to.
### Say "no"
I am bad at this. So very bad. But none of us can do everything we'd like to do. Sometimes the best thing you can do to contribute is to stop contributing in the same way you have been—or not contribute at all (see above).
Several years ago, I led the Fedora documentation team. The team's tradition was that the leader would offer to step aside at the end of each release. I had done that a time or two and nobody stepped up, so I remained in the role. But after my second or third release, I made it clear that I would not be continuing as the team lead. I still enjoyed the work, but I was working full time, in graduate school half time, and my wife was pregnant with our first child. There was no way I could consistently give the level of effort that was required, so I stepped aside. I continued to contribute, but in a less-demanding capacity.
If you're getting to the point where you struggle to find the time to meet your obligations (self-imposed or not), then perhaps it's time to reconsider your role. This can be especially hard with a project that you founded or have made a considerable investment in. But sometimes you have to—for your own good and that of the project.
### What else?
How do you find time to make your contributions? Let us know in the comments.
--------------------------------------------------------------------------------
作者简介:
Ben Cotton - Ben Cotton is a meteorologist by training and a high-performance computing engineer by trade. Ben works as a technical evangelist at Cycle Computing. He is a Fedora user and contributor, co-founded a local open source meetup group, and is a member of the Open Source Initiative and a supporter of Software Freedom Conservancy. Find him on Twitter (@FunnelFiasco) or at
----------
via: https://opensource.com/article/17/6/find-time-contribute
作者:[Ben Cotton ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/bcotton
[1]:https://opensource.com/article/17/6/find-time-contribute?rate=qWRgPXlhEZchh_vXEplj6jLXd7P0QCwzxZFWYkqawCc
[2]:https://opensource.com/user/30131/feed
[3]:http://naramore.net/blog/why-people-don-t-contribute-to-os-projects-and-what-we-can-do-about-it
[4]:https://opensource.com/users/bcotton
[5]:https://opensource.com/article/17/6/find-time-contribute#comments

View File

@@ -0,0 +1,311 @@
A user's guide to links in the Linux filesystem
============================================================
### Learn how to use links, which make tasks easier by providing access to files from multiple locations in the Linux filesystem directory tree.
![A user's guide to links in the Linux filesystem](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/links.png?itok=AumNmse7 "A user's guide to links in the Linux filesystem")
Image by : [Paul Lewin][8]. Modified by Opensource.com. [CC BY-SA 2.0][9]
In articles I have written about various aspects of Linux filesystems for Opensource.com, including [An introduction to Linux's EXT4 filesystem][10]; [Managing devices in Linux][11]; [An introduction to Linux filesystems][12]; and [A Linux user's guide to Logical Volume Management][13], I have briefly mentioned an interesting feature of Linux filesystems that can make some tasks easier by providing access to files from multiple locations in the filesystem directory tree.
There are two types of Linux filesystem links: hard and soft. The difference between the two types of links is significant, but both types are used to solve similar problems. They both provide multiple directory entries (or references) to a single file, but they do it quite differently. Links are powerful and add flexibility to Linux filesystems because [everything is a file][14].
More Linux resources
* [What is Linux?][1]
* [What are Linux containers?][2]
* [Download Now: Linux commands cheat sheet][3]
* [Advanced Linux commands cheat sheet][4]
* [Our latest Linux articles][5]
I have found, for instance, that some programs required a particular version of a library. When a library upgrade replaced the old version, the program would crash with an error specifying the name of the old, now-missing library. Usually, the only change in the library name was the version number. Acting on a hunch, I simply added a link to the new library but named the link after the old library name. I tried the program again and it worked perfectly. And, okay, the program was a game, and everyone knows the lengths that gamers will go to in order to keep their games running.
In fact, almost all applications are linked to libraries using a generic name with only a major version number in the link name, while the link points to the actual library file that also has a minor version number. In other instances, required files have been moved from one directory to another to comply with the Linux file specification, and there are links in the old directories for backwards compatibility with those programs that have not yet caught up with the new locations. If you do a long listing of the **/lib64** directory, you can find many examples of both.
```
lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.hwm -> ../../usr/share/cracklib/pw_dict.hwm
lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwd -> ../../usr/share/cracklib/pw_dict.pwd
lrwxrwxrwx. 1 root root 36 Dec 8 2016 cracklib_dict.pwi -> ../../usr/share/cracklib/pw_dict.pwi
lrwxrwxrwx. 1 root root 27 Jun 9 2016 libaccountsservice.so.0 -> libaccountsservice.so.0.0.0
-rwxr-xr-x. 1 root root 288456 Jun 9 2016 libaccountsservice.so.0.0.0
lrwxrwxrwx 1 root root 15 May 17 11:47 libacl.so.1 -> libacl.so.1.1.0
-rwxr-xr-x 1 root root 36472 May 17 11:47 libacl.so.1.1.0
lrwxrwxrwx. 1 root root 15 Feb 4 2016 libaio.so.1 -> libaio.so.1.0.1
-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.0
-rwxr-xr-x. 1 root root 6224 Feb 4 2016 libaio.so.1.0.1
lrwxrwxrwx. 1 root root 30 Jan 16 16:39 libakonadi-calendar.so.4 -> libakonadi-calendar.so.4.14.26
-rwxr-xr-x. 1 root root 816160 Jan 16 16:39 libakonadi-calendar.so.4.14.26
lrwxrwxrwx. 1 root root 29 Jan 16 16:39 libakonadi-contact.so.4 -> libakonadi-contact.so.4.14.26
```
A few of the links in the **/lib64** directory
The long listing of the **/lib64** directory above shows that the first character in the filemode is the letter "l," which means that each is a soft or symbolic link.
### Hard links
In [An introduction to Linux's EXT4 filesystem][15], I discussed the fact that each file has one inode that contains information about that file, including the location of the data belonging to that file. [Figure 2][16] in that article shows a single directory entry that points to the inode. Every file must have at least one directory entry that points to the inode that describes the file. The directory entry is a hard link, thus every file has at least one hard link.
In Figure 1 below, multiple directory entries point to a single inode. These are all hard links. I have abbreviated the locations of three of the directory entries using the tilde (**~**) convention for the home directory, so that **~** is equivalent to **/home/user** in this example. Note that the fourth directory entry is in a completely different directory, **/home/shared**, which might be a location for sharing files between users of the computer.
![fig1directory_entries.png](https://opensource.com/sites/default/files/images/life/fig1directory_entries.png)
Figure 1
Hard links are limited to files contained within a single filesystem. "Filesystem" is used here in the sense of a partition or logical volume (LV) that is mounted on a specified mount point, in this case **/home**. This is because inode numbers are unique only within each filesystem, and a different filesystem, for example, **/var**or **/opt**, will have inodes with the same number as the inode for our file.
Because all the hard links point to the single inode that contains the metadata about the file, all of these attributes are part of the file, such as ownerships, permissions, and the total number of hard links to the inode, and cannot be different for each hard link. It is one file with one set of attributes. The only attribute that can be different is the file name, which is not contained in the inode. Hard links to a single **file/inode** located in the same directory must have different names, due to the fact that there can be no duplicate file names within a single directory.
The number of hard links for a file is displayed with the **ls -l** command. If you want to display the actual inode numbers, the command **ls -li** does that.
### Symbolic (soft) links
The difference between a hard link and a soft link, also known as a symbolic link (or symlink), is that, while hard links point directly to the inode belonging to the file, soft links point to a directory entry, i.e., one of the hard links. Because soft links point to a hard link for the file and not the inode, they are not dependent upon the inode number and can work across filesystems, spanning partitions and LVs.
The downside to this is: If the hard link to which the symlink points is deleted or renamed, the symlink is broken. The symlink is still there, but it points to a hard link that no longer exists. Fortunately, the **ls** command highlights broken links with flashing white text on a red background in a long listing.
### Lab project: experimenting with links
I think the easiest way to understand the use of and differences between hard and soft links is with a lab project that you can do. This project should be done in an empty directory as a  _non-root user_ . I created the **~/temp** directory for this project, and you should, too. It creates a safe place to do the project and provides a new, empty directory to work in so that only files associated with this project will be located there.
### **Initial setup**
First, create the temporary directory in which you will perform the tasks needed for this project. Ensure that the present working directory (PWD) is your home directory, then enter the following command.
```
mkdir temp
```
Change into **~/temp** to make it the PWD with this command.
```
cd temp
```
To get started, we need to create a file we can link to. The following command does that and provides some content as well.
```
du -h > main.file.txt
```
Use the **ls -l** long list to verify that the file was created correctly. It should look similar to my results. Note that the file size is only 7 bytes, but yours may vary by a byte or two.
```
[dboth@david temp]$ ls -l
total 4
-rw-rw-r-- 1 dboth dboth 7 Jun 13 07:34 main.file.txt
```
Notice the number "1" following the file mode in the listing. That number represents the number of hard links that exist for the file. For now, it should be 1 because we have not created any additional links to our test file.
### **Experimenting with hard links**
Hard links create a new directory entry pointing to the same inode, so when hard links are added to a file, you will see the number of links increase. Ensure that the PWD is still **~/temp**. Create a hard link to the file **main.file.txt**, then do another long list of the directory.
```
[dboth@david temp]$ ln main.file.txt link1.file.txt
[dboth@david temp]$ ls -l
total 8
-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 link1.file.txt
-rw-rw-r-- 2 dboth dboth 7 Jun 13 07:34 main.file.txt
```
Notice that both files have two links and are exactly the same size. The date stamp is also the same. This is really one file with one inode and two links, i.e., directory entries to it. Create a second hard link to this file and list the directory contents. You can create the link to either of the existing ones: **link1.file.txt** or **main.file.txt**.
```
[dboth@david temp]$ ln link1.file.txt link2.file.txt ; ls -l
total 16
-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link1.file.txt
-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 link2.file.txt
-rw-rw-r-- 3 dboth dboth 7 Jun 13 07:34 main.file.txt
```
Notice that each new hard link in this directory must have a different name because two files—really directory entries—cannot have the same name within the same directory. Try to create another link with a target name the same as one of the existing ones.
```
[dboth@david temp]$ ln main.file.txt link2.file.txt
ln: failed to create hard link 'link2.file.txt': File exists
```
Clearly that does not work, because **link2.file.txt** already exists. So far, we have created only hard links in the same directory. So, create a link in your home directory, the parent of the temp directory in which we have been working so far.
```
[dboth@david temp]$ ln main.file.txt ../main.file.txt ; ls -l ../main*
-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt
```
The **ls** command in the above listing shows that the **main.file.txt** file does exist in the home directory with the same name as the file in the temp directory. Of course, these are not different files; they are the same file with multiple links—directory entries—to the same inode. To help illustrate the next point, add a file that is not a link.
```
[dboth@david temp]$ touch unlinked.file ; ls -l
total 12
-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt
-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt
-rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt
-rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file
```
Look at the inode number of the hard links and that of the new file using the **-i**option to the **ls** command.
```
[dboth@david temp]$ ls -li
total 12
657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link1.file.txt
657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 link2.file.txt
657024 -rw-rw-r-- 4 dboth dboth 7 Jun 13 07:34 main.file.txt
657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file
```
Notice the number **657024** to the left of the file mode in the example above. That is the inode number, and all three file links point to the same inode. You can use the **-i** option to view the inode number for the link we created in the home directory as well, and that will also show the same value. The inode number of the file that has only one link is different from the others. Note that the inode numbers will be different on your system.
Let's change the size of one of the hard-linked files.
```
[dboth@david temp]$ df -h > link2.file.txt ; ls -li
total 12
657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt
657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt
657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt
657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file
```
The file size of all the hard-linked files is now larger than before. That is because there is really only one file that is linked to by multiple directory entries.
I know this next experiment will work on my computer because my **/tmp**directory is on a separate LV. If you have a separate LV or a filesystem on a different partition (if you're not using LVs), determine whether or not you have access to that LV or partition. If you don't, you can try to insert a USB memory stick and mount it. If one of those options works for you, you can do this experiment.
Try to create a link to one of the files in your **~/temp** directory in **/tmp** (or wherever your different filesystem directory is located).
```
[dboth@david temp]$ ln link2.file.txt /tmp/link3.file.txt
ln: failed to create hard link '/tmp/link3.file.txt' => 'link2.file.txt':
Invalid cross-device link
```
Why does this error occur? The reason is each separate mountable filesystem has its own set of inode numbers. Simply referring to a file by an inode number across the entire Linux directory structure can result in confusion because the same inode number can exist in each mounted filesystem.
There may be a time when you will want to locate all the hard links that belong to a single inode. You can find the inode number using the **ls -li** command. Then you can use the **find** command to locate all links with that inode number.
```
[dboth@david temp]$ find . -inum 657024
./main.file.txt
./link1.file.txt
./link2.file.txt
```
Note that the **find** command did not find all four of the hard links to this inode because we started at the current directory of **~/temp**. The **find** command only finds files in the PWD and its subdirectories. To find all the links, we can use the following command, which specifies your home directory as the starting place for the search.
```
[dboth@david temp]$ find ~ -samefile main.file.txt
/home/dboth/temp/main.file.txt
/home/dboth/temp/link1.file.txt
/home/dboth/temp/link2.file.txt
/home/dboth/main.file.txt
```
You may see error messages if you do not have permissions as a non-root user. This command also uses the **-samefile** option instead of specifying the inode number. This works the same as using the inode number and can be easier if you know the name of one of the hard links.
### **Experimenting with soft links**
As you have just seen, creating hard links is not possible across filesystem boundaries; that is, from a filesystem on one LV or partition to a filesystem on another. Soft links are a means to answer that problem with hard links. Although they can accomplish the same end, they are very different, and knowing these differences is important.
Let's start by creating a symlink in our **~/temp** directory to start our exploration.
```
[dboth@david temp]$ ln -s link2.file.txt link3.file.txt ; ls -li
total 12
657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link1.file.txt
657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 link2.file.txt
658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt ->
link2.file.txt
657024 -rw-rw-r-- 4 dboth dboth 1157 Jun 14 14:14 main.file.txt
657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file
```
The hard links, those that have the inode number **657024**, are unchanged, and the number of hard links shown for each has not changed. The newly created symlink has a different inode, number **658270**. The soft link named **link3.file.txt**points to **link2.file.txt**. Use the **cat** command to display the contents of **link3.file.txt**. The file mode information for the symlink starts with the letter "**l**" which indicates that this file is actually a symbolic link.
The size of the symlink **link3.file.txt** is only 14 bytes in the example above. That is the size of the text **link3.file.txt -> link2.file.txt**, which is the actual content of the directory entry. The directory entry **link3.file.txt** does not point to an inode; it points to another directory entry, which makes it useful for creating links that span file system boundaries. So, let's create that link we tried before from the **/tmp** directory.
```
[dboth@david temp]$ ln -s /home/dboth/temp/link2.file.txt
/tmp/link3.file.txt ; ls -l /tmp/link*
lrwxrwxrwx 1 dboth dboth 31 Jun 14 21:53 /tmp/link3.file.txt ->
/home/dboth/temp/link2.file.txt
```
### **Deleting links**
There are some other things that you should consider when you need to delete links or the files to which they point.
First, let's delete the link **main.file.txt**. Remember that every directory entry that points to an inode is simply a hard link.
```
[dboth@david temp]$ rm main.file.txt ; ls -li
total 8
657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt
657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link2.file.txt
658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt ->
link2.file.txt
657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file
```
The link **main.file.txt** was the first link created when the file was created. Deleting it now still leaves the original file and its data on the hard drive along with all the remaining hard links. To delete the file and its data, you would have to delete all the remaining hard links.
Now delete the **link2.file.txt** hard link.
```
[dboth@david temp]$ rm link2.file.txt ; ls -li
total 8
657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 link1.file.txt
658270 lrwxrwxrwx 1 dboth dboth 14 Jun 14 15:21 link3.file.txt ->
link2.file.txt
657024 -rw-rw-r-- 3 dboth dboth 1157 Jun 14 14:14 main.file.txt
657863 -rw-rw-r-- 1 dboth dboth 0 Jun 14 08:18 unlinked.file
```
Notice what happens to the soft link. Deleting the hard link to which the soft link points leaves a broken link. On my system, the broken link is highlighted in colors and the target hard link is flashing. If the broken link needs to be fixed, you can create another hard link in the same directory with the same name as the old one, so long as not all the hard links have been deleted. You could also recreate the link itself, with the link maintaining the same name but pointing to one of the remaining hard links. Of course, if the soft link is no longer needed, it can be deleted with the **rm** command.
The **unlink** command can also be used to delete files and links. It is very simple and has no options, as the **rm** command does. It does, however, more accurately reflect the underlying process of deletion, in that it removes the link—the directory entry—to the file being deleted.
### Final thoughts
I worked with both types of links for a long time before I began to understand their capabilities and idiosyncrasies. It took writing a lab project for a Linux class I taught to fully appreciate how links work. This article is a simplification of what I taught in that class, and I hope it speeds your learning curve.
--------------------------------------------------------------------------------
作者简介:
David Both - David Both is a Linux and Open Source advocate who resides in Raleigh, North Carolina. He has been in the IT industry for over forty years and taught OS/2 for IBM where he worked for over 20 years. While at IBM, he wrote the first training course for the original IBM PC in 1981. He has taught RHCE classes for Red Hat and has worked at MCI Worldcom, Cisco, and the State of North Carolina. He has been working with Linux and Open Source Software for almost 20 years.
---------------------------------
via: https://opensource.com/article/17/6/linking-linux-filesystem
作者:[David Both ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/dboth
[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu
[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu
[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ
[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?src=linux_resource_menu&intcmp=7016000000127cYAAQ
[5]:https://opensource.com/tags/linux?src=linux_resource_menu
[6]:https://opensource.com/article/17/6/linking-linux-filesystem?rate=YebHxA-zgNopDQKKOyX3_r25hGvnZms_33sYBUq-SMM
[7]:https://opensource.com/user/14106/feed
[8]:https://www.flickr.com/photos/digypho/7905320090
[9]:https://creativecommons.org/licenses/by/2.0/
[10]:https://opensource.com/article/17/5/introduction-ext4-filesystem
[11]:https://opensource.com/article/16/11/managing-devices-linux
[12]:https://opensource.com/life/16/10/introduction-linux-filesystems
[13]:https://opensource.com/business/16/9/linux-users-guide-lvm
[14]:https://opensource.com/life/15/9/everything-is-a-file
[15]:https://opensource.com/article/17/5/introduction-ext4-filesystem
[16]:https://opensource.com/article/17/5/introduction-ext4-filesystem#fig2
[17]:https://opensource.com/users/dboth
[18]:https://opensource.com/article/17/6/linking-linux-filesystem#comments

View File

@@ -0,0 +1,76 @@
Free Up Some Space in Ubuntu/LinuxMint With Ubuntu Cleaner (Fork of Janitor Module)
============================================================
Most of us very often forget to remove junk files in Linux system which will make the system to run out of space.
We have to follow few stand procedure to free up space (remove distribution cache, system logs, app cache & trash) in Linux distribution, if we are doing the same procedure in manual way it would take hell lots of time and very difficult too.
In Linux verity of applications is available to make this task much easier. Today we are going to teach you about Ubuntu Cleaner which is forked from Janitor module (Its one of the module in Ubuntu tweak).
[Ubuntu Cleaner][2] is a tool that makes it easy to clean your Ubuntu system. As we already knows Ubuntu Tweak is one of the best utility which help us to tweak Ubuntu and its derivatives. Its got deprecated as his main developer did not have time to maintain it.
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]
So the developer of Ubuntu Cleaner forked the janitor module from Ubuntu tweak utility and bring back that useful functionality to the Ubuntu community with new name called Ubuntu cleaner since many users using Ubuntu tweak utility in latest version too (as they dont want to leave the utility). Its one of the most popular utility on Ubuntu many years.
Suggested Read : [uCareSystem All-In-One System Update And Maintenance Tool For Ubuntu/LinuxMint][5]
I guess whoever missing Ubuntu tweak they may feel happy by using the Ubuntu cleaner since its forked from janitor module.
Ubuntu Cleaner will remove the following junk files in Ubuntu and its derivatives:
* App caches (Browser caches)
* Thumbnail cache
* Apt cache
* Old kernels
* Package config files
* Unneeded packages
#### How to install Ubuntu Cleaner
We can easily install Ubuntu Cleaner to Ubuntu and its derivatives through PPA since the developer offering official PPA. Ubuntu Cleaner currently support Ubuntu 14.04 LTS and Ubuntu 16.04 LTS.
```
$ sudo add-apt-repository ppa:gerardpuig/ppa
$ sudo apt update
$ sudo apt install ubuntu-cleaner
```
#### How to use Ubuntu Cleaner
Launch an Ubuntu cleaner from main menu, you will get the default interface look like below.
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_001.png)][6]
Tick the `check box` in front of the file which you want to clean up. Finally hit `Clean` button to remove the junk files from system.
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_002.png)][7]
Yes, we have successfully cleaned our system now.
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_003.png)][8]
--------------------------------------------------------------------------------
via: http://www.2daygeek.com/ubuntu-cleaner-system-cleaner-ubuntu-tweak-alternative-janitor/#
作者:[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]:http://ubuntu-cleaner.blogspot.in/
[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/ucaresystem-system-update-and-maintenance-tool-for-ubuntu-linuxmint/
[6]:http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_001.png
[7]:http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_002.png
[8]:http://www.2daygeek.com/wp-content/uploads/2017/06/Ubuntu-Cleaner_003.png

View File

@@ -0,0 +1,94 @@
The What, Why and Wow! Behind the CoreOS Container Linux
============================================================
![](https://cdn-images-1.medium.com/max/1600/1*znkOJQnw5_8Ko8VMEpRlpg.png)
#### Latest Linux distro automatically updates kernel software and gives full configuration control across clusters.
The usual debate over server Linux distributions begins with:
_Do you use a _ [_Red Hat Enterprise Linux (RHEL)_][1] _-based distribution, such as _ [_CentOS_][2] _ or _ [_Fedora_][3] _; a _ [_Debian_][4] _-based Linux like _ [_Ubuntu_][5] _; or _ [_SUSE_][6] _?_
But now, [CoreOS Container Linux][7] joins the fracas. [CoreOS, recently offered by Linode on its servers][8], takes an entirely different approach than its more conventional, elder siblings.
So, you may be asking yourself: “Why should I bother, when there are so many other solid Linux distros?” Well, Ill let Greg Kroah-Hartman, the kernel maintainer for the Linux-stable branch and CoreOS advisor, start the conversation:
> (CoreOS) handles distro updates (based on the ChromeOS code) combined with Docker and potentially checkpoint/restore, (which) means that you might be [able to update the distro under your application without stopping/starting the process/container.][9] Ive seen it happen in testing, and its scary [good].”
And that assessment came when CoreOS was in alpha. Back then, [CoreOS was being developed inbelieve it or nota Silicon Valley garage][10]. While CoreOS is no Apple or HPE, its grown considerably in the last four years.
When I checked in on them at 2017s [CoreOS Fest][11] in San Francisco, CoreOS had support from Google Cloud, IBM, Amazon Web Services, and Microsoft. The project itself now has over a thousand contributors. They think theyre on to something good, and I agree.
Why? Because, CoreOS is a lightweight Linux designed from the get-go for running containers. It started as a [Docker][12] platform, but over time CoreOS has taken its own path to containers. It now supports both its own take on containers, [rkt][13] (pronounced rocket), and Docker.
Unlike most Linux distributions, CoreOS doesnt have a package manager. Instead it takes a page from Googles ChromeOS and automates software updates to ensure better security and reliability of machines and containers running on clusters. Both operating system updates and security patches are regularly pushed to CoreOS Container Linux machines without sysadmin intervention.
You control how often patches are pushed using [CoreUpdate, with its web-based interface][14]. This enables you to control when your machines update, and how quickly an update is rolled out across your cluster.
Specifically, CoreOS does this with the the distributed configuration service [etcd][15]. This is an open-source, distributed key value store based on [YAML][16]. Etcd provides shared configuration and service discovery for Container Linux clusters.
This service runs on each machine in a cluster. When one server goes down, say to update, it handles the leader election so that the overall Linux system and containerized applications keep running as each server is updated.
To handle cluster management, [CoreOS used to use fleet][17]. This ties together [systemd][18] and etcd into a distributed init system. While fleet is still around, CoreOS has joined etcd with [Kubernetes][19] container orchestration to form an even more powerful management tool.
CoreOS also enables you to declaratively customize other operating system specifications, such as network configuration, user accounts, and systemd units, with [cloud-config][20].
Put it all together and you have a Linux thats constantly self-updating to the latest patches while giving you full control over its configuration from individual systems to thousand of container instances. Or, as CoreOS puts it, “Youll never have to run [Chef ][21]on every machine in order to change a single config value ever again.”
Lets say you want to expand your DevOps control even further. [CoreOS helps you there, too, by making it easy to deploy Kubernetes][22].
So, what does all this mean? CoreOS is built from the ground-up to make it easy to deploy, manage and run containers. Yes, other Linux distributions, such as the Red Hat family with [Project Atomic][23], also enable you to do this, but for these distributions, its an add-on. CoreOS was designed from day one for containers.
If you foresee using containers in your businessand youd better because [Docker and containers are fast becoming  _The Way_  to develop and run business applications][24]then you must consider CoreOS Container Linux, no matter whether youre running on bare-metal, virtual machines, or the cloud.
* * *
_Please feel free to share below any comments or insights about your experience with or questions about CoreOS. And if you found this blog useful, please consider sharing it through social media._
* * *
_About the blogger: Steven J. Vaughan-Nichols is a veteran IT journalist whose estimable work can be found on a host of channels, including _ [_ZDNet.com_][25] _, _ [_PC Magazine_][26] _, _ [_InfoWorld_][27] _, _ [_ComputerWorld_][28] _, _ [_Linux Today_][29] _ and _ [_eWEEK_][30] _. Stevens IT expertise comes without parallelhe has even been a Jeopardy! clue. And while his views and cloud situations are solely his and dont necessarily reflect those of Linode, we are grateful for his contributions. He can be followed on Twitter (_ [_@sjvn_][31] _)._
--------------------------------------------------------------------------------
via: https://medium.com/linode-cube/the-what-why-and-wow-behind-the-coreos-container-linux-fa7ceae5593c
作者:[Steven J. Vaughan-Nichols ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://medium.com/linode-cube/the-what-why-and-wow-behind-the-coreos-container-linux-fa7ceae5593c
[1]:https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux
[2]:https://www.centos.org/
[3]:https://getfedora.org/
[4]:https://www.debian.org/
[5]:https://www.ubuntu.com/
[6]:https://www.suse.com/
[7]:https://coreos.com/os/docs/latest
[8]:https://www.linode.com/docs/platform/use-coreos-container-linux-on-linode
[9]:https://plus.google.com/+gregkroahhartman/posts/YvWFmPa9kVf
[10]:https://www.wired.com/2013/08/coreos-the-new-linux/
[11]:https://coreos.com/fest/
[12]:https://www.docker.com/
[13]:https://coreos.com/rkt
[14]:https://coreos.com/products/coreupdate/
[15]:https://github.com/coreos/etcd
[16]:http://yaml.org/
[17]:https://github.com/coreos/fleet
[18]:https://www.freedesktop.org/wiki/Software/systemd/
[19]:https://kubernetes.io/
[20]:https://coreos.com/os/docs/latest/cloud-config.html
[21]:https://insights.hpe.com/articles/what-is-chef-a-primer-for-devops-newbies-1704.html
[22]:https://blogs.dxc.technology/2017/06/08/coreos-moves-in-on-cloud-devops-with-kubernetes/
[23]:http://www.projectatomic.io/
[24]:http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/
[25]:http://www.zdnet.com/meet-the-team/us/steven-j-vaughan-nichols/
[26]:http://www.pcmag.com/author-bio/steven-j.-vaughan-nichols
[27]:http://www.infoworld.com/author/Steven-J.-Vaughan_Nichols/
[28]:http://www.computerworld.com/author/Steven-J.-Vaughan_Nichols/
[29]:http://www.linuxtoday.com/author/Steven+J.+Vaughan-Nichols/
[30]:http://www.eweek.com/cp/bio/Steven-J.-Vaughan-Nichols/
[31]:http://www.twitter.com/sjvn

View File

@@ -0,0 +1,225 @@
3 mistakes to avoid when learning to code in Python
============================================================
### These errors created big problems that took hours to solve.
![3 mistakes to avoid when learning to code in Python](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/blocks_building.png?itok=q0_Wo8Tr "3 mistakes to avoid when learning to code in Python")
Image by : opensource.com
It's never easy to admit when you do things wrong, but making errors is part of any learning process, from learning to walk to learning a new programming language, such as Python.
Here's a list of three things I got wrong when I was learning Python, presented so that newer Python programmers can avoid making the same mistakes. These are errors that either I got away with for a long time or that that created big problems that took hours to solve.
Take heed young coders, some of these mistakes are afternoon wasters!
### 1\. Mutable data types as default arguments in function definitions
It makes sense right? You have a little function that, let's say, searches for links on a current page and optionally appends it to another supplied list.
```
def search_for_links(page, add_to=[]):
    new_links = page.search_for_links()
    add_to.extend(new_links)
    return add_to
```
On the face of it, this looks like perfectly normal Python, and indeed it is. It works. But there are issues with it. If we supply a list for the **add_to** parameter, it works as expected. If, however, we let it use the default, something interesting happens.
Try the following code:
```
def fn(var1, var2=[]):
    var2.append(var1)
    print var2
fn(3)
fn(4)
fn(5)
```
You may expect that we would see:
**[3]
[4]
[5]**
But we actually see this:
**[3]
[3, 4]
[3, 4, 5]**
Why? Well, you see, the same list is used each time. In Python, when we write the function like this, the list is instantiated as part of the function's definition. It is not instantiated each time the function is run. This means that the function keeps using the exact same list object again and again, unless of course we supply another one:
```
fn(3, [4])
```
**[4, 3]**
Just as expected. The correct way to achieve the desired result is:
```
def fn(var1, var2=None):
    if not var2:
        var2 = []
    var2.append(var1)
```
Or, in our first example:
```
def search_for_links(page, add_to=None):
    if not add_to:
        add_to = []
    new_links = page.search_for_links()
    add_to.extend(new_links)
    return add_to
```
This moves the instantiation from module load time so that it happens every time the function runs. Note that for immutable data types, like [**tuples**][7], [**strings**][8], or [**ints**][9], this is not necessary. That means it is perfectly fine to do something like:
```
def func(message="my message"):
    print message
```
### 2\. Mutable data types as class variables
Hot on the heels of the last error is one that is very similar. Consider the following:
```
class URLCatcher(object):
    urls = []
    def add_url(self, url):
        self.urls.append(url)
```
This code looks perfectly normal. We have an object with a storage of URLs. When we call the **add_url** method, it adds a given URL to the store. Perfect right? Let's see it in action:
```
a = URLCatcher()
a.add_url('http://www.google.')
b = URLCatcher()
b.add_url('http://www.bbc.co.')
```
**b.urls
['[http://www.google.com][2]', '[http://www.bbc.co.uk][3]']**
**a.urls
['[http://www.google.com][4]', '[http://www.bbc.co.uk][5]']**
Wait, what?! We didn't expect that. We instantiated two separate objects, **a** and **b**. **A** was given one URL and **b** the other. How is it that both objects have both URLs?
Turns out it's kinda the same problem as in the first example. The URLs list is instantiated when the class definition is created. All instances of that class use the same list. Now, there are some cases where this is advantageous, but the majority of the time you don't want to do this. You want each object to have a separate store. To do that, we would modify the code like:
```
class URLCatcher(object):
    def __init__(self):
        self.urls = []
    def add_url(self, url):
        self.urls.append(url)
```
Now the URLs list is instantiated when the object is created. When we instantiate two separate objects, they will be using two separate lists.
### 3\. Mutable assignment errors
This one confused me for a while. Let's change gears a little and use another mutable datatype, the [**dict**][10].
```
a = {'1': "one", '2': 'two'}
```
Now let's assume we want to take that **dict** and use it someplace else, leaving the original intact.
```
b = a
b['3'] = 'three'
```
Simple eh?
Now let's look at our original dict, **a**, the one we didn't want to modify:
```
{'1': "one", '2': 'two', '3': 'three'}
```
Whoa, hold on a minute. What does **b** look like then?
```
{'1': "one", '2': 'two', '3': 'three'}
```
Wait what? But… let's step back and see what happens with our other immutable types, a **tuple** for instance:
```
c = (2, 3)
d = c
d = (4, 5)
```
Now **c** is:
**(2, 3)**
While **d** is:
**(4, 5)**
That functions as expected. So what happened in our example? When using mutable types, we get something that behaves a little more like a pointer from C. When we said **b = a** in the code above, what we really meant was: **b** is now also a reference to **a**. They both point to the same object in Python's memory. Sound familiar? That's because it's similar to the previous problems. In fact, this post should really have been called, "The Trouble with Mutables."
Does the same thing happen with lists? Yes. So how do we get around it? Well, we have to be very careful. If we really need to copy a list for processing, we can do so like:
```
b = a[:]
```
This will go through and copy a reference to each item in the list and place it in a new list. But be warned: If any objects in the list are mutable, we will again get references to those, rather than complete copies.
Imagine having a list on a piece of paper. In the original example, Person A and Person B are looking at the same piece of paper. If someone changes that list, both people will see the same changes. When we copy the references, each person now has their own list. But let's suppose that this list contains places to search for food. If "fridge" is first on the list, even when it is copied, both entries in both lists point to the same fridge. So if the fridge is modified by Person A, by say eating a large gateaux, Person B will also see that the gateaux is missing. There is no easy way around this. It is just something that you need to remember and code in a way that will not cause an issue.
Dicts function in the same way, and you can create this expensive copy by doing:
```
b = a.copy()
```
Again, this will only create a new dictionary pointing to the same entries that were present in the original. Thus, if we have two lists that are identical and we modify a mutable object that is pointed to by a key from dict 'a', the dict object present in dict 'b' will also see those changes.
The trouble with mutable data types is that they are powerful. None of the above are real problems; they are things to keep in mind to prevent issues. The expensive copy operations presented as solutions in the third item are unnecessary 99% of the time. Your program can and probably should be modified so that those copies are not even required in the first place.
_Happy coding! And feel free to ask questions in the comments._
--------------------------------------------------------------------------------
作者简介:
Pete Savage - Peter is a passionate Open Source enthusiast who has been promoting and using Open Source products for the last 10 years. He has volunteered in many different areas, starting in the Ubuntu community, before moving off into the realms of audio production and later into writing. Career wise he spent much of his early years managing and building datacenters as a sysadmin, before ending up working for Red Hat as a Principal Quailty Engineer for the CloudForms product. He occasionally pops out a
-----------------
via: https://opensource.com/article/17/6/3-things-i-did-wrong-learning-python
作者:[Pete Savage ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/psav
[1]:https://opensource.com/article/17/6/3-things-i-did-wrong-learning-python?rate=SfClhaQ6tQsJdKM8-YTNG00w53fsncvsNWafwuJbtqs
[2]:http://www.google.com/
[3]:http://www.bbc.co.uk/
[4]:http://www.google.com/
[5]:http://www.bbc.co.uk/
[6]:https://opensource.com/user/36026/feed
[7]:https://docs.python.org/2/library/functions.html?highlight=tuple#tuple
[8]:https://docs.python.org/2/library/string.html
[9]:https://docs.python.org/2/library/functions.html#int
[10]:https://docs.python.org/2/library/stdtypes.html?highlight=dict#dict
[11]:https://opensource.com/users/psav
[12]:https://opensource.com/article/17/6/3-things-i-did-wrong-learning-python#comments

View File

@@ -0,0 +1,149 @@
A introduction to creating documents in LaTeX
============================================================
### Learn to typeset documents in the LaTeX text markup language.
![A introduction to creating documents in LaTeX](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/idea_innovation_kid_education.png?itok=jpetC9wJ "A introduction to creating documents in LaTeX")
Image by : opensource.com
LaTeX (pronounced  _lay-tech_ ) is a method of creating documents using plain text, stylized using markup tags, similar to HTML/CSS or Markdown. LaTeX is most commonly used to create documents for academia, such as academic journals. In LaTeX, the author doesn't stylize the document directly, like in a word processor such as Microsoft Word, LibreOffice Writer, or Apple Pages; instead they write code in plain text that must be compiled to produce a PDF document.
### [intro.png][1]
![computer screen with LaTeX markup language](https://opensource.com/sites/default/files/u128651/intro.png "computer screen with LaTeX markup language")
### How to get started
To write in LaTeX, you'll need to install a LaTeX editor. I use a piece of free and open source software (FOSS) popular with academics called [TexStudio][8], which runs on Windows, Unix/Linux, BSD, and Mac OS X. You'll also need to install a distribution of the **Tex** typesetting system. I am writing on MacOS, so I use a distribution called [MacTex or BasicTex][9]. For Windows you can use [MiKTex][10], and Linux users should be able to find it in their repository.
Once you have downloaded TexStudio and a distribution of LaTeX, you should be ready to start typesetting your documents.
### Create your first document
In this short tutorial, we'll create a simple article with a headline, a subhead, and two paragraphs.
After you launch TexStudio, save your new document. (I called mine **helloworld.tex**, since I'm writing this tutorial in the Hello, World! tradition from programming.) Next, you need to add some boilerplate code at the top of your **.tex** file that specifies the type and size of your document. This is similar to the boilerplate code used in HTML5 documents.
My code (below) sets the page size to A4 and the text size to 12pt. You can put this code into TexStudio and edit it with your own page size, font size, name, title, and other details:
```
\documentclass[a4paper,12pt]{article}
\begin{document}
\title{Hello World! My first LaTeX document}
\author{Aaron Cocker}
\date{\today}
\maketitle
content will go here
\end{document}
```
Next, click on the large green arrow to compile the document. That's the middle button in the screenshot below.
### [compile.png][2]
![compile button in TexStudio](https://opensource.com/sites/default/files/u128651/compile.png "compile button in TexStudio")
If there are any errors, they'll appear in the dialog box at the bottom.
After you compile the document, you can see what it will look like by viewing a PDF within the program as a sort of WYSIWYG preview. Remember it must be recompiled whenever you make a change to the code, as you would when programming in C++, for example.
To view your document, click on **Tools > Commands > View PDF**, as shown in the screenshot below.
### [view_as_pdf.png][3]
![Menu to view a PDF](https://opensource.com/sites/default/files/u128651/view_as_pdf.png "Menu to view a PDF")
The PDF output will be shown on the right, like this:
### [pdf_output.png][4]
![Viewing the LaTeX code as PDF](https://opensource.com/sites/default/files/u128651/pdf_output.png "Viewing the LaTeX code as PDF")
Now you can add a paragraph. First give it a subhead by using the **\section{}**command. Type the subhead title between the curly braces of the command; I called my subhead **Introduction**.
```
\section{Introduction}
```
Now that you have labeled the paragraph with its subhead, it's time to write the paragraph. For this example, I used the Lipsum [lorem ipsum generator][11]. To create the paragraph, type the **\paragraph{}** command, then add your text  _underneath_ ,  _NOT within_ , the curly braces, inserted between **\maketitle** and **\end{document}**.
This is what my paragraph code looks like:
```
\section{Introduction}
\paragraph{}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras lorem nisi, tincidunt tempus sem nec, elementum feugiat ipsum. Nulla in diam libero. Nunc tristique ex a nibh egestas sollicitudin.
\paragraph{}
Mauris efficitur vitae ex id egestas. Vestibulum ligula felis, pulvinar a posuere id, luctus vitae leo. Sed ac imperdiet orci, non elementum leo. Nullam molestie congue placerat. Phasellus tempor et libero maximus commodo.
```
Your document is now finished, so you can export and save it as a PDF file by using **Save As** (just as you would with most programs).
Here's what my finished document and the corresponding code look like:
### [finished_document.png][5]
![The finished document with code and the PDF output side-by-side](https://opensource.com/sites/default/files/u128651/finished_document.png "The finished document with code and the PDF output side-by-side")
All my code from this tutorial is available below:
```
\documentclass[a4paper,12pt]{article}
\begin{document}
\title{Hello World! My first LaTeX document}
\author{Aaron Cocker}
\date{\today}
\maketitle
\section{Introduction}
\paragraph{}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras lorem nisi, tincidunt tempus sem nec, elementum feugiat ipsum. Nulla in diam libero. Nunc tristique ex a nibh egestas sollicitudin.
\paragraph{}
Mauris efficitur vitae ex id egestas. Vestibulum ligula felis, pulvinar a posuere id, luctus vitae leo. Sed ac imperdiet orci, non elementum leo. Nullam molestie congue placerat. Phasellus tempor et libero maximus commodo.
\end{document}
```
### Learn more
Among the thousands of excellent resources on writing in LaTeX are the guides produced by most universities, which are indexable and can be found on Google search. [Princeton University][12] offers a good extended tutorial, and for a deeper dive, the Princeton guide's creator, Donald Knuth, offers [The TexBook][13], the ultimate guide to LaTeX.
--------------------------------------------------------------------------------
作者简介:
Aaron Cocker - BSc Computing student attending university in the UK. I am an aspiring Data Scientist. My favourite language is Python. Feel free to contact me at aaron@aaroncocker.org.uk or visit my personal website: https://aaroncocker.org.uk
---------------
via: https://opensource.com/article/17/6/introduction-latex
作者:[ Aaron Cocker][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/aaroncocker
[1]:https://opensource.com/file/356521
[2]:https://opensource.com/file/356526
[3]:https://opensource.com/file/356541
[4]:https://opensource.com/file/356536
[5]:https://opensource.com/file/356531
[6]:https://opensource.com/article/17/6/introduction-latex?rate=n5CmhY55ZhQRMjd6n5-f2p9f7iGg0nAWh_Bi6jqMMyc
[7]:https://opensource.com/user/123226/feed
[8]:http://www.texstudio.org/
[9]:https://www.tug.org/mactex/morepackages.html
[10]:https://miktex.org/download
[11]:http://www.lipsum.com/feed/html
[12]:https://www.cs.princeton.edu/courses/archive/spr10/cos433/Latex/latex-guide.pdf
[13]:http://www.ctex.org/documents/shredder/src/texbook.pdf
[14]:https://opensource.com/users/aaroncocker
[15]:https://opensource.com/article/17/6/introduction-latex#comments

View File

@@ -0,0 +1,85 @@
Chromebook Dual Boot How-to: Ubuntu 17.04 GNOME and Chrome OS
============================================================
### This tutorial uses the famous Crouton installer
Last year when I got my Acer Chromebook 11 (C740), I wrote a tutorial to teach you guys how to [remove Google Chrome OS and install a GNU/Linux distribution][1] of your choice, but things got boring.
So after a few months, I reinstalled Chrome OS using a recovery image that Google provides on their website for this sort of things, which I wrote on a USB flash drive and booted from my Chromebook. Recently, I got bored again, and so I decided to install Ubuntu on my Acer Chromebook 11 (C740) using Crouton.
Why? Because of a friend who came one day at a meeting we had with his laptop, a Dell Chromebook 13, on which he ran Ubuntu Linux alongside Chrome OS. It was really cool to see him switch so easily between the two operating systems with a simple keyboard shortcut that it made me wanna do the same.
There are a lot of tutorials out there explaining how to install various releases of Ubuntu, Debian or  Kali Linux (these are the GNU/Linux distros currently supported by the Crouton installer), but I wanted to run the latest Ubuntu release, Ubuntu 17.04 (Zesty Zapus) in this case, with the GNOME 3.24 desktop environment.
How to enable Developer Mode and download Crouton
When I asked my friend which Ubuntu version is he running on his Chromebook, the answer was Ubuntu 14.04 LTS (Trusty Tahr), which I have to admit that it disappointed me. Immediately when I got home, I got my Chromebook and tried to see if I could run Ubuntu 17.04, with the GNOME desktop environment.
The first thing I did was to put my Chromebook in Developer Mode. To do that, you'll have to shut down your Chromebook without closing the lid, then hold the ESC, Refresh and Power buttons at the same time for a few seconds until you enter recovery mode, which will wipe all the data on your Chromebook.
It will take a few minutes to enter Developer Mode so be patient. When it's ready, you'll have to log in with your Google account and set various things like wallpaper or your avatar the way it was before. Now that you are in Developer Mode, access this tutorial on your Chromebook and [download Crouton][2], which will be saved in the Downloads folder.
How to install Ubuntu 17.04 with GNOME 3.24 using Crouton
Now, open Google Chrome and press CTRL+ALT+T to open the Chrome OS' terminal emulator, which is called crosh. At the command-line prompt, type the "shell" command (without quotes) and press Enter to access the Linux shell. Let's see what Crouton can do for us now.
There are two commands (listed below) that you can run to see which GNU/Linux distributions and desktop environments Crouton supports, and we can tell you that it's possible to install Debian 7 "Wheezy", Debian 8 "Jessie", Debian 9 "Stretch" and Debian Sid, Kali Linux Rolling, as well as Ubuntu 12.04 LTS, Ubuntu 14.04 LTS, and Ubuntu 16.04 LTS.
`sh -e /Downloads/crouton -r list -  _will list supported distros_
sh -e /Downloads/crouton -t list -  _will list supported desktops_`
Crouton will also list a bunch of older releases of Debian, Kali and Ubuntu, which are upstream end-of-life (all of them being marked with an exclamation mark after their name) and which you should not install because of security risks, as well as two unsupported versions of Ubuntu, namely Ubuntu 16.10 and Ubuntu 17.04.
The developers of Crouton say that these "unsupported" Ubuntu release may work with some effort, but I took my chance and installed Ubuntu 17.04 (Zesty Zapus) with the GNOME 3.24 desktop environment (without any extra apps) using the following command. I put the "-e" parameter to encrypt the installation.
`sh -e /Downloads/crouton -e -r zesty -t gnome`
It will take a few minutes for everything to be downloaded and installed in the chrooted environment that Crouton will create inside your Chromebook so, again, be patient. When it's done, you'll know it, and you'll be able to start Ubuntu 17.04 with GNOME by running the following command at the shell prompt.
`sudo startgnome`
And voila! I'm running Ubuntu 17.04 (Zesty Zapus) with the GNOME 3.24 desktop environment on my old Acer Chromebook 11 (C740), which Google is yet to support with Android apps. The best part is that I can easily switch between Chrome OS and Ubuntu 17.04 using the CTRL+ALT+Shift+Back/Forward keyboard shortcuts.
As an ending note, I would like to bring to your attention that because your Chromebook is now always in Developer Mode, you will always see a warning screen saying "OS verification is OFF - Press SPACE to re-enable" when the battery dies or you shut down and turn on the device, so press CTRL+D when you see that screen to boot. Have fun!
[Ubuntu 17.04][9]
[GNOME 3.24][10]
[Chromebook][11]
[Acer Chrombook 11][12]
[Linux][13]
### Ubuntu 17.04 on Acer Chrombook 11 (4 Images)
[![Ubuntu 17.04 with GNOME 3.24 running on Acer Chromebook 11 (C740)](http://i1-news.softpedia-static.com/images/fitted/620x/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-2.jpg)][18] [![GNOME 3.24 desktop - System menu](http://i1-news.softpedia-static.com/images/newsrsz/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-3.jpg)][14] [![GNOME 3.24 desktop - Calendar applet](http://i1-news.softpedia-static.com/images/newsrsz/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-4.jpg)][15] [![GNOME 3.24 desktop - Overview mode](http://i1-news.softpedia-static.com/images/newsrsz/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-5.jpg)][16]
--------------------------------------------------------------------------------
via: http://news.softpedia.com/news/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624.shtml
作者:[ Marius Nestor ][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://news.softpedia.com/editors/browse/marius-nestor
[1]:http://news.softpedia.com/news/here-s-how-to-install-any-linux-operating-system-on-your-chromebook-506212.shtml
[2]:https://goo.gl/fd3zc
[3]:http://news.softpedia.com/editors/browse/marius-nestor
[4]:http://news.softpedia.com/news/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624.shtml#
[5]:https://share.flipboard.com/bookmarklet/popout?v=2&title=Chromebook+Dual+Boot+How-to%3A+Ubuntu+17.04+GNOME+and+Chrome+OS&url=http%3A%2F%2Fnews.softpedia.com%2Fnews%2Fhow-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624.shtml&t=1498358928&utm_campaign=widgets&utm_medium=web&utm_source=flipit&utm_content=news.softpedia.com
[6]:http://news.softpedia.com/news/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624.shtml#
[7]:http://twitter.com/intent/tweet?related=softpedia&via=mariusnestor&text=Chromebook+Dual+Boot+How-to%3A+Ubuntu+17.04+GNOME+and+Chrome+OS&url=http%3A%2F%2Fnews.softpedia.com%2Fnews%2Fhow-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624.shtml
[8]:https://plus.google.com/share?url=http://news.softpedia.com/news/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624.shtml
[9]:http://news.softpedia.com/newsTag/Ubuntu%2017.04
[10]:http://news.softpedia.com/newsTag/GNOME%203.24
[11]:http://news.softpedia.com/newsTag/Chromebook
[12]:http://news.softpedia.com/newsTag/Acer%20Chrombook%2011
[13]:http://news.softpedia.com/newsTag/Linux
[14]:http://i1-news.softpedia-static.com/images/news2/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-3.jpg
[15]:http://i1-news.softpedia-static.com/images/news2/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-4.jpg
[16]:http://i1-news.softpedia-static.com/images/news2/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-5.jpg
[17]:https://twitter.com/intent/follow?screen_name=mariusnestor
[18]:http://i1-news.softpedia-static.com/images/news2/how-to-install-ubuntu-17-04-with-gnome-on-your-chromebook-alongside-chrome-os-516624-2.jpg

View File

@@ -0,0 +1,223 @@
Pass A Simple command-line Password Manager for Linux
============================================================
Keep tracking the password is one of the big challenge to everyone now a days since we has multiple password like email, bank, social media, online portal, and ftp, etc.,.
Password managers are become very famous due to the demand and usage. In Linux so many alternatives are available, GUI based and CLI based. Today we are going to discuss about CLI based password manager called pass.
[pass][2] is a simple command line password manager for Linux which stores password inside of a `gpg` encrypted file. These encrypted files are organized in well folder hierarchies.
All passwords live in `~/.password-store`, and it provides simple commands for adding, editing, generating, and retrieving passwords.
Suggested Read : [KeePass A Best Password Management Tool To Store/Secure Passwords][3]
It is a very short and simple shell script. Its capable of temporarily putting passwords on your clipboard and tracking password changes using git.
This is a small shell script which use few default tools like gnupg, tree and git, there are active community offering GUI & extensions for pass.
#### How to Install Pass in Linux
Pass is available in the repositories of most major distributions. So, use your distribution package manager to get installed.
For Debian based systems, use [apt-get][4] or [apt package manager][5] to install pass.
```
$ sudo apt-get install pass
```
For RHEL/CentOS based systems, use [yum package manager][6] to install pass.
```
$ sudo yum install pass
```
For Fedora system, use [dnf package manager][7] to install pass.
```
$ sudo dnf install pass
```
For openSUSE system, use [zypper package manager][8] to install pass.
```
$ sudo zypper in password-store
```
For Arch Linux based systems, use [pacman package manager][9] to install pass.
```
$ pacman -S pass
```
#### How to generate GPG key pair
Make sure you have your own GPG key pair. If no, create a GPG key pair by running following command on terminal and follow the instructions.
```
$ gpg --gen-key
```
The above command will ask a series of questions to create a GPG key pair, so input the required details carefully and few question you can leave default answer which is enough.
#### Initiate the password store
If you got a GPG key pair then initialize the local password store by running the following command, you can pass either `email-id or gpg-id`.
```
$ pass init 2daygeek@gmail.com
mkdir: created directory '/home/magi/.password-store/'
Password store initialized for 2daygeek@gmail.com
```
The above command will create a password store under `~/.password-store` directory.
pass command is offering simple syntax to manage password. Lets see one by one like adding, editing, generating, and retrieving passwords.
Check the hierarchical tree by firing below command.
```
$ pass
or
$ pass ls
or
$ pass show
Password Store
```
I didnt see any tree hierarchical, so we will create our own based on our requirement.
#### Insert a new password info
We are going to save gmail id and its password by running below command.
```
$ pass insert eMail/2daygeek@gmail.com
mkdir: created directory '/home/magi/.password-store/eMail'
Enter password for eMail/2daygeek@gmail.com:
Retype password for eMail/2daygeek@gmail.com:
```
Do the same until you insert all your entries. Saving Facebook credential.
```
$ pass insert Social/Facebook_2daygeek
mkdir: created directory '/home/magi/.password-store/Social'
Enter password for Social/Facebook_2daygeek:
Retype password for Social/Facebook_2daygeek:
```
We can list all the existing passwords in the store.
```
$ pass show
Password Store
├── 2g
├── Bank
├── eMail
│   ├── 2daygeek@gmail.com
│   └── magesh.maruthamuthu@gmail.com
├── eMail
├── Social
│   ├── Facebook_2daygeek
│   └── Gplus_2daygeek
├── Social
└── Sudha
└── sudha21.magesh@gmail.com
```
#### Show existing password
Run the following command to retrieve password info from password store, It will ask you to enter the passphrase to unlock.
[![](http://www.2daygeek.com/wp-content/uploads/2017/06/pass-command-line-package-manager-for-linux-1.png)][10]
```
$ pass eMail/2daygeek@gmail.com
*******
```
#### Copy the password in clipboard
To copy the password directly onto the clipboard temporarily instead of printing on terminal, use the following command which is more secure method and it will clear the password automatically after 45 seconds.
```
$ pass -c eMail/magesh.maruthamuthu@gmail.com
Copied eMail/magesh.maruthamuthu@gmail.com to clipboard. Will clear in 45 seconds.
```
#### Generate a new password
If you want to generate hard and guess password instead of odd one, it will do by using the pwgen utility internally.
```
$ pass generate eMail/2daygeek@gmail.com 15
An entry already exists for eMail/2daygeek@gmail.com. Overwrite it? [y/N] y
The generated password for eMail/2daygeek@gmail.com is:
y!NZ<%T)5Iwym_S
```
To generate password without symbols.
```
$ pass generate eMail/2daygeek@gmail.com 15 -n
An entry already exists for eMail/2daygeek@gmail.com. Overwrite it? [y/N] y
The generated password for eMail/2daygeek@gmail.com is:
TP9ACLyzUZUwBwO
```
#### Edit existing password
Insert a new password or edit an existing password using editor. When you run below command it will open the file `/dev/shm/pass.wUyGth1Hv0rnh/6kOBG-eMail-2daygeek@gmail.com.txt` in text editor which contain the password. Just add new password then save and exit.
```
$ pass edit eMail/2daygeek@gmail.com
File: /dev/shm/pass.wUyGth1Hv0rnh/6kOBG-eMail-2daygeek@gmail.com.txt
TP9ACLyzUZUwBwO
```
#### Remove a Password
To remove existing password. It will remove the entry from `~/.password-store` which is contain `.gpg`
```
$ pass rm eMail/2daygeek@gmail.com
Are you sure you would like to delete eMail/2daygeek@gmail.com? [y/N] y
removed '/home/magi/.password-store/eMail/2daygeek@gmail.com.gpg'
```
#### Multi-line Functionality
To save detailed info like, URL, username, password, pin, etc,., Use the following format. Make sure you have to add first entry as a password since it used to copy first line as a password when you use clipboard option, and the additional information on subsequent lines.
```
$ pass insert eMail/2daygeek@gmail.com -m
Enter contents of eMail/2daygeek@gmail.com and press Ctrl+D when finished:
H3$%hbhYT
URL : http://www.2daygeek.com
Info : Linux Tips & Tricks
Ftp User : 2g
```
--------------------------------------------------------------------------------
via: http://www.2daygeek.com/pass-command-line-password-manager-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://www.passwordstore.org/
[3]:http://www.2daygeek.com/keepass-best-linux-password-manager-arch-linux-mint-ubuntu-debian-fedora-opensuse/
[4]:http://www.2daygeek.com/apt-get-apt-cache-command-examples/
[5]:http://www.2daygeek.com/apt-command-examples/
[6]:http://www.2daygeek.com/yum-command-examples/
[7]:http://www.2daygeek.com/dnf-command-examples/
[8]:http://www.2daygeek.com/zypper-command-examples/
[9]:http://www.2daygeek.com/pacman-command-examples/
[10]:http://www.2daygeek.com/wp-content/uploads/2017/06/pass-command-line-package-manager-for-linux-1.png

View File

@@ -1,110 +0,0 @@
[Go 使用一周年][18]
============================================================
![](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 的生态系统。作为一个新语言,自我们开始开发产品以来已经有很多新版本。在这些新版本中的一些改变并不向后兼容,因此要使用最新库版本,我们要经常重新已有代码并检查我们为解决版本问题做的 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 开发者,并且在其他地方寻找也是一件非常困难的任务。
--------------------------------------------------------------------------------
via: https://bugfender.com/one-year-using-go
作者:[ALEIX VENTAYOL][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [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