- 浏览: 122493 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (131)
- J2EE (5)
- 系统配置 (2)
- eclipse (3)
- MySQL (3)
- 数据库 (1)
- log4j (2)
- hibernate (5)
- JBOSS (3)
- https (2)
- Struts2 (7)
- javascript (2)
- CSS (4)
- HTTP (2)
- J2SE (1)
- apache (6)
- XML (1)
- android (3)
- session (3)
- Spring (3)
- 前端优化 (2)
- Drools (2)
- java笔试题 (8)
- SVN (2)
- linux (19)
- linux命令 (3)
- memcache (1)
- Servlet (2)
- Java RMI (1)
- 领域模型 (1)
- LVS (4)
- Linux shell (2)
- WEB (1)
- F5 (2)
- WinRAR (1)
- TCP (1)
- MQ (2)
- weblogic (1)
- winxp安装FTP (1)
- WebLogic和Tomcat (1)
- 虚拟机 (1)
- nexus-maven (1)
- jstl (1)
- jvm (1)
- Redis (2)
- mongodb (3)
- JAVA (2)
- mybatis (1)
- SQLserver (1)
- GC (1)
- zabbix (1)
- node (1)
最新评论
-
huosange:
简单明了,通俗易懂
JAVA为什么只允许单继承
linux的编辑器:
1、gedit & (必须在图形界面打开) 1.file 1.file~
2、emcas
3、vi、vim
vim编辑器的安装。默认已经安装了vi
[root@test ~]# rpm -qa |grep vim
vim-common-7.2.411-1.8.el6.x86_64
vim-minimal-7.2.411-1.8.el6.x86_64 (vi软件包)
vim-enhanced-7.2.411-1.8.el6.x86_64 (vim软件包)
[root@test ~]#
vim的配置文件。
/etc/vimrc (rc结尾的,都是初始化文件) vim的参数添加到此文件中。
~/.viminfo (vim历史记录等信息)
vim的工作模式:
命令模式(默认模式):处理文档
编辑模式:录入文档
末行模式:处理文档,与命令模式的功能相似,但会强大一些。
各模式之间的切换:
命令--编辑(i/I o/O a/A)
命令--末行(: / ?)
末行|编辑---命令(esc健)
vim的功能命令:
新建文件:
[root@test ~]# vim 1.txt
打开文件:
[root@test ~]# vim /etc/hosts
或
[root@test ~]# vim
:e /etc/hosts
读文件:
[root@test ~]# vim 1.txt
:r /etc/hosts 将/etc/hosts文件读到1.txt文件中
:2r !ls -l /root 将ls -l /root命令的结果,读到1.txt文件中的第2行。
保存文件:(另存为)
:w /root/1.txt
:w /root/2.txt
:1,10w /root/3.txt
:10w /root/4.txt
保存退出:
:wq
:wq!
ZZ
:x
:x!
不保存退出
:q
:q!
复制:
yy 复制光标所在行
nyy 复制光标及以下的连续n-1行
y$ 复制光标到行尾的内容
y0 复制光标到行首的内容
:1,10 co $
:1 co 10
总结:vim末行模式命令的语法。
:[addr1],[addr2] <command> [addr3]|[options]
e edit
r read
w write
co copy
mo move
d delete
粘贴
p 粘贴到光标所在行的下一行。(vim的特点,小写对下一行操作)
P(大) 粘贴中 上
剪切,移动
:1,10 mo $ 将第1~10行的内容,剪切到第最后一行。
删除
:1d
:1,10 d
:/abc/d 删除包含有abc字符的行。
dd
ndd
d0 删除光标到行首
d$ 删除光标到行尾
dG 删除光标到文件末行的内容。
d1G 删除光标到第一行的内容。
替换 s :1,$ == :% 分隔符(/ # ,)
:1,$s /old/new/g 将全文的old字符替换成new字符。
:1,$s /old/new/ 将全文中每一行中的第一个old字符替换成new
:%s /^# //g 将全文中的#空格开头的删除。
:%s /\.$//g 删除点结尾的内容。
将/var/www/html替换成/srv/www/htdocs/
:%s #/var/www/html#/srv/www/htdocs#g
查找:
/char 查找char字符
?aa 查找aa字符
n或N 继续查找。
光标定位:
宏观:
H M L 定位到屏幕的上 中 下。
pgup(ctrl+b) pgdw(ctrl+f) 上下翻页
:100 定位到第100行
:$ 定位到最后一行
:1 定位到第一行。
微观:
上 下 左 右
k j h l
0 定位到行首
$ 定位到行尾
vim的选项
:set nu 显示行号
:set nonu 去除行号
:set hlsearch 显示查找的高亮度
:noh 去除高亮度
:set <tab> 查看vim支持选项
:set <回车> 查看已设置的vim选项。
实验:
编辑/root/install.log文件。
[root@test ~]# cp install.log install.sh
[root@test ~]# head install.sh
#!/bin/bash
mount /dev/cdrom /media/
rpm -ivh /media/Package/libgcc-4.4.6-4.el6.x86_64.rpm --force --nodeps
rpm -ivh /media/Packages/setup-2.8.14-16.el6.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/ca-certificates-2010.63-3.el6_1.5.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/tzdata-2012c-1.el6.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/filesystem-2.4.30-3.el6.x86_64.rpm --force --nodeps
rpm -ivh /media/Packages/foomatic-db-filesystem-4.0-7.20091126.el6.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/xml-common-0.6.3-32.el6.noarch.rpm --force --nodeps
文件系统:
ext2,ext3,ext4 linux的文件系统。
vfat,ntfs-3g
nfs,cifs
iso9660,udf
/bin /usr/bin /usr/local/bin /xxx/bin 普通用户可执行的文件。
/sbin /usr/sbin /usr/local/sbin /xxx/sbin 超级管理员可执行文件。
/etc /usr/etc /usr/local/etc /xxx/etc 配置文件
/lib /usr/lib /usr/local/lib 动态链接库文件
/lib64 /usr/lib64 /usr/local/lib64 64位的动态链接库文件
/boot 系统引导目录
/home 普通用户的自家目录
/root 超级管理员的自家目录
/tmp /usr/tmp 临时文件目录
/proc 当前系统运行的进程状态,硬件的配置,内核的参数。
/dev 设备文件目录
/lost+found 执行fsck命令找到的文件。
/media /mnt/ /misc /net 设备的挂载点。这是一个约定。
/opt 第三方软件下载或安装的目录。
/usr 系统最大目录,包命令,配置文件,动态链接库,程序,帮助。。。
/var 日志,用户的邮箱,ftp,www服务器的数据。
/selinux selinux的配置和状态。
/sys 系统硬件的固体的信息。
硬盘:
主分区:所有硬盘都只有最多4个主分区,(扩展分区属有于主分区中的一种)
逻辑分区:逻辑分区必须创建在扩展分区之上。在linux中最多11个逻辑分区。
磁盘分区的步骤:
1、在vmware中,添加新的硬盘,容量为1G,共添加到4块。
2、对/dev/sdb硬盘分区。fdisk /dev/sdb
3、将分区信息,写入到内核表 partprobe
4、创建文件系统。 mkfs.ext4 /dev/sdb1
5、挂载使用。 mkdir /media/sdb1; mount /dev/sdb1 /media/sdb1
6、设置开机自动运行。 vim /etc/fstab
m print this menu 显示帮助菜单
n add a new partition 创建分区
d delete a partition 删除分区
p print the partition table 显示分区
w write table to disk and exit 保存分区
q quit without saving changes 不保存分区
t change a partition's system id 改变分区的ID号
l list known partition types 显示分区的ID号。
磁盘分区:
[root@test ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF
disklabel
Building a new DOS disklabel with disk identifier 0xb7e9deb1.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +200M
Command (m for help): P
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
Command (m for help): N
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (27-130, default 27):
Using default value 27
Last cylinder, +cylinders or +size{K,M,G} (27-130, default 130):
Using default value 130
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 130 835380 5 Extended
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (27-130, default 27):
Using default value 27
Last cylinder, +cylinders or +size{K,M,G} (27-130, default 130): +400M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 130 835380 5 Extended
/dev/sdb5 27 78 417658+ 83 Linux
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (79-130, default 79):
Using default value 79
Last cylinder, +cylinders or +size{K,M,G} (79-130, default 130):
Using default value 130
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 130 835380 5 Extended
/dev/sdb5 27 78 417658+ 83 Linux
/dev/sdb6 79 130 417658+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@test ~]#
[root@test ~]# partprobe
[root@test ~]# cat /proc/partitions
major minor #blocks name
8 64 1048576 sde
8 0 20971520 sda
8 1 204800 sda1
8 2 20765696 sda2
8 32 1048576 sdc
8 16 1048576 sdb
8 17 208813 sdb1
8 18 1 sdb2
8 21 417658 sdb5
8 22 417658 sdb6
8 48 1048576 sdd
253 0 18665472 dm-0
253 1 2097152 dm-1
[root@test ~]#
[root@test ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
52208 inodes, 208812 blocks
10440 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=67371008
26 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801
正在写入inode表: 完成
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@test ~]# mkdir /media/sdb1
[root@test ~]# mount /dev/sdb1 /media/sdb1/
[root@test ~]# df -Ph
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
[root@test ~]#
[root@test ~]# vim /etc/fstab 在文件末尾添加以下行。
/dev/sdb1 /media/sdb1 ext4 defaults 0 0
[root@test ~]# umount /media/sdb1/
[root@test ~]# mount -a
[root@test ~]# df -hP
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
[root@test ~]#
RAID的分类:
1、软RAID,通过软件实现RAID的功能。需要消耗CPU和MEM资源。
2、ServerRAID,服务器的RAID。
3、专业的磁盘阵列。(低,中,高)
[root@test ~]# cd /lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/md/
[root@test md]# ls
dm-bufio.ko dm-queue-length.ko dm-snapshot.ko
dm-crypt.ko dm-raid45.ko dm-thin-pool.ko
dm-delay.ko dm-raid.ko dm-zero.ko
dm-flakey.ko dm-region-hash.ko faulty.ko
dm-log.ko dm-registry.ko linear.ko
dm-log-userspace.ko dm-replicator.ko persistent-data
dm-memcache.ko dm-repl-log-ringbuffer.ko raid0.ko
dm-mirror.ko dm-repl-slink-blockdev.ko raid10.ko
dm-mod.ko dm-round-robin.ko raid1.ko
dm-multipath.ko dm-service-time.ko raid456.ko
[root@test md]# ls |grep raid
dm-raid45.ko
dm-raid.ko
raid0.ko
raid10.ko
raid1.ko
raid456.ko
[root@test md]#
RAID0
RAID1
RAID5
RAID6
mdadm 创建RAID设备。
-C 创建RAID。
-v 显示创建的过程(linux通用参数)
-l RAID级别,-l0 -l1 -l5 -l6 -l10
-n RAID组中的硬盘数量
-x 热备盘的数量
[root@test md]# mdadm -Cv /dev/md0 -l1 -n2 -x1 /dev/sdc /dev/sdd /dev/sde
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 1048564K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
[===========>.........] resync = 55.3% (580160/1048564) finish=0.0min
speed=193386K/sec
unused devices: <none>
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]#
LVM的概念:
lvm逻辑卷管理。分为三层。
物理卷:由独立的分区、硬盘、卷,RAID设备组成。
卷组:由1个或多个物理卷组成。
逻辑卷:在卷组之上,可以划分1个或多个逻辑卷。在线扩容,在线缩小容量,支持快照等功能。
LVM逻辑卷的创建步骤:
1、创建物理卷 pvcreate /dev/md0
2、创建卷组 vgcreate datavg /dev/md0
3、创建逻辑卷 lvcreate -L 500M -n lun0 datavg
4、对逻辑卷进行格式化(创建文件系统) mkfs.ext4 /dev/mapper/datavg-lun0
5、挂载使用 mkdir /media/lun0;
mount /dev/mapper/datavg-lun0 /media/lun0
6、设置开机自动运行。 vim /etc/fstab
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm -Ds > /etc/mdadm.conf
[root@test md]# pvcreate /dev/md0
Writing physical volume data to disk "/dev/md0"
Physical volume "/dev/md0" successfully created
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 lvm2 a-- 1023.99m 1023.99m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
[root@test md]# vgcreate datavg /dev/md0
Volume group "datavg" successfully created
[root@test md]# vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 0 0 wz--n- 1020.00m 1020.00m
rootvg 1 2 0 wz--n- 19.80g 0
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 datavg lvm2 a-- 1020.00m 1020.00m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
[root@test md]# lvcreate -n lun0 -L 500M datavg
Logical volume "lun0" created
[root@test md]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lun0 datavg -wi-a--- 500.00m
LogVol00 rootvg -wi-ao-- 2.00g
LogVol01 rootvg -wi-ao-- 17.80g
[root@test md]# vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 1 0 wz--n- 1020.00m 520.00m
rootvg 1 2 0 wz--n- 19.80g 0
[root@test md]# mkfs.ext4 /dev/mapper/datavg-lun0
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@test md]# mkdir /media/lun0
[root@test md]# mount /dev/mapper/datavg-lun0 /media/lun0/
[root@test md]# df -hP
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
/dev/mapper/datavg-lun0 485M 11M 449M 3% /media/lun0
[root@test md]# cp /root/install.* /media/lun0/
[root@test md]# ls /media/lun0/
install.log.bak install.log.syslog install.sh lost+found
[root@test md]#
对lun0扩容。
lvextend -L +100M /dev/mapper/datavg-lun0
[root@test md]# lvextend -L +100M /dev/mapper/datavg-lun0
Extending logical volume lun0 to 600.00 MiB
Logical volume lun0 successfully resized
[root@test md]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lun0 datavg -wi-ao-- 600.00m
LogVol00 rootvg -wi-ao-- 2.00g
LogVol01 rootvg -wi-ao-- 17.80g
[root@test md]# df -Ph
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
/dev/mapper/datavg-lun0 485M 11M 449M 3% /media/lun0
[root@test md]# resize2fs /dev/mapper/datavg-lun0
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/datavg-lun0 is mounted on /media/lun0; on-line
resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/datavg-lun0 to 614400 (1k) blocks.
The filesystem on /dev/mapper/datavg-lun0 is now 614400 blocks long.
[root@test md]# df -Ph
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
/dev/mapper/datavg-lun0 582M 11M 542M 2% /media/lun0
[root@test md]#
对卷组做扩容
[root@test md]# pvcreate /dev/sdb5
Writing physical volume data to disk "/dev/sdb5"
Physical volume "/dev/sdb5" successfully created
[root@test md]# pvcreate /dev/sdb6
Writing physical volume data to disk "/dev/sdb6"
Physical volume "/dev/sdb6" successfully created
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 datavg lvm2 a-- 1020.00m 420.00m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
/dev/sdb5 lvm2 a-- 407.87m 407.87m
/dev/sdb6 lvm2 a-- 407.87m 407.87m
[root@test md]# vgextend datavg /dev/sdb5 /dev/sdb6
Volume group "datavg" successfully extended
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 datavg lvm2 a-- 1020.00m 420.00m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
/dev/sdb5 datavg lvm2 a-- 404.00m 404.00m
/dev/sdb6 datavg lvm2 a-- 404.00m 404.00m
[root@test md]# vgs
VG #PV #LV #SN Attr VSize VFree
datavg 3 1 0 wz--n- 1.79g 1.20g
rootvg 1 2 0 wz--n- 19.80g 0
[root@test md]#
模拟硬盘出错。
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm /dev/md0 -f /dev/sdd
mdadm: set /dev/sdd faulty in /dev/md0
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2] sdd[1](F) sdc[0]
1048564 blocks super 1.2 [2/1] [U_]
[========>............] recovery = 42.0% (441152/1048564) finish=0.0min
speed=220576K/sec
unused devices: <none>
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2] sdd[1](F) sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm /dev/md0 -r /dev/sdd
mdadm: hot removed /dev/sdd from /dev/md0
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm /dev/md0 -a /dev/sdd
mdadm: added /dev/sdd
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdd[3](S) sde[2] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm -S /dev/md0
mdadm: Cannot get exclusive access to /dev/md0:Perhaps a running process,
mounted filesystem or active volume group?
[root@test md]#
linux系统下的软件包。
redhat,centos,suse: rpm包
debain,ubuntu: deb包
源码软件包: .tar .tar.gz .tar.bz2 .tgz .tbz2
rpm包:
1、CPU的位数的限制。i686,i386,i586 x86_64 ppc
2、操作系统版本的限制 rhel5,rhel6 rhel6.4 rhel6.5
3、noarch,表示无CPU,操作系统的限制。
libssh2-1.2.2-7.el6_2.3.x86_64
rpm软件包的安装。
1、rpm工具。
2、yum工具。(推荐)。
yum服务器的部署
1、指定yum的安装源(本地目录/data;cdrom;http服务器;ftp服务器)
2、编写yum安装源配置文件。
[root@test ~]# cd /etc/yum.repos.d/
[root@test yum.repos.d]# ls
rhel-source.repo
[root@test yum.repos.d]# cp rhel-source.repo mycdrom.repo
[root@test yum.repos.d]# vim mycdrom.repo
[root@test yum.repos.d]# cat mycdrom.repo
[rhel6-server]
name=Red Hat Enterprise Linux $releasever
baseurl=file:///media/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@test ~]# mkdir /media/cdrom
[root@test ~]# mount /dev/cdrom /media/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@test ~]# cd /media/cdrom/
[root@test cdrom]# yum clean all
Loaded plugins: product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Cleaning repos: rhel6-server
Cleaning up Everything
[root@test cdrom]# yum list
3、安装软件包。 -i 安装 -v 显示过程 -h "#"
[root@test cdrom]# yum search tomcat
[root@test cdrom]# yum install tomcat6.noarch -y
[root@test Packages]# rpm -ivh httpd-2.2.15-15.el6_2.1.x86_64.rpm
error: Failed dependencies:
apr-util-ldap is needed by httpd-2.2.15-15.el6_2.1.x86_64
httpd-tools = 2.2.15-15.el6_2.1 is needed by
httpd-2.2.15-15.el6_2.1.x86_64
[root@test Packages]# rpm -ivh httpd-2.2.15-15.el6_2.1.x86_64.rpm
httpd-tools-2.2.15-15.el6_2.1.x86_64.rpm
apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm
Preparing... ########################################### [100%]
1:apr-util-ldap ########################################### [ 33%]
2:httpd-tools ########################################### [ 67%]
3:httpd ########################################### [100%]
[root@test Packages]#
4、升级软件包
-U 升级
--force 覆盖安装
--nodeps 强制安装(不推荐)
[root@test Packages]# rpm -Uvh httpd-2.2.15-15.el6_2.1.x86_64.rpm --force
--nodeps
Preparing... ########################################### [100%]
1:httpd ########################################### [100%]
[root@test Packages]#
5、卸载软件包。
[root@test Packages]# rpm -qa |grep httpd
httpd-tools-2.2.15-15.el6_2.1.x86_64
httpd-2.2.15-15.el6_2.1.x86_64
[root@test Packages]# rpm -e httpd httpd-tools
[root@test Packages]# rpm -qa |grep httpd
6、软件包的查询。
查询系统中已安装的软件包。 rpm -qa |grep vsftpd
查看vsftpd软件包安装到哪些目录,软件包中有哪些文件。 rpm -ql vsftpd
[root@test Packages]# rpm -ql vsftpd|more
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
...省略
查看软件包什么时候安装的。rpm -qi vsftpd
[root@test Packages]# rpm -qi vsftpd
Name : vsftpd Relocations: (not relocatable)
Version : 2.2.2 Vendor: Red Hat, Inc.
Release : 11.el6 Build Date: 2012年03月02日 星期五
20时42分21秒
Install Date: 2014年10月27日 星期一 19时29分38秒 Build Host:
x86-001.build.bos.redhat.com
Group : System Environment/Daemons Source RPM:
vsftpd-2.2.2-11.el6.src.rpm
Size : 339284 License: GPLv2 with exceptions
Signature : RSA/8, 2012年05月09日 星期三 18时33分40秒, Key ID
199e2f91fd431d51
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://vsftpd.beasts.org/
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
查询某个文件属于哪个软件包。
[root@test Packages]# whereis mpstat
mpstat: /usr/bin/mpstat /usr/share/man/man1/mpstat.1.gz
[root@test Packages]# rpm -qf /usr/bin/mpstat
sysstat-9.0.4-20.el6.x86_64
[root@test Packages]# rpm -ivh sysstat-9.0.4-20.el6.x86_64.rpm --force
Preparing... ########################################### [100%]
1:sysstat ########################################### [100%]
6、rpm包的校验。
[root@test ~]# rpm -Vf /bin/pwd
[root@test ~]# ls -l /bin/pwd
-rwxr-xr-x. 1 root root 31656 4月 17 2012 /bin/pwd
[root@test ~]# chown bin.bin /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
.....UG.. /bin/pwd
[root@test ~]# chmod 644 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
.M...UG.. /bin/pwd
[root@test ~]# touch /bin/pwd
[root@test ~]# ls -l /bin/pwd
-rw-r--r--. 1 bin bin 31656 10月 28 20:32 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
.M...UGT. /bin/pwd
[root@test ~]# echo "" >> /bin/pwd
[root@test ~]# ls -l /bin/pwd
-rw-r--r--. 1 bin bin 31657 10月 28 20:33 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
prelink: /bin/pwd: prelinked file size differs
SM?..UGT. /bin/pwd
[root@test ~]# chown root.root /bin/pwd
[root@test ~]# chmod 755 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
prelink: /bin/pwd: prelinked file size differs
S.?....T. /bin/pwd
[root@test ~]#
8、软件套件包的安装。
yum grouplist 查看光盘中的套件包名称。 ###查看
yum groupinstall "套件包名称" -y ###安装
yum groupremove "套件包名称" -y ###卸载
源码包的安装。
1、下载源码包。
2、解包和解压缩到指定目录
3、进入解包目录,查看README文件,INSTALL文件
4、根据README文件的提示安装。
4.1、配置软件包 ./configure --help
(查看./configure的选项),产生Makefile文件。
4.2、编译软件包 make ###执行Makefile文件
4.3、安装软件包 make install
安装实验:
1、安装proftpd软件包。
[root@test ~]# tar -zxf proftpd-* -C /opt
[root@test ~]# cd /opt/proftpd*
[root@test ~]# vim README
[root@test ~]# yum install gcc -y (安装gcc软件包,如果没有安装的话)
[root@test ~]# ./configure --prefix=/usr/local/proftpd
[root@test ~]# make
[root@test ~]# make install
[root@test proftpd-1.3.5]# cd /usr/local/proftpd/
[root@test proftpd]# ls
bin etc include lib libexec sbin share var
[root@test proftpd]# cd sbin/
[root@test sbin]# ls
ftpscrub ftpshut in.proftpd proftpd
[root@test sbin]# ./proftpd
2014-10-28 20:55:24,650 test proftpd[16796]: fatal: Group: Unknown group
'nogroup' on line 30 of '/usr/local/proftpd/etc/proftpd.conf'
[root@test sbin]# groupadd nogroup
[root@test sbin]# ./proftpd
2014-10-28 20:56:50,609 test proftpd[16804]: warning: unable to determine IP
address of 'test'
2014-10-28 20:56:50,609 test proftpd[16804]: error: no valid servers
configured
2014-10-28 20:56:50,609 test proftpd[16804]: fatal: error processing
configuration file '/usr/local/proftpd/etc/proftpd.conf'
2014-10-28 20:56:53,593 test proftpd[16807]: warning: unable to determine IP
address of 'test'
2014-10-28 20:56:53,593 test proftpd[16807]: error: no valid servers
configured
2014-10-28 20:56:53,593 test proftpd[16807]: fatal: error processing
configuration file '/usr/local/proftpd/etc/proftpd.conf'
[root@test sbin]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.4.47 test
[root@test sbin]# ./proftpd
[root@test sbin]#
[root@test sbin]# netstat -natup|grep :21
tcp 0 0 0.0.0.0:21 0.0.0.0:*
LISTEN 16813/proftpd
[root@test ~]# tar -zxf webmin-1.680.tar.gz -C /opt/
[root@test ~]# cd /opt/webmin-1.680/
[root@test webmin-1.680]# vim README
[root@test webmin-1.680]# ./setup.sh
***********************************************************************
* Welcome to the Webmin setup script, version 1.680 *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.
Installing Webmin in /opt/webmin-1.680 ...
***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.
Config file directory [/etc/webmin]:
Log file directory [/var/webmin]: /var/log/webmin
***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.
Full path to perl (default /usr/bin/perl):
Testing Perl ...
Perl seems to be installed ok
***********************************************************************
Operating system name: Redhat Enterprise Linux
Operating system version: 6
***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
- What port to run the web server on. There must not be another
web server already using this port.
- The login name required to access the web server.
- The password required to access the web server.
- If the webserver should use SSL (if your system supports it).
- Whether to start webmin at boot time.
Web server port (default 10000):
Login name (default admin):
Login password:
Password again:
The Perl SSLeay library is not installed. SSL not available.
Start Webmin at boot time (y/n): y
***********************************************************************
Creating web server config files..
..done
Creating access control file..
..done
Inserting path to perl into scripts..
..done
Creating start and stop scripts..
..done
Copying config files..
..done
Configuring Webmin to start at boot time..
..done
Creating uninstall script /etc/webmin/uninstall.sh ..
..done
Changing ownership and permissions ..
..done
Running postinstall scripts ..
Use of uninitialized value in -r at
/opt/webmin-1.680/webalizer/webalizer-lib.pl line 16.
Use of uninitialized value in split at /opt/webmin-1.680/acl/acl-lib.pl line
47.
..done
Enabling background status collection ..
..done
Attempting to start Webmin mini web server..
Starting Webmin server in /opt/webmin-1.680
Pre-loaded WebminCore
..done
***********************************************************************
Webmin has been installed and started successfully. Use your web
browser to go to
http://test:10000/
and login with the name and password you entered previously.
网络基础:
1、网络IP地址的配置。
方法1:直接修改/etc/sysconfifg/network-scripts/ifcfg-eth0文件.(永久IP)
方法2:执行setup命令,修改IP地址。
方法3:执行ifconfig eth0 192.168.1.1/24命令修改IP地址(临时IP)
[root@test ~]# setup
[root@test ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:34:77:bd
NM_CONTROLLED=yes ##是否收NetworkerManager服务接管,建议设为no。
ONBOOT=yes ##network服务启动时,是否激活。
TYPE=Ethernet
UUID="542a2c35-a70b-4a54-b787-2fe4f32d6130"
IPADDR=172.16.4.49
NETMASK=255.255.255.0
GATEWAY=172.16.4.1
IPV6INIT=no ##关闭IPv6
USERCTL=no ##是否允许普通用户修改IP地址
[root@test ~]# cat /etc/resolv.conf ##DNS客户端文件
nameserver 192.168.1.1
nameserver 202.96.128.166
[root@test ~]# cat /etc/sysconfig/network ##辅助配置文件
NETWORKING=yes ##激活IPv4
HOSTNAME=test ##主机名。
[root@test ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes ###网卡是否连接网线。yes表示连接。
[root@test ~]# ifconfig eth0 172.16.4.49/24
[root@test ~]# ifconfig eth0:1 192.168.100.1/24
[root@test ~]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:34:77:BD
inet addr:192.168.100.1 Bcast:192.168.100.255
Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[root@test ~]# ping 192.168.100.1 -c1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.202 ms
--- 192.168.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.202/0.202/0.202/0.000 ms
[root@test ~]# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
link/ether 00:0c:29:34:77:bd brd ff:ff:ff:ff:ff:ff
inet 172.16.4.49/24 brd 172.16.4.255 scope global eth0
inet 192.168.100.1/24 brd 192.168.100.255 scope global eth0:1
inet6 fe80::20c:29ff:fe34:77bd/64 scope link
valid_lft forever preferred_lft forever
[root@test ~]# ifconfig eth0:1 down 停止eth0:1接口
[root@test ~]# ifconfig eth0:1 up
route 设置路由。
1、设置网络路由:
route add -net <目标网段> gw <网关> dev <进出的网络接口>
到达202.13.13.0/24网段,通过172.16.4.1网关出去,设备接口为eth0
route add -net 202.13.13.0/24 gw 172.16.4.1 dev eth0
2、设置主机路由:
route add -host <目标主机> gw <网关> dev <进出的网络接口>
到达202.13.13.100网段,通过172.16.4.1网关出去,设备接口为eth0
route add -host 202.13.13.100/24 gw 172.16.4.1 dev eth0
3、设置默认路由:
route add default gw 172.16.4.1 dev eth0
192.168.100.100/25 192.168.100.0
[root@test ~]# ipcalc -mbn 192.168.100.100/25
NETMASK=255.255.255.128
BROADCAST=192.168.100.127
NETWORK=192.168.100.0
[root@test ~]# ipcalc -mbn 192.168.100.129/25
NETMASK=255.255.255.128
BROADCAST=192.168.100.255
NETWORK=192.168.100.128
网络连通性判断:
ping -c1 172.16.4.49
traceroute www.canway.net
网络端口的检查。
netstat -atnup |more -a 所有 -t tcp, -u udp, -n 不测试网络 -p 进程
[root@test ~]# netstat -atnup|grep :21
tcp 0 0 0.0.0.0:21 0.0.0.0:*
LISTEN 18350/vsftpd
tcp 0 0 172.16.4.49:21 192.168.3.158:56401
FIN_WAIT2 -
netstat -anlp -l 监听
netstat -rn 查看路由
netstat -i 查看接口。
[root@test ~]# watch netstat -i
/etc/hosts 主机名和IP地址的对应关系文件
远程管理Linux系统:
1、ssh服务器
2、vnc服务器
3、webmin服务器
ssh服务器的配置:
默认开启了ssh服务器,即22号端口,任何有效的用户都可以连接。
一个标准的sshd_config配置文件。
[root@test ~]# cat /etc/ssh/sshd_config|grep -Evn "^$|^#"
13:Port 22
15:ListenAddress 172.16.4.49
21:Protocol 2
31:ServerKeyBits 1024
36:SyslogFacility AUTHPRIV
42:PermitRootLogin no
43:allowusers jake@172.16.4.0/24
67:PasswordAuthentication yes
71:ChallengeResponseAuthentication no
82:GSSAPIAuthentication no
84:GSSAPICleanupCredentials no
98:UsePAM yes
101:AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
LC_MESSAGES
102:AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
103:AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
104:AcceptEnv XMODIFIERS
110:X11Forwarding no
123:UseDNS no
133:Subsystem sftp /usr/libexec/openssh/sftp-server
[root@test ~]# useradd jake
[root@test ~]# passwd jake
[root@test ~]# /etc/init.d/sshd restart
login as: jake
jake@172.16.4.49's password:
[jake@test ~]$ su -
密码:
[root@test ~]# ls
anaconda-ks.cfg file.txt install.sh proftpd-
1.3.5.tar.gz word
backup_etc.tar.gz install.log.bak kk1 webmin-1.680.tar.gz
dir1 install.log.syslog log winscp554setup.exe
[root@test ~]#
ssh客户端:
1、for linux
ssh -P <port> <remote_ip>
scp local.file <remote_ip>:/dirname/remote.file 上传
scp <remote_ip>:/dirname/remote.file local.file 下载
2、for windows
putty,SecureCRT==> ssh
winscp ==> scp,sftp
ssh服务器的认证机制:
1、本地用户认证。(/etc/shadow)
2、通过rsa或dsa非对称密钥对认证。(推荐)
[root@test .ssh]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
5b:5f:9c:65:b7:18:5d:a2:c4:bd:3e:09:b9:1f:1d:be root@test
The key's randomart image is:
+--[ DSA 1024]----+
| .... .|
| ...o..|
| .o o+|
| o.+=o|
| S . ==+.|
| o ...=..|
| . .. o.|
| .E |
| |
+-----------------+
[root@test .ssh]# ls
id_dsa id_dsa.pub
[root@test .ssh]# scp id_dsa.pub 172.16.4.49:/root/.ssh/authorized_keys
[root@test .ssh]# ssh 172.16.4.49
The authenticity of host '172.16.4.49 (172.16.4.49)' can't be established.
RSA key fingerprint is e6:ee:be:7c:4f:f1:1c:15:ec:01:1b:55:10:63:de:49.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.4.49' (RSA) to the list of known hosts.
Enter passphrase for key '/root/.ssh/id_dsa':
Enter passphrase for key '/root/.ssh/id_dsa':
Enter passphrase for key '/root/.ssh/id_dsa':
root@172.16.4.49's password:
Permission denied, please try again.
root@172.16.4.49's password:
Permission denied, please try again.
root@172.16.4.49's password:
Permission denied (publickey,password).
[root@test .ssh]# ssh 172.16.4.49
Enter passphrase for key '/root/.ssh/id_dsa':
Last login: Tue Oct 28 22:43:16 2014 from 172.16.4.49
[root@test ~]#
[root@test ~]#
VNC服务器:
1、vnc服务器的工作原理
2、安装vnc服务器。
[root@test ~]# yum search vnc-server
[root@test ~]# yum install tigervnc-server.x86_64 -y
[root@test ~]#
3、配置vnc服务器。
[root@test ~]# yum groupinstall "通用桌面" -y
[root@test ~]# yum search vnc-server
[root@test ~]# yum install tigervnc-server.x86_64 -y
[root@test ~]# vncserver :1
You will require a password to access your desktops.
Password:
Verify:
New 'test:1 (root)' desktop is test:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:1.log
[root@test ~]# cd /root/.vnc/
[root@test .vnc]# ls
passwd test:1.log test:1.pid xstartup
[root@test .vnc]# vim xstartup
将文件中末尾中的twm更改gnome-session
[root@test .vnc]# vncserver -kill :1 关闭:1图形界面
Killing Xvnc process ID 21090
[root@test .vnc]# vncserver :2 启动:2图形界面
New 'test:2 (root)' desktop is test:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:2.log
[root@test .vnc]# netstat -atnup|grep -i vnc
tcp 0 0 0.0.0.0:5902 0.0.0.0:*
LISTEN 21182/Xvnc
tcp 0 0 0.0.0.0:6002 0.0.0.0:*
LISTEN 21182/Xvnc
tcp 0 0 :::6002 :::*
LISTEN 21182/Xvnc
[root@test .vnc]# /etc/init.d/iptables stop
[root@test .vnc]# vim /etc/sysconfig/vncservers
[root@test .vnc]# cat /etc/sysconfig/vncservers |tail -1
VNCSERVERS="2:root"
[root@test .vnc]# service vncserver restart
关闭 VNC 服务器:2:root [失败]
正在启动 VNC 服务器:2:root
New 'test:2 (root)' desktop is test:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:2.log
[确定]
[root@test .vnc]# netstat -antup|grep -i vnc
tcp 0 0 0.0.0.0:5902 0.0.0.0:*
LISTEN 22492/Xvnc
tcp 0 0 0.0.0.0:5903 0.0.0.0:*
LISTEN 21916/Xvnc
tcp 0 0 0.0.0.0:6002 0.0.0.0:*
LISTEN 22492/Xvnc
tcp 0 0 0.0.0.0:6003 0.0.0.0:*
LISTEN 21916/Xvnc
tcp 0 0 172.16.4.49:5903 172.16.4.47:53462
ESTABLISHED 21916/Xvnc
tcp 0 0 :::6002 :::*
LISTEN 22492/Xvnc
tcp 0 0 :::6003 :::*
LISTEN 21916/Xvnc
[root@test .vnc]#
1、gedit & (必须在图形界面打开) 1.file 1.file~
2、emcas
3、vi、vim
vim编辑器的安装。默认已经安装了vi
[root@test ~]# rpm -qa |grep vim
vim-common-7.2.411-1.8.el6.x86_64
vim-minimal-7.2.411-1.8.el6.x86_64 (vi软件包)
vim-enhanced-7.2.411-1.8.el6.x86_64 (vim软件包)
[root@test ~]#
vim的配置文件。
/etc/vimrc (rc结尾的,都是初始化文件) vim的参数添加到此文件中。
~/.viminfo (vim历史记录等信息)
vim的工作模式:
命令模式(默认模式):处理文档
编辑模式:录入文档
末行模式:处理文档,与命令模式的功能相似,但会强大一些。
各模式之间的切换:
命令--编辑(i/I o/O a/A)
命令--末行(: / ?)
末行|编辑---命令(esc健)
vim的功能命令:
新建文件:
[root@test ~]# vim 1.txt
打开文件:
[root@test ~]# vim /etc/hosts
或
[root@test ~]# vim
:e /etc/hosts
读文件:
[root@test ~]# vim 1.txt
:r /etc/hosts 将/etc/hosts文件读到1.txt文件中
:2r !ls -l /root 将ls -l /root命令的结果,读到1.txt文件中的第2行。
保存文件:(另存为)
:w /root/1.txt
:w /root/2.txt
:1,10w /root/3.txt
:10w /root/4.txt
保存退出:
:wq
:wq!
ZZ
:x
:x!
不保存退出
:q
:q!
复制:
yy 复制光标所在行
nyy 复制光标及以下的连续n-1行
y$ 复制光标到行尾的内容
y0 复制光标到行首的内容
:1,10 co $
:1 co 10
总结:vim末行模式命令的语法。
:[addr1],[addr2] <command> [addr3]|[options]
e edit
r read
w write
co copy
mo move
d delete
粘贴
p 粘贴到光标所在行的下一行。(vim的特点,小写对下一行操作)
P(大) 粘贴中 上
剪切,移动
:1,10 mo $ 将第1~10行的内容,剪切到第最后一行。
删除
:1d
:1,10 d
:/abc/d 删除包含有abc字符的行。
dd
ndd
d0 删除光标到行首
d$ 删除光标到行尾
dG 删除光标到文件末行的内容。
d1G 删除光标到第一行的内容。
替换 s :1,$ == :% 分隔符(/ # ,)
:1,$s /old/new/g 将全文的old字符替换成new字符。
:1,$s /old/new/ 将全文中每一行中的第一个old字符替换成new
:%s /^# //g 将全文中的#空格开头的删除。
:%s /\.$//g 删除点结尾的内容。
将/var/www/html替换成/srv/www/htdocs/
:%s #/var/www/html#/srv/www/htdocs#g
查找:
/char 查找char字符
?aa 查找aa字符
n或N 继续查找。
光标定位:
宏观:
H M L 定位到屏幕的上 中 下。
pgup(ctrl+b) pgdw(ctrl+f) 上下翻页
:100 定位到第100行
:$ 定位到最后一行
:1 定位到第一行。
微观:
上 下 左 右
k j h l
0 定位到行首
$ 定位到行尾
vim的选项
:set nu 显示行号
:set nonu 去除行号
:set hlsearch 显示查找的高亮度
:noh 去除高亮度
:set <tab> 查看vim支持选项
:set <回车> 查看已设置的vim选项。
实验:
编辑/root/install.log文件。
[root@test ~]# cp install.log install.sh
[root@test ~]# head install.sh
#!/bin/bash
mount /dev/cdrom /media/
rpm -ivh /media/Package/libgcc-4.4.6-4.el6.x86_64.rpm --force --nodeps
rpm -ivh /media/Packages/setup-2.8.14-16.el6.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/ca-certificates-2010.63-3.el6_1.5.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/tzdata-2012c-1.el6.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/filesystem-2.4.30-3.el6.x86_64.rpm --force --nodeps
rpm -ivh /media/Packages/foomatic-db-filesystem-4.0-7.20091126.el6.noarch.rpm --force --nodeps
rpm -ivh /media/Packages/xml-common-0.6.3-32.el6.noarch.rpm --force --nodeps
文件系统:
ext2,ext3,ext4 linux的文件系统。
vfat,ntfs-3g
nfs,cifs
iso9660,udf
/bin /usr/bin /usr/local/bin /xxx/bin 普通用户可执行的文件。
/sbin /usr/sbin /usr/local/sbin /xxx/sbin 超级管理员可执行文件。
/etc /usr/etc /usr/local/etc /xxx/etc 配置文件
/lib /usr/lib /usr/local/lib 动态链接库文件
/lib64 /usr/lib64 /usr/local/lib64 64位的动态链接库文件
/boot 系统引导目录
/home 普通用户的自家目录
/root 超级管理员的自家目录
/tmp /usr/tmp 临时文件目录
/proc 当前系统运行的进程状态,硬件的配置,内核的参数。
/dev 设备文件目录
/lost+found 执行fsck命令找到的文件。
/media /mnt/ /misc /net 设备的挂载点。这是一个约定。
/opt 第三方软件下载或安装的目录。
/usr 系统最大目录,包命令,配置文件,动态链接库,程序,帮助。。。
/var 日志,用户的邮箱,ftp,www服务器的数据。
/selinux selinux的配置和状态。
/sys 系统硬件的固体的信息。
硬盘:
主分区:所有硬盘都只有最多4个主分区,(扩展分区属有于主分区中的一种)
逻辑分区:逻辑分区必须创建在扩展分区之上。在linux中最多11个逻辑分区。
磁盘分区的步骤:
1、在vmware中,添加新的硬盘,容量为1G,共添加到4块。
2、对/dev/sdb硬盘分区。fdisk /dev/sdb
3、将分区信息,写入到内核表 partprobe
4、创建文件系统。 mkfs.ext4 /dev/sdb1
5、挂载使用。 mkdir /media/sdb1; mount /dev/sdb1 /media/sdb1
6、设置开机自动运行。 vim /etc/fstab
m print this menu 显示帮助菜单
n add a new partition 创建分区
d delete a partition 删除分区
p print the partition table 显示分区
w write table to disk and exit 保存分区
q quit without saving changes 不保存分区
t change a partition's system id 改变分区的ID号
l list known partition types 显示分区的ID号。
磁盘分区:
[root@test ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF
disklabel
Building a new DOS disklabel with disk identifier 0xb7e9deb1.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +200M
Command (m for help): P
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
Command (m for help): N
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (27-130, default 27):
Using default value 27
Last cylinder, +cylinders or +size{K,M,G} (27-130, default 130):
Using default value 130
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 130 835380 5 Extended
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (27-130, default 27):
Using default value 27
Last cylinder, +cylinders or +size{K,M,G} (27-130, default 130): +400M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 130 835380 5 Extended
/dev/sdb5 27 78 417658+ 83 Linux
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (79-130, default 79):
Using default value 79
Last cylinder, +cylinders or +size{K,M,G} (79-130, default 130):
Using default value 130
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7e9deb1
Device Boot Start End Blocks Id System
/dev/sdb1 1 26 208813+ 83 Linux
/dev/sdb2 27 130 835380 5 Extended
/dev/sdb5 27 78 417658+ 83 Linux
/dev/sdb6 79 130 417658+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@test ~]#
[root@test ~]# partprobe
[root@test ~]# cat /proc/partitions
major minor #blocks name
8 64 1048576 sde
8 0 20971520 sda
8 1 204800 sda1
8 2 20765696 sda2
8 32 1048576 sdc
8 16 1048576 sdb
8 17 208813 sdb1
8 18 1 sdb2
8 21 417658 sdb5
8 22 417658 sdb6
8 48 1048576 sdd
253 0 18665472 dm-0
253 1 2097152 dm-1
[root@test ~]#
[root@test ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
52208 inodes, 208812 blocks
10440 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=67371008
26 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801
正在写入inode表: 完成
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@test ~]# mkdir /media/sdb1
[root@test ~]# mount /dev/sdb1 /media/sdb1/
[root@test ~]# df -Ph
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
[root@test ~]#
[root@test ~]# vim /etc/fstab 在文件末尾添加以下行。
/dev/sdb1 /media/sdb1 ext4 defaults 0 0
[root@test ~]# umount /media/sdb1/
[root@test ~]# mount -a
[root@test ~]# df -hP
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
[root@test ~]#
RAID的分类:
1、软RAID,通过软件实现RAID的功能。需要消耗CPU和MEM资源。
2、ServerRAID,服务器的RAID。
3、专业的磁盘阵列。(低,中,高)
[root@test ~]# cd /lib/modules/2.6.32-279.el6.x86_64/kernel/drivers/md/
[root@test md]# ls
dm-bufio.ko dm-queue-length.ko dm-snapshot.ko
dm-crypt.ko dm-raid45.ko dm-thin-pool.ko
dm-delay.ko dm-raid.ko dm-zero.ko
dm-flakey.ko dm-region-hash.ko faulty.ko
dm-log.ko dm-registry.ko linear.ko
dm-log-userspace.ko dm-replicator.ko persistent-data
dm-memcache.ko dm-repl-log-ringbuffer.ko raid0.ko
dm-mirror.ko dm-repl-slink-blockdev.ko raid10.ko
dm-mod.ko dm-round-robin.ko raid1.ko
dm-multipath.ko dm-service-time.ko raid456.ko
[root@test md]# ls |grep raid
dm-raid45.ko
dm-raid.ko
raid0.ko
raid10.ko
raid1.ko
raid456.ko
[root@test md]#
RAID0
RAID1
RAID5
RAID6
mdadm 创建RAID设备。
-C 创建RAID。
-v 显示创建的过程(linux通用参数)
-l RAID级别,-l0 -l1 -l5 -l6 -l10
-n RAID组中的硬盘数量
-x 热备盘的数量
[root@test md]# mdadm -Cv /dev/md0 -l1 -n2 -x1 /dev/sdc /dev/sdd /dev/sde
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 1048564K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
[===========>.........] resync = 55.3% (580160/1048564) finish=0.0min
speed=193386K/sec
unused devices: <none>
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]#
LVM的概念:
lvm逻辑卷管理。分为三层。
物理卷:由独立的分区、硬盘、卷,RAID设备组成。
卷组:由1个或多个物理卷组成。
逻辑卷:在卷组之上,可以划分1个或多个逻辑卷。在线扩容,在线缩小容量,支持快照等功能。
LVM逻辑卷的创建步骤:
1、创建物理卷 pvcreate /dev/md0
2、创建卷组 vgcreate datavg /dev/md0
3、创建逻辑卷 lvcreate -L 500M -n lun0 datavg
4、对逻辑卷进行格式化(创建文件系统) mkfs.ext4 /dev/mapper/datavg-lun0
5、挂载使用 mkdir /media/lun0;
mount /dev/mapper/datavg-lun0 /media/lun0
6、设置开机自动运行。 vim /etc/fstab
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm -Ds > /etc/mdadm.conf
[root@test md]# pvcreate /dev/md0
Writing physical volume data to disk "/dev/md0"
Physical volume "/dev/md0" successfully created
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 lvm2 a-- 1023.99m 1023.99m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
[root@test md]# vgcreate datavg /dev/md0
Volume group "datavg" successfully created
[root@test md]# vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 0 0 wz--n- 1020.00m 1020.00m
rootvg 1 2 0 wz--n- 19.80g 0
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 datavg lvm2 a-- 1020.00m 1020.00m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
[root@test md]# lvcreate -n lun0 -L 500M datavg
Logical volume "lun0" created
[root@test md]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lun0 datavg -wi-a--- 500.00m
LogVol00 rootvg -wi-ao-- 2.00g
LogVol01 rootvg -wi-ao-- 17.80g
[root@test md]# vgs
VG #PV #LV #SN Attr VSize VFree
datavg 1 1 0 wz--n- 1020.00m 520.00m
rootvg 1 2 0 wz--n- 19.80g 0
[root@test md]# mkfs.ext4 /dev/mapper/datavg-lun0
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
128016 inodes, 512000 blocks
25600 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2032 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
正在写入inode表: 完成
Creating journal (8192 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@test md]# mkdir /media/lun0
[root@test md]# mount /dev/mapper/datavg-lun0 /media/lun0/
[root@test md]# df -hP
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
/dev/mapper/datavg-lun0 485M 11M 449M 3% /media/lun0
[root@test md]# cp /root/install.* /media/lun0/
[root@test md]# ls /media/lun0/
install.log.bak install.log.syslog install.sh lost+found
[root@test md]#
对lun0扩容。
lvextend -L +100M /dev/mapper/datavg-lun0
[root@test md]# lvextend -L +100M /dev/mapper/datavg-lun0
Extending logical volume lun0 to 600.00 MiB
Logical volume lun0 successfully resized
[root@test md]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lun0 datavg -wi-ao-- 600.00m
LogVol00 rootvg -wi-ao-- 2.00g
LogVol01 rootvg -wi-ao-- 17.80g
[root@test md]# df -Ph
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
/dev/mapper/datavg-lun0 485M 11M 449M 3% /media/lun0
[root@test md]# resize2fs /dev/mapper/datavg-lun0
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/datavg-lun0 is mounted on /media/lun0; on-line
resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/datavg-lun0 to 614400 (1k) blocks.
The filesystem on /dev/mapper/datavg-lun0 is now 614400 blocks long.
[root@test md]# df -Ph
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/rootvg-LogVol01 18G 2.2G 15G 13% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot
/dev/sdb1 198M 5.8M 182M 4% /media/sdb1
/dev/mapper/datavg-lun0 582M 11M 542M 2% /media/lun0
[root@test md]#
对卷组做扩容
[root@test md]# pvcreate /dev/sdb5
Writing physical volume data to disk "/dev/sdb5"
Physical volume "/dev/sdb5" successfully created
[root@test md]# pvcreate /dev/sdb6
Writing physical volume data to disk "/dev/sdb6"
Physical volume "/dev/sdb6" successfully created
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 datavg lvm2 a-- 1020.00m 420.00m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
/dev/sdb5 lvm2 a-- 407.87m 407.87m
/dev/sdb6 lvm2 a-- 407.87m 407.87m
[root@test md]# vgextend datavg /dev/sdb5 /dev/sdb6
Volume group "datavg" successfully extended
[root@test md]# pvs
PV VG Fmt Attr PSize PFree
/dev/md0 datavg lvm2 a-- 1020.00m 420.00m
/dev/sda2 rootvg lvm2 a-- 19.80g 0
/dev/sdb5 datavg lvm2 a-- 404.00m 404.00m
/dev/sdb6 datavg lvm2 a-- 404.00m 404.00m
[root@test md]# vgs
VG #PV #LV #SN Attr VSize VFree
datavg 3 1 0 wz--n- 1.79g 1.20g
rootvg 1 2 0 wz--n- 19.80g 0
[root@test md]#
模拟硬盘出错。
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2](S) sdd[1] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm /dev/md0 -f /dev/sdd
mdadm: set /dev/sdd faulty in /dev/md0
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2] sdd[1](F) sdc[0]
1048564 blocks super 1.2 [2/1] [U_]
[========>............] recovery = 42.0% (441152/1048564) finish=0.0min
speed=220576K/sec
unused devices: <none>
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2] sdd[1](F) sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm /dev/md0 -r /dev/sdd
mdadm: hot removed /dev/sdd from /dev/md0
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sde[2] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm /dev/md0 -a /dev/sdd
mdadm: added /dev/sdd
[root@test md]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdd[3](S) sde[2] sdc[0]
1048564 blocks super 1.2 [2/2] [UU]
unused devices: <none>
[root@test md]# mdadm -S /dev/md0
mdadm: Cannot get exclusive access to /dev/md0:Perhaps a running process,
mounted filesystem or active volume group?
[root@test md]#
linux系统下的软件包。
redhat,centos,suse: rpm包
debain,ubuntu: deb包
源码软件包: .tar .tar.gz .tar.bz2 .tgz .tbz2
rpm包:
1、CPU的位数的限制。i686,i386,i586 x86_64 ppc
2、操作系统版本的限制 rhel5,rhel6 rhel6.4 rhel6.5
3、noarch,表示无CPU,操作系统的限制。
libssh2-1.2.2-7.el6_2.3.x86_64
rpm软件包的安装。
1、rpm工具。
2、yum工具。(推荐)。
yum服务器的部署
1、指定yum的安装源(本地目录/data;cdrom;http服务器;ftp服务器)
2、编写yum安装源配置文件。
[root@test ~]# cd /etc/yum.repos.d/
[root@test yum.repos.d]# ls
rhel-source.repo
[root@test yum.repos.d]# cp rhel-source.repo mycdrom.repo
[root@test yum.repos.d]# vim mycdrom.repo
[root@test yum.repos.d]# cat mycdrom.repo
[rhel6-server]
name=Red Hat Enterprise Linux $releasever
baseurl=file:///media/cdrom
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@test ~]# mkdir /media/cdrom
[root@test ~]# mount /dev/cdrom /media/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@test ~]# cd /media/cdrom/
[root@test cdrom]# yum clean all
Loaded plugins: product-id, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Cleaning repos: rhel6-server
Cleaning up Everything
[root@test cdrom]# yum list
3、安装软件包。 -i 安装 -v 显示过程 -h "#"
[root@test cdrom]# yum search tomcat
[root@test cdrom]# yum install tomcat6.noarch -y
[root@test Packages]# rpm -ivh httpd-2.2.15-15.el6_2.1.x86_64.rpm
error: Failed dependencies:
apr-util-ldap is needed by httpd-2.2.15-15.el6_2.1.x86_64
httpd-tools = 2.2.15-15.el6_2.1 is needed by
httpd-2.2.15-15.el6_2.1.x86_64
[root@test Packages]# rpm -ivh httpd-2.2.15-15.el6_2.1.x86_64.rpm
httpd-tools-2.2.15-15.el6_2.1.x86_64.rpm
apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm
Preparing... ########################################### [100%]
1:apr-util-ldap ########################################### [ 33%]
2:httpd-tools ########################################### [ 67%]
3:httpd ########################################### [100%]
[root@test Packages]#
4、升级软件包
-U 升级
--force 覆盖安装
--nodeps 强制安装(不推荐)
[root@test Packages]# rpm -Uvh httpd-2.2.15-15.el6_2.1.x86_64.rpm --force
--nodeps
Preparing... ########################################### [100%]
1:httpd ########################################### [100%]
[root@test Packages]#
5、卸载软件包。
[root@test Packages]# rpm -qa |grep httpd
httpd-tools-2.2.15-15.el6_2.1.x86_64
httpd-2.2.15-15.el6_2.1.x86_64
[root@test Packages]# rpm -e httpd httpd-tools
[root@test Packages]# rpm -qa |grep httpd
6、软件包的查询。
查询系统中已安装的软件包。 rpm -qa |grep vsftpd
查看vsftpd软件包安装到哪些目录,软件包中有哪些文件。 rpm -ql vsftpd
[root@test Packages]# rpm -ql vsftpd|more
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
...省略
查看软件包什么时候安装的。rpm -qi vsftpd
[root@test Packages]# rpm -qi vsftpd
Name : vsftpd Relocations: (not relocatable)
Version : 2.2.2 Vendor: Red Hat, Inc.
Release : 11.el6 Build Date: 2012年03月02日 星期五
20时42分21秒
Install Date: 2014年10月27日 星期一 19时29分38秒 Build Host:
x86-001.build.bos.redhat.com
Group : System Environment/Daemons Source RPM:
vsftpd-2.2.2-11.el6.src.rpm
Size : 339284 License: GPLv2 with exceptions
Signature : RSA/8, 2012年05月09日 星期三 18时33分40秒, Key ID
199e2f91fd431d51
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://vsftpd.beasts.org/
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
查询某个文件属于哪个软件包。
[root@test Packages]# whereis mpstat
mpstat: /usr/bin/mpstat /usr/share/man/man1/mpstat.1.gz
[root@test Packages]# rpm -qf /usr/bin/mpstat
sysstat-9.0.4-20.el6.x86_64
[root@test Packages]# rpm -ivh sysstat-9.0.4-20.el6.x86_64.rpm --force
Preparing... ########################################### [100%]
1:sysstat ########################################### [100%]
6、rpm包的校验。
[root@test ~]# rpm -Vf /bin/pwd
[root@test ~]# ls -l /bin/pwd
-rwxr-xr-x. 1 root root 31656 4月 17 2012 /bin/pwd
[root@test ~]# chown bin.bin /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
.....UG.. /bin/pwd
[root@test ~]# chmod 644 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
.M...UG.. /bin/pwd
[root@test ~]# touch /bin/pwd
[root@test ~]# ls -l /bin/pwd
-rw-r--r--. 1 bin bin 31656 10月 28 20:32 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
.M...UGT. /bin/pwd
[root@test ~]# echo "" >> /bin/pwd
[root@test ~]# ls -l /bin/pwd
-rw-r--r--. 1 bin bin 31657 10月 28 20:33 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
prelink: /bin/pwd: prelinked file size differs
SM?..UGT. /bin/pwd
[root@test ~]# chown root.root /bin/pwd
[root@test ~]# chmod 755 /bin/pwd
[root@test ~]# rpm -Vf /bin/pwd
prelink: /bin/pwd: prelinked file size differs
S.?....T. /bin/pwd
[root@test ~]#
8、软件套件包的安装。
yum grouplist 查看光盘中的套件包名称。 ###查看
yum groupinstall "套件包名称" -y ###安装
yum groupremove "套件包名称" -y ###卸载
源码包的安装。
1、下载源码包。
2、解包和解压缩到指定目录
3、进入解包目录,查看README文件,INSTALL文件
4、根据README文件的提示安装。
4.1、配置软件包 ./configure --help
(查看./configure的选项),产生Makefile文件。
4.2、编译软件包 make ###执行Makefile文件
4.3、安装软件包 make install
安装实验:
1、安装proftpd软件包。
[root@test ~]# tar -zxf proftpd-* -C /opt
[root@test ~]# cd /opt/proftpd*
[root@test ~]# vim README
[root@test ~]# yum install gcc -y (安装gcc软件包,如果没有安装的话)
[root@test ~]# ./configure --prefix=/usr/local/proftpd
[root@test ~]# make
[root@test ~]# make install
[root@test proftpd-1.3.5]# cd /usr/local/proftpd/
[root@test proftpd]# ls
bin etc include lib libexec sbin share var
[root@test proftpd]# cd sbin/
[root@test sbin]# ls
ftpscrub ftpshut in.proftpd proftpd
[root@test sbin]# ./proftpd
2014-10-28 20:55:24,650 test proftpd[16796]: fatal: Group: Unknown group
'nogroup' on line 30 of '/usr/local/proftpd/etc/proftpd.conf'
[root@test sbin]# groupadd nogroup
[root@test sbin]# ./proftpd
2014-10-28 20:56:50,609 test proftpd[16804]: warning: unable to determine IP
address of 'test'
2014-10-28 20:56:50,609 test proftpd[16804]: error: no valid servers
configured
2014-10-28 20:56:50,609 test proftpd[16804]: fatal: error processing
configuration file '/usr/local/proftpd/etc/proftpd.conf'
2014-10-28 20:56:53,593 test proftpd[16807]: warning: unable to determine IP
address of 'test'
2014-10-28 20:56:53,593 test proftpd[16807]: error: no valid servers
configured
2014-10-28 20:56:53,593 test proftpd[16807]: fatal: error processing
configuration file '/usr/local/proftpd/etc/proftpd.conf'
[root@test sbin]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.4.47 test
[root@test sbin]# ./proftpd
[root@test sbin]#
[root@test sbin]# netstat -natup|grep :21
tcp 0 0 0.0.0.0:21 0.0.0.0:*
LISTEN 16813/proftpd
[root@test ~]# tar -zxf webmin-1.680.tar.gz -C /opt/
[root@test ~]# cd /opt/webmin-1.680/
[root@test webmin-1.680]# vim README
[root@test webmin-1.680]# ./setup.sh
***********************************************************************
* Welcome to the Webmin setup script, version 1.680 *
***********************************************************************
Webmin is a web-based interface that allows Unix-like operating
systems and common Unix services to be easily administered.
Installing Webmin in /opt/webmin-1.680 ...
***********************************************************************
Webmin uses separate directories for configuration files and log files.
Unless you want to run multiple versions of Webmin at the same time
you can just accept the defaults.
Config file directory [/etc/webmin]:
Log file directory [/var/webmin]: /var/log/webmin
***********************************************************************
Webmin is written entirely in Perl. Please enter the full path to the
Perl 5 interpreter on your system.
Full path to perl (default /usr/bin/perl):
Testing Perl ...
Perl seems to be installed ok
***********************************************************************
Operating system name: Redhat Enterprise Linux
Operating system version: 6
***********************************************************************
Webmin uses its own password protected web server to provide access
to the administration programs. The setup script needs to know :
- What port to run the web server on. There must not be another
web server already using this port.
- The login name required to access the web server.
- The password required to access the web server.
- If the webserver should use SSL (if your system supports it).
- Whether to start webmin at boot time.
Web server port (default 10000):
Login name (default admin):
Login password:
Password again:
The Perl SSLeay library is not installed. SSL not available.
Start Webmin at boot time (y/n): y
***********************************************************************
Creating web server config files..
..done
Creating access control file..
..done
Inserting path to perl into scripts..
..done
Creating start and stop scripts..
..done
Copying config files..
..done
Configuring Webmin to start at boot time..
..done
Creating uninstall script /etc/webmin/uninstall.sh ..
..done
Changing ownership and permissions ..
..done
Running postinstall scripts ..
Use of uninitialized value in -r at
/opt/webmin-1.680/webalizer/webalizer-lib.pl line 16.
Use of uninitialized value in split at /opt/webmin-1.680/acl/acl-lib.pl line
47.
..done
Enabling background status collection ..
..done
Attempting to start Webmin mini web server..
Starting Webmin server in /opt/webmin-1.680
Pre-loaded WebminCore
..done
***********************************************************************
Webmin has been installed and started successfully. Use your web
browser to go to
http://test:10000/
and login with the name and password you entered previously.
网络基础:
1、网络IP地址的配置。
方法1:直接修改/etc/sysconfifg/network-scripts/ifcfg-eth0文件.(永久IP)
方法2:执行setup命令,修改IP地址。
方法3:执行ifconfig eth0 192.168.1.1/24命令修改IP地址(临时IP)
[root@test ~]# setup
[root@test ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:34:77:bd
NM_CONTROLLED=yes ##是否收NetworkerManager服务接管,建议设为no。
ONBOOT=yes ##network服务启动时,是否激活。
TYPE=Ethernet
UUID="542a2c35-a70b-4a54-b787-2fe4f32d6130"
IPADDR=172.16.4.49
NETMASK=255.255.255.0
GATEWAY=172.16.4.1
IPV6INIT=no ##关闭IPv6
USERCTL=no ##是否允许普通用户修改IP地址
[root@test ~]# cat /etc/resolv.conf ##DNS客户端文件
nameserver 192.168.1.1
nameserver 202.96.128.166
[root@test ~]# cat /etc/sysconfig/network ##辅助配置文件
NETWORKING=yes ##激活IPv4
HOSTNAME=test ##主机名。
[root@test ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes ###网卡是否连接网线。yes表示连接。
[root@test ~]# ifconfig eth0 172.16.4.49/24
[root@test ~]# ifconfig eth0:1 192.168.100.1/24
[root@test ~]# ifconfig eth0:1
eth0:1 Link encap:Ethernet HWaddr 00:0C:29:34:77:BD
inet addr:192.168.100.1 Bcast:192.168.100.255
Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[root@test ~]# ping 192.168.100.1 -c1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=64 time=0.202 ms
--- 192.168.100.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.202/0.202/0.202/0.000 ms
[root@test ~]# ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast
state UP qlen 1000
link/ether 00:0c:29:34:77:bd brd ff:ff:ff:ff:ff:ff
inet 172.16.4.49/24 brd 172.16.4.255 scope global eth0
inet 192.168.100.1/24 brd 192.168.100.255 scope global eth0:1
inet6 fe80::20c:29ff:fe34:77bd/64 scope link
valid_lft forever preferred_lft forever
[root@test ~]# ifconfig eth0:1 down 停止eth0:1接口
[root@test ~]# ifconfig eth0:1 up
route 设置路由。
1、设置网络路由:
route add -net <目标网段> gw <网关> dev <进出的网络接口>
到达202.13.13.0/24网段,通过172.16.4.1网关出去,设备接口为eth0
route add -net 202.13.13.0/24 gw 172.16.4.1 dev eth0
2、设置主机路由:
route add -host <目标主机> gw <网关> dev <进出的网络接口>
到达202.13.13.100网段,通过172.16.4.1网关出去,设备接口为eth0
route add -host 202.13.13.100/24 gw 172.16.4.1 dev eth0
3、设置默认路由:
route add default gw 172.16.4.1 dev eth0
192.168.100.100/25 192.168.100.0
[root@test ~]# ipcalc -mbn 192.168.100.100/25
NETMASK=255.255.255.128
BROADCAST=192.168.100.127
NETWORK=192.168.100.0
[root@test ~]# ipcalc -mbn 192.168.100.129/25
NETMASK=255.255.255.128
BROADCAST=192.168.100.255
NETWORK=192.168.100.128
网络连通性判断:
ping -c1 172.16.4.49
traceroute www.canway.net
网络端口的检查。
netstat -atnup |more -a 所有 -t tcp, -u udp, -n 不测试网络 -p 进程
[root@test ~]# netstat -atnup|grep :21
tcp 0 0 0.0.0.0:21 0.0.0.0:*
LISTEN 18350/vsftpd
tcp 0 0 172.16.4.49:21 192.168.3.158:56401
FIN_WAIT2 -
netstat -anlp -l 监听
netstat -rn 查看路由
netstat -i 查看接口。
[root@test ~]# watch netstat -i
/etc/hosts 主机名和IP地址的对应关系文件
远程管理Linux系统:
1、ssh服务器
2、vnc服务器
3、webmin服务器
ssh服务器的配置:
默认开启了ssh服务器,即22号端口,任何有效的用户都可以连接。
一个标准的sshd_config配置文件。
[root@test ~]# cat /etc/ssh/sshd_config|grep -Evn "^$|^#"
13:Port 22
15:ListenAddress 172.16.4.49
21:Protocol 2
31:ServerKeyBits 1024
36:SyslogFacility AUTHPRIV
42:PermitRootLogin no
43:allowusers jake@172.16.4.0/24
67:PasswordAuthentication yes
71:ChallengeResponseAuthentication no
82:GSSAPIAuthentication no
84:GSSAPICleanupCredentials no
98:UsePAM yes
101:AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
LC_MESSAGES
102:AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
103:AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
104:AcceptEnv XMODIFIERS
110:X11Forwarding no
123:UseDNS no
133:Subsystem sftp /usr/libexec/openssh/sftp-server
[root@test ~]# useradd jake
[root@test ~]# passwd jake
[root@test ~]# /etc/init.d/sshd restart
login as: jake
jake@172.16.4.49's password:
[jake@test ~]$ su -
密码:
[root@test ~]# ls
anaconda-ks.cfg file.txt install.sh proftpd-
1.3.5.tar.gz word
backup_etc.tar.gz install.log.bak kk1 webmin-1.680.tar.gz
dir1 install.log.syslog log winscp554setup.exe
[root@test ~]#
ssh客户端:
1、for linux
ssh -P <port> <remote_ip>
scp local.file <remote_ip>:/dirname/remote.file 上传
scp <remote_ip>:/dirname/remote.file local.file 下载
2、for windows
putty,SecureCRT==> ssh
winscp ==> scp,sftp
ssh服务器的认证机制:
1、本地用户认证。(/etc/shadow)
2、通过rsa或dsa非对称密钥对认证。(推荐)
[root@test .ssh]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
5b:5f:9c:65:b7:18:5d:a2:c4:bd:3e:09:b9:1f:1d:be root@test
The key's randomart image is:
+--[ DSA 1024]----+
| .... .|
| ...o..|
| .o o+|
| o.+=o|
| S . ==+.|
| o ...=..|
| . .. o.|
| .E |
| |
+-----------------+
[root@test .ssh]# ls
id_dsa id_dsa.pub
[root@test .ssh]# scp id_dsa.pub 172.16.4.49:/root/.ssh/authorized_keys
[root@test .ssh]# ssh 172.16.4.49
The authenticity of host '172.16.4.49 (172.16.4.49)' can't be established.
RSA key fingerprint is e6:ee:be:7c:4f:f1:1c:15:ec:01:1b:55:10:63:de:49.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.4.49' (RSA) to the list of known hosts.
Enter passphrase for key '/root/.ssh/id_dsa':
Enter passphrase for key '/root/.ssh/id_dsa':
Enter passphrase for key '/root/.ssh/id_dsa':
root@172.16.4.49's password:
Permission denied, please try again.
root@172.16.4.49's password:
Permission denied, please try again.
root@172.16.4.49's password:
Permission denied (publickey,password).
[root@test .ssh]# ssh 172.16.4.49
Enter passphrase for key '/root/.ssh/id_dsa':
Last login: Tue Oct 28 22:43:16 2014 from 172.16.4.49
[root@test ~]#
[root@test ~]#
VNC服务器:
1、vnc服务器的工作原理
2、安装vnc服务器。
[root@test ~]# yum search vnc-server
[root@test ~]# yum install tigervnc-server.x86_64 -y
[root@test ~]#
3、配置vnc服务器。
[root@test ~]# yum groupinstall "通用桌面" -y
[root@test ~]# yum search vnc-server
[root@test ~]# yum install tigervnc-server.x86_64 -y
[root@test ~]# vncserver :1
You will require a password to access your desktops.
Password:
Verify:
New 'test:1 (root)' desktop is test:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:1.log
[root@test ~]# cd /root/.vnc/
[root@test .vnc]# ls
passwd test:1.log test:1.pid xstartup
[root@test .vnc]# vim xstartup
将文件中末尾中的twm更改gnome-session
[root@test .vnc]# vncserver -kill :1 关闭:1图形界面
Killing Xvnc process ID 21090
[root@test .vnc]# vncserver :2 启动:2图形界面
New 'test:2 (root)' desktop is test:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:2.log
[root@test .vnc]# netstat -atnup|grep -i vnc
tcp 0 0 0.0.0.0:5902 0.0.0.0:*
LISTEN 21182/Xvnc
tcp 0 0 0.0.0.0:6002 0.0.0.0:*
LISTEN 21182/Xvnc
tcp 0 0 :::6002 :::*
LISTEN 21182/Xvnc
[root@test .vnc]# /etc/init.d/iptables stop
[root@test .vnc]# vim /etc/sysconfig/vncservers
[root@test .vnc]# cat /etc/sysconfig/vncservers |tail -1
VNCSERVERS="2:root"
[root@test .vnc]# service vncserver restart
关闭 VNC 服务器:2:root [失败]
正在启动 VNC 服务器:2:root
New 'test:2 (root)' desktop is test:2
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:2.log
[确定]
[root@test .vnc]# netstat -antup|grep -i vnc
tcp 0 0 0.0.0.0:5902 0.0.0.0:*
LISTEN 22492/Xvnc
tcp 0 0 0.0.0.0:5903 0.0.0.0:*
LISTEN 21916/Xvnc
tcp 0 0 0.0.0.0:6002 0.0.0.0:*
LISTEN 22492/Xvnc
tcp 0 0 0.0.0.0:6003 0.0.0.0:*
LISTEN 21916/Xvnc
tcp 0 0 172.16.4.49:5903 172.16.4.47:53462
ESTABLISHED 21916/Xvnc
tcp 0 0 :::6002 :::*
LISTEN 22492/Xvnc
tcp 0 0 :::6003 :::*
LISTEN 21916/Xvnc
[root@test .vnc]#
发表评论
-
linux yum 下载至本地及使用本地缓存安装包
2018-12-29 08:04 30851.搭建yum服务器 2.使用yum下载缓存进行封装,然后使用 ... -
linux grep命令
2014-12-08 10:06 5391.作用 Linux系统中grep命令是一种强大的文本搜索工具 ... -
Linux中Samba详细安装
2014-12-08 09:05 533为了实现Windows主机与Linux服务器之间的资源共享,L ... -
linux挂载光驱以及yum配置与安装
2014-12-01 10:12 11461,使用命令ll /dev/* |gr ... -
linux培训笔记3
2014-10-29 11:55 569selinux: 传统权限:以 ... -
linux 培训笔记
2014-10-27 11:33 778何世晓 server raid lsi 内存大于等于1G,带锂 ... -
linux培训笔记
2014-10-27 11:32 574/boot分区单独划分,大小为200M,其他采用LVM逻辑卷划 ... -
Linux: 字体安装
2014-04-14 11:58 693本实验以安装宋体( simsun.ttf ) 为例, 记录下安 ... -
make报错:"/usr/bin/ld: cannot find -lXXX"
2014-04-12 18:16 768在编译php时报错如下: # make 。。。 /usr/bi ... -
linux--apache的ab命令
2014-03-09 19:24 5241. 最基本的关心两个选项 -c -n 例: ./ab -c ... -
/bin/sh^M: bad interpreter:没有那个文件或目录解决
2014-03-09 18:55 910/bin/sh^M: bad interpreter:没有那个 ... -
linux定时任务的设置
2014-01-03 11:47 551为当前用户创建cron服务 ... -
Centos和RHEL的区别
2013-10-19 20:19 768CentOS简介关于CentOS CentOS是Comm ... -
Linux 查看CPU信息、机器型号等硬件信息
2013-10-11 14:20 527测试机器的硬件信息: 查看CPU信息(型号) # cat ... -
Linux 查看CPU,内存,硬盘
2013-06-08 10:59 7281 查看CPU 1.1 查看CPU个数 # cat /pr ... -
常见命令
2013-06-08 10:53 5381,打开开机启动项(win7):在菜单搜索框中输入msconf ... -
Linux init.d
2013-06-08 10:05 608本文包括3部分内容 1、 Linux的引导过程 2 ... -
Linux下which、whereis、locate、find 命令的区别
2013-06-04 17:40 650我们经常在linux要查找 ...
相关推荐
Linux 培训笔记 Linux 培训笔记是对 Linux 操作系统的基本概念和常用命令的总结。以下是笔记的要点总结: 目录结构 * /bin: 系统可执行文件存放目录 * /lib: 系统库文件存放目录,动态链接库以.so 结尾 * /usr: ...
北京培训机构资料,整理linux基础所有常用指令,快速入门必备
黑马程序员 Linux 从入门到精通配套笔记 本资源汇总了 Linux 操作系统的发展史、安装方法、特点和分支等内容。下面是从文件中提取的知识点: 一、Linux 发展史 1. Linux 的前身是 Unix,于 1968 年由 Multics ...
- **标题**:"Linux培训教程:从实践中学习Linux-学习笔记.pdf" 明确指出了这是一份针对Linux操作系统的培训资料,强调了通过实践来学习的重要性。 #### 描述解析 - **描述**:"Linux培训教程:从实践中学习Linux-...
### Linux培训笔记精要 #### 一、Linux系统概述与基础命令 1. **BusyBox在小型系统中的应用**:BusyBox是一个集成了上百个最常用Linux命令和工具的软件,它体积小巧,功能强大,特别适合嵌入式设备或资源受限的...
这篇"Linux培训学习笔记"主要涵盖了Linux的基础知识,包括登录、密码管理、文件编辑以及vi编辑器的使用。 首先,Linux的登录过程非常简单,用户通过指定的用户名和密码进入系统。例如,如果用户名是`linux`,密码是...
培训笔记Linux系统入门
2. **Linux常用命令**: - `Ctrl+l`清屏,`Ctrl+u`清除命令行。 - `ls`命令的不同选项,如`-a`, `-l`, `-ll`, `-la`分别显示隐藏文件、长格式列表、详细信息和所有文件及目录属性。 - `ip`命令用于网络配置,如...
这份“Linux培训笔记”很可能是对Linux操作系统深入学习的记录,包含了丰富的知识和实践经验。以下是对Linux系统的一些核心概念和常用命令的概述,旨在帮助初学者或需要进一步提升技能的IT从业者。 1. **Linux基础*...
Linux LAMP培训内部笔记 绝对正品
这份"公司Linux培训.rar"压缩包显然包含了一些与企业级Linux使用和管理相关的资源,可能是教程、笔记或者是培训材料。以下是根据标题和描述可能涵盖的一些关键知识点: 1. **Linux基础知识**:这部分可能介绍了...
Linux驱动程序是操作系统与硬件设备之间的桥梁,...通过这份达内培训资料,学习者可以从实际代码和讲解中获得丰富的实践经验,逐步掌握Linux驱动开发的核心技能。无论你是初学者还是有一定经验的开发者,都能从中受益。
【尚观培训Linux许巍关于C++的笔记和讲义】是针对嵌入式Linux驱动开发的学习资料,其中包含了丰富的C++编程知识。C++是一种强大的、通用的面向对象编程语言,广泛应用于系统软件、应用软件、游戏开发、驱动程序等...
这本培训笔记由Andrew McGill编写,属于Leading Edge Business Solutions公司的Linux培训计划的一部分。该文档受到版权保护,但可以在GNU自由文档许可证条款下重新分发。 LPI 101课程涵盖了LPI考核的知识点,从基础...
本人参加linux培训时的内部学习笔记,绝对是不可多得的学习资料!
【尚观培训Linux许巍老师关于C语言的课程笔记与讲义】是针对想学习或深化C语言理解的IT从业者及爱好者的一份宝贵资源。尚观是一家知名的IT培训机构,其提供的课程涵盖了广泛的IT领域,包括嵌入式Linux驱动开发。这份...
LINUX培训笔记,从基础到复杂,讲得比较详细,有兴趣的可以看看。
尚观 linux内核驱动开发 笔记 网络编程部分 绝对值得研究!