Ubuntu常用命令大全

2020-02-03 10:49:10于丽

#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

安装AMP服务
如果采用Ubuntu Server CD开始安装时,可以选择安装,这系统会自动装上apache2,php5和mysql5。下面主要说明一下如果不是安装的Ubuntu server时的安装方法。
用命令在Ubuntu下架设Lamp其实很简单,用一条命令就完成。在终端输入以下命令:
#sudo apt-get install apache2 mysql-server php5 php5-mysql php5-gd #phpmyadmin
装好后,mysql管理员是root,无密码,通过http://localhost/phpmyadmin就可以访问mysql了

修改 MySql 密码
终端下输入:
#mysql -u root
#mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY “123456″;
’123456‘是root的密码,可以自由设置,但最好是设个安全点的。
#mysql> quit; 退出mysql

apache2的操作命令
启动:#sudo /etc/init.d/apache2 start
重启:#sudo /etc/init.d/apache2 restart
关闭:#sudo /etc/init.d/apache2 stop
apache2的默认主目录:/var/www/

Ubuntu 7.10 更换软件源、更新系统
网通建议用台湾的源,电信就用cn99
在终端输入: #sudo gedit /etc/apt/sources.list

# Ubuntu.cn99.com 更新服务器(江苏省常州市电信,推荐电信用户使用。)
deb http://ubuntu.cn99.com/ubuntu/ gutsy main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ gutsy-updates main restricted universe multiverse
# mirror.rootguide.org更新服务器 (上海市 电信):
deb http://mirror.rootguide.org/ubuntu/ gutsy main restricted universe multiverse
deb-src http://mirror.rootguide.org/ubuntu/ gutsy main restricted universe multiverse
deb http://mirror.rootguide.org/ubuntu/ gutsy-updates main restricted universe multiverse
# Mirror.lupaworld.com 更新服务器(浙江省杭州市电信,亚洲地区官方更新服务器)
deb http://cn.archive.ubuntu.com/ubuntu gutsy main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu gutsy-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu gutsy-updates main restricted universe multiverse
# ubuntu.cnsite.org 更新服务器(福建省福州市 电信)
deb http://ubuntu.cnsite.org/ubuntu/ gutsy main restricted universe multiverse