mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-09-01 04:27:55 +08:00
@@ -1,76 +0,0 @@
|
||||
vim-kakali translating
|
||||
|
||||
|
||||
|
||||
Confessions of a cross-platform developer
|
||||
=============================================
|
||||
|
||||

|
||||
|
||||
[Andreia Gaita][1] is giving a talk at this year's OSCON, titled [Confessions of a cross-platform developer][2]. She's a long-time open source and [Mono][3] contributor, and develops primarily in C#/C++. Andreia works at GitHub, where she's focused on building the GitHub Extension manager for Visual Studio.
|
||||
|
||||
I caught up with Andreia ahead of her talk to ask about cross-platform development and what she's learned in her 16 years as a cross-platform developer.
|
||||
|
||||

|
||||
|
||||
**What languages have you found easiest and hardest to develop cross-platform code for?**
|
||||
|
||||
It's less about which languages are good and more about the libraries and tooling available for those languages. The compilers/interpreters/build systems available for languages determine how easy it is to do cross-platform work with them (or whether it's even possible), and the libraries available for UI and native system access determine how deep you can integrate with the OS. With that in mind, I found C# to be the best for cross-platform work. The language itself includes features that allow fast native calls and accurate memory mapping, which you really need if you want your code to talk to the OS and native libraries. When I need very specific OS integration, I switch to C or C++.
|
||||
|
||||
**What cross-platform toolkits/abstractions have you used?**
|
||||
|
||||
Most of my cross-platform work has been developing tools, libraries and bindings for other people to develop cross-platform applications with, mostly in Mono/C# and C/C++. I don't get to use a lot of abstractions at that level, beyond glib and friends. I mostly rely on Mono for any cross-platform app that includes a UI, and Unity3D for the occasional game development. I play with Electron every now and then.
|
||||
|
||||
**What has been your approach to build systems, and how does this vary by language or platform?**
|
||||
|
||||
I try to pick the build system that is most suited for the language(s) I'm using. That way, it'll (hopefully) give me less headaches. It needs to allow for platform and architecture selection, be smart about build artifact locations (for multiple parallel builds), and be decently configurable. Most of the time I have projects combining C/C++ and C# and I want to build all the different configurations at the same time from the same source tree (Debug, Release, Windows, OSX, Linux, Android, iOS, etc, etc.), and that usually requires selecting and invoking different compilers with different flags per output build artifact. So the build system has to let me do all of this without getting (too much) in my way. I try out different build systems every now and then, just to see what's new, but in the end, I end up going back to makefiles and a combination of either shell and batch scripts or Perl scripts for driving them (because if I want users to build my things, I'd better pick a command line script language that is available everywhere).
|
||||
|
||||
**How do you balance the desire for native look and feel with the need for uniform user interfaces?**
|
||||
|
||||
Cross-platform UI is hard! I've implemented several cross-platform GUIs over the years, and it's the one thing for which I don't think there's an optimal solution. There's basically two options. You can pick a cross-platform GUI toolkit and do a UI that doesn't feel quite right in all the platforms you support, with a small codebase and low maintenance cost. Or you can choose to develop platform-specific UIs that will look and feel native and well integrated with a larger codebase and higher maintenance cost. The decision really depends on the type of app, how many features it has, how many resources you have, and how many platforms you're shipping to.
|
||||
|
||||
In the end, I think there's an increase in users' tolerance for "One UI To Rule Them All" with frameworks like Electron. I have a Chromium+C+C# framework side project that will one day hopefully allow me build Electron-style apps in C#, giving me the best of both worlds.
|
||||
|
||||
**Has building/packaging dependencies been an issue for you?**
|
||||
|
||||
I'm very conservative about my use of dependencies, having been bitten so many times by breaking ABIs, clashing symbols, and missing packages. I decide which OS version(s) I'm targeting and pick the lowest common denominator release available of a dependency to minimize issues. That usually means having five different copies of Xcode and OSX Framework libraries, five different versions of Visual Studio installed side-to-side on the same machine, multiple clang and gcc versions, and a bunch of VMs running various other distros. If I'm unsure of the state of packages in the OS I'm targeting, I will sometimes link statically and sometimes submodule dependencies to make sure they're always available. And most of all, I avoid the bleeding edge unless I really, really need something there.
|
||||
|
||||
**Do you use continuous integration, code review, and related tools?**
|
||||
|
||||
All the time! It's the only way to keep sane. The first thing I do on a project is set up cross-platform build scripts to ensure everything is automateable as early as possible. When you're targeting multiple platforms, CI is essential. It's impossible for everyone to build all the different combinations of platforms in one machine, and as soon as you're not building all of them you're going to break something without being aware of it. In a shared multi-platform codebase, different people own different platforms and features, so the only way to guarantee quality is to have cross-team code reviews combined with CI and other analysis tools. It's no different than other software projects, there's just more points of failure.
|
||||
|
||||
**Do you rely on automated build testing, or do you tend to build on each platform and test locally?**
|
||||
|
||||
For tools and libraries that don't include UIs, I can usually get away with automated build testing. If there's a UI, then I need to do both—reliable, scriptable UI automation for existing GUI toolkits is rare to non-existent, so I would have to either invest in creating UI automation tools that work across all the platforms I want to support, or I do it manually. If a project uses a custom UI toolkit (like, say, an OpenGL UI like Unity3D does), then it's fairly easy to develop scriptable automation tools and automate most of that stuff. Still, there's nothing like the human ability to break things with a couple of clicks!
|
||||
|
||||
**If you are developing cross-platform, do you support cross-editor build systems so that you can use Visual Studio on Windows, Qt Creator on Linux, and XCode on Mac? Or do you tend toward supporting one platform such as Eclipse on all platforms?**
|
||||
|
||||
I favor cross-editor build systems. I prefer generating project files for different IDEs (preferably in a way that makes it easier to add more IDEs), with build scripts that can drive builds from the IDEs for the platform they're on. Editors are the most important tool for a developer. It takes time and effort to learn them, and they're not interchangeable. I have my favorite editors and tools, and everyone else should be able to use their favorite tool, too.
|
||||
|
||||
**What is your preferred editor/development environment/IDE for cross-platform development?**
|
||||
|
||||
The cross-platform developer is cursed with having to pick the lowest common denominator editor that works across the most platforms. I love Visual Studio, but I can't rely on it for anything except Windows work (and you really don't want to make Windows your primary cross-compiling platform), so I can't make it my primary IDE. Even if I could, an essential skill of cross-platform development is to know and use as many platforms as possible. That means really knowing them—using the platform's editors and libraries, getting to know the OS and its assumptions, behaviors, and limitations, etc. To do that and keep my sanity (and my shortcut muscle memory), I have to rely on cross-platform editors. So, I use Emacs and Sublime.
|
||||
|
||||
**What are some of your favorite past and current cross-platform projects?**
|
||||
|
||||
Mono is my all-time favorite, hands down, and most of the others revolve around it in some way. Gluezilla was a Mozilla binding I did years ago to allow C# apps to embed web browser views, and that one was a doozy. At one point I had a Winforms app, built on Linux, running on Windows with an embedded GTK view in it that was running a Mozilla browser view. The CppSharp project (formerly Cxxi, formerly CppInterop) is a project I started to generate C# bindings for C++ libraries so that you could call, create instances of, and subclass C++ classes from C#. It was done in such a way that it would detect at runtime what platform you'd be running on and what compiler was used to create the native library and generate the correct C# bindings for it. That was fun!
|
||||
|
||||
**Where do you see cross-platform development heading in the future?**
|
||||
|
||||
The way we build native applications is already changing, and I feel like the visual differences between the various desktop operating systems are going to become even more blurred so that it will become easier to build cross-platform apps that integrate reasonably well without being fully native. Unfortunately, that might mean applications will be worse in terms of accessibility and less innovative when it comes to using the OS to its full potential. Cross-platform development of tools, libraries, and runtimes is something that we know how to do well, but there's still a lot of work to do with cross-platform application development.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/business/16/5/oscon-interview-andreia-gaita
|
||||
|
||||
作者:[Marcus D. Hanwell ][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/mhanwell
|
||||
[1]: https://twitter.com/sh4na
|
||||
[2]: http://conferences.oreilly.com/oscon/open-source-us/public/schedule/detail/48702
|
||||
[3]: http://www.mono-project.com/
|
||||
@@ -0,0 +1,67 @@
|
||||
Android’s Next Revolution: Use Apps Even Without Installing Them!
|
||||
===================================================================
|
||||
|
||||
|
||||
A new innovation by Google’s Android will let you use apps even if they aren’t installed on your device. A few prototypes have already been made.
|
||||
|
||||
Remember that time when someone sent you a link that required you installing an app in order to view?
|
||||
|
||||
The dilemma of whether you should install the app just to view a one-time link may have frustrated you. Furthermore, the app installation itself may took some of your precious time as well.
|
||||
|
||||
The above scenario has probably been experienced by most, if not all, modern day technology users. Nonetheless, we’ve all came to accept that this is simply the correct and logical way by which things work.
|
||||
|
||||
Or is it?
|
||||
|
||||
To that question Google’s Android division came up with a new, out-of-the-box answer:
|
||||
|
||||
Android Instant Apps
|
||||
|
||||
Android Instant Apps purports to rid you of any such dilemmas in the first place by letting you simply click the link (see opening example) and start using the app straight away.
|
||||
|
||||
Another real life example of a scenario where Instant Apps might come handy, is the case you want to park your car but don’t have the parking meter matching app.
|
||||
|
||||
According to Google, you could simply tap your phone on the meter and the parking app will pop on your screen immediately, ready to be used.
|
||||
|
||||
How Does It Work?
|
||||
|
||||
Instant Apps are basically the same apps you’ve already familiarized yourself with, only with a twist – these apps have been trimmed and modularized in order to supply you only the essential parts required for you to complete a certain task.
|
||||
|
||||
For instance, expanding on the opening scenario as an example, in order to view a link, you don’t have to have a full featured app that can write, send, make coffee or whatever. All you need is the viewing feature – and that’s exactly what you’ll get.
|
||||
|
||||
That way the app could open up rapidly, allowing you to complete the task of which you came for.
|
||||
|
||||

|
||||
>AIA demo
|
||||
|
||||

|
||||
>B&H Photo (via Google Search)
|
||||
|
||||

|
||||
>BuzzFeedVideo (via a shared link)
|
||||
|
||||

|
||||
>Park and Pay (example) (via NFC)
|
||||
|
||||
|
||||
Sounds great, isn’t it? However, there are still many technical aspects need to be addressed.
|
||||
|
||||
For instance, from a security point of view: if any app can theoretically run on your device, even if you haven’t installed it – how will you keep your device safe from malaware attacks?
|
||||
|
||||
Therefore, in order to iron out such risks, Google is still working on the project, currently with a small set of partners which will gradually expand.
|
||||
|
||||
Eventually, Google plans to release AIA (Android Instant Apps) somewhere along next year.
|
||||
|
||||
relate: [Introducing Android Instant Apps][1]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.iwillfolo.com/androids-next-revolution-use-apps-even-without-installing-them/
|
||||
|
||||
作者:[iwillfolo][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.iwillfolo.com
|
||||
[1]: http://android-developers.blogspot.co.il/2016/05/android-instant-apps-evolving-apps.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+blogspot/hsDu+%28Android+Developers+Blog%29
|
||||
@@ -0,0 +1,60 @@
|
||||
Should distributors disable IPv4-mapped IPv6?
|
||||
=============================================
|
||||
|
||||
By all accounts, the Internet's transition to IPv6 has been a slow affair. In recent years, though, perhaps inspired by the exhaustion of the IPv4 address space, IPv6 usage has been [on the rise][1]. There is a corresponding interest in ensuring that applications work with both IPv4 and IPv6. But, as a recent discussion on the OpenBSD mailing list has highlighted, a mechanism designed to ease the transition to an IPv6 network may also make the net less secure — and Linux distributions may be configured insecurely by default.
|
||||
|
||||
### Address mapping
|
||||
|
||||
IPv6 may look like IPv4 in many ways, but it is a different protocol with a different address space. Server programs wanting to receive connections using either protocol must thus open separate sockets for the two different address families — AF_INET for IPv4, and AF_INET6 for IPv6. In particular, a program wishing to accept connections to any of a host's interfaces using either protocol will need to create an AF_INET socket bound to the all-zeroes wild-card address (0.0.0.0) and an AF_INET6 socket bound to the IPv6 equivalent (written as "::"). It must then listen for connections on both sockets — or so one would think.
|
||||
|
||||
Many years ago, in [RFC 3493][2], the IETF specified a mechanism by which a program could work with either protocol using a single IPv6 socket. With a socket enabled for this behavior, the program need only bind to :: to receive connections to all interfaces with both protocols. When an IPv4 connection is made to the bound port, the source address will be mapped into IPv6 as described in [RFC 2373][3]. So, for example, a program using this mode would see an incoming connection from 192.168.1.1 as originating from ::ffff:192.168.1.1 (the mixed notation is how such addresses are ordinarily written). The program can also open connections to IPv4 addresses by mapping them in the same manner.
|
||||
|
||||
The RFC calls for this behavior to be implemented by default, so most systems do so. There are exceptions, though, one of which is OpenBSD; there, programs wishing to work with both protocols can only do so by creating two independent sockets. A program that opens two sockets on Linux, though, will run into trouble: both the IPv4 and the IPv6 socket will try to bind to the IPv4 address(es), so whichever attempt comes second will fail. In other words, a program that binds a socket to a given port on :: will be bound to that port on both the IPv6 :: and the IPv4 0.0.0.0. If it then tries to bind an IPv4 socket to the same port on 0.0.0.0, the operation will fail as the port is already bound.
|
||||
|
||||
There is a way around that problem, of course; the program can call setsockopt() to turn on the IPV6_V6ONLY option. A program that opens two sockets and sets IPV6_V6ONLY should be portable across all systems.
|
||||
|
||||
Readers may be less than thoroughly shocked to learn that not every program out there gets all of this right. One of those, it turns out, is the [OpenNTPD][4] implementation of the Network Time Protocol. Brent Cook recently [proposed a small patch][5] adding the requisite setsockopt() call to the upstream OpenNTPD source, which lives within OpenBSD itself. That patch does not look likely to be accepted, though, for the most OpenBSD-like of reasons.
|
||||
|
||||
### Security concerns
|
||||
|
||||
As mentioned above, OpenBSD does not support IPv4-mapped IPv6 sockets at all. Even if a program tries to explicitly enable address mapping by setting the IPV6_V6ONLY option to zero, its author will be disappointed; that setting has no effect on OpenBSD systems. The reasoning behind this decision is that this mapping brings some security concerns with it. There are various types of attack surface that it opens up, but it all comes down to the provision of two different ways to reach the same port, each with its own access-control rules.
|
||||
|
||||
Any given server system may have set up firewall rules describing the allowed access to the port in question. There may also be mechanisms like TCP wrappers or a BPF-based filter in place, or a router on the net could be doing its own stateful connection filtering. The result is likely to be gaps in firewall protection and the potential for all kinds of confusion resulting from the same IPv4 address being reachable via two different protocols. If the address mapping is done at the edge of the network, the situation gets even more complex; see [this draft RFC from 2003][6] for a description of some other attack scenarios that come about if mapped addresses are transmitted between hosts.
|
||||
|
||||
Adapting systems and software to properly handle IPv4-mapped IPv6 addresses can certainly be done. But that adds to the overall complexity of the system, and it's a sure bet that this adaptation has not actually been done anywhere near as widely as it should be. As Theo de Raadt [put it][7]:
|
||||
|
||||
**Sometimes people put a bad idea into an RFC. Later they discover it is impossible to walk the idea back to the garbagebin. The result is concepts so complicated that everyone has to be a fulltime expert, on admin side and coder side**.
|
||||
|
||||
It is not at all clear how many of these full-time experts are actually out there configuring systems and networks where IPv4-mapped IPv6 addresses are in use.
|
||||
|
||||
One might well argue that, while IPv4-mapped IPv6 addresses create security hazards, there should be no harm in changing a program so that it turns off address mapping on systems that implement it. But Theo argues that this should not be done, for a couple of reasons. The first is that there are many broken programs out there, and it will never be possible to fix them all. But the real reason is to put pressure on distributors to turn off address mapping by default. As he put it: "**Eventually someone will understand the damage is systematic, and change the system defaults to 'secure by default'**."
|
||||
|
||||
### Address mapping on Linux
|
||||
|
||||
On Linux systems, address mapping is controlled by a sysctl knob called net.ipv6.bindv6only; it is set to zero (enabling address mapping) by default. Administrators (or distributors) can turn off mapping by setting this knob to one, but they would be well advised to be sure that their applications all work properly before deploying such a system in production. A quick survey suggests that none of the primary distributors change the default for this knob; Debian [changed the default][9] for the "squeeze" release in 2009, but the change broke enough packages ([anything involving Java][10], for example) that it was, [after a certain amount of Debian-style discussion][11], reverted. It would appear that quite a few programs rely on address mapping being enabled by default.
|
||||
|
||||
OpenBSD has the freedom to break things outside of its core system in the name of "secure by default"; Linux distributors tend to have a harder time getting away with such changes. So those distributors, being generally averse to receiving abuse from their users, are unlikely to change the default of the bindv6only knob anytime soon. The good news is that this functionality has been the default for years and stories of exploits are hard to find. But, as we all know, that provides no guarantees that exploits are not possible.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://lwn.net/Articles/688462/
|
||||
|
||||
作者:[Jonathan Corbet][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://lwn.net/
|
||||
[1]: https://www.google.com/intl/en/ipv6/statistics.html
|
||||
[2]: https://tools.ietf.org/html/rfc3493#section-3.7
|
||||
[3]: https://tools.ietf.org/html/rfc2373#page-10
|
||||
[4]: https://github.com/openntpd-portable/
|
||||
[5]: https://lwn.net/Articles/688464/
|
||||
[6]: https://tools.ietf.org/html/draft-itojun-v6ops-v4mapped-harmful-02
|
||||
[7]: https://lwn.net/Articles/688465/
|
||||
[8]: https://lwn.net/Articles/688466/
|
||||
[9]: https://lists.debian.org/debian-devel/2009/10/msg00541.html
|
||||
[10]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560056
|
||||
[11]: https://lists.debian.org/debian-devel/2010/04/msg00099.html
|
||||
190
sources/talk/20160531 Linux vs. Windows device driver model.md
Normal file
190
sources/talk/20160531 Linux vs. Windows device driver model.md
Normal file
@@ -0,0 +1,190 @@
|
||||
Linux vs. Windows device driver model : architecture, APIs and build environment comparison
|
||||
============================================================================================
|
||||
|
||||
Device drivers are parts of the operating system that facilitate usage of hardware devices via certain programming interface so that software applications can control and operate the devices. As each driver is specific to a particular operating system, you need separate Linux, Windows, or Unix device drivers to enable the use of your device on different computers. This is why when hiring a driver developer or choosing an R&D service provider, it is important to look at their experience of developing drivers for various operating system platforms.
|
||||
|
||||

|
||||
|
||||
The first step in driver development is to understand the differences in the way each operating system handles its drivers, underlying driver model and architecture it uses, as well as available development tools. For example, Linux driver model is very different from the Windows one. While Windows facilitates separation of the driver development and OS development and combines drivers and OS via a set of ABI calls, Linux device driver development does not rely on any stable ABI or API, with the driver code instead being incorporated into the kernel. Each of these models has its own set of advantages and drawbacks, but it is important to know them all if you want to provide a comprehensive support for your device.
|
||||
|
||||
In this article we will compare Windows and Linux device drivers and explore the differences in terms of their architecture, APIs, build development, and distribution, in hopes of providing you with an insight on how to start writing device drivers for each of these operating systems.
|
||||
|
||||
### 1. Device Driver Architecture
|
||||
|
||||
Windows device driver architecture is different from the one used in Linux drivers, with either of them having their own pros and cons. Differences are mainly influenced by the fact that Windows is a closed-source OS while Linux is open-source. Comparison of the Linux and Windows device driver architectures will help us understand the core differences behind Windows and Linux drivers.
|
||||
|
||||
#### 1.1. Windows driver architecture
|
||||
|
||||
While Linux kernel is distributed with drivers themselves, Windows kernel does not include device drivers. Instead, modern Windows device drivers are written using the Windows Driver Model (WDM) which fully supports plug-and-play and power management so that the drivers can be loaded and unloaded as necessary.
|
||||
|
||||
Requests from applications are handled by a part of Windows kernel called IO manager which transforms them into IO Request Packets (IRPs) which are used to identify the request and convey data between driver layers.
|
||||
|
||||
WDM provides three kinds of drivers, which form three layers:
|
||||
|
||||
- Filter drivers provide optional additional processing of IRPs.
|
||||
- Function drivers are the main drivers that implement interfaces to individual devices.
|
||||
- Bus drivers service various adapters and bus controllers that host devices.
|
||||
|
||||
An IRP passes these layers as it travels from the IO manager down to the hardware. Each layer can handle an IRP by itself and send it back to the IO manager. At the bottom there is Hardware Abstraction Layer (HAL) which provides a common interface to physical devices.
|
||||
|
||||
#### 1.2. Linux driver architecture
|
||||
|
||||
The core difference in Linux device driver architecture as compared to the Windows one is that Linux does not have a standard driver model or a clean separation into layers. Each device driver is usually implemented as a module that can be loaded and unloaded into the kernel dynamically. Linux provides means for plug-and-play support and power management so that drivers can use them to manage devices correctly, but this is not a requirement.
|
||||
|
||||
Modules export functions they provide and communicate by calling these functions and passing around arbitrary data structures. Requests from user applications come from the filesystem or networking level, and are converted into data structures as necessary. Modules can be stacked into layers, processing requests one after another, with some modules providing a common interface to a device family such as USB devices.
|
||||
|
||||
Linux device drivers support three kinds of devices:
|
||||
|
||||
- Character devices which implement a byte stream interface.
|
||||
- Block devices which host filesystems and perform IO with multibyte blocks of data.
|
||||
- Network interfaces which are used for transferring data packets through the network.
|
||||
|
||||
Linux also has a Hardware Abstraction Layer that acts as an interface to the actual hardware for the device drivers.
|
||||
|
||||
### 2. Device Driver APIs
|
||||
|
||||
Both Linux and Windows driver APIs are event-driven: the driver code executes only when some event happens: either when user applications want something from the device, or when the device has something to tell to the OS.
|
||||
|
||||
#### 2.1. Initialization
|
||||
|
||||
On Windows, drivers are represented by a DriverObject structure which is initialized during the execution of the DriverEntry function. This entry point also registers a number of callbacks to react to device addition and removal, driver unloading, and handling the incoming IRPs. Windows creates a device object when a device is connected, and this device object handles all application requests on behalf of the device driver.
|
||||
|
||||
As compared to Windows, Linux device driver lifetime is managed by kernel module's module_init and module_exit functions, which are called when the module is loaded or unloaded. They are responsible for registering the module to handle device requests using the internal kernel interfaces. The module has to create a device file (or a network interface), specify a numerical identifier of the device it wishes to manage, and register a number of callbacks to be called when the user interacts with the device file.
|
||||
|
||||
#### 2.2. Naming and claiming devices
|
||||
|
||||
##### **Registering devices on Windows**
|
||||
|
||||
Windows device driver is notified about newly connected devices in its AddDevice callback. It then proceeds to create a device object used to identify this particular driver instance for the device. Depending on the driver kind, device object can be a Physical Device Object (PDO), Function Device Object (FDO), or a Filter Device Object (FIDO). Device objects can be stacked, with a PDO in the bottom.
|
||||
|
||||
Device objects exist for the whole time the device is connected to the computer. DeviceExtension structure can be used to associate global data with a device object.
|
||||
|
||||
Device objects can have names of the form **\Device\DeviceName**, which are used by the system to identify and locate them. An application opens a file with such name using CreateFile API function, obtaining a handle, which then can be used to interact with the device.
|
||||
|
||||
However, usually only PDOs have distinct names. Unnamed devices can be accessed via device class interfaces. The device driver registers one or more interfaces identified by 128-bit globally unique identifiers (GUIDs). User applications can then obtain a handle to such device using known GUIDs.
|
||||
|
||||
##### **Registering devices on Linux**
|
||||
|
||||
On Linux user applications access the devices via file system entries, usually located in the /dev directory. The module creates all necessary entries during module initialization by calling kernel functions like register_chrdev. An application issues an open system call to obtain a file descriptor, which is then used to interact with the device. This call (and further system calls with the returned descriptor like read, write, or close) are then dispatched to callback functions installed by the module into structures like file_operations or block_device_operations.
|
||||
|
||||
The device driver module is responsible for allocating and maintaining any data structures necessary for its operation. A file structure passed into the file system callbacks has a private_data field, which can be used to store a pointer to driver-specific data. The block device and network interface APIs also provide similar fields.
|
||||
|
||||
While applications use file system nodes to locate devices, Linux uses a concept of major and minor numbers to identify devices and their drivers internally. A major number is used to identify device drivers, while a minor number is used by the driver to identify devices managed by it. The driver has to register itself in order to manage one or more fixed major numbers, or ask the system to allocate some unused number for it.
|
||||
|
||||
Currently, Linux uses 32-bit values for major-minor pairs, with 12 bits allocated for the major number allowing up to 4096 distinct drivers. The major-minor pairs are distinct for character and block devices, so a character device and a block device can use the same pair without conflicts. Network interfaces are identified by symbolic names like eth0, which are again distinct from major-minor numbers of both character and block devices.
|
||||
|
||||
#### 2.3. Exchanging data
|
||||
|
||||
Both Linux and Windows support three ways of transferring data between user-level applications and kernel-level drivers:
|
||||
|
||||
- **Buffered Input-Output** which uses buffers managed by the kernel. For write operations the kernel copies data from a user-space buffer into a kernel-allocated buffer, and passes it to the device driver. Reads are the same, with kernel copying data from a kernel buffer into the buffer provided by the application.
|
||||
- **Direct Input-Output** which does not involve copying. Instead, the kernel pins a user-allocated buffer in physical memory so that it remains there without being swapped out while data transfer is in progress.
|
||||
- **Memory mapping** can also be arranged by the kernel so that the kernel and user space applications can access the same pages of memory using distinct addresses.
|
||||
|
||||
##### **Driver IO modes on Windows**
|
||||
|
||||
Support for Buffered IO is a built-in feature of WDM. The buffer is accessible to the device driver via the AssociatedIrp.SystemBuffer field of the IRP structure. The driver simply reads from or writes to this buffer when it needs to communicate with the userspace.
|
||||
|
||||
Direct IO on Windows is mediated by memory descriptor lists (MDLs). These are semi-opaque structures accessible via MdlAddress field of the IRP. They are used to locate the physical address of the buffer allocated by the user application and pinned for the duration of the IO request.
|
||||
|
||||
The third option for data transfer on Windows is called METHOD_NEITHER. In this case the kernel simply passes the virtual addresses of user-space input and output buffers to the driver, without validating them or ensuring that they are mapped into physical memory accessible by the device driver. The device driver is responsible for handling the details of the data transfer.
|
||||
|
||||
##### **Driver IO modes on Linux**
|
||||
|
||||
Linux provides a number of functions like clear_user, copy_to_user, strncpy_from_user, and some others to perform buffered data transfers between the kernel and user memory. These functions validate pointers to data buffers and handle all details of the data transfer by safely copying the data buffer between memory regions.
|
||||
|
||||
However, drivers for block devices operate on entire data blocks of known size, which can be simply moved between the kernel and user address spaces without copying them. This case is automatically handled by Linux kernel for all block device drivers. The block request queue takes care of transferring data blocks without excess copying, and Linux system call interface takes care of converting file system requests into block requests.
|
||||
|
||||
Finally, the device driver can allocate some memory pages from kernel address space (which is non-swappable) and then use the remap_pfn_range function to map the pages directly into the address space of the user process. The application can then obtain the virtual address of this buffer and use it to communicate with the device driver.
|
||||
|
||||
### 3. Device Driver Development Environment
|
||||
|
||||
#### 3.1. Device driver frameworks
|
||||
|
||||
##### **Windows Driver Kit**
|
||||
|
||||
Windows is a closed-source operating system. Microsoft provides a Windows Driver Kit to facilitate Windows device driver development by non-Microsoft vendors. The kit contains all that is necessary to build, debug, verify, and package device drivers for Windows.
|
||||
|
||||
Windows Driver Model defines a clean interface framework for device drivers. Windows maintains source and binary compatibility of these interfaces. Compiled WDM drivers are generally forward-compatible: that is, an older driver can run on a newer system as is, without being recompiled, but of course it will not have access to the new features provided by the OS. However, drivers are not guaranteed to be backward-compatible.
|
||||
|
||||
##### **Linux source code**
|
||||
|
||||
In comparison to Windows, Linux is an open-source operating system, thus the entire source code of Linux is the SDK for driver development. There is no formal framework for device drivers, but Linux kernel includes numerous subsystems that provide common services like driver registration. The interfaces to these subsystems are described in kernel header files.
|
||||
|
||||
While Linux does have defined interfaces, these interfaces are not stable by design. Linux does not provide any guarantees about forward or backward compatibility. Device drivers are required to be recompiled to work with different kernel versions. No stability guarantees allow rapid development of Linux kernel as developers do not have to support older interfaces and can use the best approach to solve the problems at hand.
|
||||
|
||||
Such ever-changing environment does not pose any problems when writing in-tree drivers for Linux, as they are a part of the kernel source, because they are updated along with the kernel itself. However, closed-source drivers must be developed separately, out-of-tree, and they must be maintained to support different kernel versions. Thus Linux encourages device driver developers to maintain their drivers in-tree.
|
||||
|
||||
#### 3.2. Build system for device drivers
|
||||
|
||||
Windows Driver Kit adds driver development support for Microsoft Visual Studio, and includes a compiler used to build the driver code. Developing Windows device drivers is not much different from developing a user-space application in an IDE. Microsoft also provides an Enterprise Windows Driver Kit, which enables command-line build environment similar to the one of Linux.
|
||||
|
||||
Linux uses Makefiles as a build system for both in-tree and out-of-tree device drivers. Linux build system is quite developed and usually a device driver needs no more than a handful of lines to produce a working binary. Developers can use any [IDE][5] as long as it can handle Linux source code base and run make, or they can easily compile drivers manually from terminal.
|
||||
|
||||
#### 3.3. Documentation support
|
||||
|
||||
Windows has excellent documentation support for driver development. Windows Driver Kit includes documentation and sample driver code, abundant information about kernel interfaces is available via MSDN, and there exist numerous reference and guide books on driver development and Windows internals.
|
||||
|
||||
Linux documentation is not as descriptive, but this is alleviated with the whole source code of Linux being available to driver developers. The Documentation directory in the source tree documents some of the Linux subsystems, but there are [multiple books][4] concerning Linux device driver development and Linux kernel overviews, which are much more elaborate.
|
||||
|
||||
Linux does not provide designated samples of device drivers, but the source code of existing production drivers is available and can be used as a reference for developing new device drivers.
|
||||
|
||||
#### 3.4. Debugging support
|
||||
|
||||
Both Linux and Windows have logging facilities that can be used to trace-debug driver code. On Windows one would use DbgPrint function for this, while on Linux the function is called printk. However, not every problem can be resolved by using only logging and source code. Sometimes breakpoints are more useful as they allow to examine the dynamic behavior of the driver code. Interactive debugging is also essential for studying the reasons of crashes.
|
||||
|
||||
Windows supports interactive debugging via its kernel-level debugger WinDbg. This requires two machines connected via a serial port: a computer to run the debugged kernel, and another one to run the debugger and control the operating system being debugged. Windows Driver Kit includes debugging symbols for Windows kernel so Windows data structures will be partially visible in the debugger.
|
||||
|
||||
Linux also supports interactive debugging by means of KDB and KGDB. Debugging support can be built into the kernel and enabled at boot time. After that one can either debug the system directly via a physical keyboard, or connect to it from another machine via a serial port. KDB offers a simple command-line interface and it is the only way to debug the kernel on the same machine. However, KDB lacks source-level debugging support. KGDB provides a more complex interface via a serial port. It enables usage of standard application debuggers like GDB for debugging Linux kernel just like any other userspace application.
|
||||
|
||||
### 4. Distributing Device Drivers
|
||||
|
||||
##### 4.1. Installing device drivers
|
||||
|
||||
On Windows installed drivers are described by text files called INF files, which are typically stored in C:\Windows\INF directory. These files are provided by the driver vendor and define which devices are serviced by the driver, where to find the driver binaries, the version of the driver, etc.
|
||||
|
||||
When a new device is plugged into the computer, Windows looks though
|
||||
installed drivers and loads an appropriate one. The driver will be automatically unloaded as soon as the device is removed.
|
||||
|
||||
On Linux some drivers are built into the kernel and stay permanently loaded. Non-essential ones are built as kernel modules, which are usually stored in the /lib/modules/kernel-version directory. This directory also contains various configuration files, like modules.dep describing dependencies between kernel modules.
|
||||
|
||||
While Linux kernel can load some of the modules at boot time itself, generally module loading is supervised by user-space applications. For example, init process may load some modules during system initialization, and the udev daemon is responsible for tracking the newly plugged devices and loading appropriate modules for them.
|
||||
|
||||
#### 4.2. Updating device drivers
|
||||
|
||||
Windows provides a stable binary interface for device drivers so in some cases it is not necessary to update driver binaries together with the system. Any necessary updates are handled by the Windows Update service, which is responsible for locating, downloading, and installing up-to-date versions of drivers appropriate for the system.
|
||||
|
||||
However, Linux does not provide a stable binary interface so it is necessary to recompile and update all necessary device drivers with each kernel update. Obviously, device drivers, which are built into the kernel are updated automatically, but out-of-tree modules pose a slight problem. The task of maintaining up-to-date module binaries is usually solved with [DKMS][3]: a service that automatically rebuilds all registered kernel modules when a new kernel version is installed.
|
||||
|
||||
#### 4.3. Security considerations
|
||||
|
||||
All Windows device drivers must be digitally signed before Windows loads them. It is okay to use self-signed certificates during development, but driver packages distributed to end users must be signed with valid certificates trusted by Microsoft. Vendors can obtain a Software Publisher Certificate from any trusted certificate authority authorized by Microsoft. This certificate is then cross-signed by Microsoft and the resulting cross-certificate is used to sign driver packages before the release.
|
||||
|
||||
Linux kernel can also be configured to verify signatures of kernel modules being loaded and disallow untrusted ones. The set of public keys trusted by the kernel is fixed at the build time and is fully configurable. The strictness of checks performed by the kernel is also configurable at build time and ranges from simply issuing warnings for untrusted modules to refusing to load anything with doubtful validity.
|
||||
|
||||
### 5. Conclusion
|
||||
|
||||
As shown above, Windows and Linux device driver infrastructure have some things in common, such as approaches to API, but many more details are rather different. The most prominent differences stem from the fact that Windows is a closed-source operating system developed by a commercial corporation. This is what makes good, documented, stable driver ABI and formal frameworks a requirement for Windows while on Linux it would be more of a nice addition to the source code. Documentation support is also much more developed in Windows environment as Microsoft has resources necessary to maintain it.
|
||||
|
||||
On the other hand, Linux does not constrain device driver developers with frameworks and the source code of the kernel and production device drivers can be just as helpful in the right hands. The lack of interface stability also has an implications as it means that up-to-date device drivers are always using the latest interfaces and the kernel itself carries lesser burden of backwards compatibility, which results in even cleaner code.
|
||||
|
||||
Knowing these differences as well as specifics for each system is a crucial first step in providing effective driver development and support for your devices. We hope that this Windows and Linux device driver development comparison was helpful in understanding them, and will serve as a great starting point in your study of device driver development process.
|
||||
|
||||
Download this article as ad-free PDF (made possible by [your kind donation][2]): [Download PDF][1]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/linux-vs-windows-device-driver-model.html
|
||||
|
||||
作者:[Dennis Turpitka][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://xmodulo.com/author/dennis
|
||||
[1]: http://xmodulo.com/linux-vs-windows-device-driver-model.html?format=pdf
|
||||
[2]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PBHS9R4MB9RX4
|
||||
[3]: http://xmodulo.com/build-kernel-module-dkms-linux.html
|
||||
[4]: http://xmodulo.com/go/linux_device_driver_books
|
||||
[5]: http://xmodulo.com/good-ide-for-c-cpp-linux.html
|
||||
55
sources/talk/20160531 The Anatomy of a Linux User.md
Normal file
55
sources/talk/20160531 The Anatomy of a Linux User.md
Normal file
@@ -0,0 +1,55 @@
|
||||
The Anatomy of a Linux User
|
||||
================================
|
||||
|
||||
|
||||
**Some new GNU/Linux users understand right away that Linux isn’t Windows. Others never quite get it. The best distro designers strive to keep both in mind.**
|
||||
|
||||
### The Heart of Linux
|
||||
|
||||
Nicky isn’t outwardly remarkable in any way. She’s a thirtysomething who decided to go back to school later in life than most. She spent six years in the Navy until she decided a job offer from an old friend would be a better bet than a career in the armed forces. That happens a lot in any of the post-war military service branches. It was at that job where I met her. She was the regional manager for an eight state trucking broker and I was driving for a meat packing outfit in Dallas.
|
||||
|
||||

|
||||
|
||||
We became good friends in 2006, Nicky and me. She’s an outgoing spirit, curious about almost anyone whose path she crosses. We had an ongoing Friday night date to go fight in an indoor laser combat arena. It wasn’t rare for us to burn through three 30 minute sessions in a row. Maybe it wasn’t as cheap as a paint ball arena, but it was climate controlled and had a horror game feel to it. It was during one of those outings that she asked me if I could fix her computer.
|
||||
|
||||
She knew about my efforts to get computers into the homes of disadvantaged kids and I kidded her about paying into Bill Gates’ 401K plan when she complained about her computer becoming too slow. Nicky figured this was as good a time as any to see what Linux was all about.
|
||||
|
||||
Her computer was a decent machine, a mid 2005 Asus desktop with a Dell 19″ monitor. Unfortunately, it had all the obligatory toolbars and popups that a Windows computer can collect when not properly tended. After getting all of the files from the computer, we began the process of installing Linux. We sat together during the install process and I made sure she understood the partitioning process. Inside of an hour, she had a bright new and shiny PCLinuxOS desktop.
|
||||
|
||||
She remarked often, as she navigated her way through her new system, at how beautiful the system looked. She wasn’t mentioning this as an aside; she was almost hypnotized by the sleek beauty in front of her. She remarked that her screen “shimmered” with beauty. That’s something I took away from our install session and have made sure to deploy on every Linux computer I’ve installed since. I want the screen to shimmer for everyone.
|
||||
|
||||
The first week or so, she called or emailed me with the usual questions, but the one that was probably the most important was wanting to know how to save her OpenOffice documents so colleagues could read them. This is key when teaching anyone Linux or Open/LibreOffice. Most people just obey the first popup, allow the document to be saved in Open Document Format and get their fingers bit in the process.
|
||||
|
||||
There was a story going around a year or so ago about a high school kid who claimed he flunked an exam when his professor couldn’t open the file containing his paper. It made for some blustery comments from readers who couldn’t decide who was more of a moron, the kid for not having a clue or his professor for not having a ummm… clue of his own.
|
||||
|
||||
I know some college professors and each and every one of them could figure out how to open an ODF file. Heck, even as much as Microsoft can be grade A, blue-ribbon proprietary jerks, I think Microsoft Office has been able to open an ODT or ODF file for a while now. I can’t say for sure since I haven’t used Microsoft Office much since 2005.
|
||||
|
||||
Even in the bad ol’ days, when Microsoft was openly and flagrantly shoving their way onto enterprise desktops via their vendor lock-in, I never had a problem when conducting business or collaborating with users of Microsoft Office, because I became pro-active and never assumed. I would email the person or people I was to work with and ask what version of Office they were using. From that information, I could make sure to save my documents in a format they could readily open and read.
|
||||
|
||||
But back to Nicky, who put a lot of time into learning about her Linux computer. I was surprised by her enthusiasm.
|
||||
|
||||
Learning how to use Linux on the desktop is made much simpler when the person doing the learning realizes that all habits and tools for using Windows are to be left at the door. Even after telling our Reglue kids this, more often than not when I come back to do a check-up with them there is some_dodgy_file.exe on the desktop or in the download folder.
|
||||
|
||||
While we are in the general vicinity of discussing files, let’s talk about doing updates. For a long time I was dead set against having multiple program installers or updaters on the same computer. In the case of Mint, it was decided to disable the update ability completely within Synaptic and that frosted my flakes. But while for us older folks dpkg and apt are our friends, wise heads have prevailed and have come to understand that the command line doesn’t often seem warm and welcoming to new users.
|
||||
|
||||
I frothed at the mouth and raged against the machine over the crippling of Synaptic until it was ‘splained to me. Do you remember when you were just starting out and had full admin rights to your brand new Linux install? Remember when you combed through the massive amounts of software listed in Synaptic? Remember how you began check marking every cool program you found? Do you remember how many of those cool programs started with the letters “lib”?
|
||||
|
||||
Yeah, me too. I installed and broke a few brand new installations until I found out that those LIB files were the nuts and bolts of the application and not the application itself. That’s why the genius’ behind Linux Mint and Ubuntu have created smart, pretty-to-look-at and easy-to-use application installers. Synaptic is still there for us old heads, but for the people coming up behind us, there are just too many ways to leave a system open to major borks by installing lib files and the like. In the new installers, those files are tucked away and not even shown to the user. And really, that’s the way it should be.
|
||||
|
||||
Unless you are charging for support calls that is.
|
||||
|
||||
There are a lot of smarts built into today’s Linux distros and I applaud those folks because they make my job easier. Not every new user is a Nicky. She was pretty much an install and forget project for me, and she is in the minority. The majority of new Linux users can be needy at times.
|
||||
|
||||
That’s okay. They are the ones who will be teaching their kids how to use Linux.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://fossforce.com/2016/05/anatomy-linux-user/
|
||||
|
||||
作者:[Ken Starks][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://linuxlock.blogspot.com/
|
||||
@@ -0,0 +1,65 @@
|
||||
vim-kakali translating
|
||||
|
||||
Why Ubuntu-based Distros Are Leaders
|
||||
=========================================
|
||||
|
||||
Over the years, I've tried a number of great Linux distributions. The distros that had the greatest impact with me personally were those that maintained a strong community. But there's more to a popular distribution than a strong community. Popular Linux distributions tend to appeal to newcomers, often due to features that make using the distro easier. There are obviously exceptions to this, but generally speaking it is true.
|
||||
|
||||
One distribution that comes to mind is [Ubuntu][1]. Built from a solid [Debian][2] base, Ubuntu has not only become an incredibly popular Linux distro, it's also made countless other distributions such as Linux Mint a reality. In this article, I'll explore why I believe Ubuntu wins the Linux distribution wars and how it's influenced Linux on the desktop as a whole.
|
||||
|
||||
### Ubuntu is easy to use
|
||||
|
||||
Before I first tried Ubuntu years ago, I preferred using the KDE desktop. At that time, it was simply the environment I had the most experience with. The main reason is that KDE was the most popular option among various newbie-friendly Linux distributions. Newbie-friendly distros like Knoppix, Simply Mepis, Xandros, Linspire, amongst others and all of them pointed their users towards the welcoming arms of KDE.
|
||||
|
||||
At this time, KDE did what I needed it to do and I felt little reason to explore other desktop environments. Then one day after my Debian installation failed on me (due to my own user error), I decided to try out this "Ubuntu Dapper Drake" everyone was raving about. At that time, I was less than impressed with the screenshots I had seen, but figured it would be fun to try regardless.
|
||||
|
||||
The biggest impression Ubuntu Dapper Drake made on me was how cleanly everything was laid out. Bear in mind, I came from the KDE world where there were fifteen ways to make one menu change. Ubuntu's implementation of GNOME was very minimalist.
|
||||
|
||||
Flash forward to 2016 with the current 16.04 release: we have multiple Ubuntu flavors available, along with tons of distributions based on the Ubuntu base. The core thing all of these Ubuntu flavors and derivative distributions share in common is they're all designed to be easy to use. And when you're trying to grow your user base, stuff like this matters.
|
||||
|
||||
### Ubuntu LTS
|
||||
|
||||
In the past, I've almost always stuck with LTS releases for my main desktop. The x.10 releases were best left to my testing hard drive or perhaps even an old laptop. My reasons for this were simple – I had no interest in playing with short term releases on a production PC. I'm a busy guy and simply don't feel this is the best use of my time.
|
||||
|
||||
Speaking for myself, I think Ubuntu offering LTS releases is one of the big reasons why the distribution has experienced such success. Think about it – offering folks a desktop Linux distro that will be fully supported for a long period of time has its advantages. To be fair, Ubuntu's not alone here, as there are other distros that do this as well. But I think this LTS strategy bundled with a newbie friendly environment has done Ubuntu a world of good.
|
||||
|
||||
### Ubuntu Snap packages
|
||||
|
||||
In the past, users once raved about the ability to get newer software titles onto their systems using PPAs (personal package archives). Unfortunately, this technology has its shortcomings. Issues like PPA abandonment to discovery are both common issues when working with random software titles.
|
||||
|
||||
Then came the concept of [Snap packages][3]. Certainly not a completely new concept, as similar attempts have been made in the past. But what I think Snap will offer Ubuntu users in the long term is the ability to run the latest software without having to run the very latest Ubuntu release. While I still think we're seeing the early days of where Snap packages could end up, I'm excited at the prospect of bleeding edge software on a stable distribution release.
|
||||
|
||||
The obvious downside is how much disk space Snap packages might potentially use if you're running a lot of software. Not only that, but most software for Ubuntu has yet to officially make the switch over from deb packages. The first issue is solved with ample hard drive space while the latter will simply be a waiting game.
|
||||
|
||||
### Ubuntu Community
|
||||
|
||||
I'm among the first to admit that all of the major Linux distributions have great communities. However, I firmly believe that Ubuntu's community might be the most diverse in terms of folks from different walks of life. For example, we have forums ranging from Apple hardware support to gaming. That's a particularly wide variety of specialized discussions.
|
||||
|
||||
Going beyond the forums, Ubuntu also offers a highly defined community structure. This structure includes a council, technical board, [LoCo teams][4], and Developer Membership board. There are others, but these are the areas of the community structure that really stand out to me.
|
||||
|
||||
Then we have [Ask Ubuntu][5]. In my view, this feature should replace seeking help from the forums as I find it to be far more likely you'll get useful information from this area. Not only that, solutions provided that are voted highly accurate might even make it into the official documentation.
|
||||
|
||||
### Ubuntu's future
|
||||
|
||||
I think Ubuntu's Unity interface has done little to increase desktop adoption. I understand why it was implemented, how it's making things easier for Ubuntu developers and whatnot. But in the end, I also believe it's paved the way for Ubuntu MATE and Linux Mint to increase in popularity as well.
|
||||
|
||||
Another area that I wonder about is the future of Ubuntu's IRC and mailing lists. The fact is, neither lend themselves to bettering documentation like Ask Ubuntu can. As for mailing lists, I've always felt this was a painfully dated way to collaborate, but that's just me – others feel different and that's fine.
|
||||
|
||||
What say you? Do you think Ubuntu will remain a major player going into the future? Perhaps you believe Arch, Linux Mint or others will dethrone Ubuntu in terms of popularity. Hit the Comments and give your favorite distribution a shout-out. If your favorite is based on Ubuntu, explain why you prefer it over Ubuntu proper. I think many of us can mutually agree that, if nothing else, Ubuntu makes a pretty popular base from which to build other distributions.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.datamation.com/open-source/why-ubuntu-based-distros-are-leaders.html
|
||||
|
||||
作者:[Matt Hartley][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.datamation.com/author/Matt-Hartley-3080.html
|
||||
[1]: http://www.ubuntu.com/
|
||||
[2]: https://www.debian.org/
|
||||
[3]: http://www.datamation.com/open-source/ubuntu-snap-packages-the-good-the-bad-the-ugly.html
|
||||
[4]: http://loco.ubuntu.com/
|
||||
[5]: http://askubuntu.com/
|
||||
@@ -0,0 +1,39 @@
|
||||
Will Google Replace Passwords With A New Trust-Based Authentication Method?
|
||||
===========================================================================
|
||||
|
||||

|
||||
|
||||
A newly developed authentication method by Google will rate how trustworthy is your login and will authenticate it based on a “Trust Score”.
|
||||
|
||||
|
||||
Abacus is the name of the Google project that aims to rid you off of the nuisance which is remembering and typing passwords.
|
||||
|
||||
In latest Google I/O developer conference, the company has introduced a new feature stemming from the ambitious project, called “**Trust API**“.
|
||||
|
||||
The API (Application Programming Interface) which will be available for Android developers by the year end “if all goes well”, is intended to make use of Android devices’ various types of sensors in order to profile a user and create what they refer to as Trust Score.
|
||||
|
||||
Based on that Trust Score, an application which requires login credentials will be able to verify that indeed you are authorized to login and thus will not prompt for a password.
|
||||
|
||||

|
||||
>Abacus to Trust API
|
||||
|
||||
### A Point To Consider
|
||||
|
||||
Although the idea, functionality-wise, sounds pretty great – mitigating the burden which is password authentication.
|
||||
|
||||
The other side of the coin tough, is that once again, by doing so Google pushes us (deliberately or not) to give up our privacy in favor of ease of use.
|
||||
|
||||
Is it worth it? it’s up to you to decide…
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.iwillfolo.com/will-google-replace-passwords-with-a-new-trust-based-authentication-method/
|
||||
|
||||
作者:[iWillFolo][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.iwillfolo.com/
|
||||
@@ -0,0 +1,159 @@
|
||||
LAMP Stack Installation Guide on Ubuntu Server 16.04 LTS
|
||||
=========================================================
|
||||
|
||||
LAMP stack is a collection of free and open source softwares like **Linux**, Web Server (**Apache**), Database server (**MySQL / MariaDB**) and **PHP** (Scripting Language). LAMP is the platform which is required to install and build dynamic web sites and application like WordPress, Joomla, OpenCart and Drupal.
|
||||
|
||||
In this article i will describe how to install LAMP on Ubuntu Server 16.04 LTS, As We know that Ubuntu is a Linux based Operating system, so it provides the first component of LAMP and i am assuming Ubuntu Server 16.04 is already installed on your system.
|
||||
|
||||
### Installation of Web Server (Apache2) :
|
||||
|
||||
In Ubuntu Linux Web server comes with the name Apache2, Use the beneath apt command to install it.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo apt update
|
||||
linuxtechi@ubuntu:~$ sudo apt install apache2 -y
|
||||
```
|
||||
|
||||
When Apache2 package is installed then its service is automatically started and enabled across the reboot, In case it is not started and enabled, use the following command :
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo systemctl start apache2.service
|
||||
linuxtechi@ubuntu:~$ sudo systemctl enable apache2.service
|
||||
linuxtechi@ubuntu:~$ sudo systemctl status apache2.service
|
||||
```
|
||||
|
||||
If Ubuntu firewall (ufw) is active, then allow the Web Server ports (80 and 443) in firewall using below commands.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo ufw status
|
||||
Status: active
|
||||
linuxtechi@ubuntu:~$ sudo ufw allow in 'Apache Full'
|
||||
Rule added
|
||||
Rule added (v6)
|
||||
linuxtechi@ubuntu:~$
|
||||
```
|
||||
|
||||
### Access Web Server now :
|
||||
|
||||
Open the Web browser and type the IP Address or Host name of your server (http://IP_Address_OR_Host_Name), In my Case my server IP is ‘192.168.1.13’
|
||||
|
||||

|
||||
|
||||
### Installation of Data Base Server (MySQL Server 5.7) :
|
||||
|
||||
MySQL and MariaDB are the database servers in Ubuntu 16.04. MySQL Server and MariaDB Server’s packages are available in the default repositories and we can install either of the database. Run the following apt command to install MySQL Server from terminal.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo apt install mysql-server mysql-client
|
||||
```
|
||||
|
||||
During the installation, it will prompt us to set the root password of mysql server.
|
||||
|
||||

|
||||
|
||||
Confirm root password and click on ‘OK’
|
||||
|
||||

|
||||
|
||||
Installation of MySQL Server is completed Now. MySQL Service will be started and enabled automatically.We can verify the MySQL Server’s service using below systemcl command :
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo systemctl status mysql.service
|
||||
```
|
||||
|
||||
### Installation of MariaDB Server :
|
||||
|
||||
Use the beneath command to install MariaDB Server 10.0 from the terminal.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo apt install mariadb-server
|
||||
```
|
||||
|
||||
Run the following command to set root password of mariadb and disable other options like disable remote login.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo mysql_secure_installation
|
||||
```
|
||||
|
||||
### Installation of PHP ( Scripting Language ) :
|
||||
|
||||
PHP 7.0 is available in the Ubuntu repositories. Execute the beneath command from the terminal to install PHP 7 :
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo apt install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0
|
||||
```
|
||||
|
||||
Create a sample php page and place it in apache document root (/var/ww/html)
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ vi samplepage.php
|
||||
<?php
|
||||
phpinfo();
|
||||
?>
|
||||
```
|
||||
|
||||
Save and exit the file.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo mv samplepage.php /var/www/html/
|
||||
```
|
||||
|
||||
Now Access the sample PHP page from the Web Browser, type : “http://<Server_IP>/samplepage.php” , You should get the page like below.
|
||||
|
||||

|
||||
|
||||
Above Page shows that our PHP installation is completed successfully.
|
||||
|
||||
### Installation of phpMyAdmin :
|
||||
|
||||
phpMyAdmin allows us to perform all the database related administrative and other DB operation task from its web interface. Its package is already listed in the Ubuntu server repositories.
|
||||
|
||||
Use the below commands to Install phpMyAdmin on Ubuntu server 16.04 LTS.
|
||||
|
||||
```
|
||||
linuxtechi@ubuntu:~$ sudo apt install php-mbstring php7.0-mbstring php-gettext
|
||||
linuxtechi@ubuntu:~$ sudo systemctl restart apache2.service
|
||||
linuxtechi@ubuntu:~$ sudo apt install phpmyadmin
|
||||
```
|
||||
|
||||
During its installation it will prompt us to choose the Web server to be configured for phpMyAdmin.
|
||||
|
||||
Select Apache2 and Click on OK.
|
||||
|
||||

|
||||
|
||||
Click on ‘Yes’ to Configure database for phpMyAdmin.
|
||||
|
||||

|
||||
|
||||
Specify the password for phpMyAdmin to register with Database Server.
|
||||
|
||||

|
||||
|
||||
Confirm the password for phpMyAdmin and then click on ‘OK’
|
||||
|
||||

|
||||
|
||||
Now try to access the phpMyAdmin, open the browser type : “http://Server_IP_OR_Host_Name/phpmyadmin”
|
||||
|
||||
Use the user name as ‘root’ and password that we set during the installation.
|
||||
|
||||

|
||||
|
||||
When we click on ‘Go’, it will redirect the page to ‘phpMyAdmin’ Web interface as shown below.
|
||||
|
||||

|
||||
|
||||
That’s it, LAMP stack is successfully installed and is ready for use 🙂 . Please share your feedback and comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.linuxtechi.com/lamp-stack-installation-on-ubuntu-server-16-04/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.linuxtechi.com/author/pradeep/
|
||||
176
sources/tech/20160601 scp command in Linux.md
Normal file
176
sources/tech/20160601 scp command in Linux.md
Normal file
@@ -0,0 +1,176 @@
|
||||
scp command in Linux
|
||||
=======================
|
||||
|
||||

|
||||
|
||||
|
||||
scp means Secure Copy Protocol, already every Linux/Unix user known about cp command well. scp also works like cp command, cp command copies files or folders from one location i.e source to other location i.e target in local system, but scp copies the files from one host to another host in network.
|
||||
|
||||
The usage of the scp command is as follows, here i copy a file named importantfile from local system(10.10.16.147) to Remote system(10.0.0.6) here instead of ip address you can also use System name.
|
||||
|
||||
```
|
||||
[root@localhost ~]# scp importantfile admin@10.0.0.6:/home/admin/
|
||||
The authenticity of host '10.0.0.6 (10.0.0.6)' can't be established.
|
||||
RSA key fingerprint is SHA256:LqBzkeGa6K9BfWWKgcKlQoE0u+gjorX0lPLx5YftX1Y.
|
||||
RSA key fingerprint is MD5:ed:44:42:59:3e:dd:4c:12:43:4a:89:b1:5d:bd:9e:20.
|
||||
Are you sure you want to continue connecting (yes/no)? yes
|
||||
Warning: Permanently added '10.0.0.6' (RSA) to the list of known hosts.
|
||||
admin@10.0.0.6's password:
|
||||
importantfile 100% 0 0.0KB/s 00:00
|
||||
[root@localhost ~]#
|
||||
```
|
||||
|
||||
Similarly if you want to get a file from remote system you can use scp command as follows
|
||||
|
||||
```
|
||||
[root@localhost ~]# scp root@10.10.16.137:/root/importantfile /home/admin/
|
||||
The authenticity of host '10.10.16.137 (10.10.16.137)' can't be established.
|
||||
RSA key fingerprint is b0:b0:a3:c3:2e:94:13:0c:29:2e:ba:0b:d3:d6:12:8f.
|
||||
Are you sure you want to continue connecting (yes/no)? yes
|
||||
Warning: Permanently added '10.10.16.137' (RSA) to the list of known hosts.
|
||||
root@10.10.16.137's password:
|
||||
importantfile 100% 0 0.0KB/s 00:00
|
||||
[root@localhost ~]#
|
||||
```
|
||||
|
||||
You can also use various options along with scp command like cp command,The man page of the scp command clearly explain about the usage of various options and advantages of that.
|
||||
|
||||
**Sample Output.**
|
||||
|
||||

|
||||
|
||||
```
|
||||
The options are as follows:
|
||||
|
||||
-B Selects batch mode (prevents asking for passwords or passphrases).
|
||||
|
||||
-C Compression enable. Passes the -C to enable compression.
|
||||
|
||||
-c cipher
|
||||
Selects the cipher to use for encrypting the data transfer. This
|
||||
option is directly passed to ssh(1).
|
||||
|
||||
-F ssh_config
|
||||
Specifies an alternative per-user configuration file for ssh.
|
||||
This option is directly passed to ssh(1).
|
||||
|
||||
-l limit
|
||||
Limits the used bandwidth, specified in Kbit/s.
|
||||
|
||||
-P port
|
||||
Specifies the port to connect to on the remote host. Note that
|
||||
this option is written with a capital ‘P’, because -p is already
|
||||
reserved for preserving the times and modes of the file.
|
||||
|
||||
-p Preserves modification times, access times, and modes from the
|
||||
original file.
|
||||
|
||||
-q Quiet mode: disables the progress meter as well as warning and
|
||||
diagnostic messages from ssh(1).
|
||||
|
||||
-r Recursively copy entire directories. Note that scp follows sym‐
|
||||
bolic links encountered in the tree traversal.
|
||||
|
||||
-v Verbose mode. Causes scp and ssh(1) to print debugging messages
|
||||
about their progress. This is helpful in debugging connection,
|
||||
authentication, and configuration problems.
|
||||
|
||||
```
|
||||
|
||||
The scp command along with -v option you can get detailed information about authentication, debugging information etc.
|
||||
|
||||

|
||||
|
||||
Sample output is like when we pass the option `-v`
|
||||
|
||||
```
|
||||
[root@localhost ~]# scp -v abc.txt admin@10.0.0.6:/home/admin
|
||||
Executing: program /usr/bin/ssh host 10.0.0.6, user admin,
|
||||
command scp -v -t/home/admin
|
||||
OpenSSH_7.1p1, OpenSSL 1.0.2d-fips 9 Jul 2015
|
||||
debug1: Reading configuration data /etc/ssh/ssh_config
|
||||
debug1: /etc/ssh/ssh_config line 56: Applying options for *
|
||||
debug1: Connecting to 10.0.0.6 [10.0.0.6] port 22.
|
||||
debug1: Connection established.
|
||||
debug1: Server host key: ssh-rsa SHA256:LqBzkeGa6K9BfWWKgcKlQoE0u+gjorX0lPLx5YftX1Y
|
||||
debug1: Next authentication method: publickey
|
||||
debug1: Trying private key: /root/.ssh/id_rsa
|
||||
debug1: Trying private key: /root/.ssh/id_dsa
|
||||
debug1: Trying private key: /root/.ssh/id_ecdsa
|
||||
debug1: Trying private key: /root/.ssh/id_ed25519
|
||||
debug1: Next authentication method: password
|
||||
admin@10.0.0.6's password:
|
||||
debug1: Authentication succeeded (password).
|
||||
Authenticated to 10.0.0.6 ([10.0.0.6]:22).
|
||||
debug1: channel 0: new [client-session]
|
||||
debug1: Requesting no-more-sessions@openssh.com
|
||||
debug1: Entering interactive session.
|
||||
debug1: Sending environment.
|
||||
debug1: Sending command: scp -v -t /home/admin
|
||||
Sending file modes: C0644 174 abc.txt
|
||||
Sink: C0644 174 abc.txt
|
||||
abc.txt 100% 174 0.2KB/s 00:00
|
||||
Transferred: sent 3024, received 2584 bytes, in 0.3 seconds
|
||||
Bytes per second: sent 9863.3, received 8428.1
|
||||
debug1: Exit status 0
|
||||
[root@localhost ~]#
|
||||
```
|
||||
|
||||
If we need to copy the Directories or folders we can use the option –r. It Recursively copy entire directories
|
||||
|
||||

|
||||
|
||||
Quiet mode:
|
||||
|
||||
If you want disables the progress meter as well as warning and diagnostic messages pass the argument -q along with scp command.
|
||||
|
||||

|
||||
|
||||
last time we pass the argument -r only then it shows the information file by file, but when we pass the argument -q it disables the progress meter this time.
|
||||
|
||||
Preserves modification times, access times, and modes from the original file by passing the option -p along with scp.
|
||||
|
||||

|
||||
|
||||
Specifies the port to connect to on the remote host by using the option -P.
|
||||
scp uses the ssh to transfer the files between hosts, ssh uses the port number 22 so the scp also uses the same port number 22.
|
||||
|
||||
If we want to change the port number we can pass the particular port number along with -P(capital P because small p uses for preserving access time etc.)
|
||||
|
||||
for example if we want to use port number 2222 then the command is as follows
|
||||
|
||||
```
|
||||
[root@localhost ~]# scp -P 2222 abcd1 root@10.10.16.137:/root/
|
||||
```
|
||||
|
||||
**Limits the used bandwidth, specified in Kbit/s**
|
||||
|
||||
we can limit the bandwidth by using the argument -l option as follows. here i used the limit is 512kbit/s
|
||||
|
||||

|
||||
|
||||
**Compression enable**
|
||||
|
||||
we can enable the compression mode when we transfer the data through scp command to save tha bandwidth and time as follows
|
||||
|
||||

|
||||
|
||||
**Selects the cipher to use for encrypting the data**
|
||||
|
||||
By default scp uses AES-128, if we want to change the encryption then we can pass the argument -c(small c) along with scp.
|
||||
|
||||

|
||||
|
||||
Now you can transfer the files between different nodes in your network securely by using scp(Secure copy).
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.unixmen.com/scp-command-linuxunix/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+unixmenhowtos+%28Unixmen+Howtos+%26+Tutorials%29
|
||||
|
||||
作者:[Naga Ramesh][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.unixmen.com/author/naga/
|
||||
@@ -0,0 +1,66 @@
|
||||
How to mount your Google Drive on Linux with google-drive-ocamlfuse
|
||||
========================================================================
|
||||
|
||||
>If you're looking for an easy way to mount your Google Drive folders to a Linux box, Jack Wallen shows you how with the help of google-drive-ocamlfuse.
|
||||
|
||||

|
||||
>Image: Jack Wallen
|
||||
|
||||
Google has yet to release a Linux version of its Google Drive app, though there are plenty of ways to gain access to your Drive files from Linux.
|
||||
|
||||
If you prefer a GUI tool, you've got Insync. If you prefer the command line, there are tools such as Grive2 and the incredibly easy to use FUSE-based system written in Ocaml. I'll show how to use the latter to mount your Google Drive account on your Linux desktop. Although it's done via the command line, you'll be surprised at how easy it is to pull off. It's so easy, anyone can do it.
|
||||
|
||||
This system features:
|
||||
|
||||
- Full read/write access to ordinary files/folders
|
||||
- Read-only access to Google Docs, sheets, and slides
|
||||
- Access to your Drive's Trash (.trash) Directory
|
||||
- Duplicate file handling
|
||||
- Support for multiple accounts
|
||||
|
||||
Let's walk through the installation and setup of google-drive-ocamlfuse on a Ubuntu 16.04 desktop so you can gain access to your Drive files.
|
||||
|
||||
### Installation
|
||||
|
||||
1. Open a terminal window.
|
||||
2. Add the necessary PPA with the command sudo add-apt-repository ppa:alessandro-strada/ppa.
|
||||
3. When prompted, type your sudo password and hit Enter.
|
||||
4. Update app with the command sudo apt-get update.
|
||||
5. Install the software by issuing the command sudo apt-get install google-drive-ocamlfuse.
|
||||
|
||||
### Authorization
|
||||
|
||||
The next step is to authorize google-drive-ocamlfuse so it will have access to your Google account. To do this, go back to the terminal window and issue the command google-drive-ocamlfuse. This command will open a browser window that will either prompt you to log into your Google account or, if you're already logged in, ask you to allow google-drive-ocamlfuse access to your Google account. If you've not logged in, do so and then click Allow. The next window (which appeared on a Ubuntu 16.04 desktop, but not an Elementary OS Freya desktop) will ask you to grant permission for both gdfuse and OAuth2 Endpoint to access your Google account. Click Allow again. The next browser screen will inform you to wait until the authorization tokens have downloaded; you can minimize the browser at this point. When your terminal prompt returns (Figure A), you know the tokens have been downloaded, and you're ready to mount.
|
||||
|
||||
**Figure A**
|
||||
|
||||

|
||||
>Image: Jack Wallen
|
||||
|
||||
**The app has been authorized, and you're ready to go.**
|
||||
|
||||
### Mounting your Google Drive
|
||||
|
||||
Before you mount your Google Drive, you must create a folder to serve as the mount point. From the terminal, issue the command mkdir ~/google-drive to create a new folder in your home directory. Finally, issue the command google-drive-ocamlfuse ~/google-drive to mount your Google Drive to the google-drive folder.
|
||||
|
||||
At this point, you should see your Google Drive files/folders populate in the google-drive folder. You can work with Google Drive as if it were a local folder system.
|
||||
|
||||
When you want to unmount the google-drive folder, issue the command fusermount -u ~/google-drive.
|
||||
|
||||
### It's no GUI, but it works like a champ
|
||||
|
||||
I find this particular system really handy to use. It's incredibly fast at syncing with Google Drive, and it can make for an elegant means of backing up your Google Drive account locally.
|
||||
|
||||
Give google-drive-ocamlfuse a go, and see what kind of magic you can make with it.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.techrepublic.com/article/how-to-mount-your-google-drive-on-linux-with-google-drive-ocamlfuse/
|
||||
|
||||
作者:[Jack Wallen ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://www.techrepublic.com/search/?a=jack+wallen
|
||||
@@ -0,0 +1,138 @@
|
||||
How To Install And Use VBoxManage On Ubuntu 16.04 And Use Its Command line Options
|
||||
======================================================================================
|
||||
|
||||
VirtualBox comes with a suite of command line utilities, and you can use the VirtualBox command line interfaces (CLIs) to manage VMs on a remote headless server. In this tutorial, we will show you how to create and start a VM without VirtualBox GUI using VBoxManage. VBoxManage is the command-line interface to VirtualBox taht you can use to completely control VirtualBox from the command line of your host operating system. VBoxManage supports all the features that the graphical user interface gives you access to, but it supports a lot more than that. It exposes really all the features of the virtualization engine, even those that cannot (yet) be accessed from the GUI. You will need to use the command line if you want to use a different user interface than the main GUI and control some of the more advanced and experimental configuration settings for a VM.
|
||||
|
||||
You will find VBoxManage helpful when you want to create and run virtual machines (VMs) on VirtualBox, but you only have access to a terminal on a remote host machine. This can be a common situation for servers where VMs are managed from remotely.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before we start using VBoxManage command line utility, make sure that you have root or sudo user access to your Ubuntu 16.04 server and the Oracle Virtual Box is already installed on it. Then you need to install VirtualBox Extension Pack which is needed to run a VRDE remote desktop server used to access headless VMs.
|
||||
|
||||
### Installing VBoxManage
|
||||
|
||||
You can get your required package by following the link to [Virtual Box Download Page][1] to get the latest extension pack, same version as your installed version of VirtualBox!.
|
||||
|
||||

|
||||
|
||||
You can also make use of below command to get the VBoxManage extension on your system
|
||||
|
||||
```
|
||||
$ wget http://download.virtualbox.org/virtualbox/5.0.20/Oracle_VM_VirtualBox_Extension_Pack-5.0.20-106931.vbox-extpack
|
||||
```
|
||||
|
||||

|
||||
|
||||
Run the below command to confirm that VBoxManage has been successfully installed.
|
||||
|
||||
```
|
||||
$ VBoxManage list extpacks
|
||||
```
|
||||
|
||||

|
||||
|
||||
### Using VBoxManage on Ubuntu 16.04
|
||||
|
||||
Now we are going to use VBoxManage to show you that how easily you can create and manage your virtual machines by using this utility from command line terminal.
|
||||
|
||||
Let’s run the below command to create a virtual machine for Ubuntu OS.
|
||||
|
||||
```
|
||||
# VBoxManage createvm --name Ubuntu16.04 --register
|
||||
```
|
||||
|
||||
After executing this command it will create virtual machine called “Ubuntu16.vbox” in home folder under “VirtualBox VMs/Ubuntu16/Ubuntu16.04.vbox” . In the above command, “createvm” is used to create a virtual machine and “–name“ defines the name of the virtual machine while “registervm” command is used to register the virtual machine.
|
||||
|
||||
Now, create the hard disk image for the virtual machine using the below command.
|
||||
|
||||
```
|
||||
$ VBoxManage createhd --filename Ubuntu16.04 --size 5124
|
||||
```
|
||||
|
||||
Here “createhd” is used to create hard disk image and “–filename” is used to specify the virtual machine’s name, for which the hard disk image is created. Here, “–size” denotes the size of the hard disk image. The size is always given in MB. Here we have specified 5Gb that is 5124MB.
|
||||
|
||||
Next we will set the OS type, if the Linux OS has to be installed, then specify the OS type as Linux or Ubuntu Or Fedora etc using below command.
|
||||
|
||||
```
|
||||
$ VBoxManage modifyvm Ubuntu16.04 --ostype Ubuntu
|
||||
```
|
||||
|
||||
Use below command to set the memory size for the virtual OS, i.e. the ram size for the virtual OS from the host Machine.
|
||||
|
||||
```
|
||||
$ VBoxManage modifyvm Ubuntu10.10 --memory 512
|
||||
```
|
||||
|
||||

|
||||
|
||||
Now we are going to create a storage controller for the virtual machine by using below command.
|
||||
|
||||
```
|
||||
$ VBoxManage storagectl Ubuntu16.04 --name IDE --add ide --controller PIIX4 --bootable on
|
||||
```
|
||||
|
||||
Here in above command ‘storagectl’ is used to create a storage controller for virtual machine,’–name’ specifies the name of the storage controller that needs to be created, modified or removed from the virtual machine. Then ‘–add’ defines the type of system bus to which the storage controller must be connected. Its available options are ide/sata/scsi/floppy. The ‘–controller’ option allows to choose the type of chipset that is to be emulated for the given storage controller while its available options are LsiLogic / LSILogicSAS / BusLogic / IntelAhci / PIIX3 / PIIX4 / ICH6 / I82078. At the end ‘–bootable’ defines whether this controller is bootable or not.
|
||||
|
||||
The above command creates the storage controller called IDE. Later the virtual media can be attached to the controller using ‘storageattach’ command.
|
||||
|
||||
Now run below command to create a storage controller called SATA, that will be used to attach the hard disk image to this later.
|
||||
|
||||
```
|
||||
$ VBoxManage storagectl Ubuntu16.04 --name SATA --add sata --controller IntelAhci --bootable on
|
||||
```
|
||||
|
||||
Attach the previously created disk image as well as CD/DVD drive to the IDE controller. Ubuntu installation ISO image which is then inserted to the CD/DVD drive. Now, attach the storage controller to the virtual machine using ‘storageattach’ command.
|
||||
|
||||
```
|
||||
$ VBoxManage storageattach Ubuntu16.04 --storagectl SATA --port 0 --device 0 --type hdd --medium "your_iso_filepath"
|
||||
```
|
||||
|
||||
This will attach the storage controller SATA to virtual machine Ubuntu16.04 with the medium i.e., to the virtual disk image which is created.
|
||||
|
||||
Run below commands to add some features like networking setup, audio, etc.
|
||||
|
||||
```
|
||||
$ VBoxManage modifyvm Ubuntu10.10 --nic1 nat --nictype1 82540EM --cableconnected1 on
|
||||
$ VBoxManage modifyvm Ubuntu10.10 --vram 128 --accelerate3d on --audio alsa --audiocontroller ac97
|
||||
```
|
||||
|
||||
Now, start the VM by using the below command by specifying the name of the VM that you wish to start.
|
||||
|
||||
```
|
||||
$ VBoxManage startvm Ubuntu16.04
|
||||
```
|
||||
|
||||
A new window will be opened where you new VM be booted from your attached file.
|
||||
|
||||

|
||||
|
||||
To stop the virtual machine , you can make use of the following command.
|
||||
|
||||
```
|
||||
$ VBoxManage controlvm Ubuntu16.04 poweroff
|
||||
```
|
||||
|
||||
The ‘controlvm’ command is used to control the state of the virtual machine. Some of the available options are pause / resume / reset / poweroff / savestate / acpipowerbutton / acpisleepbutton. There are many options in controlvm to see all the options available in it, run below command.
|
||||
|
||||
```
|
||||
$VBoxManage controlvm
|
||||
```
|
||||
|
||||

|
||||
|
||||
Conclusion
|
||||
|
||||
In this article we have learned about an awesome tool of Oracle Virtual Box that is VBoxManage, that includes its installation and usage on Ubuntu 16.04 Operating system. The article includes a detailed instructions about its useful commands to create and manage your virtual machines using VBoxManage. Hope you find this much helpful, do not forget to share your comments or suggestions.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linuxpitstop.com/install-and-use-command-line-tool-vboxmanage-on-ubuntu-16-04/
|
||||
|
||||
作者:[Kashif][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://linuxpitstop.com/author/kashif/
|
||||
[1]: https://www.virtualbox.org/wiki/Downloads
|
||||
178
sources/tech/20160605 How to Add Cron Jobs in Linux and Unix.md
Normal file
178
sources/tech/20160605 How to Add Cron Jobs in Linux and Unix.md
Normal file
@@ -0,0 +1,178 @@
|
||||
How to Add Cron Jobs in Linux and Unix
|
||||
======================================
|
||||
|
||||
|
||||

|
||||
|
||||
### Introduction
|
||||
|
||||

|
||||
|
||||
Cron job are used to schedule commands to be executed periodically. You can setup commands or scripts, which will repeatedly run at a set time. Cron is one of the most useful tool in Linux or UNIX like operating systems. The cron service (daemon) runs in the background and constantly checks the /etc/crontab file, and /etc/cron.*/ directories. It also checks the /var/spool/cron/ directory.
|
||||
|
||||
### Command of crontab
|
||||
|
||||
crontab is the command used to install, deinstall or list the tables (cron configuration file) used to drive the [cron(8)][1] daemon in Vixie Cron. Each user can have their own crontab file, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly. You need to use crontab command for editing or setting up your own cron jobs.
|
||||
|
||||
### Types of cron configuration files
|
||||
|
||||
There are different types of configuration files:
|
||||
|
||||
- **The UNIX / Linux system crontab** : Usually, used by system services and critical jobs that requires root like privileges. The sixth field (see below for field description) is the name of a user for the command to run as. This gives the system crontab the ability to run commands as any user.
|
||||
|
||||
- **The user crontabs**: User can install their own cron jobs using the crontab command. The sixth field is the command to run, and all commands run as the user who created the crontab
|
||||
|
||||
**Note**: This faq features cron implementations written by Paul Vixie and included in many [Linux][2] distributions and Unix like systems such as in the popular 4th BSD edition. The syntax is [compatible][3] with various implementations of crond.
|
||||
|
||||
How Do I install or create or edit my own cron jobs?
|
||||
|
||||
To edit your crontab file, type the following command at the UNIX / Linux shell prompt:
|
||||
|
||||
```
|
||||
$ crontab -e
|
||||
```
|
||||
|
||||
Syntax of crontab (field description)
|
||||
|
||||
The syntax is:
|
||||
|
||||
```
|
||||
1 2 3 4 5 /path/to/command arg1 arg2
|
||||
```
|
||||
|
||||
OR
|
||||
|
||||
```
|
||||
1 2 3 4 5 /root/ntp_sync.sh
|
||||
```
|
||||
|
||||
Where,
|
||||
|
||||
- 1: Minute (0-59)
|
||||
- 2: Hours (0-23)
|
||||
- 3: Day (0-31)
|
||||
- 4: Month (0-12 [12 == December])
|
||||
- 5: Day of the week(0-7 [7 or 0 == sunday])
|
||||
- /path/to/command – Script or command name to schedule
|
||||
|
||||
Easy to remember format:
|
||||
|
||||
```
|
||||
* * * * * command to be executed
|
||||
– – – – –
|
||||
| | | | |
|
||||
| | | | —– Day of week (0 – 7) (Sunday=0 or 7)
|
||||
| | | ——- Month (1 – 12)
|
||||
| | ——— Day of month (1 – 31)
|
||||
| ———– Hour (0 – 23)
|
||||
————- Minute (0 – 59)
|
||||
```
|
||||
|
||||
Example simple crontab.
|
||||
|
||||
````
|
||||
## run backupscript 5 minutes 1 time ##
|
||||
*/5 * * * * /root/backupscript.sh
|
||||
|
||||
## Run backupscript daily on 1:00 am ##
|
||||
|
||||
0 1 * * * /root/backupscript.sh
|
||||
|
||||
## Run backup script monthly on the 1st of month 3:15 am ##
|
||||
|
||||
15 3 1 * * /root/backupscript.sh
|
||||
```
|
||||
|
||||
### How do I use operators?
|
||||
|
||||
An operator allows you to specifying multiple values in a field. There are three operators:
|
||||
|
||||
- **The asterisk (*)** : This operator specifies all possible values for a field. For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month
|
||||
|
||||
- **The comma (,)** : This operator specifies a list of values, for example: “1,5,10,15,20, 25”.
|
||||
|
||||
- **The dash (–)** : This operator specifies a range of values, for example: “5-15” days , which is equivalent to typing “5,6,7,8,9,….,13,14,15” using the comma operator.
|
||||
|
||||
- **The separator (/)** : This operator specifies a step value, for example: “0-23/” can be used in the hours field to specify command execution every other hour. Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2.
|
||||
|
||||
|
||||
### Use special string to save time
|
||||
|
||||
Instead of the first five fields, you can use any one of eight special strings. It will not just save your time but it will improve readability.
|
||||
|
||||
Special string | Meaning
|
||||
|:-- |:--
|
||||
@reboot | Run once, at startup.
|
||||
@yearly | Run once a year, “0 0 1 1 *”.
|
||||
@annually | (same as @yearly)
|
||||
@monthly | Run once a month, “0 0 1 * *”.
|
||||
@weekly | Run once a week, “0 0 * * 0”.
|
||||
@daily | Run once a day, “0 0 * * *”.
|
||||
@midnight | (same as @daily)
|
||||
@hourly | Run once an hour, “0 * * * *”.
|
||||
|
||||
|
||||
Examples
|
||||
|
||||
```
|
||||
#### Run ntpdate command every hour ####
|
||||
|
||||
@hourly /path/to/ntpdate
|
||||
```
|
||||
|
||||
|
||||
### More about /etc/crontab file and /etc/cron.d/* directories
|
||||
|
||||
/etc/crontab is system crontabs file. Usually only used by root user or daemons to configure system wide jobs. All individual user must must use crontab command to install and edit their jobs as described above. /var/spool/cron/ or /var/cron/tabs/ is directory for personal user crontab files. It must be backup with users home directory.
|
||||
|
||||
Understanding Default /etc/crontab
|
||||
|
||||
Typical /etc/crontab file entries:
|
||||
|
||||
```
|
||||
SHELL=/bin/bash
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
MAILTO=root
|
||||
HOME=/
|
||||
# run-parts
|
||||
01 * * * * root run-parts /etc/cron.hourly
|
||||
02 4 * * * root run-parts /etc/cron.daily
|
||||
22 4 * * 0 root run-parts /etc/cron.weekly
|
||||
42 4 1 * * root run-parts /etc/cron.monthly
|
||||
```
|
||||
|
||||
First, the environment must be defined. If the shell line is omitted, cron will use the default, which is sh. If the PATH variable is omitted, no default will be used and file locations will need to be absolute. If HOME is omitted, cron will use the invoking users home directory.
|
||||
|
||||
Additionally, cron reads the files in /etc/cron.d/ directory. Usually system daemon such as sa-update or sysstat places their cronjob here. As a root user or superuser you can use following directories to configure cron jobs. You can directly drop your scripts here. The run-parts command run scripts or programs in a directory via /etc/crontab file:
|
||||
|
||||
Directory |Description
|
||||
|:-- |:--
|
||||
/etc/cron.d/ | Put all scripts here and call them from /etc/crontab file.
|
||||
/etc/cron.daily/ | Run all scripts once a day
|
||||
/etc/cron.hourly/ | Run all scripts once an hour
|
||||
/etc/cron.monthly/ | Run all scripts once a month
|
||||
/etc/cron.weekly/ | Run all scripts once a week
|
||||
|
||||
|
||||
### Backup cronjob
|
||||
|
||||
```
|
||||
# crontab -l > /path/to/file
|
||||
|
||||
# crontab -u user -l > /path/to/file
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.unixmen.com/add-cron-jobs-linux-unix/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+unixmenhowtos+%28Unixmen+Howtos+%26+Tutorials%29
|
||||
|
||||
作者:[Duy NguyenViet][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.unixmen.com/author/duynv/
|
||||
[1]: http://www.manpager.com/linux/man8/cron.8.html
|
||||
[2]: http://www.linuxsecrets.com/
|
||||
[3]: http://www.linuxsecrets.com/linux-hardware/
|
||||
@@ -0,0 +1,103 @@
|
||||
|
||||
一位跨平台开发者的自白
|
||||
=============================================
|
||||
|
||||

|
||||
|
||||
Andreia Gaita[1]将会在OSCON开源大会上发表一个题为[跨平台开发者的自白][2]的演讲。她长期从事于开源工作,并且为Mono[3]【译者注:一个致力于开创.NET在Linux上使用的开源工程】工程做着贡献。Andreia任职于GitHub,她的工作是专注于为Visual Studio构建github上的可扩展管理器。
|
||||
|
||||
|
||||
我在她发表演讲前就迫不及待的想要问她一些关于跨平台开发的事,作为一名跨平台开发者,她已经有了16年的学习经验了。
|
||||
|
||||

|
||||
|
||||
|
||||
**在你跨平台工作的过程中,你使用过的最简单的和最难的代码语言是什么?**
|
||||
|
||||
|
||||
很少讨论某种语言的好坏,大多数是关于对于这种语言的库和工具的易用性。编译器、解释器以及构建器语言决定了用它们做跨平台开发的难易程度(不论它是否可能),能够实现UI和本地系统访问的函数库的可用性都决定了开发时兼容操作系统的程度。如果这样想,我认为C#最适合完成跨平台开发工作。这种语言有它自己的特色,它允许本地快速唤醒和精确的内存地址;如果你希望你的代码能够与系统和本地函数库进行交互,那么你就会需要C#。当我需要特殊的系统集成的时候,我就会切换到C或者C++。
|
||||
|
||||
|
||||
**你使用的跨平台开发工具或者抽象有哪些?**
|
||||
|
||||
我的大部分跨平台工作都是为其他人开发工具和库,然后把它们组合起来开发跨平台的应用程序,其中大多用到MONO/C#。说真的,我不太懂抽象。大多数时候,我依赖Mono去完成一个跨平台的app开发以及它的UI,或者一个偶然的游戏开发中的Unity3D部分。我经常使用Electron【译者注:Atom编辑器的兄弟项目,可以用Electron开发桌面应用】。
|
||||
|
||||
|
||||
|
||||
**你接触过哪些构建系统?它们之间的区别是由于语言还是平台的不同?**
|
||||
|
||||
|
||||
我试着选择适合我使用语言的构建系统。那样 ,就会很少遇到让我头疼的问题。它需要支持平台和体系结构间的选择、构建智能工件位置(多个并行构建)以及易配置性等。大多数时候,我的项目会结合C/C++和C#,同时我也想要为一些开源分支构建相应的配置环境(Debug, Release, Windows, OSX, Linux, Android, iOS, etc, etc.)),通常也需要为每个构建的智能工件选择带有不同标志的编译器。所以我不得不做很多工作,而这种以我的方式进行的工作并没有很多收获。我时常尝试着用不同的构建系统,仅仅是想了解到最新的情况,但是最终我还是回到使用makefile的情况,采用shell和批处理脚本之一与Perl脚本相结合的方式,以达到使用他们的目的(因为如果我想用户去做很多我做的事情,我还是最好选择一种命令行脚本语言,这样它在哪里都可以用)。
|
||||
|
||||
|
||||
|
||||
**你怎样平衡在这种统一用户接口视觉体验需求上的强烈渴望呢?**
|
||||
|
||||
|
||||
|
||||
用户接口的跨平台实现很困难。在过去几年中我已经使用了一些跨平台GUI,并且我认为一些问题没有最优解。那些问题都基于两种操作,你也可以选择一个跨平台工具去做一个UI,去用你所喜欢的所有的平台,这样感觉不是太对,用小的代码库和比较低的维护费用。或者你可以选择去开发一个特有平台的UI,那样看起来就会是很本地化并且能很好的使其与一个大型的代码库结合,也会有很高的维护费用。这种决定完全取决于APP的类型。它的特色在哪里呢?你有什么资源?你可以把它运行在多少平台上?
|
||||
|
||||
|
||||
最后,我认为用户对于这种框架性的“一个UI统治所有”的UI的容忍度更大了,就比如Electron。我曾经有个Chromium+C+C#的框架侧项目,并且希望我在一天内用C#构建Electron型的app,这样的话我就可以做到两全其美了。
|
||||
|
||||
|
||||
**你对构建或者打包有依赖性吗 ?**
|
||||
|
||||
|
||||
我很少谈及依赖性问题。很多次我都被ABI【译者注:应用程序二进制接口】的崩溃、存在冲突的征兆以及包的丢失问题所困扰。我决定我要使用的操作系统的版本,都是选择最低的依赖去使问题最小化。通常这就意味着有五种不同的Xcode的副本和OSX框架库 ,在同样的机器上有五种不同的Visual Studio版本需要相应的被安装,多种clang【译者注:C语言、C++、Object-C、C++语言的轻量级编译器】和gcc版本,一系列的可以运行的其他的VM版本。如果我不能确定我要使用的操作系统的包的规定,我时常会连接静态库与子模块之间的依赖确保它们一直可用。大多时候,我会避免这些很棘手的问题,除非我非常需要使用他们。
|
||||
|
||||
|
||||
**你使用能够持续集成的、代码重读的相关工具吗?**
|
||||
|
||||
基本每天都用。这是保持高效的唯一方式。我在一个项目中做的第一件事情是配置跨平台构建脚本,保证每件事尽可能自动化完成。当你想要使用多平台的时候,CI【译者注:持续集成】是至关重要的。在一个机器上,没有人能结合所有的不同的平台。并且一旦你的构建过程没有包含所有的平台,你就不会注意到你搞砸的事情。在一个共享的多平台代码库中 ,不同的人拥有不同的平台和特征,所以仅有的方法是保证跨团队浏览代码时结合CI和其他分析工具的公平性。这不同于其他的软件项目,如果不使用相关的工具就只有失败了。
|
||||
|
||||
|
||||
**你依赖于自动构建测试或者趋向于在每个平台上构建并且进行局部测试吗?**
|
||||
|
||||
|
||||
对于不包括UI的工具和库,我通常能够侥幸完成自动构建测试。如果那是一个UI,两种方法我都会用到——做一个可靠的,可自动编写脚本的UI,因为基本没有GUI工具,所以我不得不在去创建UI自动化工具,这种工具可以工作在所有的我用到的平台上,或者我也可以手动完成。如果一个项目使用一个定制的UI工具(一个像Unity3D那样做的OpenGL UI ),开发自动化的可编写脚本工具和更多的自动化工具就相当容易。不过,没有什么东西会像人类一样通过双击而搞砸事情。
|
||||
|
||||
|
||||
|
||||
**如果你要做跨平台开发,你想要在不同的平台上使用不同的编辑器,比如在Windows上使用Visual Studio,在Linux上使用Qt Creator,在Mac上使用XCode吗?还是你更趋向于使用Eclipse这样的可以在所有平台上使用的编辑器?**
|
||||
|
||||
|
||||
|
||||
我喜欢使用不同的编辑器构建系统。我更喜欢在不同的带有构建脚本的IDE上保存项目文件(可以使增加IDE变得更容易),这些脚本可以为他们支持的平台去驱动IDE开始工作。对于一个开发者来说编辑器是最重要的工具,开发者花费时间和精力去学习使用各种编辑器,但是它们都不能相互替代。我使用我最喜欢的编辑器和工具,每个人也应该能使用他们最喜爱的工具。
|
||||
|
||||
|
||||
|
||||
**在跨平台开发的时候,你更喜欢使用什么开发环境和IDE呢?**
|
||||
|
||||
|
||||
跨平台开发者好像被诅咒一样,他们不得不选择小众化的编辑器去完成大多数跨平台的工作。我爱用Visual Studio,但是我不能依赖它完成除windows平台外的工作(你可能不想让windows成为你的初级交叉编译平台,所以我不会使用它作为我的初级集成开发环境。即使我这么做了,跨平台开发者的潜意识也知道有可能会用到很多平台。这就意味着必须很熟悉他们——使用一种平台上的编辑器就必须知道这种操作系统的设置,运行方式以及它的局限性等。做这些事情就需要头脑清醒(我的捷径是加强记忆),我不得不依赖于跨平台编辑器。所以我使用Emacs 和Sublime。
|
||||
|
||||
|
||||
|
||||
**你最喜欢的过去跨平台项目是什么**?
|
||||
|
||||
|
||||
我一直很喜欢Mono,并且得心应手,在一些开发中大多数的项目都是用一些方法围绕着它进行的。Gluezilla曾经是我在多年前开发的一个Mozilla【译者注:Mozilla基金会,为支持和领导开源Mozilla项目而设立的非营利组织】结合器,可以C#开发的app嵌入到web浏览器试图中,并且看起来很明显。在这一点上,我开发过一个窗体app,它是在linux上开发的,它运行在带有一个嵌入GTK试图的windows系统上,并且这个系统将会运行一个Mozilla浏览器试图。CppSharp项目(以前叫做Cxxi,更早时叫做CppInterop)是一个我开始结合绑定有C#的C++库的项目,这样就可以唤醒和创建实例来把C#结合到C++中。这样做的话,它在运行的时候就能够发现所使用的平台以及用来创建本地运行库的编译器;而且还为它生成正确的C#绑定。这多么有趣啊。
|
||||
|
||||
|
||||
**你怎样看跨平台开发的未来趋势呢?**
|
||||
|
||||
|
||||
我们构建本地应用程序的方式已经改变了,我觉得在各种桌面操作系统之间存在差异,而且这种差异将会变得更加微妙;所以构建跨平台的应用程序将会更加容易,而且这种应用程序即使没有在本平台也可以完全兼容。不好的是,这可能意味着应用程序很难获得,并且当在操作系统上使用的时候功能得不到最好的发挥。我们知道怎样把库和工具以及运行环境的跨平台开发做的更好,但是跨平台应用程序的开发仍然需要我们的努力。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/business/16/5/oscon-interview-andreia-gaita
|
||||
|
||||
作者:[Marcus D. Hanwell ][a]
|
||||
译者:[vim-kakali](https://github.com/vim-kakali)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/mhanwell
|
||||
[1]: https://twitter.com/sh4na
|
||||
[2]: http://conferences.oreilly.com/oscon/open-source-us/public/schedule/detail/48702
|
||||
[3]: http://www.mono-project.com/
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
把你的旧笔记本变成 Chromebook
|
||||
========================================
|
||||
|
||||

|
||||
>学习如何用 CloudReady 在你的旧电脑上安装 Chrome OS
|
||||
|
||||
Linux 之年就在眼前。根据[报道][1],Google 在 2016 年第一季度卖出了比苹果卖出的 Macbook 更多的 Chromebook。并且,Chromebook 即将变得更加激动人心。在 Google I/O 大会上,Google 宣布安卓 Google Play 商店将在 6 月中旬来到 Chromebook,这让用户能够在他们的 Chrome OS 设备上运行安卓应用。
|
||||
|
||||
但是,你不需要购买一台全新的使用 Chrome OS 的笔记本,你可以轻松地将你的旧笔记本或电脑转换成强大的 Chromebook。我在一台 Dell Mini 和一台 2009 年购买的 Dell 笔记本上进行了尝试。那两台设备都在吃灰,而且本来注定是要被回收的,因为现代的操作系统和桌面环境,比如 Unity,Plasma 以及 Gnome 它们跑不动。
|
||||
|
||||
如果你手边有旧设备,你可以轻松地将它变成 Chromebook。你还可以在你的笔记本上安装 Chrome OS 双系统,这样你就可以同时享受不同系统的优点了。
|
||||
|
||||
多亏了 Chrome OS 的开源基础,有很多方案可以让你在你的设备上安装 Chrome OS。我试过几个,但我最喜欢的方案是 [Neverware][2] 的 CloudReady。这家公司提供一个免费的,社区支持版的系统,还有一个商业支持版,每台设备每年 49 美元。好消息是所有的授权都是可转移的,所以如果你卖掉或捐掉了设备,你也可以将 Neverware 授权转让给新用户。
|
||||
|
||||
### 你需要什么
|
||||
|
||||
在你开始在笔记本上安装 CloudReady 之前,你需要一些准备:
|
||||
|
||||
- 一个容量大于等于 4GB 的 USB 存储设备
|
||||
|
||||
- 打开 Chrome 浏览器,到 Google Chrome Store 去安装 [Chromebook Recovery Utility(Chrome 恢复工具)][3]
|
||||
|
||||
- 更改目标机器的 BIOS 设置以便能从 USB 启动
|
||||
|
||||
### 开始
|
||||
|
||||
Neverware 提供两个版本的 CloudReady 镜像:32 位和 64 位。从下载页面[下载][4]合适你硬件的系统版本。
|
||||
|
||||
解压下载的 zip 文件,你会得到一个 chromiumos_image.bin 文件。现在插入 U 盘并打开 Chromebook recovery utility。点击工具右上角的齿轮,选择 erase recovery media(擦除恢复媒介,如图 1)。
|
||||
|
||||

|
||||
>图 1:选择 erase recovery media。[image:cloudready-erase]
|
||||
|
||||
接下来,选择目标 USB 驱动器并把它格式化。格式化完成后,再次打开右上齿轮,这次选择 use local image(使用本地镜像)。浏览解压的 bin 文件并选中,选好 USB 驱动器,点击继续,然后点击创建按钮(图 2)。它会开始将镜像写入驱动器。
|
||||
|
||||

|
||||
>图 2:创建 CloudReady 镜像。[Image:cloudready-create]
|
||||
|
||||
驱动器写好可启动的 CloudReady 之后,插到目标 PC 上并启动。系统启动进 Chromium OS 需要一小段时间。启动之后,你会看到图 3 中的界面。
|
||||
|
||||

|
||||
>图 3:准备好安装 CloudReady。
|
||||
|
||||

|
||||
>图 4:单系统选项。
|
||||
|
||||
到任务栏选择 Install CloudReady(安装 CloudReady)。
|
||||
|
||||
你可以安装 Chromium OS 和其它系统的双系统启动,但另一个系统这时应该已经安装好了。
|
||||
|
||||
在下一个窗口选择单系统(图 4)或是双系统(图 5)。
|
||||
|
||||
按照下一步按钮说明选择安装。
|
||||
|
||||

|
||||
>图 5:双系统选项。
|
||||
|
||||
整个过程最多 20 分钟左右,这取决于存储媒介和处理能力。安装完成后,电脑会关闭并重启。
|
||||
|
||||
重启之后,你会看到网络设置页面(图 6)。让人激动的是,虽然我在相同硬件上要给 Linux 发行版安装无线驱动,到了 Chromium OS 这里是开箱即用的。
|
||||
|
||||
你连上无线网络之后,系统会自动查找更新并提供 Adobe Flash 安装。安装完成后,你会看到 Chromium OS 登录界面。现在你只需登录你的 Gmail 账户,开始使用你的“Chromebook”即可。
|
||||
|
||||

|
||||
>图 6:网络设置。
|
||||
|
||||
### 让 Netflix 正常工作
|
||||
|
||||
如果你想要播放 Netflix 或其它 DRM 保护流媒体站点,你需要做一些额外的工作。转到设置并点击安装 Widevine 插件(图 7)。
|
||||
|
||||

|
||||
>图 7:安装 Widevine。
|
||||
|
||||

|
||||
>图 8:安装 User Agent Switcher.
|
||||
|
||||
现在你需要使用 user agent switcher 这个伎俩(图 8)。
|
||||
|
||||
到 Chrome Webstore 去安装 [User Agent Switcher][5]。插件安装完成后,它会自动添加到浏览器的书签栏。
|
||||
|
||||
右键点击 agent switcher 图标并创建一个新条目(图 9):
|
||||
|
||||
```
|
||||
Name: "CloudReady Widevine"
|
||||
|
||||
String: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Ubuntu/16.10 Chrome/49.0.1453.93"
|
||||
|
||||
Group: "Chrome" (应该被自动填上了)
|
||||
|
||||
Append: "Replace"
|
||||
|
||||
Indicator Flag: "IE"
|
||||
|
||||
```
|
||||
|
||||
点击“添加(Add)”。
|
||||
|
||||

|
||||
>图 9:为 CloudReady 创建条目。
|
||||
|
||||
然后,到“permanent spoof list(永久欺骗列表)”选项中将 CloudReady Widevine 添加为 [www.netflix.com](http://www.netflix.com) 的永久 UA 串。
|
||||
|
||||
现在,重启机器,你就可以观看 Netflix 和其它一些服务了。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/learn/turn-your-old-laptop-chromebook
|
||||
|
||||
作者:[SWAPNIL BHARTIYA][a]
|
||||
译者:[alim0x](https://github.com/alim0x)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linux.com/users/arnieswap
|
||||
[1]: https://chrome.googleblog.com/2016/05/the-google-play-store-coming-to.html
|
||||
[2]: http://www.neverware.com/#introtext-3
|
||||
[3]: https://chrome.google.com/webstore/detail/chromebook-recovery-utili/jndclpdbaamdhonoechobihbbiimdgai?hl=en
|
||||
[4]: http://www.neverware.com/freedownload
|
||||
[5]: https://chrome.google.com/webstore/detail/user-agent-switcher-for-c/djflhoibgkdhkhhcedjiklpkjnoahfmg
|
||||
61
translated/tech/20160601 Apps to Snaps.md
Normal file
61
translated/tech/20160601 Apps to Snaps.md
Normal file
@@ -0,0 +1,61 @@
|
||||
Apps to Snaps
|
||||
================
|
||||
|
||||

|
||||
|
||||
在 Linux 分发应用不总是那么容易。你有不同的包格式,基础系统,可用库,以及发行版发布周期,所有的这些都让人头疼。但现在我们有了更简单的东西:Snap。
|
||||
|
||||
Snap 是开发者打包他们应用的新途径,它相对于传统包格式,如 .deb,.rpm 等带来了许多优点。Snap 安全,互相独立,宿主系统使用类似 AppArmor 的技术,它们跨平台,而且是自足的,让开发者可以准确打包它们应用所需要的依赖。沙盒隔离也加强了安全,并允许应用和整个基于 snap 的系统,在出现问题的时候可以回滚。Snap 确实是 Linux 应用打包的未来。
|
||||
|
||||
创建一个 snap 包并不困难。首先,你需要一个 snap 基础运行环境,能够在你的桌面理解和运行 snap,这个工具叫做 snapd 并且默认内置于所有 Ubuntu 16.04 系统中。接着你需要创建 snap 的工具,Snapcraft,可以通过一个简单的命令安装:
|
||||
|
||||
```
|
||||
$ sudo apt-get install snapcraft
|
||||
```
|
||||
|
||||
这个环境安装好了之后就可以 snap 起来了。
|
||||
|
||||
Snap 使用一个特殊的 YAML 格式文件,称作 snapcraft.yaml,它定义了应用是如何打包的以及它需要的依赖。用一个简单的应用来演示一下,下面的 YAML 文件是个如何 snap 打包 moon-buggy 游戏的实际例子,该游戏在 Ubuntu 源中提供。
|
||||
|
||||
```
|
||||
name: moon-buggy
|
||||
version: 1.0.51.11
|
||||
summary: Drive a car across the moon
|
||||
description: |
|
||||
A simple command-line game where you drive a buggy on the moon
|
||||
apps:
|
||||
play:
|
||||
command: usr/games/moon-buggy
|
||||
parts:
|
||||
moon-buggy:
|
||||
plugin: nil
|
||||
stage-packages: [moon-buggy]
|
||||
snap:
|
||||
– usr/games/moon-buggy
|
||||
```
|
||||
|
||||
上面的代码演示了几个新概念。第一部分是关于让你的应用可以在商店找到的,设置包元数据名称,版本号,摘要,以及描述。Apps 部分实现了运行命令,指向 moon-buggy 可执行文件位置。Parts 部分告诉 snapcraft 用来构建应用所需要的插件以及依赖的包。在这个简单的例子中我们需要的所有东西就是 Ubuntu 源中的 moon-buggy 应用本身,snapcraft 负责剩下的工作。
|
||||
|
||||
在你的 snapcraft.yaml 所在目录下运行 snapcraft 会创建 moon-buggy_1.0.51.11_amd64.snap 包,可以通过以下命令来安装它:
|
||||
|
||||
```
|
||||
$ snap install moon-buggy_1.0.51.11_amd64.snap
|
||||
```
|
||||
|
||||
想了解更复杂一点的 snap 打包,比如基于 Electron 的 Simplenote [看这里][1],在线教程在[这里][2],相应的代码在[Github][3]。更多的例子可以在这里的 Ubuntu 开发者[站点][4]找到。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://insights.ubuntu.com/2016/06/01/apps-to-snaps/
|
||||
|
||||
作者:[Jamie][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://insights.ubuntu.com/author/jamiebennett/
|
||||
[1]: http://www.simplenote.com/
|
||||
[2]: http://www.linuxuk.org/post/20160518_snapping_electron_based_applications_simplenote/
|
||||
[3]: https://github.com/jamiedbennett/snaps/tree/master/simplenote
|
||||
[4]: https://developer.ubuntu.com/en/desktop/get-started/
|
||||
Reference in New Issue
Block a user