Home‎ > ‎

How to

How to setup Jenkins for NodeJS application

posted Oct 24, 2017, 12:12 AM by Rahul Sehdev


Linux - how to copy, remove, archive files

posted Mar 31, 2013, 12:54 PM by Jageshwar Tripathi

Extracting a TAR

Extract linux tar gz (Gzip) archive

tar -xzvf mystuff.tgz

Extract linux simple tar archive

tar -xvf mystuff.tar

Extract linux tar archive to speciefied directory

tar -xvzf filename.tar.gz -C /desired/path

Remove files and directories

If directory is not empty

If you want to remove a directory with all its contents, you can use rm with the -r option. The -r option tells rm to remove a directory recursively:
$ rm -r dir1

Above command won't prompt you before removing. If you want a warning use following::
$ rm -ir dir1

If directory is empty

$ rmdir dir1

Copy or move

Standard format

$ cp -r dir1 dir2

To copy file1.txt in the current directory to the newdir directory.

cp file1.txt newdir

To copy a file with different name

cp /home/public_html/mylog.txt /home/public_html/backup/mylog.bak

[Copies the mylog.txt file in the public_html directory into the public_html/backup directory as mylog.bak. The files are identical however have different names.]

Copy all fines with an extension

cp *.txt newdir
[Copy all files ending in .txt into the newdir directory.]

Copy all files and directories

