Tag Archives: Linux

linux的日志管理

Linux 日志都以明文形式存储,所以您不需要特殊的工具就可以搜索和阅读它们。您还可以编写脚本,来扫描这些日志,并基于它们的内容去自动执行某些功能。
 
Linux 日志存储在 /var/log 目录中。这里有几个由系统维护的日志文件,但其他服务和程序也可能会把它们的日志放在这里。大多数日志只有 root 才可以读,不过只需要修改文件的访问权限就可以让其他人可读。
 
/var/log/messages
messages 日志是核心系统日志文件。它包含了系统启动时的引导消息,以及系统运行时的其他状态消息。IO 错误、网络错误和其他系统错误都会记录到这个文件中。其他信息,比如某个人的身份切换为 root,也在这里列出。如果服务正在运行,比如 DHCP 服务器,您可以在 messages 文件中观察它的活动。通常,/var/log/messages 是您在做故障诊断时首先要查看的文件。
dmesg | more
 
上面的命令将以分页的方式显示引导信息
上面的命令将以分页的方式显示引导信息。
 
tail
有时,当某些行为发生时,您会希望密切关注一个日志文件。 Tail 命令设计用于显示文本文件的最后几行。使用 -f 开关,当日志增加新的内容时, tail 将继续显示新的输出。
 
tail -f /var/log/messages
 
上面的命令将显示 /var/log/messages 文件的最后 10 行,然后继续监控那个文件,并输出新的行为。要停止 tail -f 命令,使用 Ctrl + C 来中止进程。
 
more
More 的工作方式与 DOS 版本相同。您可以将它指向一个文件,或者通过它以管道输出信息,以分页的方式来查看信息。例如,以分页方式显示 Xfree86 启动日志文件的内容:
 
more /var/log/XFree86.0.log
 
使用“q”或者 [Ctrl]-C 来停止查看文件。
 
less
Less 是另一个文本阅读器,不过它还允许在文件中滚动浏览以及检索信息。
 
less /var/log/messages
 
上面的命令将显示 /var/log/messages 文件的内容。使用“q”来停止查看文件。使用“h”来获得 less 的使用帮助。
 
logger
您可能会希望将自己的消息也记录到日志文件。您可以只是将日志消息附加到恰当的文本文件,但是您必须得套用日志信息格式。同样,如果日志系统被定制,您还将不得不修改您的代码。l logger 命令使您可以将自己的消息发送到日志工具。在脚本中使用它来提供关于执行和错误的消息。
 
 

趣味教程:12步让Windows变成Linux

 
步骤1:去除所有文件扩展名
步骤2:把整个注册表导出为56000个文本文件
步骤3:把步骤2得到的文件分散放置于硬盘上各个地方,并且改成简短且无意义的名字
步骤4:确保其中一些文件以“d”结尾以“.”开头步骤5:降级到Windows 3.1以得到“方框窗口,锯齿字体”效果
步骤6:输入的时候都用小写,假装你的系统是大小写敏感的
步骤7:为普通命令创建批处理文件,文件名也要短短的
步骤8:卸载打印机驱动,只使用“通用打印机驱动”
步骤9: 买一只企鹅玩偶
步骤10:言必称BSD、NFS、EXT2、GNU、GPL、FSF以及开源软件什么的
步骤11:加入共产党!(Flash中的小字写道:“因为Micro$oft支持那些使用DOS的资本家”)
步骤12:牢记Micro$oft中的“$”

增强无线功能 Linux新内核2.6.14发布

Linux最新内核版本2.6.14发布了。新版本的无线连接功能有了很大加强,内核集成了Wireless Extensions API 19版。
 
新内核还引入了两种虚拟文件系统。relayfs文件系统允许用户空间和内核之间的高速数据传输,而Securityfs则是一种安全模型专用的虚拟文件系统。
 
新版本的其他新功能还包括HostAP,FUSE,netlink connector,支持DCCP,PPTP,ppc64,numa-aware slab allocator,lock-free descriptor lookup等等。
 
目前为止Linux社区用户对新内核褒贬不一,某些用户声称他们的电脑无法在新内核下正常工作,稳定性也许不如之前的版本。他们表示Linux也许走上了和微软一样的道路:不断增加新功能,但却以稳定性下降为代价。而其他用户表示新版本一切正常。

