ubuntu 命令大全

 

第2章

拥抱Ubuntu Server

2.2  安装Ubuntu Server 

2.2.1  安装前的准备

 

/dev/sdb2 /home ext3 defaults 0 2

 

$ sudo blkid

/dev/sda1: UUID="ac369a10-e335-42b1-a3a5-ce9524c8130b" TYPE="ext3"

/dev/sda5: TYPE="swap" UUID="8f7943ed-6589-41db-90d0-f57a8ad7cdbd"

2.2.3  把语言环境变量改为英文

$ locale

LANG=zh_CN.UTF-8

LANGUAGE=zh_CN:zh

LC_CTYPE="zh_CN.UTF-8"

LC_NUMERIC="zh_CN.UTF-8"

LC_TIME="zh_CN.UTF-8"

LC_COLLATE="zh_CN.UTF-8"

LC_MONETARY="zh_CN.UTF-8"

LC_MESSAGES="zh_CN.UTF-8"

LC_PAPER="zh_CN.UTF-8"

LC="zh_CN.UTF-8"

LC_ADDRESS="zh_CN.UTF-8"

LC_TELEPHONE="zh_CN.UTF-8"

LC_MEASUREMENT="zh_CN.UTF-8"

LC_IDENTIFICATION="zh_CN.UTF-8"

LC_ALL=

 

LANG="zh_CN.UTF-8"

LANGUAGE="zh_CN:zh"

 

$ sudo nano /etc/default/locale

 

LANG="en_US.UTF-8"

LANGUAGE="en_US:en"

 

$ locale

LANG=en_US.UTF-8

LANGUAGE=en_US:en

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

2.2.4  安全补丁、版本升级


$ sudo apt-get update

$ sudo apt-get upgrade

 

--升级所有软件包

$ sudo apt-get dist-update

 

--ubuntu 系统升级

$ sudo do-release-upgrade

2.3  Ubuntu快速入门指南 

2.3.3  快速查找文件

1find命令

$ find /usr/share/doc -name *.txt 

 

$ find /tmp -name core | xargs /bin/rm -f 

 

$ find $HOME -mtime 0

 

$ find . -perm 664

2locate命令

$ sudo updatedb

 

$ locate apt-get

/usr/bin/apt-get

/usr/share/man/es/man8/apt-get.8.gz

/usr/share/man/fr/man8/apt-get.8.gz

/usr/share/man/ja/man8/apt-get.8.gz

/usr/share/man/man8/apt-get.8.gz

 

$ locate apt-get -c

5

2.3.4  软件包管理

$ apt-cache show php5-mysql


Package: php5-mysql

Priority: optional

Section: web

Installed-Size: 236

Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com>

Original-Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth. debian.or g>

Architecture: i386

Source: php5

Version: 5.2.4-2ubuntu5.3

Replaces: php5-mysqli

Depends: libc6 (>= 2.4), libmysqlclient15off (>= 5.0.27-1), php5-common (= 5.2.4-2 ubuntu5.3), phpapi-20060613+lfs

Conflicts: php5-mysqli

Filename: pool/main/p/php5/php5-mysql_5.2.4-2ubuntu5.3_i386.deb

Size: 65242

MD5sum: 003114b8d97dd35d435763338b3113f7

SHA1: 8d977486b1098c54b54036815398223a191e590d

SHA256: 8d8b301f1a1e85891d5da5c5fdebd9d7c16d7828b4be84640d824e881fe9f1df

Description: MySQL module for php5

 This package provides modules for MySQL database connections directly from

 PHP scripts.  It includes the generic "mysql" module which can be used

 to connect to all versions of MySQL, an improved "mysqli" module for

 MySQL version 4.1 or later, and the pdo_mysql module for use with

 the PHP Data Object extension.

 .

 PHP5 is an HTML-embedded scripting language. Much of its syntax is borrowed

 from C, Java and Perl with a couple of unique PHP-specific features thrown

 in. The goal of the language is to allow web developers to write

 dynamically generated pages quickly.

Bugs: mailto:ubuntu-users@lists.ubuntu.com

Origin: Ubuntu

Task: lamp-server

2.3.5  使用apt工具

2/etc/apt/sources.list文件

deb(deb-src)  网络地址  主版本代号  软件仓库1  软件仓库 软件仓库3 ...

 

deb http://archive.ubuntu.com/ubuntu/ hardy main restricted

deb-src http://archive.ubuntu.com/ubuntu/ hardy main restricted

 

deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted

deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted

 

deb http://archive.ubuntu.com/ubuntu/ hardy universe

deb-src http://archive.ubuntu.com/ubuntu/ hardy universe

deb http://archive.ubuntu.com/ubuntu/ hardy-updates universe

deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates universe

 

deb http://archive.ubuntu.com/ubuntu/ hardy multiverse

deb-src http://archive.ubuntu.com/ubuntu/ hardy multiverse

deb http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse

deb-src http://archive.ubuntu.com/ubuntu/ hardy-updates multiverse

 

