ITPub博客

首页 > IT职业 > IT生活 > 2011.3.6 (ULE)

2011.3.6 (ULE)

原创 IT生活 作者:sgy618 时间:2011-03-07 16:18:07 0 删除 编辑

2011.3.6 (ULE)

[@more@]

grep 'bin.*bin' /etc/passwd
grep '^[^b].*bin.*bin' /etc/passwd
awk -F '[:/ ]' '{print $1}' /etc/passwd
cut -d : -f 1 /etc/passwd
awk默认以空格和t来作分格符
df -h | awk '{print $1,$5}'
df -h | awk '{print $1"t"$NF}'
df -h | awk '/^t/{print $1"t"$6}'
[root@localhost ~]# locate -r '^/.*passwd$' 以/开头,以passwd结尾,-r表示要使用正则表达式
locate 是搜索哪个目录?只能从根目录开始查找
[root@localhost home]# history 1> /home/sungy/file 将历史存储,管道符是命名管道

文件类型
进程间通信
s -> socket file
p -> pipe file、
设备文件
c -> char device file
b -> block device file 一个扇区512字节 ext3:4k为8个扇区

l -> link file 符号链接
- -> normal file{纯文本,命令,库文件}
d -> dectory file

[root@localhost sungy]# find / -type l
[root@localhost sungy]# find / -type s
[root@localhost sungy]# find / -type p
[root@localhost sungy]# find / -type d
[root@localhost sungy]# find / -type f
[root@localhost sungy]# find / -type c
[root@localhost sungy]# find / -type f

更加细密度的权限设定
利用ext3文件系统的acl功能来实现
要求挂在ext3时acl,getfacl和setfacl
首先介绍mount挂在命令
图形界面下系统会自动帮助挂载,文本模式下是不能的

[root@localhost RHEL_5.5 i386 DVD]# ls -ld /dev/hdc
brw-rw---- 1 root disk 22, 0 03-07 17:35 /dev/hdc
[root@localhost RHEL_5.5 i386 DVD]# ls -ld /dev/cdrom
lrwxrwxrwx 1 root root 3 03-07 17:35 /dev/cdrom -> hdc

gnome-mount帮助自动挂载的
不能往/下或/boot下进行挂在操作!

[root@localhost mnt]# ls -d /net/ /media/ /misc/ /mnt/
/media/ /misc/ /mnt/ /net/
光盘 automount 随便 网络

[root@localhost ~]# mount /dev/cdrom /mnt/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost mnt]# mkdir a
mkdir: 无法创建目录 “a”: 只读文件系统

[root@localhost mnt]# umount /mnt/
umount: /mnt: device is busy
umount: /mnt: device is busy
[root@localhost mnt]# cd ..
[root@localhost /]# umount /mnt/
[root@localhost /]# df -h

[root@localhost /]# umount /media/RHEL_5.5 i386 DVD/

[root@localhost /]# mount -t iso9660 /dev/cdrom /mnt/ "-t" is discribed into the device type
必须知道u盘的文件系统格式(fat32,ntfs)和设备文件名字,可以通过下个命令知道
[root@localhost /]# fdisk -l
sometimes ,the u-disk or IDE is always named "sd*"
[root@localhost /]# mount -t vfat /dev/sda1 /media/
if we find I/O Eorror,mostly the u-disk has something wrong

[root@localhost /]# mount -o loop /var/ftp/*.iso /mnt -o 指定一种选项,loop是当作一种设备文件来挂载

check the mail-box
[root@localhost sungy]# mail -u root

[root@localhost /]# mount -t ext3 -o acl /dev/sda3 / 暂时不执行
[root@localhost /]# mount -o remount,acl / 重新挂载跟分区,并添加新选项

对同一个文件,不同的用户有不同的权限
[root@localhost sungy]# setfacl -m user:u1:rwx ./file
[root@localhost sungy]# setfacl -m user:u2:rx ./file
[root@localhost sungy]# setfacl -m user:u3:r ./file

[root@localhost sungy]# ls -l file
-rw-rwxr--+ 1 root root 14580 03-07 17:56 file

[root@localhost sungy]# getfacl file
# file: file
# owner: root
# group: root
user::rw-
user:u1:rwx
user:u2:r-x
user:u3:r--
group::r--
mask::rwx
other::r--

[root@localhost sungy]# setfacl -x user:u2: ./file
[root@localhost sungy]# setfacl -x user:u1: ./file
[root@localhost sungy]# setfacl -x user:u3: ./file
针对组的时候将user换为group
[root@localhost sungy]# setfacl -m group:u1:x file

