04/08/2019
😎😎ဒီေန႔ေတာ့ က်ေတာ္တုိ႔ Page မွာ စာမတင္တာၾကာပီဆုိေတာ့ ျပန္တင္ျပီဗ်ာ😎😎
👉“script” command ျဖစ္ Linux Session ကုိ record လုပ္ျခင္း???👈
“script” command သည္ Terminal မွာ မိမိရုိက္လိုက္တယ့္ commands ေတြကုိ session တခုအေနနဲ႔မွတ္ပီး result ကုိ သိမ္းေပးပါတယ္။ ဒါကုိ (cat, more, less, vi) command ေတြနဲ႔ ၾကည့္နုိင္ပါတယ္။
က်ေတာ္တုိ႔ “scriptreplay” command နဲ႔လည္းျပန္လည္ၾကည့္ရႈနုိင္ပါတယ္။ က်ေတာ္တုိ႔ record session စမယ္ဆုိရင္ script command နဲ႔ -timing option ကုိ သုံးပီး run ရပါလိမ့္မယ္။ ေနာက္မွာ မိမိၾကဳိက္ရာ name ေပးပီး record ကုိစမွတ္နုိင္ပါျပီး။
👇👇👇👇👇👇
[root@test ~] # script --timing=time.log record.txt
Script started, file is record.txt
[root@test ~] # cat time.log
[root@test ~] # hostname
test
[root@test ~] # cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@test ~] # date
Sun Aug 4 13:30:54 +0630 2019
[root@test ~] # echo " We Love Info Star"
We Love Info Star
[root@test ~] # exit
exit
Script done, file is record.txt
ကဲ record ဖမ္းတာ ပီးသြားပါပီး က်ေတာ္လုပ္ခဲ့တယ့္ Time ကုိျပန္ၾကည့္ပါ့မယ္
👇👇👇👇👇👇
[root@test ~] # cat time.log
0.494377 39
0.013179 1
6.485861 1
0.113255 1
0.163100 1
က်ေတာ္တုိ႔ရုိက္ခဲ့တယ့္ command ေတြကုိ session record အေနနဲ႔ျပန္ၾကည့္ပါ့မယ္
👇👇👇👇👇👇
[root@test ~] # scriptreplay --timing=time.log record.txt
[root@test ~] # cat time.log
[root@test ~] # hostname
test
[root@test ~] # cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@test ~] # date
Sun Aug 4 13:30:54 +0630 2019
[root@test ~] # echo " We Love Info Star"
We Love Info Star
[root@test ~] # exit
👉Linux မွာ user password ေတြကုိ Management လုပ္ျခင္း👈
က်ေတာ္တုိ႔ Password ဆုိတာနဲ႔ Linux မွာ “passwd” command ကုိ System Admin တုိင္း သိပီးသားျဖစ္ပါလုိက္မယ္။ Linux ဟာ Multitasking ဆုိတယ့္ အတုိင္း user accounts မ်ားစြာရွိသလုိ အဲဒီ user တုိင္းမွာ လည္း “password” ေတြရွိပါလိမ့္မယ္။ မိမိဟာ Linux System Administrator တေယာက္ လုပ္မယ္ဆုိ Linux မွာ User ေတြကုိ Management လုပ္ျခင္းသည္ လည္း တစိတ္တပုိင္း အေရးပါလွပါတယ္။
Linux ရွိိ “passwd” command သည္ system users ေတြ အတြက္ Password ေတြ change ရာမွာ အသုံး၀င္သည္။ က်ေတာ္တုိ႔ ဒီ command ျဖစ္ password ေတြကုိ “lock” and “unlock” စတာေတြ လုပ္နုိင္ပါတယ္။က်ေတာ္တုိ႔ Normal Users ေတြကလည္း သူတုိ႔ရဲ႕ ကုိယ္ပုိင္ password ေတြကို ေျပာင္းဖုိ႔ “passwd” command ကုိ သုံးနုိင္တယ့္အျပင္ ၊ System Administrator ျဖစ္တယ့္ Superuser root ကလည္း အျခား users ေတြရဲ႕ Passwords ေတြကို ေျပာင္းလဲနုိင္ပါတယ္။
👇👇👇👇👇👇
Syntax: passwd [options] [username]
က်ေတာ္ ဒီေနရာမွာ User အသစ္ ကုိ ထပ္ add ျပပီး “passwd” အေၾကာင္းကုိ အေသးစိတ္ေျပာသြားပါမယ္ခင္ဗ်။
“useradd” သည္ user account အသစ္ ထပ္ add ျခင္းျဖစ္ပီး။
“userdel” သည္ ရွိပီးသား user ကုိ system မွ delete လုပ္ျခင္းျဖစ္သည္။အေသးစိတ္ကုိ ေတာ့ ေနာက္ Post မွ ရွင္းသြားပါ့မယ္ခင္ဗ်။ ခုက “passwd” အေၾကာင္းဆုိေတာ့………
👇👇👇👇👇👇
[root@cwp ~] # useradd smith
useradd: cannot open /etc/passwd
[root@cwp ~] # userdel jack
userdel: cannot open /etc/passwd
ဒီေနရာမွာ က်ေတာ္ ဘာေၾကာင့္ Super User ျဖစ္ရဲ႕သားနဲ႔ ဘာေၾကာင့္ “useradd” နဲ႔ “userdel” လုပ္လုိ႔ မရတာလုိ႔ သင္ ထင္ပါသလည္း။???????????
[root@cwp ~] # rm -rf /etc/passwd
rm: cannot remove ‘/etc/passwd’: Operation not permitted
“rm -rf” လည္း မရဘူးေနာ္………
👇👇👇👇👇👇
[root@test ~] # chattr -i /etc/passwd
[root@test ~] # useradd john
useradd: cannot open /etc/shadow
[root@test ~] # chattr -i /etc/shadow
[root@test ~] # useradd john
👉/etc/passwd အေၾကာင္း????????????👈
/etc/passwd သည္ User Account ေတြကုိ အေသးစိတိေဖာ္ျပေပးတယ္။က်ေတာ္တုိ႔ Linux Admin တုိင္းသည္ ဒီ file နဲ႔ familiar ျဖစ္ဖုိ႔ေတာ့လုိပါတယ္။ password file သည္ System ရွိ Userေတြႏွင့္ပတ္သတ္တယ့္ အခ်က္အလက္ေတြပါဝင္တယ့္ human readable file ျဖစ္ပါတယ္။
👇👇👇👇👇👇
[root@test ~] # ll /etc/passwd
-rw-r--r--. 1 root root 1049 Aug 3 23:35 /etc/passwd
/etc/passwd file permission သည္ 644 ျဖစ္ပါတယ္။ Ownership ကလည္း root:root ျဖစ္ပါတယ္။ ဒါေၾကာင့္ Super User( root ) ကသာ edit လုပ္နုိင္ပါတယ္။
👇👇👇👇👇👇
[root@test ~] # cat /etc/passwd | grep -E '/home/|/root'
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
smith:x:1000:1001::/home/smith:/bin/bash
william:x:1001:1002::/home/william:/bin/bash
(1) Username (William) သည္ login ဝင္ဖို႔ရာ username ျဖစ္ပါတယ္။
(2) Encrypted PWD (x) သည္ password ရဲ႕ format ပါ။ က်ေတာ္တုိ႔ encrypt လုပ္လုိက္တယ့္ Username ၏ Password ကုိ /etc/shadow ေအာက္မွာ သိမ္းထားပါတယ္။
[root@test ~] # cat /etc/shadow
root:$6$vGtQcjIuPzNOZuA0$vfPKCv/lNetb8/YhqEyKqia6NKfLLmf6qHzGj9u4gE2LieyDASDvegSZABA70AS/jyKpQX9BgLOkYJxlFFwou0::0:99999:7:::
(3) UID (1000) သည္ User ID ျဖစ္ပါတယ္(Normal User မုိ႔ UID 1000 ကစပါတယ္)။ system က User Account ကုိသတ္မွတ္ေပးတယ့္ Unique Number တခုျဖစ္ပါတယ္။ -u option ဆုိပီးတြဲသုံးပါတယ္။
(4) GID (1001) သည္ Group ID ျဖစ္ပါတယ္။ -g option နဲ႔တြဲသုံးပါတယ္။
(5) Home Directory သည္ User ေတြ တည္ရွိတယ့္ေနရာ တစ္ခုပါပဲ။
(6) SHELL ( /bin/bash) သည္ shell name ျဖစ္ပါသည္။
👉/etc/shadow အေၾကာင္း???????👈
၄င္းသည္ User ေတြရဲ႕ password အေသးစိတ္ကုိ ေျပာျခင္းျဖစ္ပါတယ္။ root account ျဖစ္သာ shadow file ကုိ read လုပ္နုိင္ပါတယ္။ User ေတြရဲ႕ encrypt လုပ္ထားတယ့္ password ေတြကုိ သိမ္းဆည္းရာေနရာပါပဲ။
shadow file permission သည္ ---------- ျဖစ္ျပီး Ownership သည္ root:root ျဖစ္ပါတယ္။
👇👇👇👇👇👇
[root@test ~] # ll /etc/shadow
----------. 1 root root 720 Aug 4 00:23 /etc/shadow
/etc/shadow format have nine colon-separated fields.
[root@test ~] # cat /etc/shadow
testuser:$6$GbeQzXnL$VoBBtlRXrqyAugtxr7CJ4ly/j2jWGr6YvxSrw77xLWUTrDq.8dVrAFaKe8tSuxEFlG9Pc0zNtrVMaVtgWpK0k1:18112:10:90:7:14:18113:
👇👇👇👇👇👇
(1) Username => System မွာ create လုပ္ခဲ့တယ့္ user login name ျဖစ္ပါတယ္။
(2) Encrypt Password => Password ကုိ encrypt လုပ္ထားျခင္းျဖစ္ပါတယ္။
(3) Last Password Change => ေနာက္ဆုံး Password ေျပာင္းျခင္းျဖစ္ပါတယ္။
(4) Minage => password မေျပာင္းခင္ minimum number of days ျဖစ္ပါတယ္။
(5) Maxage => password မေျပာင္းခင္ maximum number of days ျဖစ္ပါတယ္။
(6) Warning => Password expire ျဖစ္မယ့္အေၾကာင္းကုိ warning period ျဖစ္ပါတယ္။
(7) Inactive => Password expire ျဖစ္ျပီးေနာက္ user account ဟာ disable ျဖစ္သြားပါလိမ့္မယ္။
(8) Expiry => Account expire ျဖစ္မယ့္ ေန႔ျဖစ္ပါတယ္။
(9) Bank => blank သည္ ေနာက္future မွာ သုံးဖုိ႔အတြက္ျဖစ္ပါတယ္။
👉“chage” command ျဖစ္ Password Aging ကုိ Manage လုပ္ျခင္း👈
က်ေတာ္တုိ႔ System Admin တုိင္း ကုိယ့္ Server ရဲ႕ Security အတြက္ User Account ေတြ၏ Password Aging ကုိ ထိန္းခ်ဳပ္ျခင္းသည္လည္းအေရးပါလွပါတယ္။ Server ေတြ၏ User Password ေတြကိုအျမဲ တစ္လ တစ္ခါ update လုပ္သင့္ပါတယ္။
ဒီေနရာမွာ “chage” command သည္ Password Aging Information ၾကည့္ရႈျခင္း၊ ေျပာင္းျခင္းလုပ္ရာမွာ အသုံးျပဳပါတယ္။
ဒီ “change” command မွာ
👇👇👇👇👇👇
(1) Last Change Date( -d option)
[root@test ~] # chage -d 2019-08-17 william
(2) Expiry Date ( -E option)
[root@test ~] # chage -E 2019-08-30 william
(3) Minimum Day ( -m option)
[root@test ~] # chage -m 7 william
(4) Maximum Day ( -M option)
[root@test ~] # chage -M 30 william
(5) Warning Days
[root@test ~] # chage -W 7 william
(7) Inactivity Period ( -I option)
[root@test ~] # chage -I 10 william
(8) Viewing all attributes
Last password change : Aug 04, 2019
Password expires : Sep 03, 2019
Password inactive : Sep 13, 2019
Account expires : Aug 30, 2019
Minimum number of days between password change : 7
Maximum number of days between password change : 30
Number of days of warning before password expires : 7
Remark : man chage ဆုိပီးၾကည့္ရင္ ဒီ option (၈) ခုလုံးကုိ အေသးစိတ္ သိရပါလိမ့္မယ္ဗ်။
😍အမွားပါကေ၀ဖန္ေထာက္ျပအၾကံျပဳေဆြးေႏြးေပးပါခင္ဗ်😍
🙏🙏သင္ဆရာျမင္ဆရာၾကားဆရာအားလုံးကုိေလးစားလ်က္🙏🙏
Freelance Engineer @ Info Star