mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-12 01:40:10 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
2d88d3146e
@ -0,0 +1,112 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-12298-1.html)
|
||||
[#]: 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/)
|
||||
|
||||
如何在 Linux 上查找和删除损坏的符号链接
|
||||
======
|
||||
|
||||

|
||||
|
||||
> 符号链接是指向另一个文件的 Linux 文件。如果删除了被引用的文件,符号链接会保留,但不会显示有问题,除非你尝试使用它。以下是查找和删除指向文件已被删除的符号链接的简单方法。
|
||||
|
||||
<ruby>符号链接<rt>symbolic link</rt></ruby>在 Linux 系统上扮演了非常有用的角色。它们可以帮助你记住重要文件在系统上的位置,使你更容易访问这些文件,并让你不必为了更方便访问大文件而复制它们,从而节省了大量的空间。
|
||||
|
||||
### 什么是符号链接?
|
||||
|
||||
通常称它们为“符号链接”或“软链接”,符号链接是非常小的文件。实际上,符号链接真正包含的是它指向的文件的名称,通常包含路径(相对于当前位置或绝对路径)。如果有个名为 `ref1` 的文件指向名为 `/apps/refs/ref-2020` 的文件,那么 `ref1` 的长度将为 19 个字符,即使 `ref-202` 文件有 2TB。如果指向 `./ref-2020`,那么长度仅为 10 个字符。如果指向 `ref-2020`,那么只有 8 个字节。
|
||||
|
||||
如果你执行 `vi ref1` 之类的命令(其中 `ref1` 是符号链接的名称),你将编辑 `ref1` 指向的文件,而不是符号链接本身的内容。Linux 系统知道如何使用符号链接,并且可以做正确的事。同样,如果你使用诸如 `cat`、`more`、`head` 或 `tail` 之类的命令,那么将查看引用文件的内容。
|
||||
|
||||
另一方面,如果删除符号链接,你将删除该链接,而不是引用的文件。再说一次,Linux 知道怎么做。符号链接使得使用和共享文件更加容易,仅此而已。
|
||||
|
||||
#### 符号链接损坏时
|
||||
|
||||
当一个符号链接所指向的文件从系统中删除或重新命名时,符号链接将不再起作用。符号链接只不过是存储在某个特定目录中的引用而已,它不会随着指向它的文件发生变化而更新或删除。它一直指向被引用的文件,即使这个文件早已消失。
|
||||
|
||||
如果你尝试使用指向一个不存在的文件的符号链接,那么将出现如下错误:
|
||||
|
||||
```
|
||||
$ tail whassup
|
||||
tail: cannot open 'whassup' for reading: No such file or directory
|
||||
```
|
||||
|
||||
如果你尝试访问指向自身的符号链接(是的,奇怪的事情发生了),你将看到类似以下的内容:
|
||||
|
||||
```
|
||||
$ cat loopy
|
||||
cat: loopy: Too many levels of symbolic links
|
||||
$ ls -l loopy
|
||||
lrwxrwxrwx 1 shs shs 5 May 28 18:07 loopy -> loopy
|
||||
```
|
||||
|
||||
而且,如果(上面的)长列表的第一个字母没有引起你的注意,这表示该文件是符号链接。`rwxrwxrwx` 权限是标准权限,并不反映符号链接指向的文件的权限。
|
||||
|
||||
### 查找损坏的符号链接
|
||||
|
||||
`find` 命令有一个选项,能让你找到指向不再存在的文件的符号链接。此命令列出当前目录中的符号链接:
|
||||
|
||||
```
|
||||
$ find . -type l
|
||||
```
|
||||
|
||||
`l` (小写字母 `L`)告诉 `find` 命令查找符号链接。
|
||||
|
||||
另一方面,下面的命令在当前目录中查找指向*不存在*的文件的符号链接:
|
||||
|
||||
```
|
||||
$ find . -xtype l
|
||||
```
|
||||
|
||||
为了避免在该命令尝试查找你无权检查的文件或目录时发生错误,你可以将所有错误输出到 `/dev/null`,如下所示:
|
||||
|
||||
```
|
||||
$ find . -xtype l 2>/dev/null
|
||||
```
|
||||
|
||||
你也可以使用此命令找到损坏的符号链接。它比前面的更长,但做的是同样的事情:
|
||||
|
||||
```
|
||||
$ find . -type l ! -exec test -e {} \; -print 2>/dev/null
|
||||
```
|
||||
|
||||
### 如何处理损坏的符号链接
|
||||
|
||||
除非你知道符号链接引用的文件会被替换,否则最好的方法是直接删除损坏的链接。实际上,如果需要,你可以使用一条命令查找并删除损坏的符号链接,如:
|
||||
|
||||
```
|
||||
$ find . -xtype l 2>/dev/null -exec rm {} \;
|
||||
```
|
||||
|
||||
该命令的 `rm {}` 部分会变成“删除文件”的命令
|
||||
|
||||
如果你想将符号链接与不同的文件相关联,你必须先删除该符号链接,然后重新创建它,使其指向新文件。这是一个例子:
|
||||
|
||||
```
|
||||
$ rm ref1
|
||||
$ ln -s /apps/data/newfile ref1
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
符号链接使引用的文件更易于查找和使用,但有时它会比那些宣传去年已经关闭的餐馆的路标还过分。`find` 命令可以帮助你摆脱损坏的符号链接,或者提醒你没有你可能仍然需要的文件。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3546252/how-to-find-and-remove-broken-symlinks-on-linux.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [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
|
131
sources/talk/20200519 24 Linux desktops you need to try.md
Normal file
131
sources/talk/20200519 24 Linux desktops you need to try.md
Normal file
@ -0,0 +1,131 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (24 Linux desktops you need to try)
|
||||
[#]: via: (https://opensource.com/article/20/5/linux-desktops)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
24 Linux desktops you need to try
|
||||
======
|
||||
Gotta catch them all!
|
||||
![Penguins][1]
|
||||
|
||||
One of the great strengths of the Linux desktop is the choice it affords its users. If you don't like your application menu in the lower left of your screen, you can move it. If you don't like the way your file manager organizes your documents, you can use a different one. Admittedly, however, that can be confusing for new users who aren't used to having a say in how they use their computers. If you're looking at installing Linux, one of the choices you're going to have to make is which desktop you want to use, and the best way to do that is to try a few different ones until you find the one that feels right for you.
|
||||
|
||||
### The defaults
|
||||
|
||||
![][2]
|
||||
|
||||
opensource.com
|
||||
|
||||
As the default on Fedora, Ubuntu, Debian, and several others, the GNOME desktop is probably the most popular desktop for Linux. It's an intuitive and modern interface, with little nods to mobile design so it feels natural even on a touch screen.
|
||||
|
||||
Some distributions of Linux opt for something different, though, including KDE Plasma, Pantheon, Cinnamon, and Mate.
|
||||
|
||||
* [GNOME][3]: the modern and intuitive default
|
||||
* [Mate][4]: legacy GNOME
|
||||
* [KDE][5]: the powerful and configurable Plasma desktop
|
||||
* [Cinnamon][6]: classic GNOME
|
||||
* [Pantheon][7]: the divine default of [ElementaryOS][8]
|
||||
* [Budgie][9]: a subdued desktop
|
||||
* [Trinity][10]: legacy KDE
|
||||
|
||||
|
||||
|
||||
# Traditional Unix
|
||||
|
||||
![Window Maker running on Fedora][11]
|
||||
|
||||
Unix, the progenitor of modern operating systems and the direct inspiration for Linux, has a surprisingly rich history of desktops. Most people aren't familiar with Unix desktop design because Unix computers were considered specialist machines common to academic, scientific, and film settings rather than the household. If you were a Unix, IRIX, or NeXT user, then you might have fond memories of desktops like [CDE][12] or NeXTStep. You're in luck because the tradition lives on:
|
||||
|
||||
* [Windowmaker][13]: the NeXT interface reborn
|
||||
* [Enlightenment][14]: a modernized and improved Windowmaker-style desktop
|
||||
* [Fluxbox][15]: thinking outside the box
|
||||
* [Openbox][16]: improving the usability of the box
|
||||
* [TWM][17]: the timeless sample desktop bundled with X11
|
||||
* [Fvwm][18]: TWM improved
|
||||
|
||||
|
||||
|
||||
### Lightweight desktops
|
||||
|
||||
![XFCE in 2019 on Mageia Linux][19]
|
||||
|
||||
You might wonder why Linux has so many desktops to choose from. While you can chalk a lot of it up to personal preference and a low tolerance for inefficiency, there are technical benefits to optimizing an interface. For instance, old computers struggling to keep up with an update to its UI [can be given new life](<https://opensource.com/article/20/2/macbook-linux-elementary>) with a lightweight desktop. Alternately, you may simply want to allocate CPU cycles to everything *but* your desktop, so keeping your primary UI minimal just makes sense. Whatever your reason, there are several you can try:
|
||||
|
||||
* [XFCE][20]: delivers a familiar desktop for a fraction of the cost
|
||||
* [LXQT and LXDE][21]: familiar desktops for a smaller fraction of the cost
|
||||
* [PekWM][22]: a box-style window manager
|
||||
* [Joe's Window Manager][23]: another box-style window manager
|
||||
* [Ratpoison][24]: don't touch that mouse
|
||||
* [Herbstluftwm][25]: Ratpoison for [Vim users][26]
|
||||
* [Lumina][27]: a desktop developed for PC-BSD
|
||||
|
||||
|
||||
|
||||
### Experimental desktops
|
||||
|
||||
![Unix Desktop Environment][28]
|
||||
|
||||
One of the things that happens when it's relatively easy to create and integrate a desktop into a system is that you get interesting proof-of-concepts and experimental projects. Some are more polished than others, and some aren't terribly easy to install. These probably aren't destined to be your permanent desktop, but they can be fun to experience:
|
||||
|
||||
* [Unix Desktop Environment][29]: a reinvention of the desktop
|
||||
* [Rox][30]: a progressive and modern desktop in its day
|
||||
* [MLVWM][31]: what if the Apple IIe had run Unix?
|
||||
* [Equinox][32]: just the basics
|
||||
|
||||
|
||||
|
||||
### Choose your desktop
|
||||
|
||||
If you're overwhelmed by choice, then keep in mind that desktops are meant to be _optional_. There's no obligation to try more than the one that ships with your distribution.
|
||||
|
||||
Many a power user of Linux settles for whatever desktop their distribution puts in front of them. The important thing is to get a Linux install that works with your computer, and spend time with it to learn how it works. Ultimately, all desktops are only meant to do the same thing: help you organize and manage your important data. As long as you know how your desktop works, that's all that matters. But if you've learned everything you need to know about your default desktop, you now have plenty of options to try out on the weekend. Have fun!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/5/linux-desktops
|
||||
|
||||
作者:[Seth Kenlon][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/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_ (Penguins)
|
||||
[2]: https://opensource.com/sites/default/files/advent-gnome.jpg
|
||||
[3]: https://opensource.com/article/19/12/gnome-linux-desktop
|
||||
[4]: https://opensource.com/article/19/12/mate-linux-desktop
|
||||
[5]: https://opensource.com/article/19/12/linux-kde-plasma
|
||||
[6]: https://opensource.com/article/19/12/cinnamon-linux-desktop
|
||||
[7]: https://opensource.com/article/19/12/pantheon-linux-desktop
|
||||
[8]: https://elementary.io/
|
||||
[9]: https://opensource.com/article/19/12/budgie-linux-desktop
|
||||
[10]: https://opensource.com/article/19/12/linux-trinity-desktop-environment-tde
|
||||
[11]: https://opensource.com/sites/default/files/uploads/advent-windowmaker.jpg (Window Maker running on Fedora)
|
||||
[12]: https://sourceforge.net/projects/cdesktopenv/
|
||||
[13]: https://opensource.com/article/19/12/linux-window-maker-desktop
|
||||
[14]: https://opensource.com/article/19/12/linux-enlightenment-desktop
|
||||
[15]: https://opensource.com/article/19/12/fluxbox-linux-desktop
|
||||
[16]: https://opensource.com/article/19/12/openbox-linux-desktop
|
||||
[17]: https://opensource.com/article/19/12/twm-linux-desktop
|
||||
[18]: https://opensource.com/article/19/12/fvwm-linux-desktop
|
||||
[19]: https://opensource.com/sites/default/files/advent-xfce.jpg (XFCE on Mageia Linux in 2019)
|
||||
[20]: https://opensource.com/article/19/12/xfce-linux-desktop
|
||||
[21]: https://opensource.com/article/19/12/lxqt-lxde-linux-desktop
|
||||
[22]: https://opensource.com/article/19/12/pekwm-linux-desktop
|
||||
[23]: https://opensource.com/article/19/12/joes-window-manager-linux-desktop
|
||||
[24]: https://opensource.com/article/19/12/ratpoison-linux-desktop
|
||||
[25]: https://opensource.com/article/19/12/herbstluftwm-linux-desktop
|
||||
[26]: https://opensource.com/resources/what-vim
|
||||
[27]: https://opensource.com/article/19/12/linux-lumina-desktop
|
||||
[28]: https://opensource.com/sites/default/files/uploads/advent-ude.jpg (Unix Desktop Environment)
|
||||
[29]: https://opensource.com/article/19/12/linux-unix-desktop-environment-ude
|
||||
[30]: https://opensource.com/article/19/12/linux-rox-desktop
|
||||
[31]: https://opensource.com/article/19/12/linux-mlvwm-desktop
|
||||
[32]: https://opensource.com/article/19/12/ede-linux-desktop
|
@ -1,111 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: 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/)
|
||||
|
||||
如何在 Linux 上查找和删除损坏的符号链接
|
||||
======
|
||||
符号链接 (symbolic link) 是指向另一个文件的 Linux 文件。如果删除了引用的文件,符号链接将保留,除非你尝试使用它,否则不会有问题。以下是查找和删除指向文件已被删除的符号链接的简单方法。
|
||||
|
||||
符号链接在 Linux 系统上扮演了非常有用的角色。它们可以帮助你记住重要文件在系统上的位置,让你不必为了更方便访问大文件而复制它们,从而更方便地访问它们并节省了大量的空间。
|
||||
|
||||
### 什么是符号链接?
|
||||
|
||||
通常称它们为 “symlink” 或“软链接”,符号链接是非常小的文件。实际上,符号链接真正包含的是它指向文件的名称,通常包含路径(相对于当前位置或绝对路径)。如果有个名为 **ref1** 的文件指向名为 **/apps/refs/ref-2020** 的文件,那么 **ref1** 的长度将为 19 个字符,即使 ref-202 文件有 2TB。如果指向 **./ref-2020**,那么长度仅为 10 个字符。如果指向 **ref-2020**,那么只有八个。
|
||||
|
||||
如果你执行 “vi ref1” 之类的命令(其中 ref1 是符号链接的名称),你将编辑 ref1 指向的文件,而不是符号链接本身的内容。Linux 系统知道如何使用符号链接,并且可以做正确的事。同样,如果你使用诸如 **cat**、**more**、**head** 或 **tail** 之类的命令,那么将查看引用文件的内容。
|
||||
|
||||
另一方面,如果删除符号链接,你将删除链接,而不是引用的文件。再说一次,Linux 知道怎么做。符号链接使得使用和共享文件更加容易,仅此而已。
|
||||
|
||||
#### 符号链接损坏时
|
||||
|
||||
当删除或重命名符号链接指向的文件时,符号链接将不再起作用。符号链接只不过是存储在某个特定目录中的引用而已,它不会随着指向它的文件的更改而更新或删除。即使该文件已经消失了很长时间,它仍然指向被引用的文件。
|
||||
|
||||
如果尝试使用指向不存在的文件的符号链接,那么将出现如下错误:
|
||||
|
||||
```
|
||||
$ tail whassup
|
||||
tail: cannot open 'whassup' for reading: No such file or directory
|
||||
```
|
||||
|
||||
如果你尝试访问指向自身的符号链接(是的,发生了陌生的事情),你将看到类似以下的内容:
|
||||
|
||||
```
|
||||
$ cat loopy
|
||||
cat: loopy: Too many levels of symbolic links
|
||||
$ ls -l loopy
|
||||
lrwxrwxrwx 1 shs shs 5 May 28 18:07 loopy -> loopy
|
||||
```
|
||||
|
||||
以防万一,如果列表中的第一个字母没有引起你的注意,这表示该文件是符号链接。**rwxrwxrwx** 权限是标准权限,并不反映符号链接指向的文件的权限。
|
||||
|
||||
### 查找损坏的符号链接
|
||||
|
||||
find 命令有一个选项,能让你找到指向不再存在的文件的符号链接。此命令列出当前目录中的符号链接:
|
||||
|
||||
```
|
||||
$ find . -type l
|
||||
```
|
||||
|
||||
“ l”(小写字母 L)告诉 find 命令查找符号链接。
|
||||
|
||||
另一方面,下面的命令在当前目录中查找指向不存在的文件的符号链接:
|
||||
|
||||
```
|
||||
$ find . -xtype l
|
||||
```
|
||||
|
||||
为了避免在命令尝试查找你无权检查的文件或目录时发生错误,你可以将所有错误输出到 /dev/null,如下所示:
|
||||
|
||||
```
|
||||
$ find . -xtype l 2>/dev/null
|
||||
```
|
||||
|
||||
你也可以使用此命令找到损坏的符号链接。它比以前的更长,但会做同样的事情:
|
||||
|
||||
```
|
||||
$ find . -type l ! -exec test -e {} \; -print 2>/dev/null
|
||||
```
|
||||
|
||||
### 如何处理损坏的符号链接
|
||||
|
||||
除非你知道符号链接引用的文件将被替换,否则最好的方法是直接删除损坏的链接。实际上,如果需要,你可以使用以下命令在单个命令中查找和删除损坏的符号链接:
|
||||
|
||||
```
|
||||
$ find . -xtype l 2>/dev/null -exec rm {} \;
|
||||
```
|
||||
|
||||
该命令的 **rm {}** 部分是“删除文件名”命令
|
||||
|
||||
相反,如果你想将符号链接与其他文件相关联,你必须先删除该符号链接,然后重新创建它,使其指向新文件。这是一个例子:
|
||||
|
||||
```
|
||||
$ rm ref1
|
||||
$ ln -s /apps/data/newfile ref1
|
||||
```
|
||||
|
||||
#### 总结
|
||||
|
||||
符号链接使引用的文件更易于查找和使用,但有时它会比路标上那些去年关闭的餐馆广告还要多。查找命令可以帮助你摆脱损坏的符号链接,或在缺少可能仍需要的文件时提醒你。
|
||||
|
||||
加入 [Facebook][1] 和 [LinkedIn][2] 上的 Network World 社区,评论热门主题。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3546252/how-to-find-and-remove-broken-symlinks-on-linux.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者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
|
Loading…
Reference in New Issue
Block a user