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

 

Loading
Latest News
Home Navigation Divied
DB/UNIX Navigation Divied UNIX/LINUX Navigation Divied UNIX CLASS NOTES
UNIX CLASS NOTES
UNIX CLASS NOTES
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
 

Shadow Bottom
   
© 2005 - 2020 Krishna Training.
Designed & Developed By BitraNet