Useful shortcuts for vi editor

Saturday, 11 October 2014

Windows makineye, Fedora 20 kurulum adımları

  1. Fedora 20 DVD(.iso) dosyasını sitesinden indir.
  2. Fedora 20 DVD(.iso) hazırlamak için Infra Recorder programını indir.
  3. Programı kurup, açtıktan sonra; Write Image seçeneğinden DVD burn edilir.
  4. Hard diski formatlamak için, Run'dan mmc yazıp, çalıştırılır.
  5. Add Snap-In -> Disk Management -> OK ile disk formatlanır.
  6. BIOS ayarlarından, bilgisayarın DVD'den boot olacak şekilde ayarla.
  7. Kurulum sırasında takılma(donma) hatasını almamak için Floopy drive -> disable yapılır.
Alternatif kurulum
  1. Universal USB installer programını kullanarak .iso dosyasından Linux kurulumu yapılabilir.
  2. Program gerekli dosyaları USB belleğe attıktan sonra, \boot\bootinst.bat çalıştırılır ve bilgisayar USB'den boot edilip, işletim sistemi kurulur.
  3. Hızlı bir linux deneyimi için SLAX dağıtımını tavsiye ederim.

Kurulum sırasında çıkan sorunlar ve çözümleri

Gigabyte anakartlarında USB Boot olmama problemi ve çözümü;
  • Öncellikle, BIOS ayarındaki Legacy USB storage detect seçeneğinin enable olduğuna emin olun. (BIOS Setup Menu -DEL tuşuyla -> Integrated Peripherals -> Legacy USB storage detect -> enable)
  • Daha sonra; USB sürücünüzü HP USB Disk Storage Format Tool ile formatlayın. (Linux için FAT32 seçilmeli)
  • Alternatif kurulum bittikten sonra; PC startup zamanında F12 ile Boot Menu'ye gidin. Açılan menuden + Hard Disk seçeneğine tıklayın.
  • Son olarak; açılan listeden USB Storage yani USB cihazınızı seçin. (Örn. USB-HDD0)

Linux işletim sistemi düzgün uninstall edilmediğinde boot sırasında ortaya çıkan grub rescue sorunu ve bu sorunun kalıcı çözümü;
  • Windows live CD veya Windows kurulum DVD ile Command Prompt penceresinden bootrec /fixmbr komutu çalıştırılır. Daha sonra bilgisayar restart edilir.
Daha fazla ayrıntı için tıklayınız.

Geçici çözüm olarak BIOS'dan boot sırası değiştirilir.
  • USB flash bellek format sorunu ortaya çıkarsa şu komutlarla flash belleğe format atılır.
    - CMD > diskpart > list disk > select disk 1 (genelde bu olur) > clean > create partition primary > select partition 1 > active > assign > formatla
Daha fazla ayrıntı için tıklayınız.

How can I do watermark my pictures?

You can easily watermark your photographs or pictures with this link. It is a free and online tool.

Bye. :)

What is the SID (Service Identifier) in Oracle?

Oracle uses service (oracle service) for connecting instance database by looking to sid. You can find which service names (sid) are using in database services with this command easily.

Connection format: IP:LSTN_PORT/SID
e.g.
C:\Users\Alper> lsnrctl status


LSNRCTL for 32-bit Windows: Version 11.2.0.2.0 - Production on 11-EKI-2014 12:01:25

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.2.0 - Production
Start Date                11-EKI-2014 11:49:12
Uptime                    0 days 0 hr. 12 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\listener.ora
Listener Log File         C:\oraclexe\app\oracle\diag\tnslsnr\Alper-PC\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Alper-PC)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Alper-PC)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
  Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

Friday, 10 October 2014

How to define a new Linux user?

# useradd -d /home/alper -g gpalper -s /bin/csh -m alper -u 1008
# passwd alper

To check it:
$ egrep -i "^alper" /etc/passwd
$ egrep -i "^gpalper " /etc/group
or
$ grep alper /etc/passwd
$ grep gpalper /etc/group

How to see that a package and a program exists in SUSE Linux ?

for package;
$ rpm –ql test_package 
or 
rpm –qa test_package

for program;
$ whereis test_program

How to resolve "Enterprise Manager Agent status is Unavailable" issue in Linux?

Please run below commands as oracle system user.
  • emctl clearstate agent 
  • emctl upload agent

[SOLUTION] ORA-28003 problem

Please execute the command as "sys";

SQL> ALTER PROFILE DEFAULT LIMIT PASSWORD_VERIFY_FUNCTION NULL;

How to see related user process in Linux?

In command window;

$ ps –u alper

(“alper”, linux system user)

[SOLUTION] ORA-00845 problem


By default /dev/shm is created to use half size of your server physical memory

If you see that MEMORY_TARGET not supported on this system​ while starting Oracle Database Instance in sqlplus window, please follow the instructions as below;

For this case, you should increase memory that using by Oracle as root user (e.g. size=10240m means 10 GB RAM)
-> umount tmpfs
-> mount -t tmpfs shmfs -o size=10240m /dev/shm

If you encounter any error like that "the system is using already", (e.g. process id of /dev/shm is "5265")
-> fuser -m /dev/shm
or
-> lsof /dev/shm
-> kill 5265

Ref: http://blog.yannickjaquier.com/linux/linux-memory-usage.html

How to change oracle max connection limits for "maximum connection exceed problem"?