[root@localhost sungy]# setfacl -b file 清空扩展权限,会发现"+"没有了,如果有“+”的话,最好不能看正常权限位的
[root@localhost sungy]# ls -l file
-rw-r--r-- 1 root root 14580 03-07 17:56 file

ext3文件系统选项acl

mount -o acl /device /mountpoint
mount -o remount,acl /
[root@server /]# touch /file
[root@server /]# setfacl -m user:u1:rwx /file
[root@server /]# setfacl -m user:u2:rx /file
[root@server /]# setfacl -m user:u3:r /file
[root@server /]# getfacl /file
[root@server /]# setfacl -x user:u2 /file
[root@server /]# setfacl -x user:u1 /file
[root@server /]# setfacl -x user:u3 /file
[root@server /]# setfacl -m group:g1:r /file
[root@server /]# setfacl -x group:g1 /file

[root@server /]# ls -l /file
-rw-r--r--+ 1 root root 18246 Mar 6 10:46 /file

[root@server /]# setfacl -b /file
[root@server /]# ls -l /file
-rw-r--r-- 1 root root 18246 Mar 6 10:46 /file

[root@localhost sungy]# cat /proc/cpuinfo cpu信息

[root@localhost sungy]# cat /proc/cpuinfo | grep vmx 支持全虚拟化
[root@localhost sungy]# cat /proc/cpuinfo | grep pae 支持半虚拟化
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc
pni monitor ds_cpl est tm2 ssse3 cx16 xtpr lahf_lm
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc
pni monitor ds_cpl est tm2 ssse3 cx16 xtpr lahf_lm

[root@localhost sungy]# cat /proc/meminfo 内存信息
[root@localhost sungy]# free -k 以k为单位,默认以字节为单位 -g以g为单位
[root@localhost sungy]# free -k
total used free shared buffers cached
Mem: 2065184 713592 1351592 0 75152 350712
-/+ buffers/cache: 287728 1777456
Swap: 4192956 0 4192956

其中:buffer 写缓存 cache 读缓存
硬盘用fdisk -l 和 df

查看显卡 声卡 网卡
[root@localhost sungy]# lspci
00:00.0 Host bridge: Intel Corporation 82G33/G31/P35/P31 Express DRAM
Controller (rev 10)
00:02.0 VGA compatible controller: Intel Corporation 82G33/G31 Express
Integrated Graphics Controller (rev 10)
00:1b.0 Audio device: Intel Corporation N10/ICH 7 Family High Definition Audio
Controller (rev 01)
00:1c.0 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 1 (rev
01)
00:1c.1 PCI bridge: Intel Corporation N10/ICH 7 Family PCI Express Port 2 (rev
01)
00:1d.0 USB Controller: Intel Corporation N10/ICH7 Family USB UHCI Controller
#1 (rev 01)
00:1d.1 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller
#2 (rev 01)
00:1d.2 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller
#3 (rev 01)
00:1d.3 USB Controller: Intel Corporation N10/ICH 7 Family USB UHCI Controller
#4 (rev 01)
00:1d.7 USB Controller: Intel Corporation N10/ICH 7 Family USB2 EHCI
Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev e1)
00:1f.0 ISA bridge: Intel Corporation 82801GB/GR (ICH7 Family) LPC Interface
Bridge (rev 01)
00:1f.2 IDE interface: Intel Corporation N10/ICH7 Family SATA IDE Controller
(rev 01)
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 01)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E
PCI Express Fast Ethernet controller (rev 02)
03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd.
RTL-8139/8139C/8139C+ (rev 10)

查看网卡详细信息
[root@localhost sungy]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
Link detected: yes

查看路由表
[root@localhost sungy]# route -n “-n”表示不进行解析
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0

广播查询arp缓冲池,默认记忆15分钟
[root@localhost sungy]# arp -n

命令提示符出现乱码,直接打reset就可以恢复

[root@localhost 1]# ps a 显示所有终端的所有进程 不要加"-" R:运行 S:睡眠
[root@localhost 1]# ps au 显示用户 VSZ虚拟内存空间大小,RSS实际内存空间大小
[root@localhost 1]# ps auw "w"宽频显示
[root@localhost 1]# ps auwf 表示进程父子关系
[root@localhost 1]# pstree 树状关系
[root@localhost 1]# ps auwfx "?"不依附于任何终端,一般都是守护程序
[root@localhost 1]# ps aux "x"正在执行

