Changing hostname on RHEL 1. Change the HOSTNAME line in /etc/sysconfig/network 2. Change the hostname (FQDN and alias) in /etc/hosts 3. Run /bin/hostname new_hostname for the hostname change to take effect immediately. 4. Run /sbin/service syslog restart for syslog to log using the new hostname. A reboot is not required to change the system hostname.
How to enable SSH in Linux: - #chkconfig -list sshd #chkconfig –level 345 sshd on
How to enable mouse in Linux: - #vi /etc/X11/xorg.conf Section “device” (add the below line) Option “HWCursor” “off” #gdm restart
How to make a iso image: - #mkisofs -o /tmp/file_name.iso /u01/software_contents_folder_name
1. for firewall enable/disable:- chkconfig iptables off chkconfig ip6tables off Or system-config-securitylevel
2. to network services:-
service network restart service network start service network stop or /etc/init.d/network start /etc/init.d/network restart /etc/init.d/network stop
3. nmap localhost: - it will display the port details, which are all opened for this Box.
4. nautilus – it’ll work in putty. It will display all the windows in the Linux server.
1.rsync –a / root@: :- to copy the files from one Linux system to another. How to create a symbolic link in Linux: - $ ln –s target_filename symlink_filename xstart gdmstart
Tar:-
1. To tar the one or more files:-
$ tar –cvzf <.tar.gz file name with path> < source file name or Directory> . . . .
2.And find out the free space in one file system, and create swap space in that file system. $dd if=/dev/zero of=//swap bs=1024 count=value_in_bytes 3.Change the permission :- $ chmod 600 swapfile 4. Setup the swap file with the command : - $ mkswap swapfile 5. To enable the swap file immediately but not automatically at boot time: - $ swapon swapfile_name 6.To enable it at boot time, edit /etc/fstab to include: - /swap_file_location swap swap defaults 0 0 (When time the system boots, it will enable the new swap file.) 7. After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free. How to change the partition name in Linux:- 1.First create a required directory under the / partition:- $mkdir /oracle 2.Edit the /etc/fstab file:- Old entre: - LABEL=/ora /ora ext3 defaults 1 2 New entre: - LABEL=/ora /oracle ext3 defaults 1 2 3.Then unmount the old partition & mount the new partition:- $umount /ora $mount /oracle $rm –rf /ora (deleting the old partition) 4.To check the progress:- $df –h Use free space to create logical volume on LVM partition:-
[root@igloo ~]# vgdisplay --- Volume group --- VG Name VolGroup00 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 74.41 GB PE Size 32.00 MB Total PE 2381 Alloc PE / Size 193 / 6.03 GB Free PE / Size 2188 / 68.38 GB VG UUID JoY5DH-S0HV-Q5Dw-b2wC-Rpe0-XeaR-QFbG75
[root@igloo ~]# lvscan ACTIVE '/dev/VolGroup00/LogVol00' [5.03 GB] inherit ACTIVE '/dev/VolGroup00/LogVol01' [1.00 GB] inherit
[root@igloo ~]# lvscan ACTIVE '/dev/VolGroup00/LogVol00' [5.03 GB] inherit ACTIVE '/dev/VolGroup00/LogVol01' [1.00 GB] inherit ACTIVE '/dev/VolGroup00/LogVol02' [68.38 GB] inherit
[root@igloo ~]# mkfs -t ext3 /dev/VolGroup00/LogVol02 mke2fs 1.36 (05-Feb-2005) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 8962048 inodes, 17924096 blocks 896204 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=20971520 547 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424
Create the partition name with required name in / and mount it:- [root@igloo ~]#mkdir /oracle [root@igloo ~]#mount /oracle Check with the df –h command.
Run Level’s in Linux:- Run Level Generic Fedora Core Slackware Debian 0 Halt Halt Halt Halt 1 Single-user mode Single-user mode Single-user mode Single-user mode 2 Basic multi-user mode (without networking) User definable (Unused) User definable - configured the same as runlevel 3 Multi-user mode 3 Full (text based) multi-user mode Multi-user mode Multi-user mode - default Slackware runlevel
4 Not used Not used X11 with KDM/GDM/XDM (session managers) Multi-user mode 5 Full (GUI based) multi-user mode Full multi-user mode (with an X-based login screen) - default runlevel User definable - configured the same as runlevel 3 Multi-user mode 6 Reboot Reboot Reboot Reboot
The script below will display all files that are greaten then one megabyte in size. Note that the size parameter is specified in K-bytes. root> find . -size +1024 –print ./prodsid_ora_22951.trc Of course, you can easily append the xargs of –exec command to automatically remove the large file: root> find . -size +1024 –print|xargs –i rm \; This find command will do a "stats" on all files in a directory structure, showing the total size of all files in the directory. You can also incorporate the "df -k" command" find ${START_DIR} -mtime -${DAYS} |xargs stat -c "%s"|awk '{sum += $1}END{print sum}'
select sid, serial# from v$session s, dba_datapump_sessions d where s.saddr = d.saddr; select sid, serial#, sofar, totalwork from v$session_longops; rman> list backup; rman> list backup of database; rman> list backup summary; rman> list incarnation; rman> list backup by file; rman> list copy of database archivelog all; rman> list copy of datafile 1, 2, 3; rman> list backup of datafile 11 summary; rman> list backup of archivelog from sequence 1234; rman> list controlfilecopy "/u01/app/oracle/ctrl1.cpy"; rman> list backupset of datafile 1;
select session_key, db_name, min(r.start_time) start_rman, min(c.checkpoint_time) start_controlfile, min(d.checkpoint_time) start_datafile, min(a.first_time) start_archivelog, max(a.next_time) end_archivelog, min(b.start_time) start_set, max(b.completion_time) end_set, min(p.start_time) start_piece, max(p.completion_time) end_piece from rman.rc_backup_controlfile_details c join rman.rc_backup_datafile_details d on c.session_key = d.session_key join rman.rc_backup_archivelog_details a on c.session_key = a.session_key join rman.rc_backup_set_details b on c.session_key = b.session_key join rman.rc_backup_piece_details p on c.session_key = p.session_key join rman.rc_rman_backup_job_details r on c.session_key = r.session_key where db_key = (select db_key from rman.rc_database where name = 'alice1') and c.checkpoint_time >sysdate-14 and d.checkpoint_time >sysdate-14 and r.start_time >sysdate-14 and a.first_time >sysdate-14 and b.start_time >sysdate-14 and p.start_time >sysdate-14 and a.next_time >sysdate-14 and b.completion_time >sysdate-14 and p.completion_time >sysdate-14 group by session_key, db_name;
Cleanup redo log files that are more than 7 days old: - root> find $DBA/$ORACLE_SID/arch/*.log -mtime +7 -exec rm {} \;
You can query v$session and join into v$sql to see session and SQL information. This will show the SID for the session that is holding a PL/SQL package: -
select x.sid from v$session x, v$sqltext y where x.sql_address = y.address and y.sql_text like '%%';
Display distinct multiple columns with SQL: -
select deptno, loc, job, sal, ename from lsc_emp join lsc_dept using (deptno) order by deptno,loc,job,sal,ename;
The fuser command will show all UNIX process ID’s that are accessing any Oracle data file: - root> fuser –u /u01/app/oracle/myfile.dbf
select to_char(logon_time,'DD/MM/YYYY HH24:MI:SS') from v$session where sid=1;
How to display your Oracle session ID number: -
select sys_context('USERENV','SID') from dual;
select sid from v$mystat where rownum <=1;
select to_number(substr(dbms_session.unique_session_id,1,4),'XXXX') mysid from dual;
select distinct sid from v$mystat;
How to share and Access file on Solaris machine In this example I will share a file from jupiter machine and then access it on neptune machine. Both machine uses Solaris platform. 1)On jupiter machine,
bash-3.00$ hostname jupiter
Log on as a root user, bash-3.00$ su Password:
Change shell to bash # bash
To make share persistence (after reboot is will also show) edit /etc/dfs/dfstab entry. Here I want to share directory /export/home/oracle and sharing option is read write. # vi /etc/dfs/dfstab share -F nfs -o rw /export/home/oracle
rw means read write permission You can also want to give ro (read only) instead of read write.
If you want it temporary you can do, # share -F nfs -o rw /export/home/oracle Restart your nfs server. # /etc/init.d/nfs.server stop # /etc/init.d/nfs.server start
Have a look at whether nfs server is running or not. # ps -ef | grep nfs daemon 317 1 0 Oct 10 ? 0:00 /usr/lib/nfs/lockd daemon 311 1 0 Oct 10 ? 0:00 /usr/lib/nfs/statd daemon 313 1 0 Oct 10 ? 0:03 /usr/lib/nfs/nfsmapid daemon 291 1 0 Oct 10 ? 0:00 /usr/lib/nfs/nfs4cbd root 12741 12424 0 03:20:34 pts/4 0:00 grep nfs
This must show statd and lockd running. In fact The statd and lockd must be running on server and client.
Have a look at which file is shared and it's mode. # share - /export/home/oracle rw ""
2)On Saturn machine log on as a root user oracle@neptune ~$ su - Password:
Create a directory where you mount the network location. root@neptune /# mkdir /export/home/oracle/remote
Mount the network drive root@neptune /# mount -F nfs jupiter:/export/home/oracle /export/home/oracle/remote
Or, with more options issue, # mount -o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 jupiter:/export/home/oracle /export/home/oracle/remote See whether it is mounted. root@neptune /# df -h . .