不推荐的命令行用法

fcicq 同学写道:

“第一行总是不好的, 或许第二行只是好了那么一点.

这个比较重要. 如果文件坏了, 前者可查不出来. sudo nano /etc/sudoers sudo visudo

同理, 这样的也是问题. sudo nano /etc/hosts sudoedit /etc/hosts

这个毛病偶没有. kill pgrep something pkill something (还有些人用 killall, 你觉得好还是不好?)

这个 ps 的不好说, 谁知道偶为什么就喜欢用前者了? 只是因为查看 zombie 进程的 ppid 比较方便? ps -el ps aux

知道两者的区别吗? 非常不幸偶是用前者的那种人. su su -

两条都不好的一组. 如果必要的话大概还是要用吧. sudo su sudo screen

有想限制上面某些操作的同学可以考虑类似: %wheel ALL=(ALL) ALL, !/bin/su, !/bin/bash

ps: 如果你也有什么不良习惯, 赶快晒出来吧... :D”

Read More:

26 Comments

  1. 1 cc98 Commented @ 2009-02-15 8:55Reply to this comment

    看得我头晕,没看懂是怎么回事

  2. 2 allbluedream Commented @ 2009-02-15 9:27Reply to this comment

    我就killall了……而且经常-s SIGTERM

  3. 3 fcicq Commented @ 2009-02-15 9:32Reply to this comment

    @allbluedream 没记错的话 kill / killall 默认都是 SIGTERM? hohoho... 手顺 :D

  4. 4 YCF.name Commented @ 2009-02-15 10:14Reply to this comment

    很不幸,我习惯于使用 su 而不是 su - 另:我真的不知道要用 su - :-(

    不过也许我们可通过alias su='su -'这类方法修正,哈哈

  5. 5 chroot Commented @ 2009-02-15 10:19Reply to this comment

    su - 有点太邪恶了,还是用 su -l 直观点。

  6. 6 32idea Commented @ 2009-02-15 10:23Reply to this comment

    偶也是懒得加 — 偶尔会用su - 还有vi用不惯啊,老忘了插入、保存与退出的命令

  7. 7 yegle Commented @ 2009-02-15 10:51Reply to this comment

    sudo永远和!!连用,不单独加命令用

  8. 8 chunchengfh Commented @ 2009-02-15 11:17Reply to this comment

    @cc98: 看第一遍我也没看懂,再看了下标题,终于明白了 linux下命令N多,参数N*N多,难免使用的参数不是最合适的,不过只要能满足自己的需要就行了 PS:我总是以普通用户登录,然后用su开一个root终端处理root相关的事务,从来不用sudo

  9. 9 ttg Commented @ 2009-02-15 11:30Reply to this comment

    su-好吗?好像是有管理员权限时同时使用管理员环境的意思,不觉得有啥好啊,除非是su不能完成时,我从用su-

  10. 10 fcicq Commented @ 2009-02-15 12:47Reply to this comment

    后来一想好像有些更常见的问题被忽略掉了. cat file | grep | awk 什么的, 不过基于理解的角度, 这样做倒是没有问题.

    还用过一些 cat file | dd | gzip > file1 另外在另一个地方 watch -n3 pkill -USR1 dd 看进度什么的. (pv = Pipe Viewer 应该更好)

  11. 11 damn Commented @ 2009-02-15 13:43Reply to this comment

    1 私下认为允许sudo一些能加参数的命令总是不太好。 2 ubuntu允许sudo su就像微软的产品一样邪恶。

  12. 12 wbsh Commented @ 2009-02-15 15:17Reply to this comment

    (还有些人用 killall, 你觉得好还是不好?)

    谁告诉我到底是好还是不好?

  13. 13 pc Commented @ 2009-02-15 15:46Reply to this comment

    我用命令就是安装软件的时候以及删除修改,其他的就不怎么用了

  14. 14 daqing Commented @ 2009-02-15 18:01Reply to this comment

    这样killall:

    1. sudo killall -g nginx
    2. sudo kill `cat /var/run/nginx.pid`
    

    好吗? 不好吗?

  15. 15 Mike Commented @ 2009-02-15 19:09Reply to this comment

    ps aux在SVR4系列上面是用不了吧。。。 是ps -ef。。。 所以现在都养成了ps -ef了。。因为要在solaris下面工作啊。。。

  16. 16 yjc Commented @ 2009-02-15 19:51Reply to this comment

    su - 和 sudo -s -H 有什么区别呢??

  17. 17 停电了 Commented @ 2009-02-15 21:18Reply to this comment

    额 这样会不会是怀习惯 alias rm='rm -f -R'

  18. 18 停电了 Commented @ 2009-02-15 21:18Reply to this comment

    而且直接用root 作平常事..........

  19. 19 Moses Commented @ 2009-02-15 21:19Reply to this comment

    最好把用和不用的原因写出来, 否则鬼才看的懂这篇文章要表达的意思...

  20. 20 eagleguo998 Commented @ 2009-02-15 21:53Reply to this comment

    没明白。我一直用su -。

  21. 21 fortruth Commented @ 2009-02-15 22:17Reply to this comment

    同意这样的说法

    (最好把用和不用的原因写出来, 否则鬼才看的懂这篇文章要表达的意思…)

  22. 22 allbluedream Commented @ 2009-02-16 9:23Reply to this comment

    @fcicq: 记错了,我是一直用SIGKILL

  23. 23 walkerxk Commented @ 2009-02-16 9:41Reply to this comment

    一直用sudo,root被我禁用(sudo passwd root -l)root下如果有什么误操作,后悔都来不及。 为什么会有sudo su?用root的权限执行su?直接su不就行了? pkill和killall的区别在于一般情况下pkill功能强大,但是killall简单,而且有些功能pkill没有。 sudo nano /etc/sudoers应该是不能保存的吧,我当时用vi,就是提示无法保存,其实使用nano也是不建议的用法,nano功能太简单了。就像gedit一样,都被我用vi和gvim替代了。 kill pgrep something就没有必要了,直接pkill ps -el ps aux 用途不一样,很难说哪个更好。 su和su-的环境不同,但是有时就是要使用非root的环境变量。

  24. 24 davix Commented @ 2009-02-16 13:22Reply to this comment

    希望作者增加自己的中文表達能力

  25. 25 fcicq Commented @ 2009-02-16 19:19Reply to this comment

    @daqing 和 /var/run/xxxx.pid 相关的东西, 一般认为需要和 start-stop-daemon 一起使用, 不推荐直接 kill. 而且它有 --signal 参数. nginx reload 的问题推荐改过来.

    @walkerxk 偶编辑 /etc/sudoers 居然能保存? 而且 ls -l 是这样的: -r--r----- 1 root root --- --- /etc/sudoers 难不成这和 Extended Attributes 有关? 还是 root 用户太强大?

    to 楼上: 谢谢提醒.

  26. 26 飯の狂熱 Commented @ 2009-02-17 17:21Reply to this comment

    我每次都是直接vim /etc/group的, 因為我老是不記得什麼addgroup還是groupadd怎麼用...