Linux常用命令(下)

上一篇 / 下一篇  2013-12-24 23:33:09 / 个人分类:linux

1. rpm命令的使用

rpm ivh ***.rpm   安装

 

rpm -qa|grep jre    查找

rpm -qa|grep jdk

 

rpm -e jre-1.5.0_14-fcs    删除

 

rpm -e --nodeps mysql   强制删除

 

2. 压缩解压缩

解压:

Gunzip  ***.tar.gz

 

Tar命令:

Tar cvf data.tar  *       #当前目录下所有文件打包

Tar cvzf data.tar.gz *     #打包,压缩

Tar tvf data.tar          #查看文件中包含的内容

Tar xvf data.tar          #解包

Tar zxvf  ***.tar

 

 

 

 

 

3. 查看端口

netstat –au

 

4. 修改linux系统时间

date 091916552011 (月日时分年 20119161655

date 091916552011.20 (月日时分年.秒 2011916165520

 

date 20110919

date s 16:55:20

 

5. 添加服务

chkconfig --add oracle   添加到服务

 

ntsysv   服务

 

setup    配置

 

6. 修改服务器IP

vi /etc/sysconfig/network-scripts/ifcfg-eth0

service network restart

 

 

7. 添加网段:

/etc/sysconfig/network-scripts/ifcfg-eth1

 

添加100网段的IP

[root@cds network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1

[root@cds network-scripts]# vi ifcfg-eth0:1

 

# Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express

DEVICE=eth0:1

BOOTPROTO=static

BROADCAST=192.168.100.255

HWADDR=B8:AC:6F:8F:1E:68

IPADDR=192.168.100.30

NETMASK=255.255.255.0

NETWORK=192.168.100.0

ONBOOT=yes

 

 

service network restart

 

8. 查看内存,cpu

Top 即时资源占用

 

Cpu情况:  

cat  /proc/cpuinfo

 

硬盘:

Dh

 

 

 

9. 查看端口

# netstat -anp |grep 8001

# ps -ef |grep ***

# kill -9 ***

 

10. 关闭防火墙

chkconfig --level 35 iptables off

 

 service iptables stop

11. 查看硬盘空间

查看整体的磁盘占用情况:

[root@bca files]# df -h

文件系统              容量  已用 可用 已用挂载点

/dev/sda2              49G  3.5G   43G   8% /

/dev/sda5             170G  160G  1.3G 100% /opt

/dev/sda1              99M   13M   82M  13% /boot

tmpfs                 2.0G  571M  1.4G  30% /dev/shm

 

查看某个目录下所有文件及文件夹占用磁盘空间大小:

[root@bca files]# du -sh *

400K    102701_100

400K    102705_100

1.8G    102901_30w

 

12. linux下查看程序关联库

ldd 程序名

 

13. 设置中文显示

export LANG="zh_CN.GB18030"

14. Xmanger启动

gnome-session

15. 查看内存命令

pmappro sc 2 1>pmap.log 2>1&

16. 查看一进程占用了多少个UDP端口

netstat -anp |grep sc | grep udp |wc -l

查看一进程"sc"占用了多少个UDP端口

 

17. 修改新服务器的安全级别

/etc/ selinux/config

 

SELINUX=enforcing

修改为:

SELINUX=disabled

 

18. 查找文件

Find dir name FileName

例如:find  /home/log/ -name  11.log

 

 

搜寻档案或目录:

which 查看可执行档案的位置

whereis 查看档案的位置

locate 配合数据库查看档案位置

find 实际搜寻硬盘去查询文件名称   慢!

 

find 在寻找数据的时候相当的耗硬盘!所以没事情不要使用 find 啦!有更棒的指令可以取代呦!那就是 whereis 与 locate 啰!!

whereislocate对与太新的文件,可能找不到,这时就需要find了。

 

[root@cds ~]# which passwd

/usr/bin/passwd

 

[root@cds ~]# whereis passwd

passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

 

[root@cds /]# find /etc/ -name passwd

/etc/pam.d/passwd

/etc/passwd

 

[root@cds /]# find /etc/ -name pass*

/etc/pam.d/passwd

/etc/passwd

 

 

 

19. 查找内容

grep High *.LOG

 

在所有LOG文件中查找字符串High

20. 查看执行过的命令

history

21. Tftp服务配置

 

编辑 /etc/xinetd.d/tftp 文件

 

  

# default: off

# description: The tftp server serves files using the trivial file transfer \

#       protocol.  The tftp protocol is often used to boot diskless \

#       workstations, download configuration files to network-aware printers, \

#       and to start the installation process for some operating systems.

service tftp

{

        disable = no

        socket_type             = dgram

   port                        = 69

        protocol                = udp

        wait                    = yes

        user                    = root

        server                  = /usr/sbin/in.tftpd

        server_args             = -s /tftp_dir –c  

        instances               = 50

        per_source              = 50

        cps                     = 100 20

        flags                   = IPv4

}

 

 

红色部分为修改。

 

   server_args             = -s /tftp_dir –c  

-s 参数指定chroot

-c 参数指定tftp可以创建文件

tftp_dir  为文件目录

 

 

rpm -qa|grep tftp

 

# mkdir tftp_dir

# chmod 777 tftp_dir/

/etc/init.d/iptables stop    停止防火墙

# service xinetd restart     重新启动tftp服务

 

#Setup

选择系统服务,去掉ipchainsiptables两项服务

 

TAG:

 

评分:0

我来说两句

Open Toolbar