From 842abe779ec68a399c014b61253985ec21c334f0 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 6 Sep 2022 21:57:24 +0800 Subject: [PATCH 01/12] R MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Return7g 感谢您,完成了第一篇翻译贡献! --- ...mparing the Different Linux Experiences.md | 103 ++++++++++-------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md b/translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md index 7ca3535a6c..7a4316a39c 100644 --- a/translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md +++ b/translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md @@ -3,78 +3,83 @@ [#]: author: "Ankush Das https://itsfoss.com/author/ankush/" [#]: collector: "lkxed" [#]: translator: "Return7g" -[#]: reviewer: " " +[#]: reviewer: "wxy" [#]: publisher: " " [#]: url: " " -对比Ubuntu和Manjaro:比较不同的Linux发行版体验 - +Ubuntu 和 Manjaro:比较两种不同的 Linux 发行版体验 ====== + +![](https://img.linux.net.cn/data/attachment/album/202209/06/215515o89v2xu8v05rv759.jpg) + Ubuntu 是基于 Debian 最流行的桌面和服务器 Linux 发行版。 Manjaro 是基于 Arch 量身定制的 Linux 发行版。 两者在用户体验以及功能上都大相径庭。 -然而,在比较Manjaro的GNOME版和Ubuntu时,其中一个共同点是[桌面环境][1]。 +然而,将 Manjaro 的 GNOME 版和 Ubuntu 放到一起比较时,其中一个共同点是 [桌面环境][1]。 - -但它们之间的差异到底在哪? Manjaro 的包管理器会更好用吗?Ubuntu 和 Manjaro 上的软件生态怎么样? +但它们到底有什么不同?Manjaro 的包管理器会更好用吗?Ubuntu 和 Manjaro 上的软件生态怎么样? 接下来,我们来看看两个 Linux 发行版在某些关键问题上的差异。 - ### 发行周期 -Ubuntu根据你选择的版本不同提供了两个发行周期。如果你选择的是长期发行版本(Long Term Support, LTS),那么你在至少未来五年内都会收到安全维护更新。 -假如你安装了 Ubuntu 22.04 ,那么你在**2027 年 4 月**之前都能获取更新。 +Ubuntu 根据你选择的版本不同提供了两个发行周期。如果你选择的是长期支持版本Long Term Support(LTS),那么你在至少未来五年内都会收到安全维护更新。 + +假如你安装了 Ubuntu 22.04 ,那么你在 **2027 年 4 月** 之前都能获取更新。 + ![ubuntu22 04 lts about][2] -因此我们更推荐普通用户使用 LTS 版本。 +因此,我们更推荐普通桌面用户使用 LTS 版本。 -如果你想要更新更好的体验,你可以选择每**九个月**更新一次的非 LTS 版本。例如 Ubuntu 21.04, Ubuntu 21.10, Ubuntu 22.10。 +如果你想要更新更好的体验,你可以选择每**九个月**更新一次的非 LTS 版本。例如 Ubuntu 21.04、 Ubuntu 21.10、Ubuntu 22.10。 需要注意的是,非 LTS 版本涉及的更改可能会影响你的工作流程以及用户体验。因此并不推荐所有人都去使用非 LTS 版本。 -选择 Manjaro Linux 时你将会获得滚动发行时间表,因此你不必担心对你使用版本的支持。它会通过定期更新升级到最新的可用版本。 +选择 Manjaro Linux 时你将会获得滚动发布的更新,因此你不必担心对你使用版本的支持过期。它会通过定期更新升级到最新的可用版本。 ![manjaro about][3] 由于滚动发行周期的原因,你可以快速获取到最新的软件包。因此如果你想使用某个软件的历史版本,Manjaro 或许并不适合你。 ### 桌面环境 -Ubuntu 有 GNOME 版本桌面的定制版。它可能不是最新的,但如果你使用较新的 Ubuntu 版本,它可能包含最新的 GNOME 桌面环境。 + +Ubuntu 特别提供了一个定制版的 GNOME 桌面。它可能不是最新的,但如果你使用较新的 Ubuntu 版本,它基本上包含的就是最新的 GNOME 桌面环境。 ![ubuntu 22 04 wallpaper][4] -Canonical (Ubuntu 背后的公司)并不提供其它桌面环境 +Canonical(Ubuntu 背后的公司)并不提供其它桌面环境。 -但如果你想在 Ubuntu 上使用其它桌面环境,你可以选择官方的[Ubuntu 风格][5] KDE, Budgie, LXQt, MATE 以及 XFCE 作为桌面环境。与具有其他桌面环境的非官方或更新版本的 Ubuntu 相比,它们是经过良好测试且稳定的 Ubuntu Linux 发行版。 +但如果你想在 Ubuntu 上使用其它桌面环境,你可以选择包含了 KDE、Budgie、LXQt、MATE 以及 XFCE 等桌面环境的 Ubuntu 官方 [风味版][5]Flavour。与提供了其他桌面环境的非官方版或更新的特色版Spin的 Ubuntu 相比,它们是经过良好测试且稳定的 Ubuntu Linux 发行版。 -但是这些Ubuntu 版本没有五年的软件支持; 相反,你将被限制为对 LTS 版本的三年支持。 +但是这些 Ubuntu 风味版没有五年的软件支持;相反,你只能受限地得到对 LTS 版本的三年支持。 -如果使用 Manjaro,你可以选择官方提供的三个版本:XFCE, KDE 和 GNOME。 无论桌面环境如何,你都会使用滚动发布模式。 +如果使用 Manjaro,你可以选择官方提供的三个版本:XFCE、KDE 和 GNOME。 无论桌面环境如何,你都会使用滚动发布模式。 ![manjaro gnome 42][6] -当然你也可以使用一些社区版本如 Budgie, MATE, LXQt。 +当然你也可以使用 Manjaro 的一些社区版本,如 Budgie、MATE、LXQt。 ### 包管理器以及软件生态 -在上述这些发行版中找到大多数必要的 Linux 应用是没问题的。 -Manjaro Linux 使用 Pamac 作为其包管理器获得了更快速的体验。 +在上述这两类发行版中,找到大多数必要的 Linux 应用是没问题的。 + +不过,Manjaro Linux 使用 Pamac 作为其包管理器而获得了更快速的体验。 ![manjaro package manager][8] -与 Ubuntu 上的应用商店相比,Manjaro Linux 在快速安装/更新软件方面提供了更好的体验。 而且,如果您想通过单击启用它们,它还支持开箱即用的 Flatpak/Snap。 +与 Ubuntu 上的应用商店相比,Manjaro Linux 在快速安装/更新软件方面提供了更好的体验。而且,它还支持开箱即用的 Flatpak/Snap,如果你只需一键即可启用它们。 -Ubuntu 比较重视 Snap 包,你会发现一些应用程序预装为 Snap包(如 Firefox 浏览器)。 +Ubuntu 比较重视 Snap 软件包,你会发现一些应用程序预装为 Snap 软件包(如 Firefox 浏览器)。 ![firefox as snap][9] -对于 Manjaro Linux来说,你可以根据自身需求决定是否启用 Flatpak/Snap。 +对于 Manjaro Linux 来说,你可以根据自身需求决定是否启用 Flatpak/Snap。 + +在使用 Ubuntu 时,其应用商店提供的 Linux 应用并不是最好的。取决于你的系统配置和使用年限,它会变得越来越慢。 -在使用 Ubuntu时,应用商店提供的 Linux 应用并不是最好的。取决于你的系统配置和使用年限,它会变得越来越慢。 ![ubuntu 22 04 software center][10] 除此之外,Manjaro Linux 还可以访问 [AUR][11],它可以获得你在 Ubuntu 应用商店中可能找不到的几乎所有软件。 @@ -87,29 +92,29 @@ Ubuntu 桌面主要是为了易于使用而量身定制的。它专注于提供 即使有人不知道 Linux 上的“包管理器”是什么,在他们使用它时也可以完全把它作为 Windows/macOS 的完美替代品。 -当然,我们也有一个指南来帮助您[安装最新的 Ubuntu 后要做的事情][12]。 +当然,我们也有一个指南来帮助你 [安装最新的 Ubuntu 后要做的事情][12]。 +Manjaro Linux 也是为桌面用户使用量身定制的。但是它并不适合首次使用 Linux 的用户使用。 -Manjaro Linux 也是为桌面用户使用量身定制的。 但是它并不适合首次使用 Linux 的用户使用。 - -它旨在简化 Arch Linux 的操作。 因此主要面向想要使用 Arch Linux 的 Linux 用户增加了一些便利性。 +它旨在简化 Arch Linux 的操作。因此主要面向想要使用 Arch Linux 的 Linux 用户,但是增加了一些便利性。 ### 稳定性 + ![stability tux][13] Ubuntu LTS 版本主要关注稳定性和可靠性,因此你也可以在服务器上部署它们。 -相比之下,Manjaro Linux 可能没有开箱即用那么稳定。 你在 Manjaro Linux 中安装软件包时需要更加仔细,同时密切注意你的配置,以确保更新不会破坏你的系统。 +相比之下,Manjaro Linux 可能没有提供现成的的稳定性。你在 Manjaro Linux 中安装软件包时需要更加仔细,同时密切注意你的配置,以确保更新不会破坏你的系统。 对于 Ubuntu 用户来说则无需担心软件更新,尤其是在考虑 LTS 版本时,更新通常不会破坏你的系统。 - ### 个性化 -Ubuntu 有一个由 Canonical 为最终用户设置的定制 GNOME 桌面。 虽然你可以自由选择不同的 Linux 发行版,但 Ubuntu 提供的开箱即用的功能让然很少 -Ubuntu 多年来一直在改进,最近增加了[在 Ubuntu 22.04 LTS 中添加强调色][14] 的能力。 但是它仍然还有很长的路要走。 +Ubuntu 特别提供了一个由 Canonical 为最终用户设置的定制 GNOME 桌面。虽然你可以自由定制你的 Linux 发行版的各个方面,但 Ubuntu 开箱即用提供定制很少。 -如果你想获得个性化的桌面体验,你只能借助[GNOME Tweak][15] 等软件来实现。 +Ubuntu 多年来一直在改进,最近增加了 [在 Ubuntu 22.04 LTS 中添加强调色][14] 的能力。 但是它仍然还有很长的路要走。 + +如果你想获得个性化的桌面体验,你只能借助 [GNOME Tweak][15] 等软件来实现。 对比 Manjaro GNOME,你也只能使用相同的工具来自定义桌面。 @@ -119,51 +124,53 @@ Manjaro 还对外观进行了一些自定义调整。但是它提供了更多组 在个性定制方面,你在 Manjaro 和 Ubuntu 上的体验大致相同。 -如果您想要更多自定义选项,Manjaro Linux 可能是一个不错的选择。 但是如果你只想要一个个性化体验而不需要太多的改变,Ubuntu 应该就足够了。 +如果你想要更多自定义选项,Manjaro Linux 可能是一个不错的选择。但是如果你只想要个性化体验而不需要太多的改变,Ubuntu 应该就足够了。 ### 臃肿的软件 -这对每个人来说可能都不是什么大问题。 但如果你不喜欢预装许多应用程序,那么 Ubuntu 可能会令你感到麻烦。 + +这对每个人来说可能都不是什么大问题。但如果你不喜欢预装许多应用程序,那么 Ubuntu 可能会令你感到麻烦。 ![ubuntu 22 apps][17] -虽然可以随时删除不需要的应用程序。但是你会发现更多随 Ubuntu 一起安装的软件和服务还有很多。 +虽然可以随时删除不需要的应用程序。但是你会发现随 Ubuntu 一起安装的软件和服务还有很多。 -使用 Manjaro时,你在安装时只需要安装最基础的内容即可。它们坚持使用最基础的实用程序,最大限度地减少预装的软件包数量。 因此,Manjaro 很少会和软件臃肿联系到一起。 - -但是你在默认安装的 Manjaro 上可能找不到你最喜欢的 Linux 软件。 因此,如果你想在安装后立即使用一些你喜欢的软件,Ubuntu 可能是一个不错的选择。 +使用 Manjaro 时,你在安装时只需要安装最基础的内容即可。它们坚持使用最基础的实用程序,最大限度地减少预装的软件包数量。因此,Manjaro 很少会和软件臃肿联系到一起。 +但是你在默认安装的 Manjaro 上可能找不到你最喜欢的 Linux 软件。因此,如果你想在安装后立即使用一些你喜欢的软件,Ubuntu 可能是一个不错的选择。 ### 性能 + ![ubuntu 22 04 neofetch lolcat][18] -虽然 Ubuntu 提高了系统性能,甚至可以在 2 GB 内存的树莓派上运行,但它仍然不是性能最好的 Linux 发行版。 +虽然 Ubuntu 改进了其系统表现,甚至可以在 2 GB 内存的树莓派上运行,但它仍然不是性能最好的 Linux 发行版。 当然,性能确实取决于你选择使用的桌面环境。 但是与 Manjaro 的 GNOME 版本相比,Manjaro 提供了更快捷的体验。 -需要注意的是,性能和动画首选项的用户体验还取决于你的系统配置。例如,Manjaro 推荐旧电脑系统达到拥有 1GB 内存和 1GHz 处理器。 - -但是,对于 Ubuntu,在撰写本文时,你至少需要 4 GB 内存 和 2 GHz 双核处理器才能获得理想的桌面体验。 +需要注意的是,性能和动画首选项的用户体验还取决于你的系统配置。例如,Manjaro 的推荐系统要求(1GB 内存和 1GHz 处理器)给了你使用就电脑的机会。 +但是,对于 Ubuntu,在撰写本文时,你至少需要 4GB 内存 和 2GHz 双核处理器,才能获得理想的桌面体验。 ### 文档 + 考虑到 Ubuntu 的受欢迎程度,Ubuntu 更易于使用,并且对新用户来说可能更舒适。 [Ubuntu 的文档][19] 即使不是最好也足够好了。 -谈到 Manjaro Linux,他们有一个 [wiki][20],其中包含基础信息和深入的指南来帮助你入门。 +谈到 Manjaro Linux,他们有一个 [维基][20],其中包含基础信息和深入的指南来帮助你入门。 总的来说,[Arch Linux 的文档][21] 非常细致,几乎每个人(甚至是老手)都会参考它来寻求帮助。 Arch Linux 的文档在很大程度上也适用于 Manjaro Linux,因此在文档方面,使用 Manjaro Linux 比 Ubuntu 更有优势。 ### 结束语 -作为两个完全不同的 Linux 发行版,它们服务于各种类型的用户。你可以选择任意你感兴趣的操作系统并尝试去使用它来判断它是否适合你。 -但是不管 Linux 发行版如何,你想避免对系统进行任何更改并专注于你的工作,Ubuntu 应该是一个明智的选择。 +作为两个完全不同的 Linux 发行版,它们服务于各种类型的用户。你可以选择你感兴趣的任意一个并尝试去使用它来判断它是否适合你。 -无论如何,如果 Ubuntu 的性能对你的体验有相当大的影响,你应该去尝试 Manjaro。 你可以阅读我的 [关于从 Ubuntu 切换到 Manjaro 的初步想法][22]。 +但是,如果你想避免对系统进行任何更改,并专注于你的工作,那么 Ubuntu 应该是一个明智的选择。 + +而如果 Ubuntu 的性能对你的体验有相当大的影响,你应该去尝试 Manjaro。 你可以阅读我的 [关于从 Ubuntu 切换到 Manjaro 的初步想法][22]。 -------------------------------------------------------------------------------- @@ -172,7 +179,7 @@ via: https://itsfoss.com/ubuntu-vs-manjaro/ 作者:[Ankush Das][a] 选题:[lkxed][b] 译者:[Return7g](https://github.com/Return7g) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 00b62db6e97b55eaf10d6fafc8de3c5ceb34eac7 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 6 Sep 2022 21:58:16 +0800 Subject: [PATCH 02/12] P MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Return7g 本文首发地址:https://linux.cn/article-15006-1.html 您的 LCTT 专页:https://linux.cn/lctt/Return7g --- ...u vs Manjaro- Comparing the Different Linux Experiences.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md (99%) diff --git a/translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md b/published/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md similarity index 99% rename from translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md rename to published/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md index 7a4316a39c..149804905b 100644 --- a/translated/tech/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md +++ b/published/20220520 Ubuntu vs Manjaro- Comparing the Different Linux Experiences.md @@ -4,8 +4,8 @@ [#]: collector: "lkxed" [#]: translator: "Return7g" [#]: reviewer: "wxy" -[#]: publisher: " " -[#]: url: " " +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-15006-1.html" Ubuntu 和 Manjaro:比较两种不同的 Linux 发行版体验 ====== From 2171a21a4d9b2c42591250d7ed60b94a8473fab6 Mon Sep 17 00:00:00 2001 From: lkxed Date: Tue, 6 Sep 2022 23:26:54 +0800 Subject: [PATCH 03/12] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][ta?= =?UTF-8?q?lk]:=2020220906=20Unix=20History-=20A=20Mighty=20Origin=20Story?= =?UTF-8?q?.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...906 Unix History- A Mighty Origin Story.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/talk/20220906 Unix History- A Mighty Origin Story.md diff --git a/sources/talk/20220906 Unix History- A Mighty Origin Story.md b/sources/talk/20220906 Unix History- A Mighty Origin Story.md new file mode 100644 index 0000000000..1daa01200e --- /dev/null +++ b/sources/talk/20220906 Unix History- A Mighty Origin Story.md @@ -0,0 +1,108 @@ +[#]: subject: "Unix History: A Mighty Origin Story" +[#]: via: "https://www.debugpoint.com/unix-history/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Unix History: A Mighty Origin Story +====== +A brief walk down memory lane about Unix and its beginning. + +![The beginning][1] + +### Unix: The origin story + +The world today runs on Linux. Billions of mobile phones and servers today run Linux. But before Linux, there was Unix, and without it, Linux would not have existed today. + +Unix’s origin can be traced back to the moon landing days. In 1965, three famous institutions started a joint venture to create an operating system that could serve multiple users and share data and resources. + +![Scanned copy of actual Unix code][2] + +They are the famous Bell Telephone Laboratories, the General Electric Company and the Massachusetts Institute of Technology. This project or the joint venture is called “Multics” – an acronym for “Multiplex Information and Computing Service”. + +But, the project did not see much success. Unfortunately. Due to complexity and poor outcome, Bell Labs discontinued the project. + +Ken Thomson from Bell Labs, who worked in Multics, started afresh. He started writing a new operating system for an ancient computer PDP-7 of Digital Equipment Corporation. Later, Dennis Ritchie joined, and they created a hierarchical file system, device files, command line interpreter and processes. This is how the Unix was born, named by another member of the Multics project – Brian Kernighan. + +In 1971, Unix was ported to a little advanced PDP-11 computer with just a 512 KB disk. At the time, Unix was only supporting 16 KB and 8 KB memory allocated for user programs. + +However, most of the Unix code was in assembly language, making it hardware dependent. So, it was not portable. + +![Ken Thompson (sitting) and Dennis Ritchie at PDP-11 (credit and learn more about this image1)][3] + +### Creation of C Programming Language + +So, the only way to make it portable and machine-independent is to write it in a high-level language so that the compile and corresponding object code can take care of the machine code conversion. + +The great brains at that time solve the problem in a jiffy. Ken Thompson created a high-level language from scratch called “B”. Then, he started the massive work to convert Unix assembly code to this newly created language. However, “B” also had some limitations, and Dennis Ritchie modified it to create the famous language “C”, which makes Unix a truly portable operating system. + +The famous “C” language is still used today. + +By the mid-’80s, Unix became so successful that it was running on thousands of hardware, from micro-computers to mainframes with a variety of hardware. + +![The text book of C which we all read][4] + +### MINIX and the birth of Linux + +In 1987, Andrew S. Tanenbaum – a computer science professional, created a Unix fork called MINIX to explain the operating system concepts in his famous book “Operating Systems: Design and Implementation” and distributed (the 16-bit version) free along with the book. Those who studied computer science (including me) or related subjects knows that it’s the ultimate textbook on Operating system which explains the basics. + +In 1991, Linux Torvalds [started a hobby project][5] while studying at the University of Helsinki. He based his work on MINIX with GNU C Compiler. He started his project to enable him to run programs on his new PC with a new 80386 processor. However, he wrote the entire operating system with features that MINIX lacked, eventually becoming the Linux Kernel. + +![Famous operating systems book by Tanenbaum][6] + +### BSD and macOS + +During the ’80s, when Unix was shaping up, Bell Labs developed BSD (Berkeley Standard Distribution) based on the original Source code of Unix (the version that runs on PDP-7 and PDP-11). BSD is distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley. After its formation, BSD has been adapted by many workstation vendors (the legacy desktop), such as Sun Microsystems, as a proprietary Unix variant. + +This version eventually forked to create open-source variants such as OpenBSD, FreeBSD and so on. These free versions created the path to create NeXTSTEP by NeXT, founded by Steve Jobs. And NeXTSTEP eventually became the foundation for Apple’s macOS. + +### Wrapping Up + +Unix is a remarkable achievement by a few individuals with their original ideas and takes on problem-solving. The operating system is a work of art if you consider how much computing power and memory were available at the time of its creation. + +All of these small steps, over several decades, eventually led us where we are today. No matter how many Kernels, OSes, and abstractions in the form of programming languages come in, at the core, it all started from a single source. + +I always think that programs/codes are thoughts of human beings. It’s your logic, ideas are merely written in “IF-ELSE” blocks to achieve some real-world result. + +References + +* [https://www.bell-labs.com/usr/dmr/www/picture.html][7]1 +* [https://groups.google.com/g/comp.os.minix/c/dlNtH7RRrGA/m/SwRavCzVE7gJ][8] +* [https://en.wikipedia.org/wiki/Andrew_S._Tanenbaum][9] +* [https://en.wikipedia.org/wiki/History_of_Linux][10] +* [https://en.wikipedia.org/wiki/History_of_Unix][11] +* [https://computerhistory.org/blog/the-earliest-unix-code-an-anniversary-source-code-release/][12] + +*“All revolutions are, until they happen, then they are historical inevitabilities.” – Cloud Atlas* + +![Join our Telegram channel and stay informed on the move.][13] + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/unix-history/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/wp-content/uploads/2022/09/The-beginning-1024x576.jpg +[2]: https://www.debugpoint.com/wp-content/uploads/2022/09/Scanned-copy-of-actual-Unix-code-1024x646.jpg +[3]: https://www.debugpoint.com/wp-content/uploads/2022/09/Ken-Thompson-sitting-and-Dennis-Ritchie-at-PDP-11.jpg +[4]: https://www.debugpoint.com/wp-content/uploads/2022/09/The-text-book-of-C-which-we-all-read.jpg +[5]: https://groups.google.com/g/comp.os.minix/c/dlNtH7RRrGA/m/SwRavCzVE7gJ +[6]: https://www.debugpoint.com/wp-content/uploads/2022/09/Famous-operating-systems-book-by-Tanenbaum.jpg +[7]: https://www.bell-labs.com/usr/dmr/www/picture.html +[8]: https://groups.google.com/g/comp.os.minix/c/dlNtH7RRrGA/m/SwRavCzVE7gJ +[9]: https://en.wikipedia.org/wiki/Andrew_S._Tanenbaum +[10]: https://en.wikipedia.org/wiki/History_of_Linux +[11]: https://en.wikipedia.org/wiki/History_of_Unix +[12]: https://computerhistory.org/blog/the-earliest-unix-code-an-anniversary-source-code-release/ +[13]: https://t.me/debugpoint From 0edc1f8018d0d3864758c15b888e4898ff5c5a81 Mon Sep 17 00:00:00 2001 From: lkxed Date: Tue, 6 Sep 2022 23:28:21 +0800 Subject: [PATCH 04/12] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][ta?= =?UTF-8?q?lk]:=2020220906=20Advantages=20and=20Disadvantages=20of=20Using?= =?UTF-8?q?=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ntages and Disadvantages of Using Linux.md | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 sources/talk/20220906 Advantages and Disadvantages of Using Linux.md diff --git a/sources/talk/20220906 Advantages and Disadvantages of Using Linux.md b/sources/talk/20220906 Advantages and Disadvantages of Using Linux.md new file mode 100644 index 0000000000..d185cf6594 --- /dev/null +++ b/sources/talk/20220906 Advantages and Disadvantages of Using Linux.md @@ -0,0 +1,253 @@ +[#]: subject: "Advantages and Disadvantages of Using Linux" +[#]: via: "https://itsfoss.com/advantages-linux/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Advantages and Disadvantages of Using Linux +====== +Linux is a buzzword and you keep hearing about Linux here and there. People discuss it in the tech forum, it is part of the course curriculum and your favorite tech YouTubers get excited while showing their Linux build. The 10x developers you follow on Twitter are all Linux fans. + +Basically, Linux is everywhere and everyone keeps talking about it. And that gives you FOMO. + +So, you wonder about the advantages of Linux and whether is it really worth trying. + +I have compiled various possible advantages and disadvantages of Linux in this article. + +If you are on the fence about choosing Linux over your preferred operating system, we would like to help you out. + +Before you start, you should know that Linux is not an operating system on its own. The operating systems are called [Linux distributions and there are hundreds of them][1]. For simplicity, I’ll address it as Linux OS instead of a specific Linux distribution. This [article][2] explains things better. + +### Advantages of Using Linux + +Considering you are curious about Linux as an alternative operating system choice, it only makes sense that you know its advantages. + +You might never regret your decision if it excels at what you want it to do. + +#### No Need to Purchase a License + +![open source proprietary illustration][3] + +You need to own an Apple device to use macOS as your daily driver and a Windows license to use Microsoft’s Windows. + +Therefore, you need a bit of investment with these options. But, with Linux? It’s entirely free. + +Not just the OS, there are many software packages available for free on Linux when compared to Windows and macOS. + +You can try every mainstream Linux distribution without paying for a license. Of course, you get the option to donate to support the project, but that is up to you if you really like it. + +**Additionally**, Linux is totally open-source, meaning anyone can inspect the source code for transparency. + +#### Can Run With Minimal System Resources + +![linux mint 21 resource usage][4] + +Typically, when users think of trying another operating system, it is because they are frustrated with the performance of their system. + +This is from my personal experience. I have had friends willing to try Linux to revive their old laptop or a system that constantly lags. + +And, when it comes to Linux distributions, they are capable of running on decent hardware configurations. You do not need to have the latest and greatest. Moreover, there are specialized [lightweight Linux distributions][5] that are tailored to run on older hardware with no hiccups. + +So, you have more chances to revive your old system or get a fast-performing computer in no time with Linux. + +#### Less Exposed to Malware + +![malware illustration][6] + +No operating system is safe from malicious files or scripts. If you download and run something from an unknown source, you cannot guarantee its safety. + +However, things are better for Linux. Yes, researchers have found attackers targeting Linux IoT devices. But, for desktop Linux, it is not “yet” something to worry about. + +Malicious actors target platforms that are more popular among households, and Linux does not have a big market share in the desktop space to attract that kind of attention. In a way, it can be a good thing. + +All you have to do is just stick to the official software packages, and read instructions before you do anything. + +As an extra plus, you do not necessarily need an antivirus program to get protection from malware. + +#### Customization + +![Pop!_OS 22.04 LTS][7] + +With an open-source code, you get the freedom to customize your Linux experience as much as you want. + +Of course, you require a bit of technical expertise to go utilize the best of it. Even without any experience, you get more customization features in your operating system when compared to macOS and Windows. + +![Customized Linux experience | Reddit user: u/ZB652][8] + +[u/ZB652][9] + +If you are into personalizing your experience and willing to put in extra effort, Linux is for you. As an example, refer to the [KDE customization guide][10] and [dock options][11] to get basic ideas. + +#### Something for Everyone + +With macOS or Windows, you get limited to the design/preference choices finalized by Microsoft or Apple. + +But, with Linux, you will find several Linux distributions that try to focus on various things. + +For instance, you can opt for a Linux distribution that focuses on getting the latest features all the time, or you can opt for something that only gives you security/maintenance updates. + +You can get something that looks beautiful out of the box or something that you provide crazy customization options. You will not run out of options with Linux. + +I recommend starting with [options that give you the best user experience][12]. + +#### Complete Development Environment + +If you are a software developer or student learning to code, Linux definitely has an edge. A lot of your build tools are available and integrated into Linux. With Docker, you can create specialized test environment easily. + +Microsoft knows about this part and this is why it created WSL to give developers access to Linux environments inside Windows. Still, WSL doesn’t come close to the real Linux experience. The same goes for using Docker on Windows. + +I know the same cannot be said about web designing because the coveted Adobe tools are not available on Linux yet. But if you don’t need Adobe for your work, Linux is a pretty good choice. + +#### Learning Linux is a Skill One Must Have! + +There is a learning curve to using Linux, but it provides you with insights on various things. + +You get to learn how things work in an operating system by exploring and customizing it, or even just by using it. + +Not everyone knows how to use Linux. + +So, it can be a great skill to gain and expand your knowledge of software and computers. + +#### Linux is an in-demand Job Skill + +![job illustration][13] + +As I mentioned above, it is a great skill to have. But, not just limited to expanding your knowledge, it is also useful professionally. + +You can work your way to become a Linux system administrator or a security expert and fill several other job roles by learning the fundamentals of Linux. + +So, learning Linux opens up a whole range of opportunities! + +#### Privacy-Friendly + +These days you cannot use Windows without a Microsoft account. And when you set up Windows, you’ll find that it tries to track your data from a number of services and applications. + +![privacy windows][14] + +While you can find such settings and disable them, it is clear that Windows is configured to disregard your privacy by default. + +That’s not the case in Linux. While some applications/distributions may have an optional feature to let you share useful insights with them, it has never been a big deal. Most of the things on Linux are tailored to give you maximum privacy by default without needing to configure anything. + +Apple and Microsoft on the other hand have clever tactics to collect anonymous usage data from your computer. Occasionally, they log your activity on their app store and while you are signed in through your account. + +#### DIY projects and Self-hosting + +Got a tinkerer in you? If you like to make electronics or software projects, Linux is your paradise. + +You can use Linux on [single-board computers like Raspberry Pi][15] and create cool things like retro gaming consoles, home automation systems, etc. + +You can also deploy open source software on your own server and maintain them. This is called self-hosting and it has the following advantages: + +* Reduce hosting costs +* Take control of your data +* Customize the app/service as per your requirements + +Clearly, you’ll be doing all this either directly with Linux or tools built on top of it. + +### Disadvantages of Linux + +Linux is not a flawless choice. Just like everything, there are some downsides to Linux as well. Those include: + +#### Learning Curve + +![too much learn illustration][16] + +Every so often it is not just about learning a new skill, it is more about getting comfortable as quickly as possible. + +If a user cannot get their way around the task they intend to do, it is not for them. It is true for every operating system. For instance, a user who uses Windows/macOS, may not get comfortable with Linux as quickly. + +You can read our comparison article to know the [difference between macOS and Linux][17]. + +I agree that some users catch on quicker than others. But, in general, when you step into the Linux world, you need to be willing to put a bit of effort into learning the things that are not obvious. + +#### Variety + +While we recommend using the [best Linux distributions tailored for beginners][18], choosing what you like at first can be overwhelming. + +You might want to try multiple of them to see what works with you best, which can be time-consuming and confusing. + +It’s best to settle with one of the Linux distributions. But, if you remain confused, you can stick to Windows/macOS. + +#### Market Share in Desktop Space + +![linux desktop market share][19] + +Linux is not a popular desktop operating system. + +This should not be of concern to a user. However, without having a significant market presence, you cannot expect app developers to make/maintain tools for Linux. + +Sure, there are lots of essential and popular tools available for Linux, more than ever. But, it remains a factor that may mean that not all good tools/services work on Linux. + +Refer to our regularly updated article on [Linux’s market share][20], to get an idea. + +#### Lack of Proprietary Software + +As I mentioned above, not everyone is interested in bringing their tools/apps to Linux. + +Hence, you may not find all the good proprietary offerings for Windows/macOS. Sure, you can use a compatibility layer to run Windows/macOS programs on Linux. + +But that doesn’t work all the time. For instance, you do not have official Microsoft 365 support for Linux and tools like Wallpaper Engine. + +#### Not a Gaming-first OS + +![gaming illustration][21] + +If you want to game on your computer, Windows remains the best option for its support for the newest hardware and technologies. + +When it comes to Linux, there are a lot of “ifs and buts” for a clear answer. You can refer to our [gaming guide for Linux][22] to explore more if interested. + +#### Lack of Professional Tech Support + +I know not everyone needs it. But, there are tech support options that can guide users/fix issues remotely on their laptop or computer. + +With Linux, you can seek help from the community, but it may not be as seamless as some professional tech support services. + +You’ll still have to do most of the hit and try stuff on your own and not everyone would like it. + +### Wrapping Up + +I am primarily a Linux user but I use Windows when I have to play games. Though my preference is Linux, I have tried to be unbiased and give you enough pointers so that you can make up your mind if Linux is for you or not. + +If you are going for Linux and have never used it, take the baby step and [use Linux in a virtual machine first][23]. You can also use WSL2 if you have Windows 11. + +I welcome your comments and suggestions. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/advantages-linux/ + +作者:[Ankush Das][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lkxed +[1]: https://itsfoss.com/what-is-linux/ +[2]: https://itsfoss.com/what-is-linux/ +[3]: https://itsfoss.com/wp-content/uploads/2022/08/open-source-proprietary-illustration.jpg +[4]: https://itsfoss.com/wp-content/uploads/2022/08/linux-mint-21-resource-usage.jpg +[5]: https://itsfoss.com/lightweight-linux-beginners/ +[6]: https://itsfoss.com/wp-content/uploads/2022/09/malware-illustration.jpg +[7]: https://itsfoss.com/wp-content/uploads/2022/08/pop-os-screenshot-2022.png +[8]: https://itsfoss.com/wp-content/uploads/2022/09/customization-reddit-unixporn.jpg +[9]: https://www.reddit.com/r/unixporn/comments/wzu5nl/plasma_cscx2n/ +[10]: https://itsfoss.com/kde-customization/ +[11]: https://itsfoss.com/best-linux-docks/ +[12]: https://itsfoss.com/beautiful-linux-distributions/ +[13]: https://itsfoss.com/wp-content/uploads/2022/09/job-illustration.jpg +[14]: https://itsfoss.com/wp-content/uploads/2022/09/privacy-windows.webp +[15]: https://itsfoss.com/raspberry-pi-alternatives/ +[16]: https://itsfoss.com/wp-content/uploads/2022/09/too-much-learn-illustration.jpg +[17]: https://itsfoss.com/mac-linux-difference/ +[18]: https://itsfoss.com/best-linux-beginners/ +[19]: https://itsfoss.com/wp-content/uploads/2017/09/linux-desktop-market-share.jpg +[20]: https://itsfoss.com/linux-market-share/ +[21]: https://itsfoss.com/wp-content/uploads/2022/08/gaming-illustration.jpg +[22]: https://itsfoss.com/linux-gaming-guide/ +[23]: https://itsfoss.com/why-linux-virtual-machine/ From a9eff6bf3fd7df94298e9a7f6052ba356e4f586e Mon Sep 17 00:00:00 2001 From: lkxed Date: Tue, 6 Sep 2022 23:29:55 +0800 Subject: [PATCH 05/12] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220906=20How=20to=20Analyse=20Sentiments=20Using=20Mac?= =?UTF-8?q?hine=20Learning.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...alyse Sentiments Using Machine Learning.md | 213 ++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 sources/tech/20220906 How to Analyse Sentiments Using Machine Learning.md diff --git a/sources/tech/20220906 How to Analyse Sentiments Using Machine Learning.md b/sources/tech/20220906 How to Analyse Sentiments Using Machine Learning.md new file mode 100644 index 0000000000..1cac4f4b89 --- /dev/null +++ b/sources/tech/20220906 How to Analyse Sentiments Using Machine Learning.md @@ -0,0 +1,213 @@ +[#]: subject: "How to Analyse Sentiments Using Machine Learning" +[#]: via: "https://www.opensourceforu.com/2022/09/how-to-analyse-sentiments-using-machine-learning/" +[#]: author: "Jishnu Saurav Mittapalli https://www.opensourceforu.com/author/jishnu-saurav-mittapalli/" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +How to Analyse Sentiments Using Machine Learning +====== +This article will help you understand the concept of sentiment analysis and learn how it is done. It uses different machine learning algorithms for sentiment analysis, and then compares them to decide which one is the best for the particular problem described here. + +Sentiment analysis is a major area in the field of natural language processing. A sentiment is any opinion or feeling that we have about an event, a product, a situation or anything else. Sentiment analysis is the field of research in which human sentiments are automatically extracted from the text. This field started evolving in the early 90s. + +This article will help you understand how machine learning (ML) can be used for sentiment analysis, and compare the different ML algorithms that can be used. It does not try to improve the performance of any of the algorithms or methods. + +In today’s fast paced world, everything is online and everyone can post their views. A few negative online comments may hurt a company’s reputation and, thereby, its sales. Now that everything’s online, everyone can post their views and opinions. It becomes very important for companies to go through these to understand what their customers really want. But since there is so much data, it cannot be gone through manually. This is where sentiment analysis comes in. + +Let us now start developing a model to do a basic sentiment analysis. + +### Let’s start! + +The first step is to select a data set. You can choose from any publicly available reviews or comments such as tweets or movie reviews. The two columns that should definitely be there in the data set are the label and the actual piece of text. + +Figure 1 shows a small sample of how the data looks. + +![Figure 1: Data sample][1] + +Now we need to import the required libraries: + +``` +import pandas as pd +import numpy as np +from nltk.stem.porter import PorterStemmer +import re +import string +``` + +As you can see in the above code, we have imported NumPy and Pandas for processing the data. We will look at the other imported libraries when we use them. + +Now that the data set is ready and the libraries are imported, we need to bring the former into our project. The Pandas library is used for this purpose. We bring the data set into the Pandas data frame using the following line of code: + +``` +sentiment_dataframe = pd.read_csv(“/content/drive/MyDrive/Data/sentiments - sentiments.tsv”,sep = ‘\t’) +``` + +Now that we have the data set in our project, let us manipulate it so that our algorithm can understand the features better. We begin by giving names to our columns in the data set. This is done by using the line of code given below: + +``` +sentiment_dataframe.columns = [“label”,”body_text”] +``` + +We then assign numerical labels to the classes — negative is replaced with 1 and positive is replaced with 0. Figure 2 shows how the data frame looks at this stage. + +![Figure 2: Data frame with basic modifications][2] + +The next step is the preprocessing of the data. This is a very important step as it helps us to convert string/text data into numerical data (machine learning algorithms can understand/process numerical data and not text). Also, the redundant and useless data needs to be removed as it may taint our training model. We remove the noisy data, missing values and other non-consistent data in this step. + +We will add the features text length and punctuation count in the data frame specifically for this application. We will also do the stemming, i.e., we will convert all similar words (like ‘give’, ‘giving’, etc) into a single form. Once this is done, we divide the data set into two — X and Y — where X is the features and Y is the prediction class. + +This is done using the following piece of code. Figure 3 shows the data frame after these steps are taken. + +![Figure 3: Data frame after the division of the data set][3] + +``` +def count_punct(text): + count = sum([1 for char in text if char in string.punctuation]) + return round(count/(len(text) - text.count(“ “)),3)*100 + + tokenized_tweet = sentiment_dataframe[‘body_text’].apply(lambda x: x.split()) +stemmer = PorterStemmer() +tokenized_tweet = tokenized_tweet.apply(lambda x: [stemmer.stem(i) for i in x]) +for i in range(len(tokenized_tweet)): + tokenized_tweet[i] = ‘ ‘.join(tokenized_tweet[i]) +sentiment_dataframe[‘body_text’] = tokenized_tweet +sentiment_dataframe[‘body_len’] = sentiment_dataframe[‘body_text’].apply(lambda x:len(x) - x.count(“ “)) +sentiment_dataframe[‘punct%’] = sentiment_dataframe[‘body_text’].apply(lambda x:count_punct(x)) +X = sentiment_dataframe[‘body_text’] +y = sentiment_dataframe[‘label’] +``` + +We now need to convert the string into numerical data. We use a count vectorizer for this purpose; that is, we get the counts of each word and convert it into a vector. + +After this, features such as length of text and punctuation count in the dataframe, i.e., X, are calculated. A sample of X is shown in Figure 4. + +![Figure 4: Sample of final features][4] + +Now the data is ready for training. The next step is to determine which algorithms we are going to use for training our model. As has been mentioned before, we are going to try several algorithms and determine the best one for sentiment analysis. Since we are basically trying to do binary classification, the following algorithms can be used: + +* K-nearest neighbors (KNN) +* Logistic regression +* Support vector machines (SVMs) +* Stochastic gradient descent +* Naive Bayes +* Decision tree +* Random Forest + +We first need to split our data set into testing and training data. This is done by using the sklearn library using the following code: + +``` +from sklearn.model_selection import train_test_split +X_train, X_test, y_train, y_test = train_test_split(X,y, test_size = 0.20, random_state = 99) +``` + +We will use 20 per cent of the data for testing and 80 per cent for the training part. We will separate the data because we want to test on a new set of data whether our model is working properly or not. + +Now let us start with the first model. We will try the KNN algorithm first, and use the sklearn library for this. We will first train the model and then assess its performance (all of this can be done using the sklearn library in Python itself). The following piece of code does this, and we get an accuracy of around 50 per cent. + +``` +from sklearn.neighbors import KNeighborsClassifier +model = KNeighborsClassifier (n_neighbors=3) +model.fit(X_train, y_train) +model.score (X_test,y_test) + +0.5056689342403629 +``` + +The code is similar in the logistic regression model — we first import the function from the library, fit the model, and then test it. The following piece of code uses the logistic regression algorithm. The output shows we got an accuracy of around 66 per cent. + +``` +from sklearn.linear_model import LogisticRegression +model = LogisticRegression() +model.fit (X_train,y_train) +model.score (X_test,y_test) + +0.6621315192743764 +``` + +The following piece of code uses SVM. The output shows we got an accuracy of around 67 per cent. + +``` +from sklearn import svm +model = svm.SVC(kernel=’linear’) +model.fit(X_train, y_train) +model.score(X_test,y_test) + +0.6780045351473923 +``` + +The following piece of code uses the Random Forest algorithm, and we get an accuracy of around 69 per cent. + +``` +from sklearn.ensemble import RandomForestClassifier +model = RandomForestClassifier() +model.fit(X_train, y_train) +model.score(X_test,y_test) + +0.6938775510204082 +``` + +Next we use the Decision tree algorithm, which gives an accuracy of around 61 per cent. + +``` +from sklearn.tree import DecisionTreeClassifier +model = DecisionTreeClassifier() +model = model.fit(X_train,y_train) +model.score(X_test,y_test) + +0.6190476190476191 +``` + +The following piece of code uses the stochastic gradient descent algorithm. The output shows that we got an accuracy of around 49 per cent. + +``` +from sklearn.linear_model import SGDClassifier +model = SGDClassifier() +model = model.fit(X_train,y_train) +model.score(X_test,y_test) + +0.49206349206349204 +``` + +The following piece of code uses Naive Bayes. We get an accuracy of around 60 per cent. + +``` +from sklearn.naive_bayes import GaussianNB +model = GaussianNB() +model.fit(X_train, y_train) +model.score(X_test,y_test) + +0.6009070294784581 +``` + +Now that we have checked out all the algorithms, let us graph their accuracy performance. The graph is shown in Figure 5. + +![Figure 5: Accuracy performance of the different algorithms][5] + +As you can see, the random forest algorithm gave the best accuracy for this problem and we can conclude that it is the best fit for sentiment analysis amongst ML algorithms. We can improve the accuracy much more by getting better features, trying out other vectorising techniques, and using a better data set or newer classification algorithms. + +Now that random forest is seen as the best algorithm for this problem, I am going to show you a sample prediction. In Figure 6, you can see that the right predictions are being made! Do try this out to improve upon this project! + +![Figure 6: Sample predictions made][6] + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/09/how-to-analyse-sentiments-using-machine-learning/ + +作者:[Jishnu Saurav Mittapalli][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/jishnu-saurav-mittapalli/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/07/Figure-1-Data-sample.jpg +[2]: https://www.opensourceforu.com/wp-content/uploads/2022/07/Figure-2-Data-frame-with-basic-modifications-3.jpg +[3]: https://www.opensourceforu.com/wp-content/uploads/2022/07/Figure-3-Data-frame-after-the-division-of-the-data-set.jpg +[4]: https://www.opensourceforu.com/wp-content/uploads/2022/07/Figure-4-Sample-of-final-features.jpg +[5]: https://www.opensourceforu.com/wp-content/uploads/2022/07/Figure-5-Accuracy-performance-of-the-different-algorithms.jpg +[6]: https://www.opensourceforu.com/wp-content/uploads/2022/07/Figure-6-Sample-predictions-made.jpg From 9a80c2d6f558feaf391fd9aa36a77748993eee0c Mon Sep 17 00:00:00 2001 From: lkxed Date: Tue, 6 Sep 2022 23:32:13 +0800 Subject: [PATCH 06/12] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220906=20A=20beginner-s=20guide=20to=20making=20a=20da?= =?UTF-8?q?rk=20theme=20for=20a=20website.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...de to making a dark theme for a website.md | 340 ++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 sources/tech/20220906 A beginner-s guide to making a dark theme for a website.md diff --git a/sources/tech/20220906 A beginner-s guide to making a dark theme for a website.md b/sources/tech/20220906 A beginner-s guide to making a dark theme for a website.md new file mode 100644 index 0000000000..bc943dd807 --- /dev/null +++ b/sources/tech/20220906 A beginner-s guide to making a dark theme for a website.md @@ -0,0 +1,340 @@ +[#]: subject: "A beginner's guide to making a dark theme for a website" +[#]: via: "https://opensource.com/article/22/9/dark-theme-website" +[#]: author: "Sachin Samal https://opensource.com/users/sacsam005" +[#]: collector: "lkxed" +[#]: translator: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +A beginner's guide to making a dark theme for a website +====== +Learn how to program dark website themes using HTML, CSS variables, classes, and JavaScript methods. + +![Digital creative of a browser on the internet][1] + +Having a dark theme for your website is a common feature these days. There are various ways to add a dark theme to your website, and in this article, I demonstrate a beginner-friendly way of programming a dark theme for the web. Feel free to explore, make mistakes, and, more importantly, learn by manipulating the code in your own way. + +![Display of both light and dark theme web pages][2] + +Image by: (Sachin Samal, CC BY-SA 4.0) + +### Icons + +I like to provide a visual way for my users to discover the dark mode feature. You can include an easy set of icons by inserting the Font Awesome link in the `` element of your HTML. + +``` + + + +  Toggle - Dark Theme + +``` + +Inside your `` tag, create a Font Awesome moon icon class, which you will switch to the Font Awesome sun icon class later using JavaScript. This icon allows users to switch from the default light theme to the dark theme and back again. In this case, you're changing from `fa-moon` while in the light theme to `fa-sun` while in the dark theme. In other words, the icon is always the opposite of the current mode. + +``` + + 
+ +``` + +Next, create a CSS class in your stylesheet. You'll append this using the JavaScript `add()` method to toggle between themes. The `toggle()` function adds or removes a class name from an element with JavaScript. This CSS code creates a `changeTheme` class, setting the background color to dark gray and the foreground color (that's the text) to light gray. + +``` +.changeTheme { +  background: #1D1E22; +  color: #eee; +} +``` + +### Toggle between themes + +To toggle the appearance of the theme button and to apply the `changeTheme` class, use the `onclick()`, `toggle()`, `contains()`, `add()`, and `remove()` JavaScript methods inside your ` +``` + +The complete code: + +``` + + + +  Toggle - Dark Theme + + + + 
+ + + +``` + +### Complete themes + +The code so far may not fully switch the theme of a complex website. For instance, your site might have a header, a main, and a footer, each with multiple divs and other elements. In that case, you could create a standard dark theme CSS class and append it to the desired web parts. + +### Get familiar with your browser's console + +To inspect your browser's console, on the webpage where you run this code, press `Ctrl+Shift+I` or right-click and select the `Inspect` option. + +When you select `Elements` in the console and toggle your theme button, the browser gives you an indication of whether or not your JavaScript is working. In the console, you can see that the CSS class you appended using JavaScript is added and removed as you toggle. + +![Use browser tools to test light and dark themes][3] + +Image by: (Sachin Samal, CC BY-SA 4.0) + +Add a navigation and card section to see how adding the CSS class name on an HTML element with JavaScript works. + +### Example code for a dark theme + +Here's some example code. You can alternately view it with a live preview [here][4]. + +``` + + + +  Toggle - Dark Theme + + + + + + 
+   

Beginner Friendly Dark Theme

+ + 
+   
+     
+ +       
+         
+           
+             
What is Lorem Ipsum?
+             
    +               
  • Sed sit amet felis tellus.
  • +               
  • Sed sit amet felis tellus.
  • +             
+           
+         
+       
+ +       
+         
+           
+             
What is Lorem Ipsum?
+             
    +               
  • Sed sit amet felis tellus.
  • +               
  • Sed sit amet felis tellus.
  • +             
+           
+         
+       
+ +       
+         
+           
+             
What is Lorem Ipsum?
+             
    +               
  • Sed sit amet felis tellus.
  • +               
  • Sed sit amet felis tellus.
  • +             
+           
+         
+       
+ +     
+   
+  + +``` + +The `for...of` loop of JavaScript applies ".dark-theme" class styling properties to each `card` on the page, regardless of its position. It applies the theme to all web parts selected with `querySelectorAll()` in the `