随笔 - 60, 文章 - 0, 评论 - 197, 引用 - 0
数据加载中……

Ubuntu 学习笔记

1. 为 root 设置密码
   sudo passwd root
   提示输入密码,第一次要输入当前帐户的密码,之后输入新密码,再输入新密码的确认
   密码, root 的密码就会设置成功。

2. 切换到 root 下进行作业
   su root

3. 设置网络代理,使 apt-get 能安装软件
   (1)在/etc/apt目录下新建文件 apt.conf
   (2)编辑 apt.conf 内容如下
      Aquire::http::your_proxy:80;
   (3)如果不想通过重启来生效,可用如下命令:
      export http_proxy=http://your_proxy:80     

4. 只显示当前路径下的目录
   ls -l | grep ^d

5. 在 Ubuntu 里安装 VMWare-tool
   由于安装VMware Tools需要针对新内核重新编译模块,所以必须先安装基本编译系统和
   内核头文件。

   $ sudo apt-get install build-essential
   $ sudo apt-get install linux-headers-`uname -r`

   安装VMware Tools。选择VMware菜单VM|Install VMware Tools,系统会自动载入
   CDROM,打开一个终端窗口执行下列命令:

   $ tar zxf /media/cdrom/VMwareTool-5.0.0-*.tar.gz
   $ cd vmware-tools-distrib
   $ sudo ./vmware-install.pl

   安装完毕后,在 /mnt 目录下会有个 hgfs 目录即安装成功,通过 VMWare 的菜单 VM
   -> Settings... -> Options -> Shared Folders 设置一文件夹,可实现Unbuntu
   对此文件夹的共享访问。

6. 使用 tar 对软件打包解包
   tar cjvf   test.tar.bz2  test
   tar zjvf   test.tar.bz2
   或者
   tar czvf  test.tar.gz  test
   tar xzvf  test.tar.gz

7. 如何挂接/卸载 U 盘
   mount -tvfat /dev/sdb1 /mnt/udisk
   umount /mnt/udisk

8. 创建连接文件
   ln -s /usr/local/emacs22/bin/emacs-22.1 emacs

9. 编译 emacs22 源码
   (1)先安装两个必须的软件包
      sudo apt-get install libidl-dev
      sudo apt-get install libgtk2.0-dev
   (2)./configure --prefix=/usr/local/emacs22 \
            --enable-font-backend --with-xft    \
            --with-freetype --with-gtk             \
            --with-x-toolkit=gtk
   (3) make bootstrap
   (4) make install

10 配置 IP 以访问 Internet
    (1) ifconfig eth0 ip netmask 255.255.255.0
    (2) route add default gw gateway
    (3) 编辑 /etc/resolv.conf 用以设置 DNS, 例如:
           search domain.corp.company.com
           nameserver 192.168.0.55
           nameserver 192.168.0.88

11 使用 grep 匹配当前目录下所有文件(包括子目录)
    grep -r 'your_contents' ./

12 杀掉进程
    (1) 先通过 ps -aux 获得进程的 PID
    (2) kill -9 PID

13 boot ubuntu without starting X
    (1) sudo gedit /etc/init.d/gdm
    (2) add "exit 0" at the second line

14 修改 console 下的分辩率
    (1) 编辑 /boot/grub/menu.lst
    (2) 在 kernel 行尾添加 vga=value, 如:
         kernel   /boot/vmlinuz-2.6.15-23-386 root=/dev/hda1 ro quiet splash  vga=791
    (3) vga 的值如何设置,可参考下表:
   

色深

640×480

800×600

1024×768

1280×1024

256

769

771

773

775

32000

784

787

790

793

65000

785

788

791

794

16.7 Mill.

786

789

792

795


15 递归显示当前目录下的内容
    ls -R $PWD

16 修改 /etc/profile 后无需重启而使之立即生效
   #. /etc/profile
   注意 /etc/profile 前面的点 .

