วันเสาร์ที่ 17 ตุลาคม พ.ศ. 2558

Tip5 : Linux , Git , Nginx command ที่ใช้บ่อยๆ

 ======Linux=========
ls -all     ดูรายชื่อโฟลเดอร์และไฟล์ทั้งหมด ณ ตำแหน่งที่เราอยู่
cd ..      ย้อนกลับโฟล์เดอร์ไป 1 ขั้น
cd [folder_name]    เข้าโฟล์เดอร์นั้น
top       ดู service ทั้งหมดที่กำลังรันอยู่ และกินเมมโมรี่ไปเท่าไหร่ เมมที่เหลือมีเท่าไหร่
df -h      ดูว่าพื้นที่ Storage เหลือเท่าไหร่ ****ถ้าพื้นที่ไม่พอ database ที่อยู่บนเซิฟนั้นจะ error****
du -h --max-depth=1    ดูพื้นที่ของแต่ล่ะไฟล์ โฟลเดอร์
sar    ดู IO activity ใน 24ชม ที่ผ่านมา
tail -n 100 [log_name]     ดูไฟล์ log 100บรรทัดสุดท้าย
grep -n [find_keyword] [log_name]    ดูไฟล์ log ตัดมาเฉพาะบรรทัดที่มีคำ find_keyword อยู่
tail -n 100 [log_name] | grep [keyword]   ดูไฟล์ log 100 บรรทัดสุดท้ายที่มี keyword อยู่
sudo chmod 777 [file_name]    เปลี่ยน permission file 
rm -rf [folder_name]    ลบโฟลเดอร์แบบหมดจดแม้จะไม่ใช่โฟลเดอร์ว่าง
iftop -n   ดูกิจกรรม network bandwidth (ต้องติดตั้งตัวคำสั่งก่อนถึงใช้ได้) 

======My SQL======
mysqld --console         เริ่มระบบ
Ctrl+c             ออกจากระบบ
mysql -u root -p         เข้าสู่ระบบด้วย username = root
mysql -h localhost -u root    เข้า localhost ด้วย username = root
show databases        แสดงลิตต์ database

======NGINX======
nginx -c C:\nginx\conf\nginx.conf    เริ่มระบบ สามารถเข้า localhost ได้หลังใช้

service nginx restart
service php-fpm restart
service memcached restart


======GIT======
git branch                เช็คว่าอยู่ brach ไหน
sudo git pull origin     ดึง brach   
sudo git checkout     ย้าย brach
sudo git commit -a -m 'commit_name'    comit git

$ git checkout -b [name_of_your_new_branch]
$ git push origin [name_of_your_new_branch]
$ git remote add [name_of_your_remote] 
$ git push origin [name_of_your_remote]
$ git fetch [name_of_your_remote]
$ git merge [name_of_your_remote]/develop
$ git branch -d [name_of_your_branch]    ลบ local branch
$ git branch -D [name_of_your_branch]    ลบ local branch แบบบังคับ


==========PHPMYADMIN remote database=========
ทำให้ phpmyadmin สามารถ access เข้า database จากที่อื่น server อื่นได้ (ปกติลงแล้วมันจะเข้าใช้ localhost)

The settings are stored in config.inc.php at the root of phpMyAdmin's installation directory; e.g. /usr/share/webapps/phpMyAdmin/config.inc.php. Do not dig deeper than that.
(It's the same place where you can find files config.sample.inc.php, ChangeLog, favicon.ico, and such.)

$i++;
$cfg['Servers'][$i]['host'] = 'yourhost.com:3306'; //provide hostname and port if other than default
$cfg['Servers'][$i]['user'] = 'root';   //user name for your remote server
$cfg['Servers'][$i]['password'] = '123456';  //password
$cfg['Servers'][$i]['auth_type'] = 'config';       // keep it as config

ไม่มีความคิดเห็น:

แสดงความคิดเห็น