以上程序的参数没有加"-"是BSD(4.4)风格,下面是UNIX风格(system v :5 贝尔实验室)
[root@localhost 1]# ps -ef

[root@localhost sungy]# ps axo user,tty,time,pid 自己定制方式"o"为定制

进程状态
R Running or runnable (on run queue
S Interruptible sleep (waiting for an event to complete) 可中断睡眠,可随时被cpu叫醒
D Uninterruptible sleep (usually IO) 不可中断睡眠(例如执行find时,通过ctrl+D发中断信息 是不可以中断的,可通过ps 查看到)
T Stopped, either by a job control signal or because it is being
traced.已经停止了的(一般看不到)
僵尸进程占CPU不多,对系统无危害


PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers
(header "STAT" or "S") will display to describe
the state of a process.
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.

For BSD formats and when the stat keyword is used, additional characters may
be displayed:
< high-priority (not nice to other users) 高优先级
N low-priority (nice to other users)
L has pages locked into memory (for real-time and custom IO)
s is a session leader 会话
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) 多线程
+ is in the foreground process group 一组进程


[root@localhost 1]# pstree -p 显示pid
top命令 按空格:刷新 >:上翻 <:下翻 1:第二个cpu
字段:up 已经运行时间 load average 平均负载(平均负载表示系统当前1 5 15分钟之内正在运行的进程个数) id空闲的cpu百分比


[root@localhost 1]# tty
/dev/pts/2

优先级[-20,10],负值为高?,只有超级管理员才能将值调小(级别高),普通用户将值调大(级别小)
[root@localhost 1]# nice ls 表示默认以优先级10来执行ls命令
[root@localhost 1]# ls 优先级别为0
数值越小优先级越高
[root@localhost 1]# nice -n 5 top top命令以优先级5来运行
[root@localhost sungy]# renice -5 -p 29096 调整进程优先级


给进程发信号(1,9,15 需要知道的)
[root@localhost 1]# kill -l 查询信号列表
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL
5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE
9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2
13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT
17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU
25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH
29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN
35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4
39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12
47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10
55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6
59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX

[root@localhost 1]# /etc/init.d/sshd start
启动 sshd: [确定]
[root@localhost 1]# ps axu | grep sshd
root 2616 0.0 0.0 7068 1036 ? Ss 17:36 0:00
/usr/sbin/sshd
root 4840 0.0 0.0 4168 772 pts/2 R+ 21:46 0:00 grep --color
sshd
[root@localhost 1]# kill -1 2616 重跑信号(/etc/init.d/sshd restart 也可以)
[root@localhost 1]# ps axu | grep sshd
root 4842 0.0 0.0 7068 1036 ? Ss 21:46 0:00
/usr/sbin/sshd
root 4844 0.0 0.0 4164 696 pts/2 S+ 21:46 0:00 grep --color
sshd

[root@localhost 1]# kill -15 4842 使其正常终止,当前终端号4842,发现没有终止
[root@localhost 1]# ps axu | grep sshd
root 4848 0.0 0.0 4164 720 pts/2 S+ 21:48 0:00 grep --color
sshd

[root@localhost 1]# kill -p 3278 强迫终止,当前终端号3278,发现终端消失

top命令执行过程中,按"k",后面输入pid号,可以杀死该进程,"h"帮助,"q"退出
[root@localhost 1]# killall sshd 可代进程的名字
[root@localhost 1]# /etc/init.d/sshd start
启动 sshd: [确定]
[root@localhost 1]# ps aux | grep sshd
root 4874 0.0 0.0 7068 1036 ? Ss 21:54 0:00
/usr/sbin/sshd
root 4878 0.0 0.0 4164 700 pts/2 S+ 21:54 0:00 grep --color
sshd
[root@localhost 1]# killall -9 sshd
[root@localhost 1]# ps aux | grep sshd
root 4881 0.0 0.0 4164 692 pts/2 R+ 21:54 0:00 grep --color
sshd

-------------关于挂载---------------

mount -t filesystem_type /devicename /mountpoint
mount -t iso9660 /dev/cdrom /mnt
mount -o loop /xxxx.iso /mnt
fdisk -l
mount -t vfat /device /mountpoint
umount /mountpoint
df -h

