Friday, September 22, 2017

set up google drive on Ubuntu 17.04

Read on website

https://www.2daygeek.com/mount-access-google-drive-on-linux-with-google-drive-ocamlfuse-client/#


Saturday, September 16, 2017

migrade user samba from old server to new server

1. Transfer use
  1. /etc/passwd
  2. /etc/group
  3. /etc/shadow
  4. home directories and shared directories
  5. /etc/samba
  6. /var/lib/samba
2. Method
    2.1 Old server

[root@old-server ~]# mkdir /root/move
[root@old-server ~]# export UGIDLIMIT=500

[root@old-server ~]# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig

[root@old-server ~]# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.mig

[root@old-server ~]# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.mig

cp /etc/gshadow /root/move/gshadow.mig

      2.2 copy to new server

rsync -ahrvz ssh /root/move 172.16.xx.xx:/root/move
OR
tar -czvf move.tar.gz move
scp move.tar.gz root@172.16.xx.xxx:/root

      2.3 Import user & passwd to new server (should be backup usernam&passwd before import data)

[root@new-server ~]# cd /root/move
[root@new-server ~]# cat passwd.mig >> /etc/passwd
[root@new-server ~]# cat group.mig >> /etc/group
[root@new-server ~]# cat shadow.mig >> /etc/shadow
cp gshadow.mig /etc/gshadow


สุดท้ายให้ก็อปปี้ user and passwd ในห้อง /etc/samba จากเครืองเก่าไปวางไว้ที่เครืองใหม่
/etc/samba
smbpasswd
smbusers
* for Centos v7
ให้ก็อปปี้เฉพาะไฟล์ smbpasswd ไปไว้ที่ Folder นี้
/var/lib/samba/private/

Ref:
1. migrating-samba-server-and-users-in.html
2. howto-move-migrate-user-accounts-old-to-new-server/
3. http://amar-linux.blogspot.com/2012/03/migrating-samba-server-and-users-in.html

Wednesday, September 6, 2017

Tuesday, September 5, 2017

Wireshark

ใช้ Wireshark hack password email
1. Run wireshark : sudo wireshark
2. ใช้คีย์เวิร์ดในการค้นหาข้อมูล : secretkey ดูข้อมูลด้านล่าง
3. Keyword แต่ละเมล เซิร์ฟเวอร์ไม่เหมือนกัน ตย. _pass, _user


Thursday, August 24, 2017

Can not use LAN after upgrad Ubunu 16.04 to 17.04

Edit file /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf


keyfile]
unmanaged-devices=*,except:type:wifi,except:type:wwan

To

[keyfile]
unmanaged-devices=*,except:type:ethernet,except:type:wifi,except:type:wwan


sudo service network-manager restart

Ref:
ethernet-adapter-was-disable-on-ubuntu-17-04

Sunday, August 20, 2017

Places & Files indicator

Install Places on top linux desktop

sudo add-apt-repository ppa:vlijm/placesfiles
sudo apt-get update
sudo apt-get install placesfiles

Ref: places-indicator-menu-ubuntu-system-tray

Thursday, August 10, 2017

Disable selinux on Centos 7 and set firewall-cmd

CentOS7

1.check status selinux enable or disable

#sestatus
#vim /etc/sysconfig/selinux
SELINUX=disabled

and Reboot system

ถ้าปิด Selinux ผิดจะขึ้น Error แบบนี้ : failed to load selinux policy freezing

วิธีแก้ไข
ในหน้าบู๊ด ให้กด e แล้วมองหา linux16 แล้วเพิ่ม selinux=0 เข้าไป แล้ว ctrl+x เพื่อเข้าสู่ระบบ จากนั้นไปแก้ไขค่า
SELINUX=disabled ตามข้อมูลด้านบน

Go to the main command (usually starting with “linux16” or something similar) and add “selinux=0” as one of the parameters:

Ref: selinux policy freezing

Ref: disable-selinux-temporarily-permanently-in-centos-rhel-fedora/

2. Enable / Disable service
- SAMBA

systemctl enable smb.service
systemctl enable nmb.service
systemctl restart smb.service
systemctl restart nmb.service

Restatr/Reload service
systemctl reload smb.service
systemctl restart smb.service

Check service runnig
systemctl list-unit-files
chkconfig --list |grep ชื่อของ service
systemctl
systemctl | more
systemctl | grep httpd
systemctl list-units --type service

systemctl list-units --type service |grep ชื่อของ service
systemctl list-units --type mount

  
example:
systemctl | grep smartd

View service running
systemd-cgtop


- IPTABLES
systemctl stop firewalld
systemctl mask firewalld
yum install iptables-services
systemctl enable iptables
systemctl start iptablesmkdir
service iptables save

- iptables command
-A RH-Firewall-1-INPUT -p udp -m udp --dport 137 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 138 -j ACCEPT-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

Check filrewall running ?
firewall-cmd --state systemctl status firewalldSet firewalld
List service on zone public
firewall-cmd --zone=public --list-all
List only port
firewall-cmd --list-ports


Add service
# firewall-cmd --zone=public --permanent --add-service=samba
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --reload
Remove service


#firewall-cmd --zone=public --remove-service=http

Add Port

firewall-cmd --zone=public --permanent --add-port=10000/tcp
firewall-cmd --zone=public --permanent --add-port=2500-2600/tcp


Delete port
firewall-cmd --remove-port=6161/tcp
firewall-cmd --zone=public --permanent --remove-port=10000/tcp
firewall-cmd --zone=public --permanent --remove-port=2500-2600/tcp

Save firewall
firewall-cmd --runtime-to-permanent
firewall-cmd --reload
firewall-cmd --get-services 
 

Ref: https://www.centos.org/forums/viewtopic.php?t=61108
Ref: quick-docs firewalld
Ref: firewall-cmd config

Wednesday, August 2, 2017

List of dangerous shell commands

1. rm -rf /
2. :(){ :|: & };:
3. mkfs /dev/sda1
4. cat /dev/zero > /dev/sda1
5. wget url -O - | sh --
6. curl url | sh
7. dd if=/dev/zero of=/dev/sda2
8. echo 726d202d7266202a | xxd -r -p
9. dd if=/dev/random of=/dev/port
10. echo 1 > /proc/sys/kernel/panic
11. cat /dev/port or cat /dev/mem
12. cat /dev/zero > /dev/mem
13. sudo chmod -r 444 / or sudo chown -r nobody:nobody /
14. last | reboot

Monday, June 26, 2017

เปิด Vim หลายหน้าจอ

#vim -p file01.txt file02.conf

สลับแต่ละหน้าด้วย :bn (next page), :bp (previous page)

Ref: open-multiple-files-using-single-vim-editor-command-linux