» linux の記事

~ wget and grep the json key value ~

connie 2017.08.30 | Linux | | No Comments

# wget -qO- http://freegeoip.net/json/
{“ip”:”8.8.8.8″,”country_code”:”HK”,”country_name”:”Hong Kong”,”region_code”:””,”region_name”:””,”city”:”San Po Kong”,”zip_code”:””,”time_zone”:”Asia/Hong_Kong”,”latitude”:11.11,”longitude”:11.11,”metro_code”:0}

# wget -qO- http://freegeoip.net/json/ | grep -Po ‘(?<=”ip”:”)[^”]*’
8.8.8.8

~ linux shellscript cannot executed ~

connie 2016.11.17 | Linux | | No Comments

因為coding 問題,另shellscript 不能正確運行DOS format VS UNIX

qq%e6%88%aa%e5%9c%9620161117161746

apt-get install dos2unix
dos2unix file.sh

 

~ Hosts file location ~

connie 2016.10.20 | Linux | | No Comments

Win7
C:\Windows\System32\drivers\etc
linux
/etc/hosts

必需東西

  1. Root機(笑,未root 可以再見了
  2. Android Terminal Emulator , 即putty
  3. Hacker's Keyboard , 感覺好小小既keyboard skin,最小你會講小左好多粗口:)
  4. Complete Linux Installer , linux container
  5. Astro File , android file system

 安裝晒以上東東後,開啟 Complete Linux Installer 

去install guides 到choose 你要安裝既OS 到,尼到會用ubuntu 12.04 尼做example

Screenshot_2013-04-01-19-47-49

Page 1 主要係叫你開USB debugging mode , 同夠位donwload ubuntu OS images

Screenshot_2013-04-01-19-47-58

之後Page2 donwload image 

Screenshot_2013-04-01-19-48-01

之後有3個size可以 download , 睇餸食飯。

Screenshot_2013-04-01-19-52-28

sourceforge 係幾好,用4G download 都好快完成, (小妹係唔係就係另mobile network 塞車的兇手,喂

Screenshot_2013-04-01-19-52-31

download 完成後就解壓,內有2個file , 一個係img , 一個係md5

Astro File check 一下md5 有無問題,按實>properties>MD5 checksum

之後將img放到你想放既位置。

完成後回到Complete Linux Installer , 去launch

SETTINGS>Edit 變更images link

save> Start Linux

開了後會自動跳到Android Terminal Emulator,問你開唔開ssh, vnc, y晒佢你就有好日子過

之後save ,一切都變回你懂的東西,update 一野

apt-get upgrade && update

install LAMP

apt-get install apache2 mysql-server php5

Screenshot_2013-04-01-19-23-02

完成

~ use Find 來找linux 內的file ~

connie 2013.01.09 | Linux | | No Comments

linux command 搵folder 入面 jpg,png,gif 以外的files
假設要找尋的folder 為 /var/www 的所有file

find . ! -name '*.jpg' ! -name '*.png' ! -name '*.gif'

 

~ 用RootKit Hunter來找linux漏洞 ~

connie 2013.01.05 | ubuntu | | No Comments

先安裝RootKit Hunter

cd /tmp
wget http://ncu.dl.sourceforge.net/project/rkhunter/rkhunter/1.4.0/rkhunter-1.4.0.tar.gz
tar -xvf rkhunter-1.4.0.tar.gz
cd rkhunter-1.4.0
./installer.sh --layout default --install
cd /usr/local/bin
mv rkhunter /usr/bin/

之後update db

rkhunter --update
rkhunter --propupd

之後要修改/etc/rkhunter.conf

nano /etc/rkhunter.conf

加入hidden file whitelist

SCRIPTDIR=/usr/local/lib/rkhunter/scripts

ALLOWHIDDENDIR="/etc/.java"
ALLOWHIDDENDIR="/dev/.udev"

ALLOWHIDDENFILE="/dev/.initramfs"

SCRIPTWHITELIST=/usr/bin/unhide.rb

Scan Machine 方法

rkhunter --checkall

完成

rm -r rkhunter-1.4.0
rm -r rkhunter-1.4.0.tar.gz

 

~ Linux Check login ~

connie 2013.01.03 | Linux | | No Comments

To show users who are logged in to the system

who

To show the list of users who have logged in last

last

To show the list of all reboots

last reboot

To print the content of the last login log from /var/log/lastlog

lastlog

To List out the login history for certain acc

last [username]

 

~ VI 常用 command ~

connie 2012.12.17 | Linux | | No Comments

有時有d server 無nano , 唯有用VI

Shift + g 頁尾
:wq save
i Insert mode
ESC 出返insert mode
:q! quit without save

 

| HOME |