unixcomm
DESCRIPTION
UNIX COMMANDSTRANSCRIPT
Unix basic commands :
1. $ LOGNAME : It displays the current user information
2. $PWD : present working directory
3. $DATE : It displays the system date & time
4. $clear : To clear the screen
5. $cal : it current month and year
6. $cal 2000 : Displays the 2000 year calendar
7. $cal 8 2006 : displays the 8th
month of 2006
8. $exit or logout : exit from current user account
9. $ who : displays the all user in who are currently working on server
10. $finger : displays the all user who are currently working on
server with more information.
11. Who am I : displays current user information
12. Which or where : displays the location of the given command
Syn: $which pwd
13. Cat : is use to create new files or to open exiting files or to
append data to the exiting files.
Syn: cat >filename
Redirect : cat file1 file2 file3 >file4.
Append : cat >>filenamesingle file.
Multi files : cat file1 file2 file3 >>kiran.
Open file : cat <filename.
Open multi files : cat file1, file2, file3.
14. Touch : It is used to create an empty file i.e. 0 byte file
SYN: $ touch filename
create multiple files : touch file1 file2 file3
15. rm : deleting files or directories
rm filename : deleting single file
rm -i filename : deleting files with confirmation
rm file1 file2 : deleting multiple file
rmdir dirname : deleting the directory but the directory must be empty
rm -r dirname: deleting directory recursively.
rm –ri dirname : remove directory with confirmation
rm * : it delets all files.
16. mkdir : creating directories
Syn: $mkdir dirname
$Mkdir .dirname : hidden directory.
17. Cd : change directory
Sys: $cd abc
cd ..: to come out from current directory
cd ../..: parent directory
cd/ : it changes to root directory
cd ~ : it changes to home directory.
18. cp : copy source file to target file.
SYN : Cp emp1 emp2
19. mv : it is used to rename or move file
Ex : mv exiting filename new filename
Mv emp .empt : to hide
Mv .emp emp : to unhide
20. ls : display, list of all files & directories in a current direc-tory
21. ls|more : display, list of all files & directories page by page
22. ls –a : display, list of all files & directories including hidden files
23. ls –r : display list of all files & directories revers order in a
current directory.
24. Ls –t : display list of all files & directories according to date.
25. cmp : it compares two files char by char
Sys: cmp file1 file2
26. comm. : It display common lines b/w 2 files
Syn: Comm File1 file2
27. diff : it display different lines b/w 2 files
syn: diff file1 file2
28. pg : it display the file contents page by page
Syn: $Pg filename
29. more : it also display the file contents page by page
Syn: $more filename
30. head : it display the 1st
n lines from the file
Sys: $ head –n filename
31. tail : it display the last n lines from file
Syn: $ tail –n filename
32. wc : it counts the no of lines, words, chars in a given file.
Syn: $wc filename
i) wc –l filename : it gives the no of lines in a given file
ii) wc –w filename : it gives the no of words in a given file
III) wc –c filename : it gives no. of char in file
iv) wc -lw filename : it gives the no of lines and character in a given file.
33.grep : Is used for to search a string or regular expression
in a given file(s).
Eg : i) $ grep kiran sample
ii) $grep kiran a1, a2, a3:
1. $ grep kiran * it searches for kiran in
current dir files (all files).
$grep “kiran raja” sample : it searches for more than one word
grep cmd options.$ grep –i kiran sample : ignore case sensitive
$ grep –c raja sample : count no of lines
$grep –n kumar sample : print along with the line numbers
34. Sed : to replace a string
Ex:$ sed “s/existing string/new string/g” filename : sed is used to find and replace
the stirng.
Ex) $sed “s/Unix/Linux/g “ kiran
35. Cut : it is used for to retrieve required fields and
characters from a given file
Ex: madhav is good boy :18 chars
Cut –f 2-5 madhav : o/p= adha
Cut –c 1-10 madhav
Cut –c 5-10, 15-20 madhav : for every line 5-10, 15-20 characters
36. Sort : it is used for to sort the file content. By default it
sorts file contents based on ASCII values-default
is ascending.
syn: $ Sort sample
i) sort –r sample : displays descending order
ii) sort –u sample : it displays unique lines in the given file
37. Uniq : it displays unique lines in the given file but the file
contents should be in sort order.
Syn: i) $ uniq filename
ii) $ uniq -u filename : it eliminate the duplicates.
iii) $ Uniq –d filename : displays only duplicated lines
iv) uniq –c filename : it counts how many times lines duplicated.
38. chmod : it is used for to change file permissions
Syn: $ chmod
i) ls –l filename : rw- rw- r—
ii) chmod g+x filename : rw- rwx r—
iii) chmod u+x, g-w filename : rwx r-x r—
Octal code
Read------4
Write-----2
Execute—1
iv) $chmod 756 filename : rwx r-x rw-
v) $chmod 642 filename : rw- r-- -w-
39. ftp : file transfer protocol -----transfer files from
one server to another
Steps:
$ ftp ipaddress
Login: -------
Password: ------
Ftp>ls (server)
Ftp>|ls(client)
Ftp>get filename (to download a file)
Ftp>mget file1 file2----- (to download multi files)
Ftp>put filename (to upload a file)
Ftp>mput file1 file2----- (to upload multi files)