cp -r /home/hope/files/* /home/hope/backup

[Copies all the files, directories, and subdirectories in the files directory into the backup directory.]

Copies with overwrite

yes | cp /home/hope/files/* /home/hope/files2

[Copies all the files and subdirectories in files into the files2 directory. If files with the same name exist or it's prompted to overwrite the file it answers yes.]

Oracle - how to check sessions, temp and other things

posted Mar 31, 2013, 12:22 PM by Jageshwar Tripathi

Log in to oracle with DBA user (user having dba rights)

How to list sessions to a database?

SELECT MACHINE, STATE, STATUS, USERNAME, SCHEMANAME, OSUSER, PROGRAM, LOGON_TIME from V$SESSION

How to monitor used temp tablespace?

SELECT  TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
select TABLESPACE_NAME, BYTES_USED/(1024*1024*1024), (BYTES_FREE)/(1024*1024*1024) from V$TEMP_SPACE_HEADER;

Temporary segments


SELECT   A.tablespace_name tablespace, D.mb_total,
         SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
         D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
FROM     v$sort_segment A,
         (
         SELECT   B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
         FROM     v$tablespace B, v$tempfile C
         WHERE    B.ts#= C.ts#
         GROUP BY B.name, C.block_size
         ) D
WHERE    A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total;


Sort space use by session

SELECT   S.sid || ',' || S.serial# sid_serial, S.username, S.osuser, P.spid, S.module,
         S.program, SUM (T.blocks) * TBS.block_size / 1024 / 1024 mb_used, T.tablespace,
         COUNT(*) sort_ops
FROM     v$sort_usage T, v$session S, dba_tablespaces TBS, v$process P
WHERE    T.session_addr = S.saddr
AND      S.paddr = P.addr
AND      T.tablespace = TBS.tablespace_name
GROUP BY S.sid, S.serial#, S.username, S.osuser, P.spid, S.module,
         S.program, TBS.block_size, T.tablespace
ORDER BY sid_serial;

Sort space usage by statement

SELECT   S.sid || ',' || S.serial# sid_serial, S.username,
         T.blocks * TBS.block_size / 1024 / 1024 mb_used, T.tablespace,
         T.sqladdr address, Q.hash_value, Q.sql_text
FROM     v$sort_usage T, v$session S, v$sqlarea Q, dba_tablespaces TBS
WHERE    T.session_addr = S.saddr
AND      T.sqladdr = Q.address (+)
AND      T.tablespace = TBS.tablespace_name
ORDER BY S.sid;

How to see what DB/Schema is doing?

SELECT S.USERNAME||'('||s.sid||')-'||s.osuser UNAM
,s.program||'-'||s.terminal||'('||s.machine||')' PROG
,s.sid||'/'||s.serial# sid
,s.status "Status",p.spid
,sql_text sqltext
from v$sqltext_with_newlines t,V$SESSION s , v$process p
where t.address =s.sql_address
and p.addr=s.paddr(+)
and t.hash_value = s.sql_hash_value
and s.machine like '%VMCAST-ANA-ST-4%'
order by s.sid,t.piece

Windows - how to list files

posted Mar 31, 2013, 12:14 PM by Jageshwar Tripathi

Some times I need to get list of files in a file with specific criteria, it is simple and easy but remembering those basic commands and syntax is a challenge and I have to do search, research and waste time again and again. Here I am putting all that for my future reference and for some one who is also looking out for the same:

List files without directories and other information inside myfolder:
/b gives you bare format, /S is for subfolders (recursive)
Example:
c:\myfolder>dir /b *.*
New Text Document (2).txt
New Text Document (3).txt
New Text Document (4).txt
New Text Document - Copy (10).java
New Text Document - Copy (11).java
New Text Document - Copy (2).java
New Text Document - Copy (3).java
New Text Document - Copy (4).java


Example:
c:\myfolder>dir /b *.txt
New Text Document (2).txt
New Text Document (3).txt
New Text Document (4).txt

If you want names not the extension:

for /r %i in (*.war) do @echo %~ni>>apps.txt

Example:
c:\myfolder>for /r %i in (*.txt) do @echo %~ni
apps
New Text Document (2)
New Text Document (3)
New Text Document (4)


If you want date and time but not the directory info but just a clean list:

With default date time

DIR /S *.zip | FIND "/"

With specific date time

DIR /S * /T:C .zip | FIND "/"

C=Created

W=Written

Example:
c:\myfolder>DIR /S *.txt | FIND "/"
04/01/2013  12:34 AM                69 apps.txt
04/01/2013  12:30 AM                 0 New Text Document (2).txt
04/01/2013  12:30 AM                 0 New Text Document (3).txt
04/01/2013  12:30 AM                 0 New Text Document (4).txt



Oracle - how to find objects (schemas, tables etc)

posted Mar 31, 2013, 11:54 AM by Jageshwar Tripathi

Schemas

This is a query to get all Oracle schemas in an Oracle database instance.

select USERNAME from SYS.ALL_USERS order by USERNAME

 Tables

This is a query to get all Oracle tables that can be viewed by the current user.

select TABLE_NAME, OWNER from SYS.ALL_TABLES order by OWNER, TABLE_NAME

 The query can be filtered to return tables for a given schema by adding a where OWNER = 'some_schema' clause to the query.

  Views

This is a query to get all Oracle views that can be viewed by the current user.

select VIEW_NAME, OWNER from SYS.ALL_VIEWS order by OWNER, VIEW_NAME

 The query can be filtered to return views for a specific schema by adding a where OWNER = 'some_schema' clause to the query.

 Packages

This is a query to get all Oracle packages that can be viewed by the current user.

select OBJECT_NAME, OWNER from SYS.ALL_OBJECTS where UPPER(OBJECT_TYPE) = 'PACKAGE' order by OWNER, OBJECT_NAME

 To query for package bodies, substitute PACKAGE BODY for PACKAGE.

 The query can be filtered to return packages for a specific schema by adding a where OWNER = 'some_schema' clause to the query.

 Procedures

This is a query to get all Oracle procedures that can be viewed by the current user.

select OBJECT_NAME, OWNER from SYS.ALL_OBJECTS where upper(OBJECT_TYPE) = upper('PROCEDURE') order by OWNER, OBJECT_NAME

 The query can be filtered to return procedures for a specific schema by adding a where OWNER = 'some_schema' clause to the query.

 Procedure Columns

This is a query to get the columns in an Oracle procedure.

select OWNER, OBJECT_NAME, ARGUMENT_NAME, DATA_TYPE, IN_OUT from SYS.ALL_ARGUMENTS order by OWNER, OBJECT_NAME, SEQUENCE

 Functions

This is a query to get all Oracle functions for the current user.

select OBJECT_NAME, OWNER from SYS.ALL_OBJECTS where upper(OBJECT_TYPE) = upper('FUNCTION') order by OWNER, OBJECT_NAME

 The query can be filtered to return functions for a specific schema by adding a where OWNER = 'some_schema' clause to the query.

 Triggers

This is a query to get all Oracle triggers for the current user.

select TRIGGER_NAME, OWNER from SYS.ALL_TRIGGERS order by OWNER, TRIGGER_NAME

 The query can be filtered to return triggers for a specific schema by adding a where OWNER = 'some_schema' clause to the query.

 Indexes

This is a query to get all Oracle indexes.

select INDEX_NAME, TABLE_NAME, TABLE_OWNER from SYS.ALL_INDEXES order by TABLE_OWNER, TABLE_NAME, INDEX_NAME

Linux - check free space on filesystem

posted Feb 1, 2011, 3:28 PM by Jageshwar Tripathi   [ updated Mar 31, 2013, 12:32 PM ]

How to see filesystems and space used

df command reports file system usage

Example: df –k,

Options:

-a, --all
include filesystems having 0 blocks
-B, --block-size=SIZE use SIZE-byte blocks
-h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G)
-H, --si
likewise, but use powers of 1000 not 1024
-i, --inodes
list inode information instead of block usage
-k
like --block-size=1K
-l, --local
limit listing to local filesystems
--no-sync
do not invoke sync before getting usage info (default)
-P, --portability
use the POSIX output format
--sync
invoke sync before getting usage info
-t, --type=TYPE
limit listing to filesystems of type TYPE
-T, --print-type
print filesystem type
-x, --exclude-type=TYPE
limit listing to filesystems not of type TYPE
-v
(ignored)
--help
display this help and exit
--version
output version information and exit

1-6 of 6