-
Notifications
You must be signed in to change notification settings - Fork 125
/
Copy path1. LINUX
328 lines (234 loc) · 8.78 KB
/
1. LINUX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
LINUX: Free and Open-source OS
OS: Operating system -- > communication blw user & system.
TYPES OF OS:
1. WINDOWS
2. LINUX
3. MAC OS
LINUX COMPONENTS:
1. KERNEL: Manages hardware components (CPU, MEMORY, etc --)
The lowest level of OS.
2. DAEMON: Manage the Background Service (Lights, Sounds, schedule)
While starting the system.
3. SHELL: Manage the User Inputs (Command, Script, programs)
Takes input from the user and executes and gives the output.
LINUX OS FLAVOURS/DISTRIBUTIONS:
IPHONE: 14, 14+, 14 PRO, 14 PRO MAX,
VERSIONS: 14, 13, 12, 11
MAIN:
RedHat
Ubuntu (75%)
Amazon Linux
MODES:
1. GUI: Its having the Dashboard
2. CLI: Command line interface (Works with commands only)
HISTORY:
1991 -- > Linus Torvalds -- > student from finland.
1991 -- > Want to create an OS that works like UNIX.
LINUX is Written in C Programming. (1972)
Firstly he wanted to name it as 'Freax' but later it became 'Linux'.
1992 -- > Linxu's initial version was released.
TOTAL PROGRAMMING LANGUAGES: 700 +
OPEN SOURCE:
It is free no need to pay money.
It is available publically.
We can change the code.
we can give a copy of the code to other people.
ADVANTAGES:
It's free and open-source.
Multi-user based.
Fewer Bugs.
Better Performance.
It can be used for all programming languages.
It will hang very rarely.
===========================================================================
DAY-02: SERVER & COMMANDS
MOBAXTERM LINK: https://download.mobatek.net/2312023031823706/MobaXterm_Portable_v23.1.zip
NOTE: Go to the path where you have keypair
CONNECT: SELECT THE SERVER -- > CONNECT -- > SSH CLINET -- > COPY TO TERMINAL
PASTE: 1. RIGHT CLICK 2. SHIFT + INSERT
COMMANDS:
ec2-user: default user root: admin
* : refers all in linux
sudo -i : switch to root user form ec2-user
clear/ctrl + l : to clear the screen
touch file1 : to create a file
ll/ls : to list the files
ll -a / ls -a : to list the hidden files
pwd : to show the present working directory
cat file1 : to show the content in a file
more file1 : to show the content in a file
cat>file1 : to insert the content
enter, ctrl d : to save the content
cat>>file1 : to insert the content more than one time.
cp file1 file2 : to copy the content from file1 to file2
mv file1 file5 : to rename file1 to file5
rm file2 : to remove file2
rm file4 -f : to remove file4 forcefully
rm * -f : to remove all files forcefully
touch java{1..5}: to create series of files
rm j* -f : to remove all the files starting with j
wc file1 : to see number of lines, words & characters.
head file2 : to print top 10 lines
head -7 file2 : to print top 7 lines
head -5 file2 : to print top 5 lines
tail file2 : to print bottom 10 lines
tail -7 file2 : to print bottom 7 lines
tail -5 file2 : to print bottom 5 lines
sed -n '6,16p' file2 : to print form line numbers 6 to 16
FOLDERS = DIRECTORIES
mdkir dir1 : to create a folder
cd dir1 : to go inside the directory
cd .. : to go back one directory
rmdir dir1 : to remove a directory
echo "hai raham" > file3
===============================================================
DAY-03:
STATIC: We can't modify
DYNAMIC: We can mofify
VI/VIM EDITOR: Used to edit files and insert content.
i: used to modify/insert content
esc: to get out from insert mode
3. SAVE MODE:
:w : to save
:q : to quit
:wq : to save & quit
! : forcefully
2. INSERT MODE:
A : End of line
I : Starting of line
O : Create new line above existing line
o : Create new line below existing line
1. COMMAND MODE:
yy : copies single line
p : paste single line
dd : delete single line
u : undo
nyy : copies n lines
np : pastes n line
ndd : delete n lines
nu : undo n times
gg : top of file
shift+g : bottom of file
:15 : to go to line 15
:set number: print lines inside the file
===========================================================================================================
HARDWARE:
cat /proc/meminfo : to show memory information
lsmem : to show memory information
cat /proc/cpuinfo : to show cpu information
lscpu : to show cpu information
cat /etc/os-release : to print flavoure
fdisk -l : to show the ebs volume info
lsblk : to show the ebs volume info
df : to show the mount point
df -m : to show the mount point in mb
free : to show how much ram is available
free -m : to show how much ram is available
yum install lshw -y : to install the package
lshw : to show the hardware information.
====================================================================================================================
USERS:
ec2-user: he is the default user.
root: he is the admin, he will have all permissions.
superuser:
he is a normal user created by root user.
normal user -- > visudo -- > super user
useradd raham: to create a user
cat /etc/passwd: to see the users list.
user -- > GROUP & FOLDER
cat /etc/group: to see the groups list.
ls /home: to show user folder on home
id raham: to show the user info
passwd raham: to assign password for user
NOTE: in linux password will not be visible.
password -- > more than 8 char.
username should not be given as password.
To create super user:
1. create user (useradd raham)
2. password (passwd raham)
3. visudo -- > 100 -- > yy & p -- > root=raham
su - rajesh : to login to super user
NOTE: In linux if you are on non root use sudo command
root -- > normal -- > visudo -- > super user
logout or ctrl d used to exit from super user.
=============================================================
-rw-r--r-- 1 root root 0 Jun 8 16:02 file1
TYPE OF FILES:
- : Regular file
b : Blocked file
c : Charcter file
d : Directory
l : link file
PERMISSION:
rw-r--r--
r : read : 4
w : write : 2
x : executable : 1
user : rw- : 4+2+0 : 6
group : r-- : 4+0+0 : 4
others : r-- : 4+0+0 : 4
chmod 777 file1
chmod 666 file2
1 : acl -- > access control list
chown raham file1: to make raham as owner to file1
chgrp raham file1: to make raham as group to file1
chown raham:raham file2 : to make raham user&group for file2
chown rajesh:raham file1: rajesh as user & raham as group
groupadd devops : to create devops group
usermod -aG devops raham : to add raham user to devops group
usermod -aG aws raham : to add raham user to aws group
gpasswd --delete raham devops : to remove raham user form devops group
userdel raham : to delete raham user
=======================================================================================================
DAY-05:
GREP : Global Regular Expression Print
to search for a particular word
grep is file1 : to search word is on file1
grep IS file1 -i : to avoid the case sensitive
grep IS file1 -i -v : to avoid the line which is having word is
cat file1 | grep is : to search word is on file1
cat file1 | grep IS -i : to avoid the case sensitive
cat file1 | grep IS -iv : to avoid the line which is having word is
| : is pipe sysmbol -- > to work with pipe we need to have 2 commands
here 1 st command output will be input of 2 nd command.
lscpu | grep cpu -i
lsmem | grep memory -i
dmesg | grep image -i
SED: Stream Editor -- > to replace words in a file.
%s/is/abc/ -- > to replace is with abc
sed '3c/abc/' file1 -- > to replce 3rd line in a file
sed 's/linux/unix/' file1-- > single word replace
sed 's/linux/unix/; s/session/class/' file1 -- > multi word replace
cat file1 -n -- > to print line numbers in a file
sed '=' file1 -- > to print line numbers in a file
sed -n '5,13p' file1 -- > to print line 5 to 13
sed -e '5,13p' file1 -- > to print line 5 to 13 double times
NETWORKING:
ip addr
ip addr show
hostname -i
ifconfig -- > all the 4 commands used to show ip address
ping google.com -- > to get response form server
ping -c 4 google.com
netstat --- > to show active internet connections
ps -- > to check the process
kill -9 32555 -- > to kill a process
ps aux -- > to list process in ids
===========================================================================
LINUX DIRECTORY SYSTEM:
FHS
bin : it stores all the binary files and also it stores the commands that had been executed by the user.
sbin : it stores the commands that had been executed by the super user.
boot : it contains boot images & boot files.
dev : it contains all the device files
etc : it contains all the host specific system configuration files.
lib : it contains all the library files of the system.
lib64 : it contains all the library files of the system of 64 bit.
mnt : it is used for the mounting purpose.
opt : it stores all the file details of the 3 rd party when it installed.
proc : it is used to see all the processing related files (Hardware details).
srv : it stores all the service related information provided by system.
sys : it stores any new changes that obtained while changing Hardware.
tmp : it stores temperory files and have access to all.
usr : it contains local system files which are continuing with the old system architecture.
var : it stores all the system services.