mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
a656f3d667
@ -0,0 +1,78 @@
|
||||
Emacs 系列(一):抛掉一切,投入 Emacs 和 org 模式的怀抱
|
||||
======
|
||||
|
||||
我必须承认,在使用了几十年的 vim 后, 我被 [Emacs][1] 吸引了。
|
||||
|
||||
长期以来,我一直对如何组织安排事情感到沮丧。我也有用过 [GTD][2] 和 [ZTD][3] 之类的方法,但是像邮件或是大型文件这样的事务真的很难来组织安排。
|
||||
|
||||
我一直在用 Asana 处理任务,用 Evernote 做笔记,用 Thunderbird 处理邮件,把 ikiwiki 和其他的一些项目组合作为个人知识库,而且还在电脑的归档了各种文件。当我的新工作需要将 Slack 也加入进来时,我终于忍无可忍了。
|
||||
|
||||
许多 TODO 管理工具与电子邮件集成的很差。当你想做“提醒我在一周内回复这个邮件”之类的事时,很多时候是不可能的,因为这个工具不能以一种能够轻松回复的方式存储邮件。而这个问题在 Slack 上更为严重。
|
||||
|
||||
就在那时,我偶然发现了 [Carsten Dominik 在 Google Talk 上关于 org 模式的讲话][4]。Carsten 是 org 模式的作者,即便是这个讲话已经有 10 年了,但它仍然很具有参考价值。
|
||||
|
||||
我之前有用过 [org 模式][5],但是每次我都没有真正的深入研究它,
|
||||
因为我当时的反应是“一个大纲编辑器?但我需要的是待办事项列表”。我就这么错过了它。但实际上 org 模式就是我所需要的。
|
||||
|
||||
### 什么是 Emacs?什么是 org 模式?
|
||||
|
||||
Emacs 最初是一个文本编辑器,现在依然是一个文本编辑器,而且这种传统无疑贯穿始终。但是说 Emacs 是个编辑器是很不公平的。
|
||||
|
||||
Emacs 更像一个平台或是工具包。你不仅可以用它来编辑源代码,而且配置 Emacs 本身也是编程,里面有很多模式。就像编写一个 Firefox 插件一样简单,只要几行代码,然后,模式里的操作就改变了。
|
||||
|
||||
org 模式也一样。确实,它是一个大纲编辑器,但它真正所包含的不止如此。它是一个信息组织平台。它的网站上写着,“你可以用纯文本来记录你的生活:你可以用 org 模式来记笔记,处理待办事项,规划项目和使用快速有效的纯文本系统编写文档。”
|
||||
|
||||
### 捕获
|
||||
|
||||
如果你读过基于 GTD 的生产力指南,那么他们强调的一件事就是毫不费力地获取项目。这个想法是,当某件事突然出现在你的脑海里时,把它迅速输入一个受信任的系统,这样你就可以继续做你正在做的事情。org 模式有一个专门的捕获系统。我可以在 Emacs 的任何地方按下 `C-c c` 键,它就会空出一个位置来记录我的笔记。最关键的是,自动嵌入到笔记中的链接可以链接到我按下 `C-c c` 键时正在编辑的那一行。如果我正在编辑文件,它会链回到那个文件和我所在的行。如果我正在浏览邮件,它就会链回到那封邮件(通过邮件的 Message-Id,这样它就可以在任何一个文件夹中找到邮件)。聊天时也一样,甚至是当你在另一个 org 模式中也可也这样。
|
||||
|
||||
这样我就可以做一个笔记,它会提醒我在一周内回复某封邮件,当我点击这个笔记中的链接时,它会在我的邮件阅读器中弹出这封邮件 —— 即使我随后将它从收件箱中存档。
|
||||
|
||||
没错,这正是我要找的!
|
||||
|
||||
### 工具套件
|
||||
|
||||
一旦你开始使用 org 模式,很快你就会想将所有的事情都集成到里面。有可以从网络上捕获内容的浏览器插件,也有多个 Emacs 邮件或新闻阅读器与之集成,ERC(IRC 客户端)也不错。所以我将自己从 Thunderbird 和 mairix + mutt (用于邮件归档)换到了 mu4e,从 xchat + slack 换到了 ERC。
|
||||
|
||||
你可能不明白,我喜欢这些基于 Emacs 的工具,而不是具有相同功能的单独的工具。
|
||||
|
||||
一个小花絮:我又在使用离线 IMAP 了!我甚至在很久以前就用过 GNUS。
|
||||
|
||||
### 用一个 Emacs 进程来管理
|
||||
|
||||
我以前也经常使用 Emacs,那时,Emacs 是一个“大”的程序(现在显示电源状态的小程序占用的内存要比 Emacs 多)。当时存在在启动时间过长的问题,但是现在已经有连接到一个正在运行的 Emacs 进程的解决方法。
|
||||
|
||||
我喜欢用 Mod-p(一个 [xmonad][6] 中 [dzen][7] 菜单栏的快捷方式,但是在大多数传统的桌面环境中该功能的快捷键是 `Alt-F2`)来启动程序(LCTT 译注:xmonad 是一种平铺桌面;dzen 是 X11 窗口下管理消息、提醒和菜单的程序)。这个设置在不运行多个<ruby>[emacs 们](https://www.emacswiki.org/emacs/Emacsen)<rt>emacsen</rt></ruby>时很方便,因为这样就不会在试图捕获另一个打开的文件时出问题。这中方法很简单:创建一个叫 `em` 的脚本并将它放到我自己的环境变量中。就像这样:
|
||||
|
||||
```
|
||||
#!/bin/bash exec emacsclient -c -a "" "$@"
|
||||
```
|
||||
|
||||
如果没有 emacs 进程存在的话,就会创建一个新的 emacs 进程,否则的话就直接使用已存在的进程。这样做还有一个好处:`-nw` 之类的参数工作的很好,它实际上就像在 shell 提示符下输入 `emacs` 一样。它很适合用于设置 `EDITOR` 环境变量。
|
||||
|
||||
### 下一篇
|
||||
|
||||
接下来我将讨论我的使用情况,并展示以下的配置:
|
||||
|
||||
* org 模式,包括计算机之间的同步、捕获、日程和待办事项、文件、链接、关键字和标记、各种导出(幻灯片)等。
|
||||
* mu4e,用于电子邮件,包括多个账户,bbdb 集成
|
||||
* ERC,用于 IRC 和即时通讯
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://changelog.complete.org/archives/9861-emacs-1-ditching-a-bunch-of-stuff-and-moving-to-emacs-and-org-mode
|
||||
|
||||
作者:[John Goerzen][a]
|
||||
译者:[oneforalone](https://github.com/oneforalone)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://changelog.complete.org/archives/author/jgoerzen
|
||||
[1]:https://www.gnu.org/software/emacs/
|
||||
[2]:https://gettingthingsdone.com/
|
||||
[3]:https://zenhabits.net/zen-to-done-the-simple-productivity-e-book/
|
||||
[4]:https://www.youtube.com/watch?v=oJTwQvgfgMM
|
||||
[5]:https://orgmode.org/
|
||||
[6]:https://wiki.archlinux.org/index.php/Xmonad_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
|
||||
[7]:http://robm.github.io/dzen/
|
@ -1,26 +1,27 @@
|
||||
Akash Angle: 你如何使用 Fedora?
|
||||
Akash Angle:你如何使用 Fedora?
|
||||
======
|
||||
|
||||
![](https://fedoramagazine.org/wp-content/uploads/2018/11/akash-angle-816x345.jpg)
|
||||
|
||||
我们最近采访了Akash Angle 来了解他如何使用 Fedora。这是 Fedora Magazine 上 Fedora [系列的一部分[1]。该系列介绍 Fedora 用户以及他们如何使用 Fedora 完成工作。请通过[反馈栏][2]与我们联系表达你对成为受访者的兴趣。
|
||||
我们最近采访了Akash Angle 来了解他如何使用 Fedora。这是 Fedora Magazine 上 Fedora [系列的一部分][1]。该系列介绍 Fedora 用户以及他们如何使用 Fedora 完成工作。请通过[反馈表单][2]与我们联系表达你对成为受访者的兴趣。
|
||||
|
||||
### Akash Angle 是谁?
|
||||
|
||||
Akash 是一位不久前抛弃 Windows 的 Linux 用户。作为一名过去 9 年的狂热 Fedora 用户,他已经尝试了几乎所有的 Fedora 定制版和桌面环境来完成他的日常任务。他被一位学校朋友介绍给 Fedora。
|
||||
Akash 是一位不久前抛弃 Windows 的 Linux 用户。作为一名过去 9 年的狂热 Fedora 用户,他已经尝试了几乎所有的 Fedora 定制版和桌面环境来完成他的日常任务。是一位校友给他介绍了 Fedora。
|
||||
|
||||
### 使用什么硬件?
|
||||
|
||||
Akash 在工作时使用联想 B490。它配备了英特尔酷睿 i3-3310 处理器和 240GB 金士顿 SSD。Akash 说:“这台笔记本电脑非常适合一些日常任务,如上网、写博客,以及一些照片编辑和视频编辑。虽然不是专业的笔记本电脑,而且规格并不是那么高端,但它完美地完成了工作。“
|
||||
|
||||
他使用一个入门的罗技无线鼠标,并希望能有一个机械键盘。他的 PC 是一台定制桌面电脑,拥有最新的第 7 代 Intel i5 7400 处理器和 8GB Corsair Vengeance 内存。
|
||||
他使用一个入门级的罗技无线鼠标,并希望能有一个机械键盘。他的 PC 是一台定制桌面电脑,拥有最新的第 7 代 Intel i5 7400 处理器和 8GB Corsair Vengeance 内存。
|
||||
|
||||
![][3]
|
||||
|
||||
### 使用什么软件?
|
||||
|
||||
Akash 是 GNOME 3 桌面环境的粉丝。他喜欢操作系统为完成基本任务而加入的华丽功能。
|
||||
Akash 是 GNOME 3 桌面环境的粉丝。他喜欢该操作系统为完成基本任务而加入的华丽功能。
|
||||
|
||||
出于实际原因,他更喜欢全新安来升级到最新 Fedora 版本。他认为 Fedora 29 可以说是最好的工作站。Akash 说这得到了各种科技传播网站和开源新闻网站评论的支持。。
|
||||
出于实际原因,他更喜欢全新安来升级到最新 Fedora 版本。他认为 Fedora 29 可以说是最好的工作站。Akash 说这种说法得到了各种科技传播网站和开源新闻网站评论的支持。
|
||||
|
||||
为了播放视频,他的首选是打包为 [Flatpak][4] 的 VLC 视频播放器 ,它提供了最新的稳定版本。当 Akash 想截图时,他的终极工具是 [Shutter,Magazine 曾介绍过][5]。对于图形处理,GIMP 是他不能离开的工具。
|
||||
|
||||
@ -46,7 +47,7 @@ via: https://fedoramagazine.org/akash-angle-how-do-you-fedora/
|
||||
作者:[Adam Šamalík][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@ -58,4 +59,4 @@ via: https://fedoramagazine.org/akash-angle-how-do-you-fedora/
|
||||
[4]: https://fedoramagazine.org/getting-started-flatpak/
|
||||
[5]: https://fedoramagazine.org/screenshot-everything-shutter-fedora/
|
||||
[6]: https://fedoramagazine.org/wp-content/uploads/2018/11/Fedora-16-300x188.png
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2018/11/wallpaper2you_72588-300x169.jpg
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2018/11/wallpaper2you_72588-300x169.jpg
|
@ -1,20 +1,21 @@
|
||||
如何在 SUSE 12 Linux 中进入单用户模式?
|
||||
======
|
||||
一篇了解如何在 SUSE 12 Linux 服务器中进入单用户模式的简短文章。
|
||||
|
||||
> 一篇了解如何在 SUSE 12 Linux 服务器中进入单用户模式的简短文章。
|
||||
|
||||
![How to enter single user mode in SUSE 12 Linux][1]
|
||||
|
||||
在这篇简短的文章中,我们将向你介绍在 SUSE 12 Linux 中进入单用户模式的步骤。在排除系统主要问题时,单用户模式始终是首选。单用户模式禁用网并且没有其他用户登录,你可以排除许多多用户系统的情况,可以帮助你快速排除故障。单用户模式最常见的一种用处是[重置忘记的 root 密码][2]。
|
||||
在这篇简短的文章中,我们将向你介绍在 SUSE 12 Linux 中进入单用户模式的步骤。在排除系统主要问题时,单用户模式始终是首选。单用户模式禁用网络并且没有其他用户登录,你可以排除许多多用户系统的情况,可以帮助你快速排除故障。单用户模式最常见的一种用处是[重置忘记的 root 密码][2]。
|
||||
|
||||
### 1\. 暂停启动过程
|
||||
### 1、暂停启动过程
|
||||
|
||||
首先,你需要拥有机器的控制台才能进入单用户模式。如果它是 VM 就要 VM 控制台,如果它是物理机那么你需要连接它的 iLO/串口控制台。重启系统并按任意键停止 grub 启动菜单中的内核自动启动。
|
||||
首先,你需要拥有机器的控制台才能进入单用户模式。如果它是虚拟机那就是虚拟机控制台,如果它是物理机那么你需要连接它的 iLO/串口控制台。重启系统并在 GRUB 启动菜单中按任意键停止内核的自动启动。
|
||||
|
||||
![Kernel selection menu at boot in SUSE 12][3]
|
||||
|
||||
### 2\. 编辑内核的启动选项
|
||||
### 2、编辑内核的启动选项
|
||||
|
||||
进入上面的页面后,在所选内核(通常是你首选的最新内核)上按 “e” 更新其启动选项。你会看到下面的页面。
|
||||
进入上面的页面后,在所选内核(通常是你首选的最新内核)上按 `e` 更新其启动选项。你会看到下面的页面。
|
||||
|
||||
![grub2 edits in SUSE 12][4]
|
||||
|
||||
@ -22,9 +23,9 @@
|
||||
|
||||
![Edit to boot in single user shell][5]
|
||||
|
||||
### 3\. 引导编辑后的内核
|
||||
### 3、引导编辑后的内核
|
||||
|
||||
现在按 `Ctrl-x` 或 `F10` 来启动这个编辑过的内核。内核将以单用户模式启动,你将看到井号提示符,即有服务器的 root 访问权限。此时,根文件系统以只读模式挂载。因此,你对系统所做的任何更改都不会被保存。
|
||||
现在按 `Ctrl-x` 或 `F10` 来启动这个编辑过的内核。内核将以单用户模式启动,你将看到 `#` 号提示符,即有服务器的 root 访问权限。此时,根文件系统以只读模式挂载。因此,你对系统所做的任何更改都不会被保存。
|
||||
|
||||
运行以下命令以将根文件系统重新挂载为可重写入的。
|
||||
|
||||
@ -41,7 +42,7 @@ via: https://kerneltalks.com/howto/how-to-enter-single-user-mode-in-suse-12-linu
|
||||
作者:[kerneltalks][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,175 +0,0 @@
|
||||
[translating by dianbanjiu]
|
||||
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: subject: (How to use the sudo command to deploy superuser powers on Linux)
|
||||
[#]: via: (https://www.networkworld.com/article/3322504/linux/selectively-deploying-your-superpowers-on-linux.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
[#]: url: ( )
|
||||
|
||||
How to use the sudo command to deploy superuser powers on Linux
|
||||
======
|
||||
|
||||
![](https://images.idgesg.net/images/article/2018/11/superman-100781085-large.jpg)
|
||||
|
||||
The **sudo** command is very handy when you need to run occasional commands with superuser power, but you can sometimes run into problems when it doesn’t do everything you expect it should. Say you want to add an important message at the end of some log file and you try something like this:
|
||||
|
||||
```
|
||||
$ echo "Important note" >> /var/log/somelog
|
||||
-bash: /var/log/somelog: Permission denied
|
||||
```
|
||||
|
||||
OK, it looks like you need to employ some extra privilege. In general, you can't write to a system log file with your user account. Let’s try that again with **sudo**.
|
||||
|
||||
```
|
||||
$ sudo !!
|
||||
sudo echo "Important note" >> /var/log/somelog
|
||||
-bash: /var/log/somelog: Permission denied
|
||||
```
|
||||
|
||||
Hmm, that didn't work either. Let's try something a little different.
|
||||
|
||||
```
|
||||
$ sudo 'echo "Important note" >> /var/log/somelog'
|
||||
sudo: echo "Important note" >> /var/log/somelog: command not found
|
||||
```
|
||||
|
||||
**[ Also see:[Invaluable tips and tricks for troubleshooting Linux][1] ]**
|
||||
|
||||
### What's going on here?
|
||||
|
||||
The response to the first of the commands shown above indicates that you lack the required privilege to write to the log file. In the second, you have simply tried to run the previously entered command with root privilege, but that resulted in a **Permission denied** error. In the third, you've tried to rerun the command by putting the entire command in quotes and ran into a **command not found** error. So, what went wrong?
|
||||
|
||||
* First command: You can’t write to that log without root privilege.
|
||||
* Second command: Your superpowers don't extend to the redirect.
|
||||
* Third command: Sudo doesn’t recognize everything you’ve put into the quotes as a "command."
|
||||
|
||||
|
||||
|
||||
And if you had tried to use sudo when you had no sudo access at all, you would have seen an error like this:
|
||||
|
||||
```
|
||||
nemo is not in the sudoers file. This incident will be reported.
|
||||
```
|
||||
|
||||
### What can you do?
|
||||
|
||||
One fairly simple option is to use the sudo command to briefly become root. Given you have sudo privileges, you might be able to do that with a command like this one:
|
||||
|
||||
```
|
||||
$ sudo su
|
||||
[sudo] password for nemo:
|
||||
#
|
||||
```
|
||||
|
||||
Notice that the prompt has changed to indicate your new authority. Then you can run the original command as root:
|
||||
|
||||
```
|
||||
# echo "Important note" >> /var/log/somelog
|
||||
```
|
||||
|
||||
And then you can enter **^d** and go back to being yourself. Of course, some sudo configurations might prevent you from using sudo to become root.
|
||||
|
||||
Another option is to switch user to root with just the **su** command, but that requires knowing the root password. Many people will be given access to sudo without being provided with the root password, so this won't always work.
|
||||
|
||||
If you switch user to root, you can then run commands as root to your heart’s content. The problems with this approach are 1) everyone exercising root privilege will have to know the root password (not very secure) and 2) you won't be protected from the repercussions of making big mistakes if you fail to exit your privileged status after you run the specific commands that require root privilege. The sudo command is intended to allow you to use root privilege _only_ when you really need it and to control how much of root’s power each sudo user ought to have. It’s also intended to easily revert to having you working in your normal user state.
|
||||
|
||||
Note also that this entire discussion is predicated on the assumption that you have access to sudo and that your access is not narrowly defined. More on that in a moment.
|
||||
|
||||
Another option is to use a different command. If adding to a file by editing it is an option, you might use a command such as "sudo vi /var/log/somelog", though editing an active log file isn't generally a good idea because of how frequently the system might need to write to it.
|
||||
|
||||
A final but more complex option is to use one of the following commands that get around the problems we saw earlier, but they involve more complex syntax. The first command allows you to repeat your command using !! after getting the "Permission denied" rejection:
|
||||
|
||||
```
|
||||
$ sudo echo "Important note" >> /var/log/somelog
|
||||
-bash: /var/log/somelog: Permission denied
|
||||
$ !!:gs/>/|sudo tee -a / <=====
|
||||
$ tail -1 /var/log/somelog
|
||||
Important note
|
||||
```
|
||||
|
||||
The second allows you to add your message by passing your message to **tee** using the sudo command. Note that the **-a** specifies that the text should be appended to the file:
|
||||
|
||||
```
|
||||
$ echo "Important note" | sudo tee -a /var/log/somelog
|
||||
$ tail -1 /var/log/somelog
|
||||
Important note
|
||||
```
|
||||
|
||||
### How controllable is sudo?
|
||||
|
||||
The quick answer to this question is that it depends on the person administering it. Most Linux systems default to a very simple setup. If a user is assigned to a particular group, which might be called **wheel** or **admin** , that user will have the ability to run any command as root without having to know the root password. This is the default setup on most Linux systems. Once a user is added to the privileged group in the **/etc/group** file, that person can run any command with root privilege. On the other hand, sudo can be set up so that some users can only run a single command or any in a set of commands as root and nothing more.
|
||||
|
||||
If lines like those shown below were added to the **/etc/sudoers** file, for example, the user "nemo" would be allowed to run the **whoami** command with root authority. While this might not make any sense in the "real world," it works fairly well as an example.
|
||||
|
||||
```
|
||||
# User alias specification
|
||||
nemo ALL=(root) NOPASSWD: WHOAMI
|
||||
|
||||
# Cmnd alias specification
|
||||
Cmnd_Alias WHOAMI = /usr/bin/whoami
|
||||
```
|
||||
|
||||
Note that we've added both a command alias (Cmnd_Alias) that specifies the command that can be run — with their full paths — and a user alias that allows that user to run that single command with sudo without even entering a password.
|
||||
|
||||
When nemo runs the command **sudo whoami** , he will see this:
|
||||
|
||||
```
|
||||
$ sudo whoami
|
||||
root
|
||||
```
|
||||
|
||||
Notice that, since nemo is running the command using sudo, the response to **whoami** shows that when the command is running, the user is **root**.
|
||||
|
||||
For other commands, nemo will see something like this:
|
||||
|
||||
```
|
||||
$ sudo date
|
||||
[sudo] password for nemo:
|
||||
Sorry, user nemo is not allowed to execute '/bin/date' as root on butterfly.
|
||||
```
|
||||
|
||||
### Default sudo setup
|
||||
|
||||
In the default approach, we'd be taking advantage of a line like one of those shown below from the **/etc/sudoers** file:
|
||||
|
||||
```
|
||||
$ sudo egrep "admin|sudo" /etc/sudoers
|
||||
# Members of the admin group may gain root privileges
|
||||
%admin ALL=(ALL) ALL <=====
|
||||
# Allow members of group sudo to execute any command
|
||||
%sudo ALL=(ALL:ALL) ALL <=====
|
||||
```
|
||||
|
||||
In these lines, **%admin** and **%sudo** both refer to groups that permit anyone added to one of these groups to run any command as root using the sudo command.
|
||||
|
||||
A line like the one shown below from the /etc/group file makes the individuals listed members of the group, thereby giving them sudo privileges without any changes required in the /etc/sudoers file.
|
||||
|
||||
```
|
||||
sudo:x:27:shs,nemo
|
||||
```
|
||||
|
||||
### Wrap-up
|
||||
|
||||
The sudo command is meant to allow you to easily deploy superuser access on an as-needed basis, but also to endow users with very limited privileged access when that's all that is required. You can run into problems that require a different approach than a simple "sudo command," and the responses that you get from **sudo** should indicate what problem you've run into.
|
||||
|
||||
Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3322504/linux/selectively-deploying-your-superpowers-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.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html
|
||||
[2]: https://www.facebook.com/NetworkWorld/
|
||||
[3]: https://www.linkedin.com/company/network-world
|
@ -1,75 +0,0 @@
|
||||
Emacs 系列 1:抛掉一切,投入 Emacs 和 org-mode 的怀抱
|
||||
======
|
||||
我必须承认,在使用了几十年的 vim 后, 我被 [Emacs][1] 吸引了。
|
||||
|
||||
长期以来,我一直对如何组织安排事情感到沮丧。我也有用过 [GTD][2] 和 [ZTD][3] 之类的方法,但是像邮件或是大型文件这样的事务真的很难来组织安排。
|
||||
|
||||
我一直在用 Asana 处理任务,用 Evernote 做笔记,用 Thunderbird 处理邮件,把 ikiwiki 和其他的一些项目组合作为个人知识库,而且还在电脑的归档了各种文件。当需要将 Slack 加入到归档中时,我终于忍无可忍了。
|
||||
|
||||
许多 todo 的管理工具与电子邮件集成的很差。当你想做“提醒我在一周内回复这个邮件”之类的事时,很多时候是不可能的,因为这个工具不能以一种能够轻松回复的方式存储邮件。而这个问题在 Slack 上更为严重。
|
||||
|
||||
就在那时,我偶然发现了 [Carsten Dominik 在 Google Talk 上关于org-mode 的话题][4]。Carsten 是 org-mode 的作者,即便是这个话题已经有 10 年了,但它仍然很具有参考价值。
|
||||
|
||||
我之前有用过 [org-mode][5],但是每次我都没有真正的深入研究它,
|
||||
因为我当时的反应是“一个大纲?但我需要的是待办事项列表”。我就这么错过了它。但实际上 org-mode 就是我所需要的。
|
||||
|
||||
### 什么是 Emacs? 什么是 org-mode?
|
||||
|
||||
Emacs 最初是一个文本编辑器,现在依然如此,而且这种传统无疑贯穿始终。但是说 Emacs 是个编辑器是很不公平的。
|
||||
|
||||
Emacs 更像一个平台或是工具包。你不仅可以用它来编辑源代码,而且配置 Emacs 本身就是也编程,里面有很多模式。就像编写一个 Firefox 插件一样简单,只要几行代码,然后,模式里的操作就改变了。
|
||||
|
||||
org-mode 也一样。确实,它是一个处理大纲的,但它真正所包含的不止如此。它是一个信息组织平台。它的网站上写着,“你可以用纯文本来记录你的生活:你可以用 org 模式来记笔记,处理待办事项,规划项目和使用快速有效的纯文本系统编写文档。
|
||||
|
||||
### 捕获
|
||||
|
||||
如果你读过基于GTD的生产力指南,那么他们强调的一件事就是毫不费力地获取项目。这个想法是,当某件事突然出现在你的脑海里时,把它迅速输入一个受信任的系统,这样你就可以继续做你正在做的事情。org-mode 有一个专门的捕获系统。我可以在 Emacs 的任何地方按下 `C-c c` 键,它就会空出一个位置来记录我的笔记。最关键的是,自动嵌入到注释中的链接可以链接到我按下 `C-c c` 键时正在编辑的那一行。如果我正在浏览邮件,它就会给我一个链接回那封邮件的链接(通过邮件的 ID,这样它就可以在任何一个文件夹中找到邮件)。聊天时也一样,甚至是当你在另一个 org-mode 中也可也这样。
|
||||
|
||||
这样我就可以做一个笔记,它会提醒我在一周内回复某封邮件,当我点击这个笔记中的链接时,它会在我的邮件阅读器中弹出这封邮件 -- 即使我随后将它从收件箱中存档。
|
||||
|
||||
没错,这正是我要找的!
|
||||
|
||||
### 工具套件
|
||||
|
||||
一旦你开始使用 org-mode,很快你就会想将所有的事情都集成到里面。有可以从网络上捕捉东西的浏览器插件,也有多个 Emacs 邮件或新闻阅读器与之集成,ERC(IRC client) 也不错。所以我将自己从 Thunderbird 和 mairix + mutt (用于邮件归档)换到了 mu4e,从 xchat + slack 换到了 ERC
|
||||
|
||||
你可能不明白,我喜欢这些基于 Emacs 的工具,而不是具有相同功能的的单独的工具。
|
||||
|
||||
一个小花絮:我又在使用离线 imap 了!我甚至在很久以前就用过 GNUS
|
||||
|
||||
### 用一个 Emacs 进程来管理
|
||||
|
||||
我以前也经常使用 Emacs,那时,Emacs 是一个“大”的程序(现在显示电源状态的小程序占用的内存要比 Emacs 的多)。当时存在在启动时间过长的问题,但是现在已经有连接到一个正在运行的 Emacs 进程的解决方法。
|
||||
|
||||
我喜欢用 Mod-p(一个 [xmonad][6](译者注:一种平铺桌面) 中 [dzen][7](译者注:X11 窗口下管理消息,提醒和菜单的程序)菜单栏的快捷方式,但是 DEs(译者注:不太清楚是啥,但据我的经验来说大概是 Debian 系列的缩写吧) 中常用的快捷键是 `Alt-F2`) 来启动程序。这个设置在不运行多个 emacsen 时很方便,因为这样就不会在试图捕获另一个打开的文件时出问题。这中方法很简单:创建一个叫 `em` 的脚本并将它放到我自己的环境变量中。就像这样:
|
||||
|
||||
`#!/bin/bash exec emacsclient -c -a "" "$@"`
|
||||
|
||||
如果没有 emacs 进程存在的话,就会创建一个新的 emacs 进程,否则的话就直接使用已存在的进程。这样做还有一个好处:`-nw` 之类的参数成功的话,它实际上就像在 shell 提示符下输入 `emacs` 一样。这样的设置对`编辑器`来说很合适。
|
||||
|
||||
### 下一篇
|
||||
|
||||
接下来我将讨论我的使用情况,并展示以下的配置:
|
||||
* org-mode,包括计算机之间的同步、捕获、日程和待办事项、文件、链接、关键字和标记、各种导出(幻灯片)等。
|
||||
* mu4e,用于电子邮件,包括多个账户,bbdb集成
|
||||
* ERC,用于 IRC(Internet Relay Chat) 和即时通讯
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://changelog.complete.org/archives/9861-emacs-1-ditching-a-bunch-of-stuff-and-moving-to-emacs-and-org-mode
|
||||
|
||||
作者:[John Goerzen][a]
|
||||
译者:[oneforalone](https://github.com/oneforalone)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://changelog.complete.org/archives/author/jgoerzen
|
||||
[1]:https://www.gnu.org/software/emacs/
|
||||
[2]:https://gettingthingsdone.com/
|
||||
[3]:https://zenhabits.net/zen-to-done-the-simple-productivity-e-book/
|
||||
[4]:https://www.youtube.com/watch?v=oJTwQvgfgMM
|
||||
[5]:https://orgmode.org/
|
||||
[6]:https://wiki.archlinux.org/index.php/Xmonad_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
|
||||
[7]:http://robm.github.io/dzen/
|
@ -0,0 +1,162 @@
|
||||
如何使用 sudo 命令在 Linux 中部署超级用户权限
|
||||
======
|
||||
|
||||
![](https://images.idgesg.net/images/article/2018/11/superman-100781085-large.jpg)
|
||||
|
||||
**sudo** 命令在你想要使用超级权限运行一条林临时的命令时非常方便,但是当它不能做到你期望的所有事的时候,你也会遇到一些麻烦。比如说你想在某些日志文件结尾添加一些重要的信息,你可能会尝试这样做:
|
||||
|
||||
```
|
||||
$ echo "Important note" >> /var/log/somelog
|
||||
-bash: /var/log/somelog: Permission denied
|
||||
```
|
||||
|
||||
好吧,看起来你似乎需要一些额外的特权。一般来说,你不能使用你的用户账号向系统日志中写入东西。我们使用 **sudo** 再尝试一次吧。
|
||||
|
||||
```
|
||||
$ sudo !!
|
||||
sudo echo "Important note" >> /var/log/somelog
|
||||
-bash: /var/log/somelog: Permission denied
|
||||
```
|
||||
|
||||
emmm,它还是没有啥反应。我们来试点不同的吧。
|
||||
|
||||
```
|
||||
$ sudo 'echo "Important note" >> /var/log/somelog'
|
||||
sudo: echo "Important note" >> /var/log/somelog: command not found
|
||||
```
|
||||
|
||||
**[ 也可以查看:[在 Linux 下排查故障的宝贵提示和技巧][1] ]**
|
||||
|
||||
### 接下来该干什么?
|
||||
|
||||
上面在执行完第一条命令后的回应显示,我们缺少向日志文件写入时必须的特权。第二次,我们使用 root 权限运行了第一次的命令,但是返回了一个 **没有权限** 的错误。第三次,我们把整个命令放在一个引号里面再运行了一遍,返回了一个 **没有发现命令** 的错误。 。所以,到底错在哪里了呢?
|
||||
|
||||
* 第一条命令:没有 root 特权,你无法向这个日志中写入东西。
|
||||
* 第二条命令:你的超级权限没有被正确重定位。
|
||||
* 第三条命令:Sudo 不理解你用引号括起来的整个 “命令”。
|
||||
|
||||
|
||||
|
||||
在你的用户还未添加到 sudo 用户组的时候,如果尝试使用 sudo,你可能已经看到过像下面的这么一条命令了:
|
||||
|
||||
```
|
||||
nemo is not in the sudoers file. This incident will be reported.
|
||||
```
|
||||
|
||||
### 你可以做什么?
|
||||
|
||||
一个相当简单的选择就是使用 sudo 命令成为 root。鉴于你已经有了 sudo 特权,你可以使用下面的命令执行此操作:
|
||||
|
||||
```
|
||||
$ sudo su
|
||||
[sudo] password for nemo:
|
||||
#
|
||||
```
|
||||
注意这个改变的符号表明了你的新身份。然后你就可以以 root 运行之前的命令了:
|
||||
|
||||
```
|
||||
# echo "Important note" >> /var/log/somelog
|
||||
```
|
||||
接着你可以输入 **^d** 返回你之前的身份。当然了,一些 sudo 的配置可能会阻止你使用 sudo 命令成为 root。
|
||||
|
||||
用 **su** 命令是另一个切换用户为 root 的选择,但是这需要你知道 root 密码许多人被赋予了访问 sudo 的权限,而且无需提供 root 密码,所以这并不是总有用。
|
||||
|
||||
切换到 root 之后,你就可以以 root 的身份运行任何你想执行的命令了。要想通过这种途径有三个问题 1) 每个想要使用 root 特权的人都需要事先知道 root 的密码(这样很不安全) 2) 如果在运行需要 root 权限的特定命令后未能退出特权状态,你的系统可能会受到一些重大错误的波及。最好 _只有_ 当你真的需要 root 特权,以及能控制好每个 sudo 用户可以拥有多少 root 权限的时候再去使用它。在使用完 root 特权之后,最好及时恢复到普通用户的状态。
|
||||
|
||||
另外请注意,整个讨论的前提是你可以正常地访问 sudo,并且你的访问权限没有受限。详细的内容后面会介绍到。
|
||||
|
||||
还有一个选择就是使用一个不同的命令。如果通过编辑文件从而在其后添加内容是一种选择的话,你也许可以使用 “sudo vi /var/log/somelog”,通过编辑一个活跃的日志文件通常不是一个好办法,因为系统可能会频繁的向这个文件中进行写入操作。
|
||||
|
||||
最后一个但是有点复杂的选择是,使用下列可以解决我们之前看到的问题的命令之一,但是它们涉及到了很多复杂的语法。第一个命令允许你在得到 “没有权限” 的拒绝之后可以使用 !! 重复你的命令:
|
||||
|
||||
```
|
||||
$ sudo echo "Important note" >> /var/log/somelog
|
||||
-bash: /var/log/somelog: Permission denied
|
||||
$ !!:gs/>/|sudo tee -a / <=====
|
||||
$ tail -1 /var/log/somelog
|
||||
Important note
|
||||
```
|
||||
|
||||
第二种是通过 sudo 命令,把你想要添加的信息传递给 **tee**。注意,**-a** 指定了你要添加文本的目标文件:
|
||||
|
||||
```
|
||||
$ echo "Important note" | sudo tee -a /var/log/somelog
|
||||
$ tail -1 /var/log/somelog
|
||||
Important note
|
||||
```
|
||||
|
||||
### sudo 有多可控?
|
||||
|
||||
回答这个问题最快速的回答就是,它取决于管理它的人。大多数 Linux 的默认设置都非常简单。如果一个用户被安排到了一个特别的组中,例如 **wheel** 或者 **admin** 组,那这个用户无需知道 root 的密码就可以拥有运行任何命令的能力。这就是大多数 Linux 系统中的默认设置。一旦在 **/etc/group** 中添加了一个用户到了特权组中,这个用户就可以以 root 的权力运行任何命令。另一方面,可以配置 sudo,以便一些用户只能够以 root 身份运行单一指令或者一组命令中的任何一个。
|
||||
|
||||
如果把像下面展示的这些行添加到了 **/etc/sudoers** 文件中,例如 “nemo” 这个用户可以以 root 身份运行 **whoami** 命令。在现实中,这可能不会造成任何影响,作为一个例子,它做的非常好。
|
||||
|
||||
```
|
||||
# User alias specification
|
||||
nemo ALL=(root) NOPASSWD: WHOAMI
|
||||
|
||||
# Cmnd alias specification
|
||||
Cmnd_Alias WHOAMI = /usr/bin/whoami
|
||||
```
|
||||
|
||||
注意,我们添加了一个命令别名(Cmnd_Alias),它指定了一个可以运行的命令的全路径,以及一个用户别名,允许这个用户无需密码就可以使用 sudo 执行的单个命令。
|
||||
|
||||
当 nemo 运行 **sudo whoami** 命令的时候,他将会看到这个:
|
||||
|
||||
```
|
||||
$ sudo whoami
|
||||
root
|
||||
```
|
||||
|
||||
注意这个,一旦 nemo 使用 sudo 执行了这条命令,**whoami** 会显示此时的用户是 **root**。
|
||||
|
||||
至于其他的命令,nemo 将会看到像这样的一些内容:
|
||||
|
||||
```
|
||||
$ sudo date
|
||||
[sudo] password for nemo:
|
||||
Sorry, user nemo is not allowed to execute '/bin/date' as root on butterfly.
|
||||
```
|
||||
|
||||
### sudo 的默认设置
|
||||
|
||||
在默认路径中,我们会利用像下面展示的 **/etc/sudoers** 文件中的几行:
|
||||
|
||||
```
|
||||
$ sudo egrep "admin|sudo" /etc/sudoers
|
||||
# Members of the admin group may gain root privileges
|
||||
%admin ALL=(ALL) ALL <=====
|
||||
# Allow members of group sudo to execute any command
|
||||
%sudo ALL=(ALL:ALL) ALL <=====
|
||||
```
|
||||
|
||||
在这几行中,**%admin** 和 **%sudo** 都说明了任何添加到这些组中的人都可以使用 sudo 命令 以 root 的身份运行任何命令。
|
||||
|
||||
下面列出的是 /etc/group 中的一行,它意味着每一个在该组中列出的成员,都拥有了 sudo 特权,而无需在 /etc/sudoers 中进行任何修改。
|
||||
|
||||
```
|
||||
sudo:x:27:shs,nemo
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
sudo 命令意味着你可以根据需要轻松地部署超级用户的访问权限,而且只有在需要的时候才能赋予用户非常有限的特权访问权限。你可能会遇到一些与简单的 "sudo command" 不同的问题,不过在 **sudo** 的回应中应该会显示你遇到了什么问题。
|
||||
|
||||
欢迎加入 [Facebook][2] 和 [LinkedIn][3] 上的 Network World 社区,并在其中重要的主题下进行留言评论。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3322504/linux/selectively-deploying-your-superpowers-on-linux.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[dianbanjiu](https://github.com/dianbanjiu)
|
||||
校对:[校对者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.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html
|
||||
[2]: https://www.facebook.com/NetworkWorld/
|
||||
[3]: https://www.linkedin.com/company/network-world
|
Loading…
Reference in New Issue
Block a user