Wednesday, 3 October 2012

UNIX: Permissions in UNIX

Question: Permissions in Unix
Answers: with 'chmod' command, the permissions in UNIX can be changed.

Say if someone says to a UNIX admin , 'Grant 740 or 755 permission on this server'
What does 740 or 755 mean?

Read (R) means : 4
Write (W) means : 2
Execute (X) means : 1

754 permission means:
7=4+2+1 ( give RWX permission to users)
5=4+1 ( give read and execute permission to group )
4=4+0+0 ( give read permission to others )


Saturday, 15 September 2012

UNIX: Word Count and file copy command

For word count type 'wc command.

bash -3.2$wc -l File1

The above command will show the total number of words in a file.
The output will be shown like below:

bash -3.2$wc -l File1
  7   22   104 File1

7 denotes total number of lines in a file
22 denotes total number of words in a file ( like 'unix program' means 2 words )
104 denotes total number of characters in a file.

For copying the file
bash -3.2$cp -i File1 newFile

i denotes here the interactive mode.
In this mode unix will as whether you want to overwrite the file or not.

See the screen shot for more details:


UNIX: Calculator

Calculator in UNIX:

bash -3.2$bc

typing 'bc' you will enter in calculator mode.
Now do any operations like 5*6 or 5+22 , etc press enter and the result will be shown.

If you do 11/2 , then the screen will show you 5 , it will not give results in decimal.

For viewing result in decimal , type
scale=2 
and now do any division , the result will be shown up to two places.

For coming out of the calculator mode , type 'quit' 
See the screen for more details.



Saturday, 8 September 2012

UNIX: Create directory and view files in ascending and descending order

Question 1: Create a directory in UNIX
Answer:
bash -3.2$ mkdir newFile

The above command creates a new directory with name 'newFile' 

Question 2: How to see files in a directory in ascending and descending order ?
Answer : 
bash -3.2$ ls -l
This command displays the files in a directory

bash -3.2$ ls -lt
This command displays the files first which are recently added and then older files. ( like 10AM, 9AM , 8AM ) in this order.

'-lt' means sorted by time

bash -3.2$ ls -ltr sorted by time in reverse order

In the below screen shot please see the time of the files.
See the green arrows to locate the commands.



Unix commands: Create files of zero blocks with figure

Question: Create files in unix of zero blocks.

Answer: The size of file in UNIX is measured in 'blocks'
1 Block= 512 bytes or 1024 bytes , it depends on administrator to set this limit.

bash -3.2$ touch abc pqr xyz

'bash' is the shell in unix.

The above  command will create three files 'abc' , 'pqr' and 'xyz' in unix of zero blocks.

See the below figure for this. The arrow is showing the size of files. In place of zero it can be any number like 2, 25, etc. Hope this makes it clear.

UNIX basic commands 1


Unix Commands


Question 1:  To go to a path or directory in Unix
Answer:  a) –bash -3.2$ cd ..   [ to come to one level up]
                     –bash -3.2$cd ../..   [ to come to two level up ]
                     –bash -3.2$cd /  [ to come to root directory ]
                     –bash -3.2$cd ../..   [ to come to two level up ]

Note : here bash is the shell in unix , as far as i know.

Question 2: What is the meaning of first character when you type ‘ls –l’. The output comes like this  crwx - -x-wx
Answer: if the first character is ‘c’ then it means file with special character
             if the first character is ‘d’ then it means file is a directory
            if the first character is ‘-’ then it means file is a plane text file
The following screen shot will make it clear
                                                                              



       

                                                                      
Question 3: Permissions in UNIX.
Answer: if you see the above screen shot , then after the first character ‘c or d or –‘ there are nine characters in the form of rwx-rx—x

 Small ‘r’ stands for read , small ‘w’ stands for write and small ‘x’ stands for execute

The first three characters are for ‘owners/users’ , then next three characters are for ‘Group’ and final three characters are for others. E.g,

               rwxr-xr- -
i) the first three characters rwx represents that the owners have got read,write and execute permissions on the file

ii) the next three characters r-x represents that ‘group’ has got read and execute permission on the file

iii) the final three characters r - - represents ‘others’ have read only permission on the file.
Hope this example makes permission in unix clear.


Thursday, 30 August 2012

Unix Questions-2

Question 4. How to configure informatica at UNIX level?
Answer: Awaiting for the answer

Question 5: Alternative of grep command
Answer: awk, sed

Question 6: How to delete a file in Unix
Answer: rm -r <filename>

Question 7: How to connect to a Data base in Unix
Answer:  $ sqlite3 <dbname>        [ This will connect to data base ]
    sqlite> select * from dual;
    sqlite> .import <dumpfile> <tablename>

Unix Questions

Question 1:Without opening in vi mode , replace a particular string.

Answer: It can be done by using 'sed' command in UNIX
The wikipedia link is given below

sed on Wikipedia

Example:
 sed -e 's/oldstuff/newstuff/g' inputFileName > outputFileName

Question 2: How to hold a workflow by a UNIX command.
Answer:
 'wait' command can do the job

Though 'sleep' command can can make a job to wait for a particular time
e.g. ->    sleep 5
This will sleep the job for 5 seconds

e.g of wait command:
wait [pid] [jobid]

pid= process id
jobid=job id

Question 3: How to display the 10th line of a file and last 2 lines in one command?
Answer: Awaiting for the answer
 
 
 
 
 
 
 
 
 
 

This blog addresses the questions related to ETL testing

This blog addresses the questions related to ETL testing.

It will have mainly three parts:

1. SQL
2. ETL Tools ( like Informatica mainly )
3. Unix

And some generic questions.