Krishna Logo
qa training in canada now
Divied
Call: Anusha @ 1 (877) 864-8462

 

Latest News
Home Navigation Divied
DATABASE Navigation Divied UNIX/LINUX
Showing 1 - 10 of 18 Previous | 1 | 2 | Next
UNIX/LINUX
Subcategories
 

USE THE BELLOW LINK TO DOWNLOAD THE LINUX SOFTWARE    ...  

 
 
2
UNIX
----
To log into any computer on network you need 
1. host name
2. user name
3. password
 
 
putty.exe - it connects to another unix machine in the network.
 
1 bit
8 bit = 1 byte
 
$ - Unix Prompt
 
Permissions of users:
---------------------
Read    - r - 4
write   - w - 2
Execute - x - 1
 
rwx or 421
 
user  - rwx
group - r_x
other - rw_
 
'/' - Root
 
UNIX - Case sensitve. 
all the commands in unix are in small letters
 
1. pwd
gives the path of the folder
 
2. clear
clear the work area
 
3. exit
exits out of the terminal
 
4. cal
gives the calender
 
5. date - display current timestamp
 
  date +%D - date part 
      +%T - time part of timestamp
+%H - hour
+%M - minute
+%S - Second
+%d - day (just day of the month)
+%m - 2 digit month
+%y - 2 digit year
+%Y - 4 digit year
+%b - abbreviated month
+%B - Fullname of the month
+%a - Abbreviated weekday 
+%A - Abbreviated Full Name Weekday
 
6. logname - displays the username
 
7. hostname - displays the hostname(server name)
 
8. man - similar to help
 
9. ls - displays all the directories and files in your current working directory
 
   ls -R  - display all the directories, files and subdirectories in your current working directory
      -l  - long list 
      -r  - reverse order
      -lr - long list in reverse order
      -t  - timestamp wise
      -lt
      -ltr or -lrt
      -a  - all files including hidden files 
      -P* - display directories starting with P
 
10. passwd - change the password
 
11. history - It will display all unix commands you used till date
    ! - can be used to get the previous commands
        !
 
12 mkdir - make a directory
   mkdir
 
13. cd -- change directory
    cd ..       - takes one step back 
    cd ../..    - 2 steps back
    cd f1/f2/f3 - 3 steps forward 
    cd ../f1    - 1 step back and 1 step forward
    cd /        - comes out of the home folder
    cd -        - Takes you to the last working directory
 
14. touch - creates a empty file with the current timestamp
       touch
    touch -t - changes the file to a specific time
       touch -t yymmddhhmm  
       - yymmddhhmm - yearmonthdatehourmin
 
15. cat - Displays content of a existing file or create a new file
cat - display content of the file 
cat > - creates a newfile or opens up a existing file for editing and all the existing data in 
  that file will be overwrited by the new file
cat >> - adds the data to the existing data or creates a new file
cat > - File1 data will be overwritten to File 2 data
cat >> - File 1 data will be added to the File 2 data 
 
16. cp - copies files and copied files have new timestamp
cp -p - copies files with the same timestamp
cp -i - will ask the permission to be over written or not
 
17. mv - rename the file
mv oldfilename newfile
 
18. chmod - change the permissions of a file
read    - 4
write   - 2
execute - 1
 
read - r user - u all - a
write - w group - g
execute - x others - o
 
+ Add permission
- Remove permission
= Assign Permission
 
     user group others
7    5   4
$ chmod 754 pr1
 
pr1 r-x rwx r--   ----> permissions
 
$ chmod u+w pr1
pr1 rwx rwx r--   ----> permissions
 
$ chmod g-w pr1
pr1 rwx r-x r--   ----> permissions
 
$ chmod u=rwx pr1
$ chmod u=rwx,g=rx pr1
 
19. rm - removes files
rm
rm * - removes all the files starting with that letter
 
20. rmdir - removes directories
rmdir -  removes empty directory 
rm -r - removes directory and the content inside it
rm -ir - asks for confirmation
 
21. file - displays what type of file 
$ file
 
22. head - displays number of lines from top
$ head -5 - displays first 5 lines
 
23. tail - displays number of lines from bottom
$ tail -3 - displays last 3 lines
 
24. link - links one file to another file. 
- you can always link to new file you cannot link to existing file.
$ link
 
25. find - finds the files and directories 
$ find . -name '' -print
. - specifies the working folder
-name - syntax that says we are searching a name
- specifies the name you are searching in the folder 
-print - prints the output in the window 
or
 
