基础命令

系列一、LINUX命令

查看系统发行版?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# cat /etc/issue | grep Linux  
  2. Red Hat Enterprise Linux Server release 5.5 (Tikanga)   

查看系统内核信息?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# uname -a  
  2. Linux hylhost.domain.com 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux   

查看系统内核参数信息?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # cat /etc/sysctl.conf  

补充:修改内核参数后使用sysctl –p命令使内核参数生效

通常情况下,如何修改oracle的环境变量?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # su - oracle  
  2. $ vi .bash_profile   

查看机器型号?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# dmidecode | grep "Product Name"  
  2.         Product Name: VirtualBox  
  3.         Product Name: VirtualBox  
  4. --次处命令使用在虚拟机环境下显示出如上信息   

查看网卡信息?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# dmesg | grep -i eth  
  2. e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection  
  3. ADDRCONF(NETDEV_UP): eth0: link is not ready  
  4. e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX  
  5. ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready  
  6. eth0: no IPv6 routers present  
  7. e1000: eth0 NIC Link is Down  
  8. e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX   

查看内存信息?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# cat /proc/meminfo  
  2. MemTotal:      2075468 kB  
  3. MemFree:        935756 kB  
  4. Buffers:        103892 kB  
  5. Cached:         877804 kB  
  6. SwapCached:          0 kB  
  7. Active:         340736 kB  
  8. Inactive:       735020 kB  
  9. HighTotal:     1179584 kB  
  10. HighFree:       198880 kB  
  11. LowTotal:       895884 kB  
  12. LowFree:        736876 kB  
  13. SwapTotal:     4192956 kB  
  14. SwapFree:      4192956 kB  
  15. Dirty:               8 kB  
  16. Writeback:           0 kB  
  17. AnonPages:       94088 kB  
  18. Mapped:          38204 kB  
  19. Slab:            52624 kB  
  20. PageTables:       3664 kB  
  21. NFS_Unstable:        0 kB  
  22. Bounce:              0 kB  
  23. CommitLimit:   5230688 kB  
  24. Committed_AS:   361940 kB  
  25. VmallocTotal:   114680 kB  
  26. VmallocUsed:      4716 kB  
  27. VmallocChunk:   109848 kB  
  28. HugePages_Total:     0  
  29. HugePages_Free:      0  
  30. HugePages_Rsvd:      0  
  31. Hugepagesize:     4096 kB   

查看硬盘分区?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# df -h  
  2. Filesystem            Size  Used Avail Use% Mounted on  
  3. /dev/sda3              25G  3.5G   21G  15% /  
  4. /dev/sda1             487M   16M  446M   4% /boot  
  5. tmpfs                1014M     0 1014M   0% /dev/shm   

查看硬盘型号?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. [root@hylhost ~]# cat /proc/scsi/scsi  
  2. Attached devices:  
  3. Host: scsi0 Channel: 00 Id: 00 Lun: 00  
  4.   Vendor: ATA      Model: VBOX HARDDISK    Rev: 1.0   
  5.   Type:   Direct-Access                    ANSI SCSI revision: 05  