deb http://security.ubuntu.com/ubuntu hardy-security main restricted

deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted

deb http://security.ubuntu.com/ubuntu hardy-security universe

deb-src http://security.ubuntu.com/ubuntu hardy-security universe

deb http://security.ubuntu.com/ubuntu hardy-security multiverse

deb-src http://security.ubuntu.com/ubuntu hardy-security multiverse

 

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list-backup

3apt-get命令

$ sudo apt-get install php5-mysql apache2-mpm-prefork libapache2-mod-php5

 

$ sudo apt-get update && sudo apt-get upgrade

4apt-cache命令

$ apt-cache search mysql

 

$ apt-cache search mysql | grep server

 

$ apt-cache show ssh

5aptitude命令

 

$ sudo aptitude update

 

$ sudo aptitude upgrade

 

$ aptitude search mysql | grep server

 

$ sudo aptitude clean --purge-unused

6tasksel命令

$ tasksel --task-packages lamp-server

apache2

mysql-client-5.0

libapache2-mod-php5

apache2.2-common

apache2-utils

php5-common

libaprutil1

php5-mysql

libmysqlclient15off

libdbi-perl

mysql-server

libplrpc-perl

mysql-server-5.0

libdbd-mysql-perl

libnet-daemon-perl

libapr1

libxml2

libpcre3

libpq5

apache2-mpm-prefork

mysql-common

 

$ tasksel --list-tasks

u dns-server    DNS server

u edubuntu-server       Edubuntu server

u lamp-server   LAMP server

u mail-server   Mail server

i openssh-server        OpenSSH server

u postgresql-server     PostgreSQL database

u print-server  Print server

u samba-server  Samba File server

 

$ tasksel install lamp-server

$ tasksel remove lamp-server

7dpkg命令

$ dpkg -l apt

Desired=Unknown/Install/Remove/Purge/Hold

| Status=Not/Installed/Config-f/Unpacked/Failed-cfg/Half-inst/t-aWait/T-pend

|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)

||/ Name           Version        Description

+++-===========-==============-============================================

ii  apt            0.7.9ubuntu17  Advanced front-end for dpkg

 

$ dpkg -l apache

No packages found matching apache.

 

$ dpkg -L whiptail

/.

/usr

/usr/bin

/usr/bin/whiptail

/usr/share

/usr/share/doc

/usr/share/doc/whiptail

/usr/share/doc/whiptail/README.whiptail

/usr/share/doc/whiptail/copyright

/usr/share/doc/whiptail/newt.spec.gz

/usr/share/doc/whiptail/changelog.Debian.gz

/usr/share/man

/usr/share/man/man1

/usr/share/man/man1/whiptail.1.gz

 

$ dpkg -S /bin/ls

coreutils: /bin/ls

 

$ dpkg -C

 

$ man dpkg

8dpkg-reconfigure命令

$ sudo dpkg-reconfigure postfix

9.给apt设置代理服务器

$ export http_proxy=http://yourproxyaddress:proxyport

 

$ sudo nano /etc/apt/apt.conf

 

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

2.3.6  Red Hat用户

1.关于root用户

$ sudo su

[sudo] password for hiweed:

2.3.7  Ubuntu网络配置

1.网络配置文件/etc/network/interfaces

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

 

# The loopback network interface

auto lo

iface lo inet loopback

 

# The primary network interface

auto eth0

iface eth0 inet dhcp

 

auto eth0

iface eth0 inet static

address 192.168.1.10

netmask 255.255.255.0

gateway 192.168.1.1

 

$ sudo /etc/init.d/networking restart

 

$ sudo ifdown eth0

$ sudo ifup eth0

2.域名服务器配置文件/etc/resolv.conf

search localdomain

nameserver 192.168.1.1

nameserver 202.102.14.68

3./etc/hosts文件

127.0.0.1       localhost

127.0.1.1       ubuntu.localdomain      ubuntu

 

# The following lines are desirable for IPv6 capable hosts

::1     ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

4TCP/IP协议简介

$ ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0c:29:f1:fb:b9

          inet addr:192.168.1.140  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fef1:fbb9/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:47 errors:0 dropped:0 overruns:0 frame:0

          TX packets:53 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:5967 (5.8 KB)  TX bytes:7288 (7.1 KB)

          Interrupt:17 Base address:0x1400

 

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

6NTP时间同步

$ sudo nano /etc/cron.daily/timeupdate

 

ntpdate ntp.ubuntu.com

 

$ sudo chmod 755 /etc/cron.daily/timeupdate

 

ntpdate ntp.ubuntu.com pool.ntp.org

2.3.8  远程管理Ubuntu Server

$ sudo apt-get install openssh-server

 

$ ssh 192.168.1.10 -p 3322

 

$ ssh hiweed@192.168.1.10 -p 3322

 

2.3.9  系统更新:apt-get update && apt-get upgrade

$ sudo apt-get update && apt-get upgrade

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值