使用旧的内核启动

2009年10月15日 18:36

编译内核后,如果新的内核出了点问题,想使用旧的内核怎么办?

环境PcBSD7.11

  1. 确定旧的内核还在系统中,一般是在/boot/kernel.old/目录下。
  2. 在启动界面中,选择 Escape to loader prompt选项进入loader程序。
  3. 接着在ok提示符下输入如下命令:

unload                                             #移除所有已加载的模块 
set kernel="kernel.old"                 #设置全局变量kernel 说明使用旧的内核启动 
load /boot/kernel.old/kernel         #加载旧的内核
boot-conf                                         #基于变量对模块进行自动配置(使用之前设置的kernel变量)

就会以旧的内核装载运行了

如何在字符界面下滚动屏幕

2009年9月14日 21:22

以前在使用类Unix系统时,如果没有装桌面系统要在字符界面下工作,会遇到这样一个问题:

如果屏幕输出过多,最早输出的内容会被挤出屏幕看不到了,字符界面又没有滚动条这样的东西,那么该怎么查看那些被挤到“屏幕上面“的内容呢?

有几种方法:

  1. 通过输出重定向将输出定向到文件里,再用编辑器看。
  2. 将输出定向到more或less这样的程序里看。

这也是我之前常使用的,但是直到最近我才发现有第三种方法。。

在键盘的右上角有一个按键叫做Screen lock,在print screen和pause/break按键之间。这个按键的左右就是查看屏幕上的输出。

使用方法:

首先按下Screen lock按钮看到右边键盘灯亮起,既说明开启了滚动屏幕模式,接着可以通过pageup/pagedown来滚动屏幕了。再次按下Screen lock按钮退出滚动屏幕模式。

以前一直没注意这个按钮是干嘛的,原来是做这个的。:-)

nbtscan

2009年3月25日 02:01

 根据ip地址 查看机器名

Grep

2009年1月14日 19:11

grep 常用命令

grep -Inr "str" .       递归查找当前目录下包含字符串str的文件 并跳过binary文件

-I        跳过binary

-n        显示该字符串出现的行号

-r        递归查找      

Learning Python

2008年11月10日 22:54

Shell Script

#!/usr/local/bin/python

String

Raw Strings :

r"C:\new\test"
'C:\\new\\test'

Copy

If you want a complete copy which copy nested data structures, use the strandard copy module:

import copy
X=copy.deepcopy(Y)

Comparisons, Equality

The ==  operator tests value equivalence
The  is  operator tests object identity

Vim配置文件

2008年11月06日 23:23

"if v:progname =~? "evim"
" finish
"endif

" 禁止兼容模式
set nocompatible

" 设置<BS>可以删除的字符
set backspace=indent,eol,start

" 除了VMS系统外 覆盖文件时保留备份
if has("vms")
set nobackup       
else
set backup       
endif

set history=50        " 保存50个命令历史
set ruler        " 始终显示当前位置
set showcmd        " 显示未完成的命令
set incsearch        " 输入搜索时显示匹配

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" 不使用Ex模式, 将Q映射
map Q gq

" In many terminal emulators the mouse works just fine, thus enable it.
set mouse=a

" 颜色数目大于2 或在 GUI 的情况下运行时
" 开启语法高亮与查找模式匹配
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif

" 如果支持自动命令
if has("autocmd")

" 允许文件类型探测.
" 使用文件类型相关的插件
" 'cindent' is on in C files, etc.
" 使用缩进文件.
filetype plugin indent on

" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!

" 一行长于78字符时自动换行.
autocmd FileType text setlocal textwidth=78

" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

augroup END

else

set autoindent        " always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
         \ | wincmd p | diffthis

//输入括号或引号后 光标自动移到括号中
:inoremap () ()<Left>
:inoremap [] []<Left>
:inoremap "" ""<Left>

//在插入模式中使用Ctrl-x 来控制光标
:inoremap <C-H> <Left>
:inoremap <C-L> <Right>
:inoremap <C-J> <Down>
:inoremap <C-K> <Up>

//颜色主题
:colorscheme darkblue

gdb 学习

2008年11月06日 23:10

gcc -g 添加调试信息到可执行文件中

list 列出代码

break 设置断点

info break 查看断点

n     单条语句执行

c     继续运行程序

p x    打印变量 x 的值

bt    查看函数堆栈

finish 退出函数

shell command 运行shell程序

set args     指定运行时参数

show args    查看设置好的参数

set environment varname [=value]    设置环境变量

show environment     查看环境变量

set print element <number-of-elements> 设置显示数组的长度

show print elements  显示print element 的值



调试已运行的程序

gdb pid           或            attach detach
info program        查看程序的运行 进程号

断点

break ...if ...

观察点

watch <expr> expr变化时停住程序
rwatch <expr> expr被读时停住程序
awatch <expr> expr被读写时停住程序
info watchpoints 列出观察点

clear 清楚所有停止点

delete [breakpoints][range...]   删除断点

condition <bnum><expression> 修改断点号为bnum的停止条件为expression
condition <bnum>   清楚断点号为bnum的停止条件

ignore <bnum><count> 忽略断点停止条件count次

commands [bnum]   为断点设置命令

线程

info threads         查看线程信息
break <linespec> thread <threadno>   linespec 指定源程序行号


backtrace     显示栈信息
frame
info fram        查看栈层的信息

数组
p *array@len        打印数组

examine        查看内存

display        自动显示

signal            产生信号量

grub menu.list配置

2008年11月06日 23:09


# 默认选项为0
# 由于sda6分区为boot所在分区 root命令定位 kernel initrd这两个命令所使用文件的位置
default        0
#等待时间30
timeout        30
#选项颜色
color cyan/blue white/blue

#Vista 选项
title        Windows Vista/Longhorn (loader)
#Vista所在分区
root        (hd0,0)
savedefault
makeactive
#从第一个扇区启动
chainloader    +1

#Fedora 选项
title        Fedora (2.6.25-14.fc9.i686) (on /dev/sda2)
#boot分区位置
root        (hd0,5)
#根目录的Label为UUID=85648c8b-3762-462b-b955-ac3510693ae8
#可以通过/etc/fstab文件查看
kernel        /fedora/vmlinuz-2.6.25-14.fc9.i686 ro root=UUID=85648c8b-3762-462b-b955-ac3510693ae8 rhgb quiet
initrd        /fedora/initrd-2.6.25-14.fc9.i686.img
savedefault
boot

#Ubuntu选项
title        Ubuntu 8.04.1, kernel 2.6.24-19-generic
#boot分区位置
root        (hd0,5)
kernel        /ubuntu/vmlinuz-2.6.24-19-generic root=UUID=f3f3338b-4dcd-4d0e-b6cd-122081a352ec ro quiet splash
initrd        /ubuntu/initrd.img-2.6.24-19-generic
quiet

title        Ubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root        (hd0,5)
kernel        /ubuntu/vmlinuz-2.6.24-19-generic root=UUID=f3f3338b-4dcd-4d0e-b6cd-122081a352ec ro single
initrd        /ubuntu/initrd.img-2.6.24-19-generic

title        Ubuntu 8.04.1, memtest86+
root        (hd0,5)
kernel        /ubuntu/memtest86+.bin
quiet


Ubuntu 软件安装过程中出现软件包版本过高 导致依赖失败的问题 可以使用aptitude对软件包进行降级

图形界面

man.ddvip.com/linux/debian/aptitude aptitude简明手册

ldd

2008年10月09日 00:24

ldd查看可执行文件依赖的库