Ubuntu 一些有用的命令

Last updated on 2007/07/18

调整更改ubuntu时区,时间

执行
tzselect
按照提示进行选择时区
sudo cp /usr/share/zoneinfo/Asia/ShangHai /etc/localtime
执行
sudo ntpdate cn.pool.ntp.org
cn.pool.ntp.org是位于中国的公共NTP服务器,用来同步你的时间

gdm 的开启与关闭
sudo /etc/init.d/gdm start
sudo /etc/init.d/gdm stop

dpkg 的使用

dpkg –l
命令用于查询当前系统所有以安装的deb包的信息.,通过less和grep可以执行更复杂的查询工作.
例如查找跟vim有关的软件包
dpkg –l |grep –ivim
(如发现iU 表示软件包未安装成功,ii表示安装成功)

dpkg –s package-name
命令查看软件包的详细情况,包括版本,依赖之类的

查询系统中所安装软件包所安装的文件
dpkg -L package-name|more
命令用于查询系统中所安装软件包的安装的文件安装到系统的位置和安装了那些

生成 Fluxbox 桌面右键菜单
fluxbox-generate_menu

去掉终端中的PC喇叭响铃
在终端上方向箭头移动到头或者到底的时候,主机喇叭就会响,很难听,使用如下方法禁用它:
sudo vim /etc/inputrc
将代码:
set bell-style none
前面的“#”去掉。

卸载软件包
apt-get remove [--purge]
卸载 以及任何倚赖这个软件包的其它软件包。
--purge 指明这个软件包应该被完全清除 (purged) 。

清空回收站
rm -r ~/.Trash/*

Ubuntu命令行下修改网络配置 (From here)
以eth0为例

1. 以DHCP方式配置网卡
编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces
并用下面的行来替换有关eth0的行:
# The primary network interface - use DHCP to find our address
auto eth0
iface eth0 inet dhcp

用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart
当然,也可以在命令行下直接输入下面的命令来获取地址
sudo dhclient eth0

2. 为网卡配置静态IP地址

编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces
并用下面的行来替换有关eth0的行:
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255

将上面的ip地址等信息换成你自己就可以了.

用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart

3. 设定第二个IP地址(虚拟IP地址)

编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces
在该文件中添加如下的行:
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x

根据你的情况填上所有诸如address,netmask,network,broadcast和gateways等信息.

用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart

4. 设置主机名称(hostname)

使用下面的命令来查看当前主机的主机名称:
sudo /bin/hostname
使用下面的命令来设置当前主机的主机名称:
sudo /bin/hostname newname
系统启动时,它会从/etc/hostname来读取主机的名称.

关于设置主机名称的更多信息,请访问这里

5. 配置DNS

首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询.
要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件.

假设DNS服务器的IP地址是192.168.3.2, 那么/etc/resolv.conf文件的内容应为:
search test.com
nameserver 192.168.3.2

去掉终端中的PC喇叭响铃
在终端上方向箭头移动到头或者到底的时候,主机喇叭就会响,很难听,使用如下方法禁用它:
sudo vim /etc/inputrc
将代码:
set bell-style none
前面的“#”去掉。

关闭 Linux 的 IPv6 通讯协议
sudo vim /etc/modprobe.d/aliases
里面有一行是 "alias net-pf-10 ipv6"
将以上一行用以下两行取代
alias net-pf-10 off
alias ipv6 off

将光盘制作成 ISO
cp /dev/cdrom XXX.iso
或者
dd if=/dev/cdrom of=xxx.iso

Tags: ubuntu, 命令, 网络设置

相关日志

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

还没有评论。

发表评论

(必填)

(必填)


*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Comment moderation is enabled. Your comment may take some time to appear.