如何用鼠标右按钮直接以 Root 身份开启文件?

gedit $HOME/.gnome2/nautilus-scripts/Open as root

# 在新增的文件内加入下面这几行

for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
    gnome-sudo "gnome-open $uri" &
done

# 保存编辑过的文件 (范例)
#

chmod +x $HOME/.gnome2/nautilus-scripts/Open as root

#

鼠标右按钮点击文件 -> Scripts -> Open as root

默认conf

# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
# (Type "man /etc/X11/xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following commands:
#
#   cp /etc/X11/xorg.conf /etc/X11/xorg.conf.custom
#   sudo sh -c ‘md5sum /etc/X11/xorg.conf >/var/lib/xfree86/xorg.conf.md5sum’
#   sudo dpkg-reconfigure xserver-xorg

Section "Files"
    FontPath    "unix/:7100"            # local font server
    # if the local font server has problems, we can fall back on these
    FontPath    "/usr/lib/X11/fonts/misc"
    FontPath    "/usr/lib/X11/fonts/cyrillic"
    FontPath    "/usr/lib/X11/fonts/100dpi/:unscaled"
    FontPath    "/usr/lib/X11/fonts/75dpi/:unscaled"
    FontPath    "/usr/lib/X11/fonts/Type1"
    FontPath    "/usr/lib/X11/fonts/CID"
    FontPath    "/usr/lib/X11/fonts/100dpi"
    FontPath    "/usr/lib/X11/fonts/75dpi"
        # paths to defoma fonts
    FontPath    "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
    FontPath    "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID"
EndSection

Section "Module"
    Load    "bitmap"
    Load    "dbe"
    Load    "ddc"
    Load    "dri"
    Load    "extmod"
    Load    "freetype"
    Load    "glx"
    Load    "int10"
    Load    "record"
    Load    "type1"
    Load    "vbe"
EndSection

Section "InputDevice"
    Identifier    "Generic Keyboard"
    Driver        "keyboard"
    Option        "CoreKeyboard"
    Option        "XkbRules"    "xorg"
    Option        "XkbModel"    "pc104"
    Option        "XkbLayout"    "us"
EndSection

Section "InputDevice"
    Identifier    "Configured Mouse"
    Driver        "mouse"
    Option        "CorePointer"
    Option        "Device"        "/dev/input/mice"
    Option        "Protocol"        "ImPS/2"
    Option        "Emulate3Buttons"    "true"
    Option        "ZAxisMapping"        "4 5"
EndSection

Section "Device"
    Identifier    "NVIDIA Corporation NV11 [GeForce2 MX/MX 400]"
    Driver        "nv"
    BusID        "PCI:1:0:0"
EndSection

Section "Monitor"
    Identifier    "LXB-L15"
    Option        "DPMS"
    HorizSync    30-61
    VertRefresh    55-75
EndSection

Section "Screen"
    Identifier    "Default Screen"
    Device        "NVIDIA Corporation NV11 [GeForce2 MX/MX 400]"
    Monitor        "LXB-L15"
    DefaultDepth    24
    SubSection "Display"
        Depth        1
        Modes        "1024×768" "832×624" "800×600" "720×400" "640×480"
    EndSubSection
    SubSection "Display"
        Depth        4
        Modes        "1024×768" "832×624" "800×600" "720×400" "640×480"
    EndSubSection
    SubSection "Display"
        Depth        8
        Modes        "1024×768" "832×624" "800×600" "720×400" "640×480"
    EndSubSection
    SubSection "Display"
        Depth        15
        Modes        "1024×768" "832×624" "800×600" "720×400" "640×480"
    EndSubSection
    SubSection "Display"
        Depth        16
        Modes        "1024×768" "832×624" "800×600" "720×400" "640×480"
    EndSubSection
    SubSection "Display"
        Depth        24
        Modes        "1024×768" "832×624" "800×600" "720×400" "640×480"
    EndSubSection
EndSection

Section "ServerLayout"
    Identifier    "Default Layout"
    Screen        "Default Screen"
    InputDevice    "Generic Keyboard"
    InputDevice    "Configured Mouse"
EndSection

Section "DRI"
    Mode    0666
EndSection