UNIX
UNIX
UNIX
COMMANDS:
SYSTEM INFO :-
1. Date :- it will show the date.
Ex :- date +%d-%m-%y / date "+DATE: %m%d%y" here it
will show the date is a particular format.
2. cal :- it will show the calendar.
Ex:- cal ,it will show the date.
3. uptime :- it will show the time from how much time we are
being logged into the system.
4. who am I :- it will show the details of current user
5. who :- it will show the details of the logged users.
6. w :- it will show the detailed information about the logged user.
When we log into the system
7. uname –a :- it will show the details about the system like linux
or unix and which version and keranal ect.
8. Man :- it will show the manual for command.
9. Df :- it will show the disc usage.
10. Du :- it will show the directory space usage.
11. Free :- it will show the memory and swap usage.
12. Where is app :- it will show possible location of app.
13. Which app :- it will show which app will be run by
default.
FILE COMMANDS
14. Ls :- list down the files and directories.
15. ls -l :- it will show the long list format.
16. Ls –s :- it will show the files with size.
17. Ls –h :- human readable files will be displayed.
18. Ls –i :- it will show the files with inode numbers.
19. Ls –ltr :- it will show the files and directories in the
vertically.
20. ls ma*.doc :-
Here .doc filles will be displayed starting with ma.
UNIX
21. ls *.txt :-
here it will be displayed .txt files.
22. ls -d */ :- list down the all directories from current
directory.
23. Ls –a :-
Hidden files also will be displayed.
24. ls –b :-
here files and directories will be displayed as ascending order.
25. ls –la :-
here it will show the directories and files in the long list format.
26. Ls -1 :-
Here it will display the files and directories in the ascending order.
27. Ls -R :-
files will be opened in recursive mode.
28. Ls * : - it will display the all files and directories according
to directory wise./ list all subdirectories.
29. ls -lrt *.log :-
it will show the .log files.
30. ls -lrt * /- :- files will be displayed and after files will be
displayed according to directory.
31. ls -lrt [aeiou]* :-
it will show the files starting with (aeiou)
32. ls -a :- it will show the hidden files.
33. ls -d $pwd/* :- list down the directories full path.
34. Ls –la /home/maha/mahasai :- we can sea the files in any
path.
35. ls s* : - here it will show the files and directories starting
with “s”.
36. ls ???.txt :- it will display the 3 letters .txt files.
37. ls *.txt :- it will display all files ending with .txt.
38. ls m,s * : - it will display the files and directories starting
with m&s.
39. ls [a,e]* :- we can list of the files starting with a and e.
40. ls -l -d */ :- only directories will be displayed in long list
format.
UNIX
41. ls –f :- it will display only files.
42. ls -d .* :- it will display .files and directories.
43. Ls –F :- it will display executable files with *.
CP
cp :- it is used to perform below 2 operations.
44. Taking backup of a file.
Ex :- existing file name target file name
cp Abc abc123
Here the data will be copied from abc to abc123.
45. To copy existing files or directories to another location
Ex :- cp abc /home/maha/maha.txt
Here the files will be having new inode numbers which have been
copied.
46. cp maha nag
47. cp –r dir1 dar2 :-
here the directory will be copied from dir1 to dir2.
mv
This command is use to rename the files or directories
48. mv mahanandhi maha here mahanandhi name will be
changed into maha.
49. mv maha /home/sai/mahanandhi.txt here the data will be
copied to mahanandhi.txt.
RM :-
rm :- rm is the command to remove the files or directories
50. rm :- filename (maha) here maha file will be removed.
51. Rm –r :- directory name (Mahanandhi) here Mahanandhi
directory will be removed
52. rm -f : - maha maha file will be removed forcefully.
53. rm -rf :- (directory name) mahanandhi here mahanandhi
directory name will be removed reforcefully.
touch:-
UNIX
it will create the number of emty files like testing123 (here file has
been created) we can create more files also like touch (we should
give space to the each name )ram raghava radha ramesh etc
54. We can create like this also ravi\ kumar here ravi kumar file
has been created.
We can create no of files with touch command
55. Ex:- touch file{1..200}.txt , here 200 files have been created.
Wc ;-
It is used to count the no of lines, words, characters from a file .
56. Ex :- wc maha111
Here it will count lines characters and words for a file.
6 = lines
32 = words
162 = characters
57. Wc –l :- it will show the line numbers.
58. Wc –w :- it will show no of words.
59. Wc –c ;- it will show the no characters.
Links:-
hard link :-
it is used to extract 1 file information in to another file
60. ln sai111 maha111
here sai111 file information will extract to maha111.
If you change any modifications in any file but both files will be
reflected the same information.
If you delete parent file but child file will be not be effected and
if you delete child file parent file will not be effected.
Inode numbers will be same to the both files.
Soft link :-
UNIX
It is used to extract 1 file information in to another file.
61. ln –s maaha111 /home/nag/ kittu111
here maaha111 file information will extract to kittu111.
If you change any modifications in any child file it will not
be reflected to the parent file. but if you do any modifications
in parent file it will be reflected to the same information in
the child file.
If you delete parent file but child file will be be effected and
if you delete child file parent file will not be effected.
Inode numbers will be different to the both files.
CAT:-
62. Cat :- it will create the file and we can write something here
Ex :- cat > mahanandhi then enter and write the text and press
ctrl+d now file will be saved and came to previous promt. We can
see the file like ..… cat mahanandhi, now file will be opened and
shown the data.
63. Cat >> kittu (existing filename) here we have created
kittu file and written something. But with this command we can
add something in that existing file.
64. Cat jana kittu nagendra here 3 files information will be
shown in 1 terminal.
65. Cat maha1>maha2 here the data will be copied from
maha1 to maha2 but existing data will be erased.
66. cat maha1 >> maha2 here the data will be copied from
maha1 t maha2 but existing data will be there only.
67. Cat –n or Cat –b or cat < maha -n (kittu) filename it will
show the no of lines in the particular file.
68. cat -e maha :- it will show the $ symbol in the end of the
lines.
69. cat *.txt :- it will display all the information from .txt files.
70. cat ???.txt :- it will open the files information starting with
3 letters.txt.
71. cat ?? :- here files data will be opened which are 2 letter
files.
UNIX
72. cat [m,s] * :- it will display the files information starting
with m&s.
grep :-
it defines as globally search for regular expression and printings.
73. grep -i "kittu" sai123123 :- here kittu name lines will
be displayed in a file.
74. grep -c "kittu" sai123123 :- here it will show the number
how many lines are with kittu.
75. grep -n "kittu" sai123123:- here it will show the line
numbers with lines.
76. grep -v "kittu" sai123123 :- here it will show the lines
except ‘’kittu string names’’
77. grep -w "kittu" sai123123 :- here it will match the
exact word.
78. grep –l (yal) "kittu" * :- here it will show the file names
which contain the string name “kittu”.
79. grep -A +2 "kittu" sai123123 :- here it will show the 2
lines after kittu line.
80. grep -B +2 "kittu" sai123123 :- here it will show the 2
lines before kittu line.
81. egrep -i "kittu|nag" sai123123 :- here we can search
multiple strings at time.
82. egrep -i "kittu|nag" kgf king :- Here we can search
multiple strings from multiple files.
Ex :-
kgf:i am kittu
kgf:i am nag
king:I am kittu
CUT :-
It extracts the characters according to the requirement in a
specific file.
83. cut -b 1,2,3 maha :- it will show the upto 3 characters in a
specified file.
UNIX
84. cut -b 5-7 maha :- it will show the line 5 character to 7th
characters.
85. cut -f 3,5 maha :-
86. cut -d '|' -f '2,7' maha :-
87. cut -c '1-10' nag11 :- it will show the 1 to 10 characters in
10 lines in a specified file.
SORT :-
It is used to sort the files in ascending or descending order.
88. sort maha :- we can sort the information in ascending order
in a file.
89. sort -r maha :- the information will come in descending
order.
90. sort –r maha>>sai :- the information from maha to sai will be
appended.
91. sort -k3 -nr maha
TAR :-
we can create files into tar
92. tar -cvf maaha.tar Krishna
here Krishna file becomes maaha.tar file.
93. tar -cvf mahanandhi.tar sai krishna maha :-
we can create a tar file with multiple files or directories.
94. tar -tvf maaha.tar :-
it will list down the files in a tar file with full details.
95. Tar –tf mahanandhi.tar:-
we can see the file names only.
96. tar -xvf mahanandhi.tar :-
here we can extract files from tar file
ZIP: -
UNIX
It is used to compres the files.
97. Gzip maha
here maha file or directory has zgiped. Extension is like
maha.gz
98. Gunzip maha.gz
Here maha.gz file has become the ungzipped.
99. zip ssss.zip maha
here maha file is going to become zip file as ssss.zip
100. unzip ssss.zip
here ssss.zip file is going to become unzip as maha (old
file name)
HEAD :-
It will show the lines from head of the file.
101. head -6 maha:- it will show the 6 lines from the head of the
file.
TAIL :-
It will show the lines from bottom of the file.
102. tail -3 maha :- it will show the 3 lines from the bottom of the
file.
MORE:-
It will show the line by line.
103. more maha :- here we need to press enter for going to next
line.
LESS :-
Here it is similar to more but here we can use navigation keys.
104. less maha
FIND COMMANDS :-
105. find . –type f –empty :- empty files will be displayed in a
current directory.
UNIX
106. Find . –type d -empty :- empty directories will be displayed
in a current directory.
107. Find . –type f –empty | (pipe) wc –l (yal) :- it will show the
empty files number.
108. Find . –type d –empty | wc –l :- it will show the empty
directories in a current directory.
109. Find . –type f –empty –delete :- empty files will be deleted.
110. Find . –type d – empty –delete:- empty directories will be
deleted.
111. Find /home/maha/mahasai –empty –type f –delete :-
empty files will be deleted in a particular path (directory).
112. Find /home/maha/mahasai/ -empty –type d | wc –l :-
it will display the number that how many directories are empty
in a current directory.
113. Find/home/maha/mahasai/ -empty –type f | wc –l :-
It will display the number of files which are empty in a
current directory
114. Find/home/maha/mahasai/ -empty –type d – delete
Here it will delete the empty directories in a current
directory.
115. Find . –type f -name “krishna”
It will show the path of a particular file.
( Or)
Find . – name “Krishna”
SPLIT:-
127. Split - l 5 rama
Rama file will split in to 5 pieces.
128. Csplit sai 10
Here two files will be displayed
9 lines will be having
Remaining lines will be having
129. Split - b 100 sai
Here sai file will be divided according to 100 bytes.
UNIX
130. Esc:%s/sai/maha/g
Here the sai name replace with maha in the entire data.
131. Esc:1,20s/sai/maha/g
Here the range (1-20) sai will be change as maha.
132. /maha
Find the word.
133. Esc: set nu:-
It assigns line number for each line
134. Esc: 1,10 co 25:-
1,10 lines will be copied & paste from 26th-35th.
135. Esc : q :-
Quit
(or)
Esc : q !
Uniq
136.
UNIX
UNIX