如何修改IP、主机名?
[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 1. 地址解析文件# vi /etc/hosts  
  2.   
  3. 2. 网卡配置文件# vi /etc/sysconfig/network-scripts/ifcfg-eth0  
  4. 其中内容点为:  
  5. 网卡设备名:DEVICE=eth0  
  6. 是否为静态:BOOTPROTO=static  
  7. IP地址:IPADDR=192.168.56.103  
  8. 子网掩码:NETMASK=255.255.255.0  
  9. 硬件MAC地址:HWADDR=08:00:27:29:DB:B2  
  10. 是否启动:ONBOOT=yes  
  11.   
  12. 3. 网络配置文件:# vi /etc/sysconfig/network  
  13. 其中内容点为:  
  14. 网络配置:NETWORKING=yes  
  15. 关闭ipv6设置:NETWORKING_IPV6=no  
  16. 主机名:HOSTNAME=hyl   

如何创建组、创建用户?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # groupadd oinstall  
  2. # groupadd dba  
  3. # useradd -g oinstall -G dba oracle  

如何修改用户密码?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # passwd oracle   

如何查看用户的uid、gid?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # id oracle   

如何创建oracle用户目录?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # mkdir -p /u01/app/oracle   

如何修改目录的所属关系?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # chown -R oracle:oinstall /home/u01/app   

如何改变目录的权限?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # chmod -R 775 /home/u01/app   

如何添加swap分区?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 生成一个空文件:# dd if=/dev/zero of=/u01/swpf1 bs=1024k count=2048  
  2. 创建一个swap文件:# mkswap -c /u01/swpf1  
  3. 生成一个swap文件:# swapon /u01/swpf1  
  4. 修改开机自启动:# vi /etc/fstab  
  5. 添加/u01/swpf1     swap     swap    defaults    0 0   

如何解压各种常见的包?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. (例1)、解压.cpio.gz格式包  
  2. # zcat 10201_database_linux_x86_64.cpio.gz | cpio -idmv > /dev/null 2>&1  
  3.   
  4. (例2)、解压.cpio格式包  
  5. # cpio -idmv < 10201_database_linux_x86_64.cpio  
  6.   
  7. (例3)、解压.zip  
  8. # unzip p8202632_10205_Linux-x86-64.zip   

删除?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 删除目录: rm -rf <目录名>   

挂载?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 1. 挂载光盘的方法:  
  2. [root@hyl soft]# df -h  
  3. Filesystem            Size  Used Avail Use% Mounted on  
  4. /dev/sr0              4.2G  4.2G     0 100% /media/CentOS_6.2_Final  
  5. [root@hyl soft]# mount /dev/sr0 /cd  
  6. mount: block device /dev/sr0 is write-protected, mounting read-only  
  7.   
  8. 2. 挂载镜像文件的方法:  
  9. [root@hyl soft]# ls  
  10. WASND70_LINX64_Disk1.iso  WASND70_LINX64_Disk2.iso   
  11. [root@hyl soft]# mount -o loop /soft/WASND70_LINX64_Disk1.iso /cd1  
  12. [root@hyl soft]# mount -o loop /soft/WASND70_LINX64_Disk2.iso /cd2   

yum?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 1. 配置yum  
  2. # cd /etc/yum.repos.d/  
  3. 到此路径下修改yum.repo,注意几处细节:  
  4. baseurl=file:///cdrom1        //修改成挂载路径  
  5. gpgcheck=0                 //关闭校验  
  6. enabled=1                                      //启动  
  7. 2. 查询yum列表  
  8. # yum list  
  9.   
  10. 3. yum安装包  
  11. # yum install -y libaio*    

yum配置参考,可点击访问:配置yum举例

top关注可以得到哪些信息?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 第一部分:  
  2. 1. top:当前时间 | 系统运行时长 | 终端数 | 系统负载(1分钟前、5分钟前、15分钟前)  
  3. 2. tasks:系统进程总数 | 当前运行进程数 | 等待状态进程数 | 停止进程数 | 被复原进程数  
  4. 3. cpu:cpu使用率  
  5. 4. mem:内存总量 | 使用量 | 空闲内存量 | 缓冲使用中内存量  
  6. 5. swap:wasp分区使用情况  
  7. 第二部分:可以使用交互命令控制  
  8. 第三部分:内部进程使用情况列表   

rpm?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 1. 安装包  
  2. #rpm  -ivh  <rpm包名>  
  3.   
  4. 2. 查询是否已经安装的包  
  5. [root@hyl bin]# rpm -qa |grep numactl  
  6. numactl-devel-2.0.3-9.el6.x86_64  
  7. numactl-2.0.3-9.el6.x86_64  
  8.   
  9. 3. 卸载已经安装的包  
  10. [root@hyl ~]# rpm -e numactl-devel-2.0.3-9.el6.x86_64  
  11. [root@hyl ~]# rpm -e numactl-2.0.3-9.el6.x86_64  
 如何将结果输出到日志文件中?
[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 例如将安装包信息写入到rpm.log文件中,命令为:rpm -ivh binutils-2.17.50.0.6-14.el5.x86_64.rpm >> rpm.log 2>&1   

系列二、SQL指令

执行SQL脚本方法?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL>@/soft/mkuser.sql   

查看数据库里有哪些用户?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL> select username,account_status from dba_users;  
  2. USERNAME        ACCOUNT_STATUS  
  3. --------------- -------------------------  
  4. OUTLN           OPEN  
  5. SYS             OPEN  
  6. SYSTEM          OPEN  
  7. ROSE            OPEN  
  8. SCOTT           OPEN  
  9. ops$oracle      OPEN  
  10. TOM             OPEN  
  11. DBSNMP          EXPIRED & LOCKED  
  12. TSMSYS          EXPIRED & LOCKED  
  13. DIP             EXPIRED & LOCKED   

如何对用户进行简单的授权及回收权限

[sql] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL> grant connect,resource to scott;  
  2. SQL> grant select any table to scott with admin option;        
  3. --用户不仅被授权,而且可以把权限授予给其他人  
  4. SQL> grant INSERT, UPDATE, DELETE on scott.tcustord to ogg;    
  5. --举例:授予插入、更新、删除权限  
  6. SQL> grant all on directory dir to public;                     
  7. --目录权限(给所有人权限)  
  8. SQL> revoke select any table from scott;                 
  9. --回收权限时不能级联  
  10. SQL> revoke INSERT, UPDATE, DELETE any table from ogg;   
  11. --举例   

如何让其它用户访问dba视图?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 访问dba视图限制  
  2. SQL> show parameter o7  
  3. SQL> alter system set O7_DICTIONARY_ACCESSIBILITY=true scope=spfile;   
  4. --改变true使其它用户可以访问dba视图   

表空间?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL> create tablespace metro1 datafile '/u01/app/oradata/metroscore.dbf' size 1000mb;  
  2. --创建表空间  
  3. SQL>alter tablespace COMMON_PICTURE2012 drop DATAFILE '/oracle/oradata/hyl3209/COMMON_PICTURE2012_02.dbf';  
  4. --删除数据文件  
  5. SQL> alter tablespace COMMON_PICTURE2012 add DATAFILE '/oracle/oradata/hyl3209/COMMON_PICTURE2012_02.dbf' SIZE 3000M REUSE AUTOEXTEND ON NEXT 1000M MAXSIZE UNLIMITED;  
  6. --为表空间扩容并开启自动扩展功能  
  7. SQL> select tablespace_name,contents,status from dba_tablespaces;  
  8. --查看表空间状态  
  9. SQL> select name,bytes/1024/1024 M from v$datafile;   
  10. --查看表空间大小、数据文件大小  
  11. SQL> select tablespace_name,sum(bytes)/1024/1024 mb from dba_free_space group by tablespace_name;  
  12. --查看表空间剩余空间  
  13. SQL> select file_name,autoextensible,increment_by from dba_data_files;  
  14. --查看表空间是否自动扩展  
  15. SQL> drop tablespace hyltablespace including contents and datafiles cascade constraints;  
  16. --删除表空间  
  17. SQL> drop user hyl cascade;  
  18. --删除用户  
临时表空间查询相关?
[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. --dba_temp_files视图、v_$tempfile视图  
  2. SQL> select file_id,file_name,tablespace_name from dba_temp_files;    
  3. --查看临时表空间对应的文件及文件号  
  4. SQL> select tablespace_name,file_name,bytes/1024/1024 file_size,autoextensible from dba_temp_files;  
  5. SQL> select status,enabled, name, bytes/1024/1024 file_size from v$tempfile;  
  6. SQL> alter database tempfile '/u01/app/oracle/oradata/EMREP/temp01.dbf' drop;  
  7. --删除临时表空间  
  8. SQL> create temporary tablespace tempts tempfile '/u01/app/oracle/oradata/EMREP/temp01.dbf' size 200M autoextend on next 20M maxsize unlimited;  
  9. --创建临时表空间   

表空间扩容

[sql] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL> alter tablespace hyl add datafile '/u01/app/oracle/oradata/PROD/disk5/hyl.dbf' size 2000m;  
  2. --给hyl表空间扩容约2G  
  3. SQL> select tablespace_name,segment_space_management from user_tablespaces;  
  4. --查看表空间段管理方式(是否为自动扩展)  
  5. SQL> alter database datafile '/u01/app/oracle/oradata/PROD/disk5/hyl.dbf' autoextend on;   
  6. --开启自动扩展   

如何分析表?

[sql] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL> analyze table emp3 estimate statistics;   

配置监听后立即完成注册?

[sql] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. SQL> ALTER SYSTEM REGISTER;   

系列三、WAS相关

Linux下启动WAS的方法?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. ./startServer.sh server1  
  2. 路径一般在profiles文件路径下,例如“/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin”。   

WAS优化?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 1、连接池的连接数设置  
  2. 2、java虚拟机的堆大小设置(内存的分配)  
  3. 3、应用现场的端口号设置  
  4. 4、启动servlet高速缓存   

系列四、Oracle相关

oracle开机自启动设置?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # vi /etc/rc.d/rc.local  
  2. 添加如下面的例子:  
  3. su - oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/dbstart start"  
  4. su - oracle -c "/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"  
[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. # vi /etc/oratab  
  2. 更改为开机启动  
  3. xcky:/home/u01/app/oracle/product/11.2.0/db_1:Y   

逻辑备份的方法?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 导出复杂写法:  
  2. exp user/password@service buffer=128000 feedback=10000 filesize=15G file_format=D:\信息大表20100101_%s.dmp TABLES='P表' query=\"where create_datetime<=to_date('20100101','yyyymmdd')\" log=D:\bak\信息大表20100101.log  
  3.   
  4. 导入复杂写法:  
  5. >imp user/password@service fromuser=user1 touser=user2 feedback=10000 ignore=y commit=y filesize=15G file=D:\bak\信息小表名.dmp log=D:\bak\信息小表名Imp.log  

系列五、操作系统

如何打开win下注册表?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. 运行中输入regedit。   

如何快速使用远程连接?

[plain] view plain copy
 
 在CODE上查看代码片派生到我的代码片
  1. mstsc。   
 
转:http://blog.csdn.net/huangyanlong/article/details/39738501

posted on 2016-11-15 15:25  张冲andy  阅读(445)  评论(0编辑  收藏  举报

导航