$ find /home/krishnatraining1 -name '' -print
 
$ find . -name '' -type f -print --> displays files with this name
$ find . -name '' -type d -print --> displays directories with this name
$ find . '*.txt' -print --> displays all the .txt files in the working folder
$ find . '*.jpeg' -print 
 
26. comm - compares two files and displays the common values in one line and unmatched records in another line
 
$ comm
 
 
27. cmp - compares both the files and returns no data if both the files are equal.
 
$ cmp  
 
28. sort - will sort the data in the file
 
$ sort     - Ascending
$ sort -r  - Descending
$ sort -n  - Sorting on the numbers
$ sort -t ';' -k2 - sorting delimeted files
    -k2 - specifes sorting on columns
$ sort -k2 - if the file is a tab delimited file
 
29. wc - counts of lines, words or letters(characters)
 
$ wc -l - Count of lines in the file
$ wc -w - Count of Words in the file
$ wc -c - Count of characters(letters) in the file
 
30. FTP - File Transfer Protocol
 
30. $ ftp - Command to log into the remote server
   ftp cd  - when logged in remote server 'cd' will change folders in remote server
31. ftp lcd - when logged in remote server 'lcd' will change folders in local server
32. ftp lpwd - displays the local machine path
33. ftp put - copies files from local to remote server 
34. ftp get - copies files from remote to local machine
35. ftp bye - logging out of remote server
 
$ pwd
- /home/main
$ ftp userx/password @ xyz
ftp pwd
- /x
ftp cd y/z
ftp pwd
- /x/y/z
ftp lcd b/b1
ftp put customer.txt
ftp cd ../..
ftp lcd ../b2
ftp get x.txt
ftp cd y/z
ftp lcd ../../c/c1
ftp get z.txt
ftp bye
 
36. diff - compare two files and display difference in details. It gives no output if both the files are equal
 
$ diff
a - added 
c - changed
d - deleted
 
37. printenv - Prints all the environmental variables
 
$ printenv
 
38. echo - displays the text 
 
$ echo
 
39. sleep - it allows the system to sleep for specified time 
 
$ sleep 5s - seconds
$ sleep 5m - minutes
$ sleep 5h - hours
$ sleep 5& - sleep process running in background
 
40. ps - it shows all the processes running and gives the information related that process - PID (Process ID)
 
$ ps
 
41. fg - it brings the process to foreground
   
$ fg % ProcessID
 
42. bg - it brings the process to background 
 
$ bg % ProcessID
 
43. kill - completly kills the process - force kill until the root
 
$ kill -9 ProcessID
 
44. nohup - no hangup, makes the process run on the server
 - process runs in background
$ nohup ProcessID
 
45. cut - to displays specific columns
- can be used for all the delimiters
 
$ cut -f c1,c2...
 - by default this command will execute for tab delimited file
$ cut -f c1,c2,.. -d ';'
 - for a ';' delimited file
 
46. gzip - will compress the file (similar to winzip)
- original file will be replaced with the zipped file
 
$ gzip  
 
47. gunzip - will uncompress the file
 
$ gunzip
 
48. zcat - display the contents of a compressed file (zipped)
 
$ zcat
 
49. more - allows you to read long documents
 
$ more
enter - next line
space - next page
q     - quit 
 
50. less - allows you to read the documents in smaller compressed window
 
$ less
enter - next line
space - next page
q     - quit 
 
51. grep - globally searches the complete file for a word or a phrase and prints
 
$ grep 'search_phrase'
- will display all the lines that has the search_phrase
 
$ grep -w 'search_phrase'
- will display all the lines considering search_phrase as a word.
 
$ grep -i 'search_phrase'
- Makes the search case sensitive independent
 
$ grep -v 'search_phrase'
- Displays all the lines that doesn't have the search+phrase
 
$ grep -n 'search_phrase'
- Displays all the line that has the search_phrase with the line numbers
 
$ grep '^I'
- displays all the lines starting with 'I'
 
$ grep -i '^I'
- displays all the lines starting with 'I' and makes it case sensitve independent
 
$ grep 'I$'
- displays all the lines ending with 'I'
 
$ grep '^IS$'
- all the lines starts and ends with 'IS'
 
$ grep '^$'
- Displays the null value lines
 
$ grep '^..$'
- Display any line that has two characters
 
52. mail - helps to email the recepient
 
