forked from gangireddydanam/saggiapps
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRunningnotes
More file actions
2465 lines (1359 loc) · 41.6 KB
/
Runningnotes
File metadata and controls
2465 lines (1359 loc) · 41.6 KB
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
telnet websitname port------------To check firewall open or not
https://www.google.co.in
protocal: https
websitename: www.google.co.in
port :443
ip allocation types--2
static-- ip never change
dhcp--dynamic--ip will change
-------------------------------------
network template
ping
nslookup
tracert/traceroute/tracepath
destinaion address/ip
source ip
=======================
subnetmask
dns--name,ip
firewall
client--------------------------->firewall|server|
internet facing DMZ network----firewall/webservers
client--------------->DMZ--------------->backend(app/db)
loadbalancers are two types
1)h/w lb--f5
2)s/w--
ip types
===========================================
Unix--cmd line--
multi-user
mult-tasking-----
multi-session login with username------
Unix(AIX/HP-UX) and Linux(redhat/ubuntu/centos)
IBM-AIX----Power Server
Windows Server 2008---rdp session--terminal server
Security(permissions)---file/directory/acl/username-pwd/iptables(firewall)/SElinux
Windows Server---->.msi/bat/exe---->GUI
Unix-----rpm/yum/source code/extract the archive---instalaltion types
pgming--->source code----->compile----->execute
Unix----
IBM---AIX--
Solaris---Solaris
Redhat---RedhatLinux--
HP----HP-UX
================================
kernel-OS--- uname -a
machine/h-w-----0 and 1
ls---------shell-------kernel-----1/0--------H/w
shell--bash/csh/ksh/zsh
echo $SHELL
/bin---all users commands will be located
high level language to low level language translator and communicates with h/w
username----Deskstop
C:\Users\username\Desktop\
/home/<username>
/home/test
/home/tomcat
/home/devop
pwd
User/admin--two types
1)normal user(who will be created by root user)
2)admin user----root--default- primary administrator---during OS installation--Super user
/home/<normaluser>-------------home directory for users
/ ---my computer--top directory--root directory
/---directory
/home
/root-----only for root user home directory
pwd
/root
normal user----root----Sudoers
===========================================
varibales---two types--1)user variables 2)System variables(caps letter)
echo $SHELL---SHELL system varible
echo $USER
echo $PATH
echo $DIRNAME
maven_home=/opt/maven
echo $maven_home
set or env
/bin--commands--any user
ls
cd
date
cp...etc
/boot---os botable files
/dev/<hard disc>--device information
/dev/sda-----
/dev/hda
/dev/vda
/etc------important os configuration files.
/etc/hosts
/etc/init.d----os bootables files
/etc/cron
/etc/logrotate
/etc/system/*
/etc/network
/etc/fstab
/etc/passwd
/etc/group
/etc/shadow
/etc/mount
/home----normal users home directory
devopadmin--/home/devopadmin
/lib---kernel modules
/media---removable devices
/mnt---mount purpose
/opt/ and /usr ----------C:\ProgramFiles\
/sbin--System/secure binaries----root /sudoer (normal)
/tmp---copying files/temporary files storage
/var-----runtime log files
/var/log/messages
/var/log/cron
/var/log/secure
/root----root user home directory
/proc------------os runtime information ---0--virual directory
memory information
cpu core
no of opened files--/etc/secuirty/limits.conf
==============================================================
date/what time files got modified
size of the file
owner/group
is that file or directory
permissions
where am i
travering--
1 tier/ Desktop based
Client------------->Application(Server)------------->DB----------->Application
=============================
hostname
[ec2-user@ip-172-31-72-227 ~]$ pwd
/home/ec2-user
[ec2-user@ip-172-31-72-227 ~]$ cd /tmp
[ec2-user@ip-172-31-72-227 tmp]$ pwd
/tmp
[ec2-user@ip-172-31-72-227 tmp]$
cd ../-------------->pwd---->/
cd .. --------------->pwd--->/
cd -----------OK
cd ../../home/ec2-user---------->ok
cd - --------->ok
cd /home---------->pwd----------->/home-------->cd ec2-user----------->
cd /home/ec2-user
normal1 --- normal2 --- prompts-- normal2
user-----root ----- i need root user passwd
user-----root ----- Entering user password you can switchc to root ( in that case user has to be
sudoer)
user ----root----without asking user or root password you can switch to root(sudoer)
you have to add sudo command.
root -- any user ---no password
ec2 instance( ami)/image--base template/base image
ec2-user
/home/ec2-user
cd /opt
pwd---------->/opt
sudo su root
pwd
/opt
su - <it takes to user home directory>
vi ---editor
escape--- not edit---dafult----i---insert mode-----esacape----:wq!
insert mode---edit/update--
execute mode
To get line numbers
esc--->:set nu
To go end of the file---->shift+g(G)
first line of the file--->gg
To seach a keyword ---->esc--->/keyword---->to check another occurence--->n
to copy a line --->esc--->press--yy
to paste--->p
how to create one user id in 1000 servers ? what are possible ?
how to make one user in 1000 servers as a sudoer user ?
[root@ip-172-31-72-227 tmp]# history
1 yum install traceroute*
2 traceroute 49.205.223.43
3 eexit
4 exit
5 pwd
6 exit
7 visudo
8 cat /etc/redhat-release
9 ls -l /etc/redhat-release
10 cat /etc/redhat-release
11 ps -ef
12 ps -ef | grep tomcat
13 ps -ef | grep puppet
14 mkdir test
15 pwd
16 ls -ltr
17 pwd
18 mkdir test1 test2 test3 test4
19 ls -ltr
20 whoami
21 id
22 ls -ltr
23 dirs
24 ls dirs
25 ls -ltr
26 ls -ltr test*
27 ls -ld test*
28 ls -ltr test
29 ls -ld test
30 pwd
31 mkdir /tmp/test
32 mkdir /tmp/ansible/playbook
33 mkdir /tmp/ansible
34 mkdir /tmp/ansible/playbook
35 mkdir -p /tmp/chef/recipies
36 man mkdir
37 pwd
38 ls -ltr /tmp/
39 cd /tmp/
40 ls -ltr
41 ls -ltr ansible/
42 ls -ltr ansible/playbook/
43 ls -lRt ansible/
44 tree ansible/
45 ls -lRt /tmp/
46 ls -ltr /tmp/
47 ls -ltr /tmp/ | wc -l
48 ls -lRt /tmp/ | wc -l
49 wc -l /etc/sudoers
50 grep -Ri "devopadmin" *
51 grep -in "devopadmin" /etc/sudoers
52 grep -in "wheel" /etc/sudoers
53 grep -cin "wheel" /etc/sudoers
54 grep -in "wheel" /etc/sudoers | wc -l
55 grep -il "wheel" *
56 grep -in "wheel" /etc/sudoers
57 grep -in "wheel | devopadmin" /etc/sudoers
58 egrep -in "wheel | devopadmin" /etc/sudoers
59 egrep -in "wheel|devopadmin" /etc/sudoers
60 history
61 alias
62 hisotry
63 history
[root@ip-172-31-72-227 tmp]#
[root@hostname~]---pwd----/root----e:
cd
cd /tmp/ansible/playbooks---d:
mkdir -p /tmp/ansible/playbooks/tomcat/
[ec2-user@ip-172-31-72-227 ~]$ sh second.sh
Sat Jan 20 03:49:05 UTC 2018
my name is ec2-user
this is fourth lines
[ec2-user@ip-172-31-72-227 ~]$ cat second.sh
date
echo "my name is $USER"
echo " this is fourth lines"
[ec2-user@ip-172-31-72-227 ~]$
rw-rw-r--=664
chmod 755 filename
chmod -R 755 directory
chmod -R 700 directory
rwx-------
rwxr-xr-x
devops------>
automation
developers---->git---->automation---->deploy ?---->servers-->
update dev----automation
====================================================
kfc
petclinic---->www.petclinic.com
infosys: --- Requirement--->devoperls---->choose language-->design---->package--->.zip .jar .war .ear directory .tar .msi .exe .rpm
server--hosting company
=============
IBM---
==========
development----testing---www.petclinicdev.com---(5server)
staging-----www.petclinicstg.com----(5)
integration---equal to prod---www.petclinicint.com------inernal users --- education(10 server)
production--------www.petclinic.com----10 servers(same application)
============================================
30servers----->linux------>petclinic--->
useradding ----->30 servers--->
[serverslist]
server1
server2
server3
ipaddress
...etc
useradd petlicnic
user.yml
name: Create a login user
user:
name: petclinic
groups: # Empty by default, here we give it some groups
- docker
- sudo
state: present
shell: /bin/bash # Defaults to /bin/bash
createhome: yes # Defaults to yes
home: /home/petlicinic # Defaults to /home/<username>
ansbile-playbook user.yml serverlist------------->server4 unable resolve--->
nslookup server4--no hostname
ping ip
jenkins--->create--->
filetype --- --- ---
rw-rw-r--
--- --- ---
rwxrwxrwx=777
r=4
w=2
x=1 ====7
-rw-rw-r--. 1 ec2-user ec2-user 0 Jan 20 03:35 scripts
-rw-rw-r--. 1 ec2-user ec2-user 0 Jan 20 03:35 restart
-rw-rw-r--. 1 ec2-user ec2-user 0 Jan 20 03:35 jenkins
drwxrwxr-x. 2 ec2-user ec2-user 6 Jan 20 03:37 test
-rw-rw-r--. 1 ec2-user ec2-user 20 Jan 20 03:45 first.sh
-rw-rw-r--. 1 ec2-user ec2-user 59 Jan 20 03:48 second.sh
chmod 700 *
chmod -R 700 directory
chown -R user:group directory
chown user:group filename
mv-- cut and paste---& rename
/tmp
/root
mv helloworld /tmp
cp
rw-r--r--.
644---
r=4
w=2
x=1
./=== 7 and sh
/opt/automation/scripts
cp source destination
cp -r source destination
scp
How many ways to install ?
yum/apt-get
rpm
sourcecode
archive(zip/tar/tar.gz/gz/tgz)
yum --------------->/etc/yum.repos.d/*.repo---->base url: --- http://internet/intracnet---->
url
tar -cvf filename.tar targetdirectory ------------>to create tar file
tar -tvf filename.tar ---->without extract to see tar content
tar -xvf filename.tar --------> to extract
c=create
v=verbose
f=filename
tar -cvzf filename.tar.gz targetdirectory ------------>to create tar file
tar -tvzf filename.tar.gz ---->without extract to see tar content--------------------->
tar -xvzf filename.tar.gz --------> to extract------------------>
z=gzip
gunzip --------->filename.gz------->filename
gzip filename----->filename.gz(it creates existing filename with .gz)
note:--never ever to gzip existing udpated files
100 tickets----->50--->file system /disc full------>gzip---
filename 5gb->gzip filename------->300MB(log filename)
clear(rm )----->disc full/fs issue--->house keeping--->delete files older than x days-------------->
zip
zip -r filename.zip targetdirectory ---->to create zip files
unzip filename.zip ---->to extract unzip
less filename.zip --without extract to see content inside archive
unzip -l filename.zip
yum install <package> ----------------installs package
for ex:
------>/etc/yum.repo.d/*.repo->base url--->http/ftp--->
yum install nc
yum install telnet
yum install zip
yum install wget
wget --->download package in cli
curl --->to view the page/to download pacakge
tar - to make compression files with tarball
/opt/apachetomcat.xx
/tmp
tar -cvzf filena.tar.gz /opt/apachetomcat--------->filena.tar.gz ----> opt/apache
cd /opt
tar -cvzf /tmp/filena.tar.gz apachetomcat.xx----------->filena.tar.gz--->apachxxxx
============================================================================
applications--->to deal business
websites--->static/dynamic
static--->html/css/jquery/images/--------------->webservers--->Apache(http server)/Nginx/IHS/OHS/JWS
yum install httpd
apache--80
2.4x---->7
2.2----->business
/etc/httpd------->installation path of apache
[root@ip-172-31-72-227 httpd]# ls -ltr
total 0
drwxr-xr-x. 2 root root 82 Jan 21 02:39 conf.d
drwxr-xr-x. 2 root root 146 Jan 21 02:39 conf.modules.d
drwxr-xr-x. 2 root root 37 Jan 21 02:39 conf
lrwxrwxrwx. 1 root root 10 Jan 21 02:39 run -> /run/httpd
lrwxrwxrwx. 1 root root 29 Jan 21 02:39 modules -> ../../usr/lib64/httpd/modules
lrwxrwxrwx. 1 root root 19 Jan 21 02:39 logs -> ../../var/log/httpd
[root@ip-172-31-72-227 httpd]# pwd
/etc/httpd
[root@ip-172-31-72-227 httpd]#
redhatpage----------------->default page-----------deveoploer------->/var/www/html/---------------
saggi.awsmiddleware.in----------------->dns--->ip-->80--->ip
DNS---www.saggisolutionstechs.com --- ip
ec2-public--52.x.x.x.
saggi.awsmiddleware.in -------------->DNS---->IP
protocal://<wesitename>:<port>
saggi.awsmiddleware.in
protocal:http
websitename: saggi.awsmiddleware.in--->dns-->52.x.x.x
port:80
ec2---->80---->Apache---->/var/www/html/index.html---------------
Developers(10)--->html----->source code--->saving at location----->source code repository
developers----->svn/cvs/github/temcity/ibm------>package-->zip----->download--->unzip---->cp paste--->
/opt/automation/scripts/websitebuilder.sh
#!/bin/bash
unzip *.zip
cd CookingSchool-FreeHtmlPageTemplate/
cp -r * /var/www/html/
packagte-->/home/ec2-user------>/tmp/websites--->extract---->/var/www/html/
================================================================
[root@ip-172-31-72-227 scripts]# cat staticdeploy.sh
#!/bin/bash
#Author:Name
#Version:1.0
#Purpose: Deployment
cp /home/ec2-user/Coo* /tmp/websites/
sleep 2
cd /tmp/websites/
unzip *.zip
cd CookingSchool-FreeHtmlPageTemplate/
cp -r * /var/www/html/
===================================================================
saggi.awsmiddleware.in---------->znetdns--->ip----->80------ec2--->apache----->/var/www/html/inde.html-----
developers----->Source code reposity---->package--->zip---->url--->deployed--->websites---
jenkins---->one click--->
=================================
/opt/automation/scripts/apache/
stopapache.sh
#!/bin/bash
#stopping apache
systemctl stop httpd
---------------------------------
startapache.sh
#!/bin/bash
#starting apache
systemctl start httpd
--------------------------------
restartapache.sh
#!/bin/bash
#stopping apache
systemctl stop httpd
wait 2
systemctl start httpd
========================
restartapache.sh
#!/bin/bash
#stopping apache
/opt/automation/scripts/apache/stopaapche.sh
wait 2
#starting
/opt/automation/scripts/apache/startapache.sh
==================================
/opt/automation/scripts/apache/restartapache.sh
.bashrc or .bashprofile
alias restartapche=/opt/automation/scripts/apache/restartapache.sh
restartapache
Commands Reference:-
https://www.thegeekstuff.com/2010/11/50-linux-commands/?utm_source=feedburner
https://www.webair.com/community/top-50-linux-commands/
https://www.tecmint.com/18-tar-command-examples-in-linux/
https://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/
https://www.cyberciti.biz/faq/star-stop-restart-apache2-webserver/
Shell Scripting:
http://www.techpaste.com/2012/04/shell-script-stop-start-apache-web-server-linux/
=========================================================================================
telnet websitname port------------To check firewall open or not
https://www.google.co.in
protocal: https
websitename: www.google.co.in
port :443
ip allocation types--2
static-- ip never change
dhcp--dynamic--ip will change
-------------------------------------
network template
ping
nslookup
tracert/traceroute/tracepath
destinaion address/ip
source ip
=======================
subnetmask
dns--name,ip
firewall
client--------------------------->firewall|server|
internet facing DMZ network----firewall/webservers
client--------------->DMZ--------------->backend(app/db)
loadbalancers are two types
1)h/w lb--f5
2)s/w--
ip types
===========================================
Unix--cmd line--
multi-user
mult-tasking-----
multi-session login with username------
Unix(AIX/HP-UX) and Linux(redhat/ubuntu/centos)
IBM-AIX----Power Server
Windows Server 2008---rdp session--terminal server
Security(permissions)---file/directory/acl/username-pwd/iptables(firewall)/SElinux
Windows Server---->.msi/bat/exe---->GUI
Unix-----rpm/yum/source code/extract the archive---instalaltion types
pgming--->source code----->compile----->execute
Unix----
IBM---AIX--
Solaris---Solaris
Redhat---RedhatLinux--
HP----HP-UX
================================
kernel-OS--- uname -a
machine/h-w-----0 and 1
ls---------shell-------kernel-----1/0--------H/w
shell--bash/csh/ksh/zsh
echo $SHELL
/bin---all users commands will be located
high level language to low level language translator and communicates with h/w
username----Deskstop
C:\Users\username\Desktop\
/home/<username>
/home/test
/home/tomcat
/home/devop
pwd
User/admin--two types
1)normal user(who will be created by root user)
2)admin user----root--default- primary administrator---during OS installation--Super user
/home/<normaluser>-------------home directory for users
/ ---my computer--top directory--root directory
/---directory
/home
/root-----only for root user home directory
pwd
/root
normal user----root----Sudoers
===========================================
varibales---two types--1)user variables 2)System variables(caps letter)
echo $SHELL---SHELL system varible
echo $USER
echo $PATH
echo $DIRNAME
maven_home=/opt/maven
echo $maven_home
set or env
/bin--commands--any user
ls
cd
date
cp...etc
/boot---os botable files
/dev/<hard disc>--device information
/dev/sda-----
/dev/hda
/dev/vda
/etc------important os configuration files.
/etc/hosts
/etc/init.d----os bootables files
/etc/cron
/etc/logrotate
/etc/system/*
/etc/network
/etc/fstab
/etc/passwd
/etc/group
/etc/shadow
/etc/mount
/home----normal users home directory
devopadmin--/home/devopadmin
/lib---kernel modules
/media---removable devices
/mnt---mount purpose
/opt/ and /usr ----------C:\ProgramFiles\
/sbin--System/secure binaries----root /sudoer (normal)
/tmp---copying files/temporary files storage
/var-----runtime log files
/var/log/messages
/var/log/cron
/var/log/secure
/root----root user home directory
/proc------------os runtime information ---0--virual directory
memory information
cpu core
no of opened files--/etc/secuirty/limits.conf
==============================================================
date/what time files got modified
size of the file
owner/group
is that file or directory
permissions
where am i
travering--
1 tier/ Desktop based
Client------------->Application(Server)------------->DB----------->Application
=============================
hostname
[ec2-user@ip-172-31-72-227 ~]$ pwd
/home/ec2-user
[ec2-user@ip-172-31-72-227 ~]$ cd /tmp
[ec2-user@ip-172-31-72-227 tmp]$ pwd
/tmp
[ec2-user@ip-172-31-72-227 tmp]$
cd ../-------------->pwd---->/
cd .. --------------->pwd--->/
cd -----------OK
cd ../../home/ec2-user---------->ok
cd - --------->ok
cd /home---------->pwd----------->/home-------->cd ec2-user----------->
cd /home/ec2-user
normal1 --- normal2 --- prompts-- normal2
user-----root ----- i need root user passwd
user-----root ----- Entering user password you can switchc to root ( in that case user has to be
sudoer)
user ----root----without asking user or root password you can switch to root(sudoer)