----------------- 系统状态检查及进程管理 ---------------------
cat /proc/cpuinfo
cat /proc/meminfo
free
lspci
fdisk -l
df df -h
-------------
ps
ps axu
ps auxwf
ps -ef
pstree
pstree -p
top
nice command
nice -n nice_value command
renice nice_value -p pid
kill -l
man 7 signal
kill -1 pid
kill -9 pid
kill -15 pid
killall procname
killall -9 procname
killall -15 procname

--------------------
软件包的管理
安装
卸载
升级
查看安装位置
查看某程序是安装什么软件生成的

在Linux下,软件包分为两种:
二进制包:可双击安装
xxxx.rpm--redhat的包格式(redhat,centos,fedora)
一般用rpm命令来管理
xxxx.deb --- debian的包格式(ubuntu)
一般用dpkg命令来管理
源代码包: 需要编译再安装
xxx.tar.gz
xxxx.tar.bz2
xxxx.zip
xxxx.rar

软件包分为两种:
二进制:可双击 *.rpm(redhat,centos,fedora 一般用rpm命令管理) *.deb(ubuntu,debian 一般用dpkg命令管理)
源代码包:需编译安装 *.tar.gz 等压缩包(解压看帮助)
[root@localhost mnt]# rpm -qa 查询系统中所有已经安装的包
[root@localhost mnt]# rpm -q stardict 查询stardict是否安装、
[root@localhost mnt]# rpm -ql stardict 查询这个包装哪去了

]# rpm -qa | grep stardict
stardict-2.4.5-5
]# rpm -q stardict
stardict-2.4.5-5
]# rpm -ql stardict查看软件包安装后生成的文件
主要是 bin/命令
lib/库文件
man/帮助

[root@localhost mnt]# rpm -ql stardict | grep 'desktop'
/usr/share/applications/stardict.desktop 快捷方式存放的地方
[root@localhost applications]# rm -rf stardict.desktop
[root@localhost applications]# ln -s /usr/bin/stardict /root/Desktop/ 创建快捷方式
[root@localhost share]# rpm -e stardict 卸载
[root@localhost share]# rpm -ivh /mnt/Server/stardict-2.4.5-5.i386.rpm 安装i:安装 v:查看安装过程 h:以哈希算法显示进度条
[root@localhost sungy]# rpm -Uvh /mnt/Server/stardict-2.4.5-5.i386.rpm “U”表示升级
[root@localhost sungy]# rpm -qi openssh-server :查该包是干嘛的
Name : openssh-server Relocations: (not relocatable)
Version : 4.3p2 Vendor: Red Hat, Inc.
Release : 41.el5 Build Date: 2010年01月22日 星期五
23时35分16秒
Install Date: 2011年02月21日 星期一 20时00分30秒 Build Host:
x86-002.build.bos.redhat.com
Group : System Environment/Daemons Source RPM:
openssh-4.3p2-41.el5.src.rpm
Size : 486643 License: BSD
Signature : DSA/SHA1, 2010年03月04日 星期四 17时37分00秒, Key ID
5326810137017186
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://www.openssh.com/portable.html
Summary : The OpenSSH server daemon
Description :
OpenSSH 是 SSH(Secure SHell)的免费版本,它被用来
在远程机器上登录并执行命令。
该软件包包括安全 shell 守护进程(sshd)。sshd 守护进程
允许 SSH 客户安全地连接到您的 SSH 服务器。您还需要
安装 openssh 软件包。

[root@localhost sungy]# rpm -qpi /mnt/Server/stardict-2.4.5-5.i386.rpm "p"指定路径和全名
warning: /mnt/Server/stardict-2.4.5-5.i386.rpm: Header V3 DSA signature:
NOKEY, key ID 37017186
Name : stardict Relocations: (not relocatable)
Version : 2.4.5 Vendor: Red Hat, Inc.
Release : 5 Build Date: 2006年07月18日 星期二
23时13分20秒
Install Date: (not installed) Build Host:
hs20-bc2-2.build.redhat.com
Group : Applications/System Source RPM:
stardict-2.4.5-5.src.rpm
Size : 1301404 License: GPL
Signature : DSA/SHA1, 2007年01月19日 星期五 00时18分37秒, Key ID
5326810137017186
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://stardict.sourceforge.net
Summary : 用 GTK+2编写的强大的字典平台
Description :
StarDict is a Cross-Platform and international dictionary written in Gtk2.
It has powerful features such as "Glob-style pattern matching", "Scan
selection word,"
"Fuzzy query," etc.

