mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
23d2b322c4
@ -0,0 +1,59 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How open standards guide us in a world of change)
|
||||
[#]: via: (https://opensource.com/article/20/5/oasis-open)
|
||||
[#]: author: (Guy Martin https://opensource.com/users/guyma)
|
||||
|
||||
How open standards guide us in a world of change
|
||||
======
|
||||
OASIS Open brings open source and standards communities together during
|
||||
this time of crisis to help define a new, collaborative future to
|
||||
benefit all.
|
||||
![Globe up in the clouds][1]
|
||||
|
||||
As I write this article in my home office in Beaverton, Oregon, a Portland suburb, I'm relying (and reflecting) on years of work that went into standards like TCP/IP, HTTP, NTP, XMPP, SAML, and many others, as well as open source implementations of these standards from organizations such as the [Apache Software Foundation][2]. The combination of these standards and technologies is literally saving lives, as many of us are able to work from home while "flattening the curve."
|
||||
|
||||
Nothing has dominated the news more in 2020 than COVID-19. Yet, in the midst of challenging time, I've found opportunities for personal and industrial renewal. By fortunate (some may say unfortunate) timing, I found myself switching roles in the middle of this crisis from helping to build and run Open Source Program Offices (OSPOs) to becoming the executive director at [OASIS Open][3], a standards development organization that is helping bring standards and open source together in practical and productive ways.
|
||||
|
||||
Looking through the many articles on Opensource.com related to [standards][4] (and there are [quite a few][5]), I went on an interesting journey through the different thought processes—and sometimes biases—that people involved in each community have. What stood out most was this: both standards professionals and open source advocates want the same thing—better technology that we all can rely on.
|
||||
|
||||
As I was transitioning to this new role at OASIS, some colleagues and friends in the open source world that I've been a part of for many years questioned my motivations for making this move. In explaining why I took this job, I reflected on the larger role I think the intersection of standards and open source can play, especially in the current crisis we all face.
|
||||
|
||||
### 4 reflections on open source and standards
|
||||
|
||||
First, I've seen efforts like the [Open Connectivity Foundation][6], which I was fortunate to help start, get this right in balancing a standard with multiple reference implementations. Early in that effort, the standard was actively driven by the open source project, and the project took cues from the work of the standards teams. The result is both working code and a standard that can help shield IoT developers from having to worry about the many underlying network protocols in use in this ecosystem.
|
||||
|
||||
Second, I'm extremely energized by the opportunity to work with some of the best minds in the open source community, many of whom I'm fortunate enough to call friends. One of the first steps OASIS took when developing its [Open Projects][7] program was to assemble an advisory council of open source all-stars. Chris Ferris, Jim Jagielski, Nithya Ruff, Deb Bryant, and many others regularly come together, with support from OASIS staffer Jory Burson, to hash out best practices with a path to standardization and recognition in international standards bodies like ISO, ITU, W3C, and others.
|
||||
|
||||
This group, along with our staff, is rethinking everything from governance to IP to community building to funding and process, taking the best from both worlds to create something new. We're bridging the agile, collaborative excellence that is open source with the trusted, interoperable reliability that is open standards, and helping to demystify open source for heavily regulated procurement processes (government, financial, NGO, etc.). The possibility of getting open source into supply chains that have traditionally relied on standards is very exciting.
|
||||
|
||||
Third, I see the huge potential for what the response to this pandemic represents. This is arguably a once-in-a-generation opportunity for standards and open source communities to help define and build the future of emergency management, e-learning, medical technologies, and many other aspects of our daily lives. Determining how these elements work together effectively will be paramount to our shared future.
|
||||
|
||||
Finally, I'm excited to see the role that OASIS and other standards and open source bodies can play as we tackle some of our biggest challenges in the coming months and years together. COVID-19 is changing our world and our way of life forever; how we adapt and thrive will, in large part, be determined by how well we all collaborate, and I can think of no better time for the open source and standards communities to unite to chart a course forward for all of us.
|
||||
|
||||
I'm proud to be part of the movement to build a stronger bridge between open source and open standards, and I invite you all to join us. If you have thoughts to share or a project you'd like to advance, I'd love to hear from you. You can [visit us][8] or use the comments section below. Let's write the next chapter together.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/5/oasis-open
|
||||
|
||||
作者:[Guy Martin][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/guyma
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cloud-globe.png?itok=_drXt4Tn (Globe up in the clouds)
|
||||
[2]: https://apache.org
|
||||
[3]: https://oasis-open.org
|
||||
[4]: https://opensource.com/resources/what-are-open-standards
|
||||
[5]: https://opensource.com/tags/open-standards
|
||||
[6]: https://openconnectivity.org
|
||||
[7]: https://oasis-open-projects.org/
|
||||
[8]: https://oasis-open-projects.org/get-involved
|
@ -0,0 +1,149 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (20 productivity tools for the Linux terminal)
|
||||
[#]: via: (https://opensource.com/article/20/6/productivity-tools-linux-terminal)
|
||||
[#]: author: (Alan Smithee https://opensource.com/users/alansmithee)
|
||||
|
||||
20 productivity tools for the Linux terminal
|
||||
======
|
||||
Try some of these open source tools. Get more done.
|
||||
![Computer screen with files or windows open][1]
|
||||
|
||||
Many of us, admittedly, only use computers because they're fun. But some people use computers to get stuff done, and their theory is computers are supposed to make things faster, better, and more organized. In practice, though, computers don't necessarily improve our lives without a little manual reconfiguration to match our individual work styles.
|
||||
|
||||
[Kevin Sonney][2] likes to design systems, not just for networks but for improving his own workday, and this year he covered 18 different productivity tools in a series of 20 articles. This article gets all of Kevin's favorite tools in one place and provides a quick summary of what each one can do for you.
|
||||
|
||||
### File sync
|
||||
|
||||
![][3]
|
||||
|
||||
Important files deserve to be managed carefully.
|
||||
|
||||
* [Syncthing][4] is a way for you to keep files on different devices in sync with one another. A _device_ can be a Linux, Windows, or Mac computer, a server, an Android tablet or phone, and so on, and the files can be any file you want to keep updated across many machines. Syncthing is lightweight and peer-to-peer, so you don't need to pay for a service, you don't need a third-party server, and it's fast.
|
||||
* Synchronization is one thing, but sometimes you also need help dealing with the files you have. Say you want an application to behave differently depending on whether it's being used as a graphical application or as a console application. You could change the config file between, say, `.foo-gui` and ****`.foo-term` by changing which its symlink points to. Doing that manually is entirely possible, but it could be scripted, or you could just use [GNU Stow][5] instead.
|
||||
|
||||
|
||||
|
||||
### Email management
|
||||
|
||||
![][6]
|
||||
|
||||
We all depend on email and inboxes, but few of us seem to be comfortable with how we manage it. If you're inclined to working in the terminal, why not stay in the terminal for email? It's one thing to check and send email from a terminal, but it's even more exciting to organize your email that way. If you're a typist by trade and scripter by nature, check out some of these tools.
|
||||
|
||||
* I use [OfflineIMAP][7] every day to sync work email to my laptop for viewing in Mutt. It's a specific tool that does exactly one thing: it ensures that a local copy of your email inbox mirrors your remote inbox. It's relatively easy to set up and schedule with [cron][8], and then you can forget it exists. Easy and worth every minute you spend fighting with IMAP.
|
||||
* [Notmuch][9] indexes, tags, and searches mail messages. If you have a problem with your inbox, it takes _not much_ effort to remedy it.
|
||||
* [Vim][10] can check and send email and manage your calendar.
|
||||
* [Emacs][11], of course, also does email and calendaring.
|
||||
|
||||
|
||||
|
||||
### Calendars and contacts
|
||||
|
||||
![][12]
|
||||
|
||||
Every Linux system I've ever used comes with the `cal` command installed. This is a handy little calendar for the terminal, and it's a great quick reference. However, it's hardly what you'd call a calendaring application. The [iCalendar][13] specification (no relation to Apple's old desktop calendar) provides rich shared calendaring functionality, and while `.ics` appointments and events are plain text, the workflow for managing them in the terminal is basically non-existent. Or at least, it was non-existent until khal and vdirsyncer.
|
||||
|
||||
* [Khal][14] is a console-based calendar that reads and writes `.ics` files.
|
||||
* [Vdirsyncer][14] is a terminal command that synchronizes online calendars (and contacts) to your local drive. Khal works locally and vdirsyncer works remotely, so your calendars online stay in sync with the calendar you're managing on your hard drive. ****
|
||||
* Contact management can be hard, but it gets easier if you use [Khard][15], a terminal command that reads and writes files in the vCard format. This, in turn, can be synchronized to a remote server using vdirsyncer (which you may already be using for your khal calendar). This makes calendaring and contacts easy, and it's easier than ever to [run your own personal information management (PIM) server][16].
|
||||
|
||||
|
||||
|
||||
### To-do lists
|
||||
|
||||
![][17]
|
||||
|
||||
* There are many ways to organize your day, but one of the easiest is [todo.txt][18], a simple, portable, understandable system that doesn't break down even if a device doesn't have todo.txt installed on it. The reason todo.txt works is because it's just a Bash shell script, which will run on nearly any computing device you can find. The process is simple: you download the script, install it to your home directory, and start scheduling tasks with a simple command. If you're on a computer that doesn't have the `todo.sh` command installed, your to-do list is still useful as a plain-text file, which you can update manually as needed.
|
||||
* [Jrnl][19] is a digital notebook to keep track of your daily agenda and activities. This is the program you've been looking for if you compulsively jot notes on scraps of paper on your desk or echo idle thoughts into random text files.
|
||||
|
||||
|
||||
|
||||
### Keep in touch
|
||||
|
||||
![][20]
|
||||
|
||||
Communication is key, and yet now more than ever, there seems to be a chat platform problem. There aren't just several clients, there are several isolated networks. How do you manage them all? Here are two ideas.
|
||||
|
||||
* If you've got lots of contacts spread across too many chat networks, you ought to try [BitlBee][21], the singular chat client that lets you infiltrate all the others.
|
||||
* [Rainbow Stream][22] is a Twitter client that can be awfully useful to keep you away from the distractions of an open web browser while still keeping you in touch with your adoring public.
|
||||
|
||||
|
||||
|
||||
### Keep informed
|
||||
|
||||
![][23]
|
||||
|
||||
Web browsers are nice, but they can sometimes be overkill. You want to stay informed, but you don't want to give yourself entirely over to the internet. Because the internet is built upon open specifications and a lot of open source technology, you don't have to do everything through just one interface. There are _clients_ for all kinds of tasks, and they give you access to the information you need, using the interface you prefer.
|
||||
|
||||
* [Tuir][24] is a terminal client to Reddit.
|
||||
* [Newsboat][25] is an RSS feed reader.
|
||||
* [Wego][26] brings you a weather report.
|
||||
* [Vim][27] can help you check in with Reddit and Twitter.
|
||||
* [Emacs][28] can keep you connected with clients for Reddit, Twitter, chat, and much more.
|
||||
|
||||
|
||||
|
||||
### Keep that terminal open
|
||||
|
||||
![][29]
|
||||
|
||||
If you're spending time in a terminal, what's the point in ever closing a terminal? Do away with the temptation of `exit` or `Ctrl+D` and keep your console open.
|
||||
|
||||
* [Tmux][30] lets you split your terminal, "layer" one terminal window on top of another, and even walk away from one computer and continue the same terminal session from another computer.
|
||||
* [DESQview][31] takes a different approach: it's essentially a window manager for your terminal.
|
||||
|
||||
|
||||
|
||||
### Keep going
|
||||
|
||||
The tools in this article are but a subset of amazing productivity tools for your Linux terminal. This list must end, but your personal list can grow. Find the tools you love, learn them, and use them to your greatest advantage. Of course, a good tool doesn't always have to increase your productivity: sometimes your favorite command is the one that makes you happiest. Your job is to find the commands you love and to do amazing things with them.
|
||||
|
||||
Have fun!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/6/productivity-tools-linux-terminal
|
||||
|
||||
作者:[Alan Smithee][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/alansmithee
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open)
|
||||
[2]: https://opensource.com/users/ksonney
|
||||
[3]: https://opensource.com/sites/default/files/uploads/productivity_2-1.png
|
||||
[4]: https://opensource.com/article/20/1/sync-files-syncthing
|
||||
[5]: https://opensource.com/article/20/1/configuration-management-stow
|
||||
[6]: https://opensource.com/sites/default/files/uploads/productivity_3-1.png
|
||||
[7]: https://opensource.com/article/20/1/sync-email-offlineimap
|
||||
[8]: https://opensource.com/article/17/11/how-use-cron-linux
|
||||
[9]: https://opensource.com/article/20/1/organize-email-notmuch
|
||||
[10]: https://opensource.com/article/20/1/vim-email-calendar
|
||||
[11]: https://opensource.com/article/20/1/emacs-mail-calendar
|
||||
[12]: https://opensource.com/sites/default/files/uploads/productivity_5-1.png
|
||||
[13]: https://tools.ietf.org/html/rfc5545
|
||||
[14]: https://opensource.com/article/20/1/open-source-calendar
|
||||
[15]: https://opensource.com/article/20/1/sync-contacts-locally
|
||||
[16]: https://opensource.com/alternatives/google-calendar
|
||||
[17]: https://opensource.com/sites/default/files/uploads/productivity_7-1.png
|
||||
[18]: https://opensource.com/article/20/1/open-source-to-do-list
|
||||
[19]: https://opensource.com/article/20/1/python-journal
|
||||
[20]: https://opensource.com/sites/default/files/uploads/productivity_9-1.png
|
||||
[21]: https://opensource.com/article/20/1/open-source-chat-tool
|
||||
[22]: https://opensource.com/article/20/1/tweet-terminal-rainbow-stream
|
||||
[23]: https://opensource.com/sites/default/files/uploads/productivity_13-1.png
|
||||
[24]: https://opensource.com/article/20/1/open-source-reddit-client
|
||||
[25]: https://opensource.com/article/20/1/open-source-rss-feed-reader
|
||||
[26]: https://opensource.com/article/20/1/open-source-weather-forecast
|
||||
[27]: https://opensource.com/article/20/1/vim-task-list-reddit-twitter
|
||||
[28]: https://opensource.com/article/20/1/emacs-social-track-todo-list
|
||||
[29]: https://opensource.com/sites/default/files/uploads/productivity_14-1.png
|
||||
[30]: https://opensource.com/article/20/1/tmux-console
|
||||
[31]: https://opensource.com/article/20/1/multiple-consoles-twin
|
@ -0,0 +1,182 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (A new way to build cross-platform UIs for Linux ARM devices)
|
||||
[#]: via: (https://opensource.com/article/20/5/linux-arm-ui)
|
||||
[#]: author: (Bruno Muniz https://opensource.com/users/brunoamuniz)
|
||||
|
||||
A new way to build cross-platform UIs for Linux ARM devices
|
||||
======
|
||||
A proof of concept using AndroidXML and TotalCross provides an easier
|
||||
way of creating UIs for Raspberry Pi and other devices.
|
||||
![Digital images of a computer desktop][1]
|
||||
|
||||
Creating a great user experience (UX) for your applications is a tough job, especially if you are developing embedded applications. Today, there are two types of graphical user interface (GUI) tools generally available for developing embedded software: either they involve complex technologies, or they are extremely expensive.
|
||||
|
||||
However, we have created a proof of concept (PoC) for a new way to use existing, well-established tools to build user interfaces (UIs) for applications that run on desktop, mobile, embedded devices, and low-power Linux ARM devices. Our method uses Android Studio to draw the UI; [TotalCross][2] to render the Android XML on the device; a new [TotalCross API][3] called [KnowCode][4]; and a [Raspberry Pi 4][5] to execute the application.
|
||||
|
||||
### Choosing Android Studio
|
||||
|
||||
It's possible to build a responsive and beautiful UX for an application using the TotalCross API, but creating the UI in Android Studio shortens the time between prototyping and the real application.
|
||||
|
||||
There are a lot of tools available to build UIs for applications, but [Android Studio][6] is the one developers worldwide use most often. In addition to its massive adoption, this tool is also super-intuitive to use, and it's really powerful for creating both simple and complex applications. The only drawback, in my opinion, is the computing power required to use the tool, which is way heavier than other integrated development environments (IDEs) like VSCode or its open source alternative, [VSCodium][7].
|
||||
|
||||
By thinking through these issues, we created a proof of concept using Android Studio to draw the UI and TotalCross to run the Android XML directly on the device.
|
||||
|
||||
### Building the UI
|
||||
|
||||
For our PoC, we wanted to create a home-appliance application to control temperature and other things and that would run on a Linux ARM device.
|
||||
|
||||
![Home appliance application to control thermostat][8]
|
||||
|
||||
(Bruno Muniz, [CC BY-SA 4.0][9])
|
||||
|
||||
We wanted to develop our application for a Raspberry Pi, so we used Android's [ConstraintLayout][10] to build a fixed-screen-size UI of 848x480 (the Raspberry Pi's resolution), but you can build responsive UIs with other layouts.
|
||||
|
||||
Android XML adds a lot of flexibility for UI creation, making it easy to build rich user experiences for applications. In the XML below, we used two main components: [ImageView][11] and [TextView][12].
|
||||
|
||||
|
||||
```
|
||||
<ImageView
|
||||
android:id="@+id/imageView6"
|
||||
android:layout_width="273dp"
|
||||
android:layout_height="291dp"
|
||||
android:background="@drawable/Casa"
|
||||
tools:layout_editor_absoluteX="109dp"
|
||||
tools:layout_editor_absoluteY="95dp" />
|
||||
<TextView
|
||||
android:id="@+id/insideTempEdit"
|
||||
android:layout_width="94dp"
|
||||
android:layout_height="92dp"
|
||||
android:background="#F5F5F5"
|
||||
android:text="20"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center"
|
||||
android:textColor="#000000"
|
||||
android:textSize="67dp"
|
||||
android:textStyle="bold"
|
||||
tools:layout_editor_absoluteX="196dp"
|
||||
tools:layout_editor_absoluteY="246dp" />
|
||||
```
|
||||
|
||||
The TextView elements are used to show some data to the user, like the temperature inside a building. Most ImageViews are used as buttons for user interaction with the UI, but they're also needed to implement the Events provided by the components on the screen.
|
||||
|
||||
### Integrating with TotalCross
|
||||
|
||||
The second technology in this PoC is TotalCross. We don't want to use anything from Android on the device because:
|
||||
|
||||
1. Our goal is to provide a great UI for Linux ARM.
|
||||
2. We want to achieve a low footprint on the device.
|
||||
3. We want the application to run on low-end hardware devices with low computing power (e.g., no GPU, low RAM, etc.).
|
||||
|
||||
|
||||
|
||||
To begin, we created an empty TotalCross project using our [VSCode plugin][13]. Next, we saved a copy of the images inside the **drawable** folder and a copy of the Android XML file inside the **XML** folder—both are located inside the **Resources** folder:
|
||||
|
||||
![Home Appliance file structure][14]
|
||||
|
||||
(Bruno Muniz, [CC BY-SA 4.0][9])
|
||||
|
||||
To run the XML file using the TotalCross Simulator, we added a new TotalCross API called KnowCode and a MainWindow to load the XML. The code below uses the API to load and render the XML:
|
||||
|
||||
|
||||
```
|
||||
public void initUI() {
|
||||
XmlScreenAbstractLayout xmlCont = XmlScreenFactory.create(“xml / homeApplianceXML.xml”);
|
||||
swap(xmlCont);
|
||||
}
|
||||
```
|
||||
|
||||
That's it! With only two commands, we can run an Android XML file using TotalCross. Here is how the XML performs on TotalCross' simulator:
|
||||
|
||||
![TotalCross simulator running temperature application][15]
|
||||
|
||||
(Bruno Muniz, [CC BY-SA 4.0][9])
|
||||
|
||||
There are two things remaining to finish this PoC: adding some events to provide user interaction and running it on a Raspberry Pi.
|
||||
|
||||
### Adding events
|
||||
|
||||
The KnowCode API provides a way to get an XML element by its ID (getControlByID) and change its behavior to do things like adding events, changing visibility, and more.
|
||||
|
||||
For example, to enable users to change the temperature in their home or other building, we put plus and minus buttons on the bottom of the UI and a "click" event that increases or decreases the temperature one degree every time the buttons are clicked:
|
||||
|
||||
|
||||
```
|
||||
[Button][16] plus = ([Button][16]) xmlCont.getControlByID("@+id/plus");
|
||||
[Label][17] insideTempLabel = ([Label][17]) xmlCont.getControlByID("@+id/insideTempLabel");
|
||||
plus.addPressListener(new PressListener() {
|
||||
@Override
|
||||
public void controlPressed(ControlEvent e) {
|
||||
try {
|
||||
[String][18] tempString = insideTempLabel.getText();
|
||||
int temp;
|
||||
temp = Convert.toInt(tempString);
|
||||
insideTempLabel.setText(Convert.toString(++temp));
|
||||
} catch (InvalidNumberException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Testing on a Raspberry Pi 4
|
||||
|
||||
Finally, the last step! We ran the application on a device and checked the results. We just needed to package the application and deploy and run it on the target device. A [VNC][19] can also be used to check the application on the device.
|
||||
|
||||
The entire application, including assets (images, etc.), Android XML, TotalCross, and the KnowCode API, is about 8MB on Linux ARM.
|
||||
|
||||
Here's a demo of the application:
|
||||
|
||||
![Application demo][20]
|
||||
|
||||
(Bruno Muniz, [CC BY-SA 4.0][9])
|
||||
|
||||
In this example, the application was packaged only for Linux ARM, but the same app will run as a Linux desktop app, Android devices, Windows, Windows CE, and even iOS.
|
||||
|
||||
All of the sample source code and the project are available in the [HomeApplianceXML GitHub][21] repository.
|
||||
|
||||
### New possibilities with existing tools
|
||||
|
||||
Creating GUIs for embedded applications doesn't need to be as hard as it is today. This proof of concept brings a new perspective on how to do this task easily—not only for embedded systems but for all major operating systems, all using the same code base.
|
||||
|
||||
We are not aiming to create a new tool for designers or developers to build UI applications; our goal is to provide new possibilities for using the best tools that are already available.
|
||||
|
||||
What's your opinion of this new way to build apps? Share your thoughts in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/5/linux-arm-ui
|
||||
|
||||
作者:[Bruno Muniz][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/brunoamuniz
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop)
|
||||
[2]: https://totalcross.com/
|
||||
[3]: https://yourapp.totalcross.com/knowcode-app
|
||||
[4]: https://github.com/TotalCross/KnowCodeXML
|
||||
[5]: https://www.raspberrypi.org/
|
||||
[6]: https://developer.android.com/studio
|
||||
[7]: https://vscodium.com/
|
||||
[8]: https://opensource.com/sites/default/files/uploads/homeapplianceapp.png (Home appliance application to control thermostat)
|
||||
[9]: https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[10]: https://codelabs.developers.google.com/codelabs/constraint-layout/index.html#0
|
||||
[11]: https://developer.android.com/reference/android/widget/ImageView
|
||||
[12]: https://developer.android.com/reference/android/widget/TextView
|
||||
[13]: https://medium.com/totalcross-community/totalcross-plugin-for-vscode-4f45da146a0a
|
||||
[14]: https://opensource.com/sites/default/files/uploads/homeappliancexml.png (Home Appliance file structure)
|
||||
[15]: https://opensource.com/sites/default/files/uploads/totalcross-simulator_0.png (TotalCross simulator running temperature application)
|
||||
[16]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+button
|
||||
[17]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+label
|
||||
[18]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string
|
||||
[19]: https://tigervnc.org/
|
||||
[20]: https://opensource.com/sites/default/files/uploads/application.gif (Application demo)
|
||||
[21]: https://github.com/TotalCross/HomeApplianceXML
|
@ -0,0 +1,221 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Add interactivity to your Python plots with Bokeh)
|
||||
[#]: via: (https://opensource.com/article/20/5/bokeh-python)
|
||||
[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan)
|
||||
|
||||
Add interactivity to your Python plots with Bokeh
|
||||
======
|
||||
Plotting in Bokeh is a little more complicated than in some of the other
|
||||
plotting libraries, but there's a payoff for the extra effort.
|
||||
![Hands on a keyboard with a Python book ][1]
|
||||
|
||||
In this series of articles, I'm looking at the characteristics of different Python plotting libraries by making the same multi-bar plot in each one. This time I'm focusing on [Bokeh][2] (pronounced "BOE-kay").
|
||||
|
||||
Plotting in Bokeh is a little more complicated than in some of the [other plotting libraries][3], but there's a payoff for the extra effort. Bokeh is designed both to allow you to create your own interactive plots on the web _and_ to give you detailed control over how the interactivity works. I'll show this by adding a tooltip to the multi-bar plot I've been using in this series. It plots data from UK election results between 1966 and 2020.
|
||||
|
||||
![A zoomed-in view on the plot][4]
|
||||
|
||||
A zoomed-in view on the plot (© 2019 [Anvil][5])
|
||||
|
||||
### Making the multi-bar plot
|
||||
|
||||
To make the multi-bar plot, you need to massage your data a little.
|
||||
|
||||
The original data looks like this:
|
||||
|
||||
|
||||
```
|
||||
>> print(long)
|
||||
year party seats
|
||||
0 1966 Conservative 253
|
||||
1 1970 Conservative 330
|
||||
2 Feb 1974 Conservative 297
|
||||
3 Oct 1974 Conservative 277
|
||||
4 1979 Conservative 339
|
||||
.. ... ... ...
|
||||
103 2005 Others 30
|
||||
104 2010 Others 29
|
||||
105 2015 Others 80
|
||||
106 2017 Others 59
|
||||
107 2019 Others 72
|
||||
|
||||
[60 rows x 3 columns]
|
||||
```
|
||||
|
||||
You can think of the data as a series of `seats` values for each possible `(year, party)` combination. That's exactly how Bokeh thinks of it. You need to make a list of `(year, party)` tuples:
|
||||
|
||||
|
||||
```
|
||||
# import the DataFrame shown above
|
||||
from votes import long as df
|
||||
|
||||
# Get a tuple for each possible (year, party) combination
|
||||
x = [(str(r[1]['year']), r[1]['party']) for r in df.iterrows()]
|
||||
|
||||
# This comes out as [('1922', 'Conservative'), ('1923', 'Conservative'), ... ('2019', 'Others')]
|
||||
```
|
||||
|
||||
These will be the x-values. The y-values are simply the seats:
|
||||
|
||||
|
||||
```
|
||||
` y = df['seats']`
|
||||
```
|
||||
|
||||
Now you have data that looks something like this:
|
||||
|
||||
|
||||
```
|
||||
x y
|
||||
('1966', 'Conservative') 253
|
||||
('1970', 'Conservative') 330
|
||||
('Feb 1974', 'Conservative') 297
|
||||
('Oct 1974', 'Conservative') 277
|
||||
('1979', 'Conservative') 339
|
||||
... ... ...
|
||||
('2005', 'Others') 30
|
||||
('2010', 'Others') 29
|
||||
('2015', 'Others') 80
|
||||
('2017', 'Others') 59
|
||||
('2019', 'Others') 72
|
||||
```
|
||||
|
||||
Bokeh needs you to wrap your data in some objects it provides, so it can give you the interactive functionality. Wrap your x and y data structures in a `ColumnDataSource` object:
|
||||
|
||||
|
||||
```
|
||||
from bokeh.models import ColumnDataSource
|
||||
|
||||
source = ColumnDataSource(data={'x': x, 'y': y})
|
||||
```
|
||||
|
||||
Then construct a `Figure` object and pass in your x-data wrapped in a `FactorRange` object:
|
||||
|
||||
|
||||
```
|
||||
from bokeh.plotting import figure
|
||||
from bokeh.models import FactorRange
|
||||
|
||||
p = figure(x_range=FactorRange(*x), width=2000, title="Election results")
|
||||
```
|
||||
|
||||
You need to get Bokeh to create a colormap—this is a special `DataSpec` dictionary it produces from a color mapping you give it. In this case, the colormap is a simple mapping between the party name and a hex value:
|
||||
|
||||
|
||||
```
|
||||
from bokeh.transform import factor_cmap
|
||||
|
||||
cmap = {
|
||||
'Conservative': '#0343df',
|
||||
'Labour': '#e50000',
|
||||
'Liberal': '#ffff14',
|
||||
'Others': '#929591',
|
||||
}
|
||||
fill_color = factor_cmap('x', palette=list(cmap.values()), factors=list(cmap.keys()), start=1, end=2)
|
||||
```
|
||||
|
||||
Now you can create the bar chart:
|
||||
|
||||
|
||||
```
|
||||
` p.vbar(x='x', top='y', width=0.9, source=source, fill_color=fill_color, line_color=fill_color)`
|
||||
```
|
||||
|
||||
Visual representations of data on Bokeh charts are referred to as glyphs, so you've created a set of bar glyphs.
|
||||
|
||||
Tweak the details of the graph to get it looking how you want:
|
||||
|
||||
|
||||
```
|
||||
p.y_range.start = 0
|
||||
p.x_range.range_padding = 0.1
|
||||
p.yaxis.axis_label = 'Seats'
|
||||
p.xaxis.major_label_orientation = 1
|
||||
p.xgrid.grid_line_color = None
|
||||
```
|
||||
|
||||
And finally, tell Bokeh you'd like to see your plot now:
|
||||
|
||||
|
||||
```
|
||||
from bokeh.io import show
|
||||
|
||||
show(p)
|
||||
```
|
||||
|
||||
This writes the plot to an HTML file and opens it in the default web browser. Here's the result:
|
||||
|
||||
![A multi-bar plot in Bokeh][6]
|
||||
|
||||
A multi-bar plot in Bokeh (© 2019 [Anvil][5])
|
||||
|
||||
This already has some interactive features, such as a box zoom:
|
||||
|
||||
![Bokeh's built-in box zoom][7]
|
||||
|
||||
Bokeh's built-in box zoom (© 2019 [Anvil][5])
|
||||
|
||||
But the great thing about Bokeh is how you can add your own interactivity. Explore that in the next section by adding tooltips to the bars.
|
||||
|
||||
### Adding tooltips to the bars
|
||||
|
||||
To add tooltips to the bars, you just need to create a `HoverTool` object and add it to your figure:
|
||||
|
||||
|
||||
```
|
||||
h = HoverTool(tooltips=[
|
||||
('Seats', '@y'),
|
||||
('(Year, Party)', '(@x)')
|
||||
])
|
||||
p.add_tools(h)
|
||||
```
|
||||
|
||||
The arguments define what data is displayed on the tooltips. The variables `@y` and `@x` refer to the variables you passed into the `ColumnDataSource`. There are a few other values you could use; for example, the position of the cursor on the plot is given by `$x` and `$y` (no relation to `@x` and `@y`).
|
||||
|
||||
Here's the result:
|
||||
|
||||
![The election graph, now with tooltips][8]
|
||||
|
||||
The election graph, now with tooltips (© 2019 [Anvil][5])
|
||||
|
||||
Thanks to Bokeh's HTML output, you get the full interactive experience when you embed the plot in a web app. You can copy this example as an Anvil app [here][9] (Note: Anvil requires registration to use).
|
||||
|
||||
Now you can see the reason for the extra effort of wrapping all your data in Bokeh in objects such as `ColumnDataSource`. In return, you can add interactivity with relative ease.
|
||||
|
||||
### Back to simplicity: Altair
|
||||
|
||||
Bokeh is one of the four most popular plotting libraries, and this series is looking into [what makes each of them special][3].
|
||||
|
||||
I'm also looking at a couple of libraries that stand out for their interesting approach. Next, I'll look at [Altair][10], whose declarative API means it can make really complex plots without causing brain ache.
|
||||
|
||||
* * *
|
||||
|
||||
_This article is based on [How to make plots using Bokeh][5] on Anvil's blog and is reused with permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/5/bokeh-python
|
||||
|
||||
作者:[Shaun Taylor-Morgan][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者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/shaun-taylor-morgan
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book )
|
||||
[2]: https://bokeh.org/
|
||||
[3]: https://opensource.com/article/20/4/plot-data-python
|
||||
[4]: https://opensource.com/sites/default/files/uploads/bokeh-closeup.png (A zoomed-in view on the plot)
|
||||
[5]: https://anvil.works/blog/plotting-in-bokeh
|
||||
[6]: https://opensource.com/sites/default/files/uploads/bokeh_0.png (A multi-bar plot in Bokeh)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/bokeh-box-zoom.gif (Bokeh's built-in box zoom)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/bokeh-tooltips.gif (The election graph, now with tooltips)
|
||||
[9]: https://anvil.works/build#clone:CFRUWSM6PQ6JUUXH%3dSX4SACDSXBB4UOIVEVPWXH55%7cMYTOLCU2HM5WKJYM%3d6VJKGRSF74TCCVDG5CTVDOCS
|
||||
[10]: https://altair-viz.github.io/
|
@ -0,0 +1,112 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to find and remove broken symlinks on Linux)
|
||||
[#]: via: (https://www.networkworld.com/article/3546252/how-to-find-and-remove-broken-symlinks-on-linux.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
How to find and remove broken symlinks on Linux
|
||||
======
|
||||
A symlink or "symbolic link" is a Linux file that simply points at another file. If the referenced file is removed, the symlink will remain but not indicate there's a problem until you try to use it. Here are some easy ways to find and remove symlinks that point to files that have been moved or removed.
|
||||
Thinkstock
|
||||
|
||||
Symbolic links play a very useful role on Linux systems. They can help you remember where important files are located on a system, make it easier for you to access those files and save you a good amount of disk space and trouble by making it unnecessary for you to copy large files just to make them a little more accessible.
|
||||
|
||||
### What exactly is a symbolic link?
|
||||
|
||||
Generally referred to as a "symlink" or "soft link", symbolic links are very small files. In fact, all a symlink really contains is the name of whatever file it points to, generally along with the file system path (relative to the current location or absolute). If a file named **ref1** points to a file named **/apps/refs/ref-2020**, **ref1** will be 19 characters long even if the ref-2020 file is 2 terabytes. If it points to **./ref-2020**, it will be only 10 characters in length. If it points to **ref-2020**, only eight.
|
||||
|
||||
If you issue a command like "vi ref1" (where ref1 is the name of a symlink), you will end up editing whatever file ref1 points to, not the contents of the symlink itself. Linux systems know how to work with symlinks and simply do the right thing. Similarly, if you use commands like **cat**, **more**, **head** or **tail**, you'll be looking at the content of the referenced file.
|
||||
|
||||
If you delete a symlink, on the other hand, you will be removing the link, never the referenced file. Again, Linux does what makes sense. Symlinks were meant to make using and sharing files easier -- nothing more.
|
||||
|
||||
#### When symlinks get broken
|
||||
|
||||
When the file that a symbolic link points to is removed from the system or renamed, the symlink will no longer function as intended. Being little more than a reference stored in some particular directory, the symlink isn't going to be updated or removed with changes to the file it points to. It keeps pointing at the referenced file, even after that file is long gone.
|
||||
|
||||
If you try to use a symlink that points to a non-existent file, you will get an error like this:
|
||||
|
||||
```
|
||||
$ tail whassup
|
||||
tail: cannot open 'whassup' for reading: No such file or directory
|
||||
```
|
||||
|
||||
If you try to access a symlink that points to itself (yes, stranger things have happened), you will see something like this:
|
||||
|
||||
```
|
||||
$ cat loopy
|
||||
cat: loopy: Too many levels of symbolic links
|
||||
$ ls -l loopy
|
||||
lrwxrwxrwx 1 shs shs 5 May 28 18:07 loopy -> loopy
|
||||
```
|
||||
|
||||
And, just in case that first letter in the long listing didn't catch your attention, it indicates that the file is a symbolic link. The **rwxrwxrwx** permissions are standard and don't reflect the permissions on the file the symlink points at.
|
||||
|
||||
### Finding broken symlinks
|
||||
|
||||
The find command has an option that allows you to locate symlinks that point to files that no longer exist. This command lists symlinks in the current directory:
|
||||
|
||||
```
|
||||
$ find . -type l
|
||||
```
|
||||
|
||||
The "l" (lowercase L) tells the find command to look for symbolic links.
|
||||
|
||||
The command shown below, on the other hand, looks in the current directory for symlinks that point to files that don't exist:
|
||||
|
||||
```
|
||||
$ find . -xtype l
|
||||
```
|
||||
|
||||
To avoid running into errors when the command tries to look into files or directories that you don't have permission to examine, you can send all error output to /dev/null like this:
|
||||
|
||||
```
|
||||
$ find . -xtype l 2>/dev/null
|
||||
```
|
||||
|
||||
You can also find broken symlinks with a command like this one. It's longer than the earlier one, but should do the same thing:
|
||||
|
||||
```
|
||||
$ find . -type l ! -exec test -e {} \; -print 2>/dev/null
|
||||
```
|
||||
|
||||
### What to do with broken symlinks
|
||||
|
||||
Unless you know that the file a symlink references is going to be replaced, the best move is to simply remove the broken link. In fact, you can find and remove broken symlinks in a single command if you want to, with a command like this one:
|
||||
|
||||
```
|
||||
$ find . -xtype l 2>/dev/null -exec rm {} \;
|
||||
```
|
||||
|
||||
The **rm {}** portion of that command turns into a "remove filename" command.
|
||||
|
||||
If, instead, you want to associate the symlink with a different file, you will have to remove the symlink and then recreate it so that it points to the new file. Here's an example:
|
||||
|
||||
```
|
||||
$ rm ref1
|
||||
$ ln -s /apps/data/newfile ref1
|
||||
```
|
||||
|
||||
#### Wrap-Up
|
||||
|
||||
Symbolic links make the referenced files easier to find and use, but they sometimes evolve into little more than road signs that advertise a diner that closed last year. Finding commands can help you get rid of the broken symlinks or alert you to the absence of files that you might still require.
|
||||
|
||||
Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3546252/how-to-find-and-remove-broken-symlinks-on-linux.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.facebook.com/NetworkWorld/
|
||||
[2]: https://www.linkedin.com/company/network-world
|
@ -1,67 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (HankChow)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What is the Difference Between Soft link vs Hard link in Linux?)
|
||||
[#]: via: (https://www.2daygeek.com/difference-between-soft-link-vs-hard-link-linux/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
What is the Difference Between Soft link vs Hard link in Linux?
|
||||
======
|
||||
|
||||
A link is a mechanism for creating a shortcut to the original file or directory. It contains information about another file or directory.
|
||||
|
||||
Links allow more than one filename to reference the same file.
|
||||
|
||||
### What’s Soft link
|
||||
|
||||
A symbolic link, also known as a symlink or a soft link, is a special type of file that points to another file or directory on Linux.
|
||||
|
||||
It’s like a shortcut in Windows. It contains the path of the original file and not the contents.
|
||||
|
||||
In general Symbolic links are used to link libraries. Also, used to link log files and folders on mounted NFS (Network File System) shares.
|
||||
|
||||
### What’s Hard link
|
||||
|
||||
Hard link is a mirror copy of the original file. Deleting the original file does not impact anything, because the hard link file serves as a mirror copy of the original file.
|
||||
|
||||
Why would you want to create a link file instead of copying them?
|
||||
|
||||
This is especially useful when you want to keep a same files in multiple location with updated contents.
|
||||
|
||||
When you copy a file to another location, it will copy the content and never get updated from the source file.
|
||||
|
||||
The contents of the file will be different from time to time.
|
||||
|
||||
### The difference between Soft link vs Hard link
|
||||
|
||||
I’ve included possible difference between soft link and hard link in the table below.
|
||||
|
||||
S.No | Soft Link | Hard Link
|
||||
---|---|---
|
||||
1 | The soft link is similar to the file shortcut on Windows. | Hard link is a mirror copy of the original file.
|
||||
2 | Soft link can be called Symbolic link or symlink. | Hard link has no other name
|
||||
3 | Changes in both file are reflected in the other. | It's like a soft link.
|
||||
4 | Soft links can be created on different file systems. | Hard link can only be made on the same file system.
|
||||
5 | Can create a soft link to files and directories | Only files can be linked
|
||||
6 | It has different inode number and file permissions compared to the original file. | It has the same inode number and file permissions.
|
||||
7 | It contains the path of the original file and not the contents. | It contains the actual contents of the original file.
|
||||
8 | When the original file is removed, the link will die because it points to a non-existent file. This is called the hanging link. | Nothing happens when the original file is removed.
|
||||
9 | You can create a soft link with the following command (# ln -s [Source Filename] [Link Name]) | Hard link can be created using the following command (# ln [Source Filename] [Link Name])
|
||||
10 | The soft link file contains a special symbol "l" in the file permission field. | There is no special symbol for this.
|
||||
11 | You can find the soft link file with the following command (# find / -type l) | You can find the hard link file with the following command (# find / -samefile [Source Filename])
|
||||
12 | A broken soft link can be found using the following command (# symlinks [Path/to/Directory]). | Not applicable
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/difference-between-soft-link-vs-hard-link-linux/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
@ -0,0 +1,70 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (HankChow)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (What is the Difference Between Soft link vs Hard link in Linux?)
|
||||
[#]: via: (https://www.2daygeek.com/difference-between-soft-link-vs-hard-link-linux/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
|
||||
Linux 中软链接和硬链接的区别
|
||||
======
|
||||
|
||||
<ruby>链接<rt>Link</rt></ruby>是一种快捷访问机制,它通过一个文件指向原始文件或目录的方式实现快捷访问,同时还记录了原始文件或目录的一些信息。
|
||||
|
||||
链接允许多个不同文件对同一个文件进行引用。
|
||||
|
||||
### 什么是软链接
|
||||
|
||||
<ruby>符号链接<rt>Symbolic Link</rt></ruby>,又称<ruby>软链接<rt>Soft Link</rt></ruby>,是一种特殊的文件,它指向 Linux 系统上的另一个文件或目录。
|
||||
|
||||
这和 Windows 系统中的快捷方式有点类似,链接文件中记录的只是原始文件的路径,并不记录原始文件的内容。
|
||||
|
||||
符号链接通常用于对库进行链接,也常用于链接<ruby>网络文件系统<rt>Network File System</rt></ruby>(NFS)上共享的日志文件和目录。
|
||||
|
||||
### 什么是硬链接
|
||||
|
||||
硬链接是原始文件的一个镜像副本。创建硬链接后,如果把原始文件删除,链接文件也不会受到影响,因为此时原始文件和链接文件互为镜像副本。
|
||||
|
||||
为什么要创建链接文件而不直接复制文件呢?
|
||||
|
||||
当你需要将同一个文件保存在多个不同位置,而且还要保持持续更新的时候,硬链接的重要性就体现出来了。
|
||||
|
||||
如果你只是单纯把文件复制到另一个位置,那么另一个位置的文件只会保存着复制那一刻的文件内容,后续也不会跟随着原始文件持续更新。
|
||||
|
||||
而使用硬链接时,各个镜像副本的文件内容都会同时更新。
|
||||
|
||||
### 软链接和硬链接的区别
|
||||
|
||||
下表列出了软链接和硬链接之间的区别。
|
||||
|
||||
# | 软链接 | 硬链接
|
||||
---|---|---
|
||||
1 | 软链接类似于 Windows 系统中的快捷方式 | 硬链接是原始文件的一个镜像副本
|
||||
2 | 软链接又称符号链接 | 硬链接没有别名
|
||||
3 | 链接中任何一个文件发生改变,都会同步到连接中的其它文件 | 和软链接一样
|
||||
4 | 软链接可以跨文件系统进行创建 | 硬链接不可以跨文件系统进行创建
|
||||
5 | 软链接可以指向文件或目录 | 硬链接只能指向文件
|
||||
6 | 链接文件和原始文件之间的 inode 和文件权限不完全一致 | 链接文件和原始文件的 inode 和文件权限完全一致
|
||||
7 | 链接文件只记录原始文件的路径,不记录原始文件的内容 | 链接文件记录了原始文件的内容
|
||||
8 | 如果原始文件被移除,软链接就会因为指向不存在的文件而失效。这被称为“<ruby>挂起链接<rt>the hanging link</rt></ruby>” | 即使原始文件被移除,链接文件也不受影响。
|
||||
9 | 通过 `ln -s <原始文件> <链接文件>` 命令创建软链接 | 通过 `ln <原始文件> <链接文件>` 命令创建硬链接
|
||||
10 | 软链接文件的文件权限中有一个特殊标记 "l" | 硬链接文件没有特殊标记
|
||||
11 | 通过 `find / -type l` 命令可以查找软链接文件 | 通过 `find / -samefile <原始文件>` 命令可以查找硬链接文件
|
||||
12 | 通过 `symlinks <目录>` 命令可以查找失效的软链接 | 硬链接不存在失效链接
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/difference-between-soft-link-vs-hard-link-linux/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[HankChow](https://github.com/HankChow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
Loading…
Reference in New Issue
Block a user