17 在 VMware Ubuntu 7.0.4 用 Ctrl+Alt+F1~F7 实现多用户切换
    在 VMware 里使用 Ubuntu 与真实机一样,但却无法用 Ctrl + Alt + F1~F7 实现多用户切换。折腾了半天,原来是 VMware 将 Ctrl + Alt 用作了快捷键。可通过如下操作: VMware -> Edit -> Preference... -> Hot Keys,将里面默认的快捷键改成 Ctrl + Shift + Alt, 之后重启 VMware ,就可在 Ubuntu 里通过 Ctrl + Alt + F1~F7 实现多用户切换了。

18 获知某一目录的大小
   du -sh /root
 
19 获知用到了哪些共享库文件
   #readelf -a hello | grep -i 'share'
   0x00000001 (NEEDED)                     Shared library: [libc.so.6]

20 以静态方式指定 IP
   (1) 编辑文件 /etc/network/interfaces, 添加内容如下:
         auto eth0
         iface eth0 inet static
         address 10.0.0.1
         netmask 255.0.0.0
         gateway 10.0.0.1
   (2) 重新启动网络服务
        #/etc/init.d/networking restart

21 添加服务
 (1)安装网络请求守护进程(如果需要)
     sudo apt-get install openbsd-inetd

 (2)配置端口并指定服务名
    在 /etc/services 添加内容如下:
     hello 20001/tcp
    其意义为 hello 这项服务的端口为 20001, 并且是一个 TCP 服务

 (3)在 /etc/inetd.conf 中添加下面这一行
     hello stream tcp nowait root /home/jbw/hello
    各个参数意义如下:
    <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
    service_name: 服务名称(这个服务名称要和你在 /etc/services 中设置的服务名称一致)
    sock_type: stream 或 dgram
    proto: 一般用 tcp/udp
    flags: wait/nowait
    user: 指定该程序要以哪一个用户来启动
    server_path: 服务程序的全路径
    args: 服务程序的参数(可选)

 (4)测试服务
    telnet localhost hello
    或者
    telnet localhost 20001

22 apt 常用命令 
    sudo apt-cache show <package> 安装的软件包
    sudo apt-get clean           清理所有apt下载的软件缓存
    sudo apt-get autoremove 自动卸载不需要的软件包
    sudo apt-get autoclean     清理旧版本的软件缓存

23 dd 的常见应用
 (1) 克隆磁盘
     dd if=/dev/sda of=/dev/sdb

 (2) 将整张光盘转化为 ISO 文件
     dd if=/dev/cdrom of=/tmp/cdrom.iso bs=1024
   
     装载该 ISO 文件
     mount -o loop -t iso9660 /tmp/cdrom.iso /mnt

 (3) 备份 MBR
     dd if=/dev/sda of=/boot/mbr_backup bs=512 count=1

 (4) 还原 MBR
     dd if=/boot/mbr_backup of=/dev/sda bs=446 count=1

 (5) 制作一个 1GB 的交换文件
     dd if=/dev/zero of=/swapfile bs=1024 count=1000000

     加入并激活该交换文件
     mkswap /swapfile && swapon /swapfile

posted on 2008-01-08 14:50 Normandy 阅读(3190) 评论(4)  编辑 收藏 引用 所属分类: Linux Usage

评论

# re: Ubuntu 学习笔记  回复  更多评论   

这个好.能不能不断地往下写啊.
2008-03-31 12:16 | niube's son

# re: Ubuntu 学习笔记  回复  更多评论   

@niube's son
呵呵, 一定! 很高兴能对大家有点帮助。大家也可把自己用 Ubuntu 时遇到的困难写出来,一起解决嘛 :-)
2008-03-31 14:33 | Normandy

# re: Ubuntu 学习笔记  回复  更多评论   

大哥,多谢了阿
2008-04-01 13:02 | niube's son

# re: Ubuntu 学习笔记  回复  更多评论   

很好,,,大家一起努力
2009-08-05 00:06 | minix

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理