Browse > Home /

| 订阅RSS

晒晒自己的svn备份做法

四月 4th, 2009 | No Comments | Posted in Linux

今天在google reader的分享中,看到东东分享的备份脚本,发现那个备份脚本最大不好的地方就是每次是一个全库备份,这要是上万次的提交,那个速度相当的受不了,现在把我一直使用的svn备份拿出来分享一下。

More »

Tags: , , ,

围绕在SVN(subversion)周围的GIT运用

四月 3rd, 2009 | No Comments | Posted in Linux, 开发环境

前一段因为家里面的宽带不是包月的,按照时间收费的,在开发的时候,老要提交东西,不提交的放在本地总感觉要和别人冲突了(谁都怕冲突呀,:)),然后就想到了git,现在还是挺火的,然后就试试,没想到等我尝试完毕之后再也放不下了,真是爱不释手,谈谈我的使用感受吧,git看起来很复杂,使用起来的确很方便。

More »

Tags: , , , ,

ubuntu 上安装atheros无线驱动

四月 3rd, 2009 | No Comments | Posted in Linux

现在使用的是Thinkpad的T400,里面内置的无线网卡是Atheros的(win下面显示好像是:thinkpad a/b),但是默认安装ubuntu 8.04并不支持这个程序,具体安装如下:

More »

Tags: , , ,

[命令集3.8]通过Samba和Windows进行数据共享

四月 2nd, 2009 | No Comments | Posted in Linux

现在windows大行天下,难免要和windows的机器进行共享数据,通过linux中的samba协议能够获得windows的共享数据。
假设我们要访问计算机 smbserver 上的名叫 myshare 的 SMB 共享,在 window PC 上键入的地址是
\\smbserver\myshare\。我挂载到 /mnt/smbshare 上。注意 cifs 必须是 IP 或 DNS 名,不是 Windows 名
字。

More »

Tags: , , , ,

[命令集3.7] 立刻创建swap分区

三月 24th, 2009 | No Comments | Posted in Linux

假设你需要很多的 swap 空间 (即刻),如一个 2GB 文件 /swap2gb (只限 Linux)。

# dd if=/dev/zero of=/swap2gb bs=1024k count=2000
# mkswap /swap2gb                    # 创建交换区
# swapon /swap2gb                    # 激活这个 swap。现在可以使用了
# swapoff /swap2gb                   # 当使用完毕,释放这个 swap
# rm /swap2gb
Tags: , ,

[Linux秘籍31] PS3 - 在shell脚本中的提示符

三月 24th, 2009 | No Comments | Posted in Linux

在shell脚本中,你能够定义一个自定义的提示符,举个例子如下:
当没有定义PS3的时候

jcai@jcai-notebook:~/tmp$ cat ps3.sh 
  select i in mon tue wed exit
  do
     case $i in
        mon) echo "Monday";;
        tue) echo "Tuesday";;
        wed) echo "Wednesday";;
        exit) exit;;
     esac
  done
jcai@jcai-notebook:~/tmp$ ./ps3.sh 
1) mon
2) tue
3) wed
4) exit
#? 1
Monday
#? 2
Tuesday
#? 4

当定义了PS3的时候如下:

jcai@jcai-notebook:~/tmp$ cat ps3.sh
  PS3="请选择 1-4:"
  select i in mon tue wed exit
  do
     case $i in
        mon) echo "Monday";;
        tue) echo "Tuesday";;
        wed) echo "Wednesday";;
        exit) exit;;
     esac
  done
jcai@jcai-notebook:~/tmp$ ./ps3.sh 
1) mon
2) tue
3) wed
4) exit
请选择 1-42
Tuesday
请选择 1-44
Tags: ,

[命令集3.6]挂载/重挂载一个文件系统

三月 23rd, 2009 | No Comments | Posted in Hacks, Linux

举个 cdrom 的例子。如果已经列于 /etc/fstab 中:

 # mount /cdrom

或在 /dev/ 中查找设备,亦或使用 dmesg 命令
FreeBSD

 # mount -v -t cd9660 /dev/cd0c /mnt # cdrom
 # mount_cd9660 /dev/wcd0c /cdrom      # 另外一个方法
 # mount -v -t msdos /dev/fd0c /mnt # 软驱

/etc/fstab 中的一条:

 # Device                 Mountpoint      FStype  Options         Dump    Pass#
 /dev/acd0                /cdrom          cd9660  ro,noauto       0       0