$ sqlplus
Enter user-name: sys as sysdba @sys
to see parameter process for altering system sessions (processes (integer) = sessions)

SQL> show parameter session 
SQL> ALTER system SET sessions= 300 scope=spfile;
SQL> show parameter process
SQL> ALTER system SET processes= 300 scope=spfile;

Finally, restart the database to activate all changes

How to drop a user from database in Oracle?

Please login to database server with ssh as oracle user and run that commands.
  • sqlplus / as sysdba
  • SQL> DROP USER testuser CASCADE; --If testuser's schema contains objects such as tables, then you must use the CASCADE clause to drop testuser.
  • SQL> exit

How to see the size of users on specific tablespace in Oracle?

Please execute following command as "sys";

SELECT tablespace_name, owner, segment_type "Object Type",
       COUNT(owner) "Number of Objects",
       ROUND(SUM(bytes) / 1024 / 1024, 2) "Total Size in MB"
FROM   sys.dba_segments
WHERE  tablespace_name IN ('ALPERTABLESPACE')
GROUP BY tablespace_name, owner, segment_type
ORDER BY tablespace_name, owner, segment_type;

How to login sqlplus on linux command window in Linux?

$ sqlplus scott/tiger@orcl

@orc1 -> tnsnames.ora – connection node name
scott -> db username
tiger -> db username password 

$ sqlplus / as sysdba@orcl

Login as sysdba with this.

How to see tablespace usage for Oracle Database?

Please execute following commands as "sys";

select b.tablespace_name, tbs_size SizeMb, a.free_space FreeMb
 from  (select tablespace_name, round(sum(bytes)/1024/1024 ,2) as  free_space from dba_free_space
 group by tablespace_name) a,
 (select tablespace_name, sum(bytes)/1024/1024 as tbs_size
from dba_data_files
 group by tablespace_name) b
where a.tablespace_name(+)=b.tablespace_name

How to add a alias for using by all users in Linux?

Please edit /etc/bash.bashrc, for example;
  • alias c='cd' 
  • alias a='dir'
  • alias l='ls -l'
  • alias p='cd -'
  • alias '..'='cd ..'

How to trace Linux CPU usage on system?

mpstat -P ALL 20
  •  Shows that CPU usage information related to each core and all cpu in every 20 seconds.
sar 10
  •  Shows that CPU usage information related to all cpu in every 10 seconds.
Examples:

oracle@alperdb:~> mpstat -P ALL 1
Linux 2.6.32.12-0.7-default (alperdb)  02/21/2014  _x86_64_

09:12:46 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
09:12:47 AM  all    0.53    0.00    0.00    0.53    0.00    0.00    0.00    0.00   98.94
09:12:47 AM    0    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
09:12:47 AM    1    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
09:12:47 AM    2    1.11    0.00    0.00    0.00    0.00    0.00    0.00    0.00   98.89
09:12:47 AM    3    1.14    0.00    0.00    2.27    0.00    0.00    0.00    0.00   96.59

oracle@alperdb:~> sar 10
Linux 2.6.32.12-0.7-default (alperdb)  02/21/2014  _x86_64_

09:16:13 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
09:16:23 AM     all      0.20      0.00      0.05      0.18      0.00     99.57
09:16:33 AM     all      0.90      0.00      0.32      0.22      0.00     98.56
09:16:43 AM     all      1.89      0.00      0.47      0.32      0.00     97.32

Linux - command line keyboard shortcuts

Here are some basic shortcuts while you are in command window;

CTRL + a -> go to begin of the line
CTRL + e -> go to end of the line
CTRL + d -> log-out
CTRL + w -> remove one word
CTRL + u -> remove all line
CTRL + r -> search for a word in history
CTRL + ins -> paste the clipboard

"cd -" -> go to last directory

How to kill a session with custom procedure?

-If you are authorized to sys user.

Firstly run this procedure to compile and save.
---
CREATE OR REPLACE PROCEDURE P_KILL_SESSION(DATABASE_USER_NAME IN VARCHAR2, STR_RESULT OUT VARCHAR2)
   IS
str_exec VARCHAR2(1000);
   BEGIN
     FOR cur_session IN (SELECT sid, serial#
                         FROM v$session
                        WHERE username = upper(DATABASE_USER_NAME)
                          AND status != 'KILLED') LOOP                          
      str_exec := 'alter system kill session ''' || cur_session.sid || '' || ',' || cur_session.serial# ||'''';      
      BEGIN
          execute immediate str_exec;
          STR_RESULT := 'Sessions are terminated successfully';
      EXCEPTION
      WHEN OTHERS THEN
        RAISE_APPLICATION_ERROR ( -20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM ) ;
      END;     
   END LOOP;
END;
---

To use it;
In command window-editor,

var STR_RESULT VARCHAR2
EXEC P_KILL_SESSION('test_user',:STR_RESULT)
--test_user session could be killed

How to overcome special character problem in Windows?

You can type special character with using ASCII Table.
eg. If you want to type backslash (\), press ALT + 92

You can reach all ASCII table via this link. (Refer to DEC)

Note: Please be sure that NUM_LOCK is on.

[SOLUTION] ORA-06550 and PLS-009005 problems

Please login to database server with ssh as oracle user and run that commands.
  • sqlplus / as sysdba
  • SQL> grant execute on DBMS_JOB to ALPERDB_USER;
  • SQL> exit