词典管理
要管理词典,单击位于主窗口右下角的词典管理按钮,或是单击主菜单按钮并选择词典管理。
在词典管理对话框中,你可以屏蔽掉不需要的词典,你也可以设置词典查询的顺序。
星际译王将在 "/usr/share/stardict/dic" 和 "~/.stardict/dic"
目录查找词典文件,在 "/usr/share/stardict/treedict" 和 "~/.stardict/treedict"
目录查找树型词典文件。


[root@localhost sungy]# rpm -qf /bin/ls
coreutils-5.97-23.el5_4.2

[root@localhost sungy]# rm -rf /bin/ls
[root@localhost sungy]# ls
bash: /bin/ls: 没有那个文件或目录
[root@localhost sungy]# rpm -Uvh --force /mnt/Server/coreutils-5.97-23.el5_4.2.i386.rpm "--force"表示强制升级

[root@localhost sungy]# rm -rf /bin/ls
[root@localhost sungy]# ls
bash: /bin/ls: 没有那个文件或目录
[root@localhost sungy]# rpm -V coreutils 查询该包是否有变化
missing /bin/ls

[root@localhost sungy]# rpm -Va 检查系统中是否有变化,查询所有rpm包

有以下的变化,通过 rmp -V 能检查出
S file Size differs
M Mode differs (includes permissions and file type)
5 MD5 sum differs
D Device major/minor number mismatch
L readLink(2) path mismatch
U User ownership differs
G Group ownership differs
T mTime differs

yum管理
/etc/yum.repos.d
[root@localhost yum.repos.d]# ls
control.repo rhel-debuginfo.repo
内容:
1 [rhel-control] rhel最好别删
2 name= +++++++ CONTROL ++++++++
3 baseurl=file:///mnt/Server
4 enabled=1
5 gpgcheck=1
6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[root@localhost ~]# yum clean all
[root@localhost ~]# yum -y install gcc44-c++ 加"-y"避免交互

yum remove packagename
yum update packagename

如果图形没有了,怎么办yum install *gnome*


[root@localhost ~]# stardict & 让星际译王后台运行
[root@localhost ~]# jobs 查看当前运行的任务
[1]+ Running stardict &
[root@localhost ~]# fg 1 将后台程序转换成前台
stardict

ctrl+z 停止当前进程
[root@localhost ~]# bg 1 将前台程序转换从后台,需要提前ctrl+z停止
[1]+ stardict &


[root@localhost ~]# nohup stardict & 运行一个程序不依赖任何一个tty


ftp服务: lftp 192.168.1.254:/> mirror package/ 下目录用mirror,文件下载用get

《linux企业集群》

watch -n 0.5 uptime 每0.5秒刷新
watch uptime 默认2秒


-------------关于rpm包的依赖关系问题----------------

[root@server Server]# rpm -q gcc44-c++
package gcc44-c++ is not installed
[root@server Server]# rpm -ivh gcc44-c++-4.4.0-6.el5.i386.rpm
error: Failed dependencies:
gcc44 = 4.4.0-6.el5 is needed by gcc44-c++-4.4.0-6.el5.i386
libgmp.so.3 is needed by gcc44-c++-4.4.0-6.el5.i386
libstdc++44-devel = 4.4.0-6.el5 is needed by gcc44-c++-4.4.0-6.el5.i386

学习配置yum,来实现软件包的自动依赖关系 解决
1、把软件包放到一个目录下,通过FTP/HTTP共享,或者是一个本地目录
2、每个需要使用yum的主机都配置yum的配置文件,来指定那个放软件包的本地目录位置或者FTP共享位置或者HTTP共享位置
----------------
具体操作方法一:
我们把包放到了本地的/mnt/Server下
然后修改yum的配置文件,进行位置的指定:
[root@server yum.repos.d]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/pg.repo
[root@server yum.repos.d]# vim /etc/yum.repos.d/pg.repo
[root@server yum.repos.d]# cat /etc/yum.repos.d/pg.repo
[rhel-server]
name=redhat enterprise linux 5.5 for pg
baseurl=file:///mnt/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

yum clean all
yum -y install packagename
yum remove packagename
yum update packagename
man yum
yum -y install *gnome*

方法二:
在192.168.1.254把软件包通过FTP共享
[root@server yum.repos.d]# mkdir /var/ftp/rhel5u5
[root@server yum.repos.d]# mount -o loop /rhel5u5.iso /var/ftp/rhel5u5/
[root@server yum.repos.d]# service vsftpd restart
Shutting down vsftpd: [ OK ]
Starting vsftpd for vsftpd: [ OK ]