要允许用户做这些,可以这么做:

 # sysctl vfs.usermount=1   # 或者在 /etc/sysctl.conf 中插入一条 "vfs.usermount=1"

Linux

 # mount -t auto /dev/cdrom /mnt/cdrom # 典型的 cdrom 挂载命令
 # mount /dev/hdc -t iso9660 -r /cdrom # IDE
 # mount /dev/sdc0 -t iso9660 -r /cdrom # SCSI

/etc/fstab 中的条目:
/dev/cdrom /media/cdrom subfs noauto,fs=cdfss,ro,procuid,nosuid,nodev,exec 0 0
用 Linux 挂载一个 FreeBSD 分区
用 fdisk 查找分区号,这通常是 root 分区,但也可能是其他 BSD slice。如果 FreeBSD 有许多 slice,他们
不列于同一个 fdisk 分区表中,但可见于 /dev/sda* 或 /dev/hda* 中。

 # fdisk /dev/sda                      # 查找 FreeBSD 分区
 /dev/sda3 *          5357         7905    20474842+ a5 FreeBSD
 # mount -t ufs -o ufstype=ufs2,ro /dev/sda3 /mnt
 /dev/sda10 = /tmp; /dev/sda11 /usr # 其他 slice

重挂载
不用卸载一个设备来重挂载。 对 fsck 来说是必须的。举个例子:

 # mount -o remount,ro /               # Linux
 # mount -o ro /                       # FreeBSD

从 cdrom 拷贝原始数据进一个 iso 映像文件:

# dd if=/dev/cd0c of=file.iso
Tags: , ,

[linux秘笈30]. PS2 - 持续交互的提示符

三月 23rd, 2009 | No Comments | Posted in Linux

A very long command can be broken down to multiple lines by giving \ at the
end of the line. The default interactive prompt for a multi-line command is
“> “. Let us change this default behavior to display “continue->” by using PS2
environment variable as shown below.
ramesh@dev-db ~> myisamchk –silent –force –fast –
update-state \
> –key_buffer_size=512M –sort_buffer_size=512M \
> –read_buffer_size=4M –write_buffer_size=4M \
> /var/lib/mysql/bugs/*.MYI
[Note: This uses the default ">" for continuation
prompt]
ramesh@dev-db ~> export PS2=”continue-> ”
ramesh@dev-db ~> myisamchk –silent –force –fast –
update-state \
continue-> –key_buffer_size=512M –
sort_buffer_size=512M \
continue-> –read_buffer_size=4M –write_buffer_size=4M
\
continue-> /var/lib/mysql/bugs/*.MYI
[Note: This uses the modified "continue-> " for continuation prompt]
I found it very helpful and easy to read, when I break my long commands into
multiple lines using \. I have also seen others who don’t like to break-up long
commands.

Tags: , , ,

[命令集3.4]系统挂载点/磁盘使用情况

三月 21st, 2009 | No Comments | Posted in Linux
# mount | column -t        # 显示系统已挂载分区情况
# df                       # 显示磁盘剩余空间和挂载的设备
# cat /proc/partitions     # 显示所有设备的所有分区(Linux)
Tags: , ,

[Linux秘笈28].显示用户连接时间

三月 21st, 2009 | No Comments | Posted in Linux

Ac command will display the statistics about the user’s connect time.
Connect time for the current logged in user
With the option –d, it will break down the output for the individual days. In
this example, I’ve been logged in to the system for more than 6 hours today.
On Dec 1st, I was logged in for about 1 hour.

   $ ac –d
   Dec 1      total             1.08
   Dec 2      total             0.99
   Dec 3      total             3.39
   Dec 4      total             4.50
   Today      total             6.10

Connect time for all the users
To display connect time for all the users use –p as shown below. Please note
that this indicates the cumulative connect time for the individual users.

   $ ac -p
              john                                            3.64
              madison                                      0.06
              sanjay                                          88.17
              nisha                                           105.92
             ramesh                                        111.42
             total 309.21

Connect time for a specific user
To get a connect time report for a specific user, execute the following:

  $ ac -d sanjay
  Jul 2      total          12.85
  Aug 25     total            5.05
  Sep 3      total            1.03
  Sep 4      total            5.37
  Dec 24     total            8.15
  Dec 29     total            1.42
  Today      total            2.95
Tags: , ,