$ mail -s 'HELLO' abc@abc.com --> subject
$ mail -c  --> cc
$ mail -b  --> bcc
$ mail -a  --> attach a file
 
53. split - it helps to split the big file into multiple small files
 
$ split
- by default it splits the lines in 1000 lines interval
 
$ split -l2000
 
$ split -d
- display number instead of alphabets
 
54. whoami - shows the current user name
 
$ whoami
 
55. uname - gives the processor and computer details
 
$ uname
$ uname -a
 
56. uniq - this is a unix untility that collapes or merges identical rows into a single row
         - Always provide sorted input into the uniq command
 
$ uniq
$ uniq -i - removes case sensitivity
$ uniq -c - count of each row
$ uniq -d - display duplicate rows
$ uniq -u - diaplay only unique rows
 
 '|' - pipe operator --> can be used to give input for the next statement
 ';' --> it seperates the commands
 
57. sed - stream editor
 
$ sed -n r1,r2..p
- displays the lines r1, r2
 
$ sed s/is/was/g
- replaces the existing string with a new string
 
UNIX CLASS NOTES
Date Posted: 11/12/2013

UNIX ---- To log into any computer on network you need  1. host name 2. user name 3. password     putty.exe - it connects to another unix machine in the network.   1 bit 8 bit = 1 byt...  

 
 

  download putty.exe file to connect to the unix server using t...  

 
 

CLICK HERE TO DOWNLOAD

 
 

Location of System logs The "/etc/rsyslog.conf" file defin...  

 
 