每一个需要通过YUM装包的主机做如下配置指向FTP
cat /etc/yum.repos.d/xxxx.repo
1 [rhel-server]
2 name=redhat enterprise linux 5.5 for pg
4 baseurl=ftp://192.168.1.254/rhel5u5/Server
5 enabled=1
6 gpgcheck=1
7 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY -redhat-beta,file:///etc/pki/rpm-gpg/RPM-G PG-KEY-redhat-release
~
最简洁的FTP服务搭建 方式,实现匿名共享。(上面的实验是拿FTP来共享软件包)
[root@server yum.repos.d]# yum -y install vsftpd
[root@server yum.repos.d]# /etc/init.d/vsftpd start
[root@server yum.repos.d]# cd /var/ftp/
[root@server ftp]# pwd
/var/ftp
[root@server ftp]# 默认的匿名共享目录是/var/ftp,你想共享什么 文件,就放到此目录下。
[root@server ftp]# 你的客户端可以通过浏览器, 输入URL路径 : ftp://ftp_server_ip 来访问到你 的共享。或者通过lftp工具,敲 lftp ftp_server_ip 这个命令来匿名连接ftp服务器端,通过get下载普通文件,通过mirror下载目录文件


以下可以写多段,最重要是baseurl路径必须存在,是可用的。[名字]不要一样 。另外,如果某一段中的baseurl路径,并不可用,那必然会影响 Yum的使用,则可以通过把enabled=0进行设置。

vim /etc/yum.repo.d/xxxxx.repo
1 [rhel-server]
2 name=redhat enterprise linux 5.5 for pg
3 baseurl=ftp://192.168.1.254/rhel5u5/Server
4 enabled=1
5 gpgcheck=1
6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-be ta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
7 [rhel-cluster]
8 name=redhat enterprise linux 5.5 for pg
9 #baseurl=ftp://192.168.1.254/rhel5u5/Server
10 baseurl=file:///mnt/Cluster
11 enabled=1
12 gpgcheck=1
13 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-be ta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
------------------------
[root@server ftp]# createrepo /dir 存放所有软件包的目录,读取它们的头部信息,生成 依赖关系资料文件。
[root@server ftp]# ls /dir/repodata/ 这就是生成的依赖关系文件。
[root@server ftp]# yum -y install createrepo 如果没有createrepo命令,先装同名包生成


[root@server ftp]# stardict &
[root@server ftp]# jobs
[1]+ Running stardict &
[root@server ftp]# fg 1
stardict


敲ctrl+z
[1]+ Stopped stardict
[root@server ftp]# jobs
[1]+ Stopped stardict
[root@server ftp]# bg 1
[1]+ stardict &
[root@server ftp]# jobs
[1]+ Running stardict &

[root@server ftp]# jobs
[1]+ Running stardict &
[root@server ftp]#

[root@server ftp]# top &
[2] 32164
[root@server ftp]# jobs
[1]- Running stardict &
[2]+ Stopped top
[root@server ftp]# jobs
[1]- Running stardict &
[2]+ Stopped top
[root@server ftp]# kill %2
[root@server ftp]# jobs
[1]- Running stardict &
[2]+ Terminated top
[root@server ftp]# jobs
[1]+ Running stardict &
[root@server ftp]# kill %1
[root@server ftp]# jobs
[1]+ Terminated stardict
[root@server ftp]# jobs

=========================
[root@server ftp]# jobs
[1]- Running stardict &
[2]+ Running sleep 1000 &
[root@server ftp]# sleep 1000 &
[3] 32218
[root@server ftp]# jobs
[1] Running stardict &
[2]- Running sleep 1000 &
[3]+ Running sleep 1000 &
[root@server ftp]# kill %%
[3]+ Terminated sleep 1000
[root@server ftp]# jobs
[1]- Running stardict &
[2]+ Running sleep 1000 &
[root@server ftp]# kill %%
[2]+ Terminated sleep 1000
[root@server ftp]# jobs
[1]+ Running stardict &
[root@server ftp]# kill %%


[root@server Server]# nohup stardict &
[root@server Server]# man nohup

[root@server ~]# uptime
16:24:07 up 6:53, 5 users, load average: 0.02, 0.02, 0.08
[root@server ~]# 平均负载表示系统当前1、5、15 分钟之内正在运行的进程个数
[root@server ~]#

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23168012/viewspace-1046919/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-01-12

  • 博文量
    104
  • 访问量
    396309