6INTERVIEW TECHNICAL WRITTEN TEST
Date Posted: 05/31/2013

  1. what are sed, awk,xargs
  2. how do you list files in directories
    Ans: ls command

     
  3. how do you log files
    Ans: 
  4. grep with directories
     
  5. cat cmmand
     
  6. how to look nth line in file, example i want to see the line 789 in a file which has 1000 lines
    sed -n '789p' file
  7. question about file system
  8.  
  9.  
  10. what is chmod .. what are different permissions
    Chmod is a Unix command that lets permission levels be assigned to each file or directory.
     
    The three digits in a permission (for example, 644), represent permissions for the owner, the group and the world, respectively. Common digits include 4 (read only), 5 (read and execute), 6 (read and write) and 7 (read, write and execute). These are permissions as far as the operating system is concerned, not visitors to your web site. In a secured hosting environment, 666 or 777 are not dangerous, but 644 or 664 are the recommended permissions for everyday use. Please read about why chmod 777 is NOT a security risk for more information on the topic.
  11. what is lprm
    lprm:  this command remove jobs from the line printer spooling queue
     
  12. communication command in unix
    click here to download
  13. there were two syntax what would be the output
  14. if i have a unix file with 100 lines in it how do you retrieve 30 to 40 lines
    Ans: tail -70 ||head -40
    tail command retrieves last 70 lines and out put of tail command will be given to input of head command and it will retrieve  top 40 of the 70 lines retrieved in the previous tail command
  15.  

 

  1. who,sort, cat,file,logfiles
     
  2. how to count words in file
    wc command will give the number words in a file
  3.  
  4. in sql
  5. what are dcl , dml, ddl
  6. recursive command in sql
  7. What is view
  8.  
  9.  
  10. difference between having and where clause
  11. what is self join and explain with example
  12.  
  13. there were few tables
  14. asked me to write query to find duplicate rowsasked me to write query to find duplicate rows
  15. delete duplicate rows
  16.  
  17. replace all the null values in manager column as no manager
  18.  
  19. two tables in two different database compare two rows
  20.  
  21.  
  22. there were two query where i had to use group by and having clause
  23. Random 25 record from the table
  24. questions about primary key in table(can table has two primary key
  25. who can write primary key in table
  26. how to fill default value in the field
  27. want to delete field content from the file what will you use drop,delete,truncate?
  28. whatis dml statement
  29. delete
  30. update
  31. insert
  32. these are mixed question with new and old one

 
 

http://www.ee.surrey.ac.uk/Teaching/Unix/unixintro.html

 
 
8

 

UNIX Introduction

What is UNIX?

UNIX® License PlateUNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer work. It is a stable, multi-user, multi-tasking system for servers, desktops and laptops.

UNIX systems also have a graphical user interface (GUI) similar to Microsoft Windows which provides an easy to use environment. However, knowledge of UNIX is required for operations which aren't covered by a graphical program, or for when there is no windows interface available, for example, in a telnet session.

Types of UNIX

The Linux PenguinThere are many different versions of UNIX, although they share common similarities. The most popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X.

Here in the School, we use Solaris on our servers and workstations, and Fedora Linux on the servers and desktop PCs.

The UNIX operating system

The UNIX operating system is made up of three parts; the kernel, the shell and the programs.

The kernel

The kernel of UNIX is the hub of the operating system: it allocates time and memory to programs and handles the filestore and communications in response to system calls.

As an illustration of the way that the shell and the kernel work together, suppose a user types rm myfile (which has the effect of removing the file myfile). The shell searches the filestore for the file containing the program rm, and then requests the kernel, through system calls, to execute the program rm on myfile. When the process rm myfile has finished running, the shell then returns the UNIX prompt % to the user, indicating that it is waiting for further commands.

The shell

The shell acts as an interface between the user and the kernel. When a user logs in, the login program checks the username and password, and then starts another program called the shell. The shell is a command line interpreter (CLI). It interprets the commands the user types in and arranges for them to be carried out. The commands are themselves programs: when they terminate, the shell gives the user another prompt (% on our systems).

The adept user can customise his/her own shell, and users can use different shells on the same machine. Staff and students in the school have the tcsh shell by default.

The tcsh shell has certain features to help the user inputting commands.

Filename Completion - By typing part of the name of a command, filename or directory and pressing the [Tab] key, the tcsh shell will complete the rest of the name automatically. If the shell finds more than one name beginning with those letters you have typed, it will beep, prompting you to type a few more letters before pressing the tab key again.

History - The shell keeps a list of the commands you have typed in. If you need to repeat a command, use the cursor keys to scroll up and down the list or type history for a list of previous commands.

 

Files and processes

Everything in UNIX is either a file or a process.

A process is an executing program identified by a unique PID (process identifier).

A file is a collection of data. They are created by users using text editors, running compilers etc.

Examples of files:

  • a document (report, essay etc.)
  • the text of a program written in some high-level programming language
  • instructions comprehensible directly to the machine and incomprehensible to a casual user, for example, a collection of binary digits (an executable or binary file);
  • a directory, containing information about its contents, which may be a mixture of other directories (subdirectories) and ordinary files.

 

The Directory Structure

All the files are grouped together in the directory structure. The file-system is arranged in a hierarchical structure, like an inverted tree. The top of the hierarchy is traditionally called root (written as a slash / )

Unix File Structure

In the diagram above, we see that the home directory of the undergraduate student "ee51vn" contains two sub-directories (docs and pics) and a file called report.doc.

The full path to the file report.doc is "/home/its/ug1/ee51vn/report.doc"

Starting an UNIX terminal

To open an UNIX terminal window, click on the "Terminal" icon from Applications/Accessories menus.

Gnome Menus

 

An UNIX Terminal window will then appear with a % prompt, waiting for you to start entering commands.

Unix Terminal window

 

UNIX COMMANDS
Date Posted: 06/28/2012

  UNIX Introduction What is UNIX? UNIX is an operating system which was first developed in the 1960s, and has been under constant development ever since. By operating system, we mean the suite of programs which make the computer w...  

 
 
Date Posted: 05/05/2012

PUTTY DOWNLOAD LINK http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe Introduction to the UNIX Operating System What is UNIX? Files and processes The Directory Structure Starting an UNIX terminal &nbs...  

 
 
10

Awk command

awk -- it allows the user to manipulate files that are structured as columns of data and strings, JUST SEE THE FIRST EXAMPLE U WILL GET IDEA

Example 1:
Assume you want to process a file called file 'dimensions' that has the following content:

12 8
15 24
9 12

Assume you want to generate a file 'area' that has the same content as the file 'dimensions', but has one more column that contains the product of the two numbers on each line:

12 8 96
15 24 360
9 12 108

The following command would accomplish that:

awk '{print $0, $1*$2}' dimenions > area

 awk -- it allows the user to manipulate files that are structured as columns of data and strings. (--continued after the ads...)

Once you understand the basics of awk you will find that it is surprisingly useful. You can use it to automate things in ways you have never thought about. It can be used for data processing and for automating the application of Linux / Unix commands. It also has many spreadsheet-type functionalities.

There are two ways to run awk:

  1. A simple awk command can be run from the command line.
  2. More complex tasks should be written as awk programs ("scripts") to a file. Examples of each are provided below. A simple awk command is of the form

% awk 'pattern {action}' input-file > output-file

meaning: take each line of the input file; if the line contains the pattern apply the action to the line and write the resulting line to the output-file.

If the pattern is omitted, the action is applied to all lines:

% awk '{action}' input-file > output-file

By default, awk works on files that have columns of numbers or strings that are separated by white space (tabs or spaces), but the -F option can be used if the columns are separated by another character. awk refers to the first column as $1, the second column as $2, etc. The whole line referred to as $0.

Example 1:

Assume you want to process a file called file 'dimensions' that has the following content:

12 8
15 24
9 12

Assume you want to generate a file 'area' that has the same content as the file 'dimensions', but has one more column that contains the product of the two numbers on each line:

12 8 96
15 24 360
9 12 108

The following command would accomplish that:

awk '{print $0, $1*$2}' dimenions > area

The term {print $0, $1*$2} means: first print the whole line ($0), then print the product of the number in column 1 ($1) and the number in column 2 ($2).

Example 2:

If you want the output file to contain only those lines on which the first number is less than the second number, you would use the following command:

awk '$1 < $2 {print $0, $1*$2}' dimenions > area2

The contents of file area2 would then be:

15 24 360
9 12 108

Example 3:

The following command does exactly the same as the command in Example 2, but it illustrates how awk can be combined with other Unix commands:

cat dimenions | awk '$1 < $2 {print $0, $1/$2}' > area2

Used by itself, the command 'cat dimenions' simply prints the contents of file 'dimenions' to the sceen. However, if a command is followed by a '|' (called "pipe"), the contents goes as input to command to the right of the '|'.

Example 4:

Assume you have hundreds of files you want to move into a new directory and rename them by appending a .new to the filenames. Assume all the files have names that start with "data", they need to be moved to ../newdata, and need to have a '.new' appended to the name. Use the following command to accomplish this:

ls data* | awk '{print "mv "$0" ../newdata/"$0".new"}' | csh

ls data* lists the filenames. This output list is then "piped" into awk. Since there is no pattern specified, awk proceeds to print something for each line. For example, if the first two lines from 'ls data*' produced data1 and data2, respectively, then awk would print:

mv data1 ../newdata/data1.new
mv data2 ../newdata/data2.new

These are Unix commands that are executed by piping them into the "csh" command ("csh" is an operating system shell).

More complex awk scripts need to be run from a file. The syntax for such cases is:

cat file-1 | awk -f script-1.awk > file-2

where file-1 is the input file, file-2 is the output file, and script-1.awk is a file containing awk commands. awk scripts that contain more than one line need to be run from files. The following example is an awk-script that would saved in a file (e.g, script-1.awk) and executed by the above command.

Example 5:

The following awk-script prints frequency a histogram of the first column of the input file (assumed to contain numbers):

($1 > 0.1) && ($1 <= 0.2) {num_b = num_b+1}
($1 > 0.2) && ($1 <= 0.3) {num_c = num_c+1}
($1 > 0.3) && ($1 <= 0.4) {num_d = num_d+1}
($1 > 0.4) && ($1 <= 0.5) {num_e = num_e+1}
($1 > 0.5) && ($1 <= 0.6) {num_f = num_f+1}
($1 > 0.6) && ($1 <= 0.7) {num_g = num_g+1}
($1 > 0.7) {num_h = num_h+1}
END {print num_a, num_b, num_c, num_d, num_e, num_f, num_g, num_h}

Note that each line contains an instruction of the form pattern {action}. All instructions are executed sequentially. The "pattern" 'END' is satisfied when the end of the input file is reached.

Other useful awk-variables are:
· NF: number of columns;
· NR: the current line that awk is working on;
· BEGIN: satisfied before anything is read;
· length: number of characters in a line or a string;

awk also provides looping capability, a search (/) command, a substring command, and formatted printing. It provides the logical operators || (or) and && (and) that can be used in specifying patterns. You can define variables and assign values to them.

 

AWK COMMAND IN UNIX
Date Posted: 05/04/2012

Awk command awk -- it allows the user to manipulate files that are structured as columns of data and strings, JUST SEE THE FIRST EXAMPLE U WILL GET IDEA Example 1: Assume you want to process a file called file 'dimensions' that h...  

 
Showing 1 - 10 of 18 Previous | 1 | 2 | Next
Shadow Bottom
 
 
© 2005 -