แสดงบทความที่มีป้ายกำกับ Ubuntu แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Ubuntu แสดงบทความทั้งหมด

วันจันทร์ที่ 21 มีนาคม พ.ศ. 2565

(Shortcut) TAR File

# TAR Command Line

### 1 Create Archive File / Directory / Zip ###
# -c create
# -z gzip, gunzip, ungzip
# -f file

tar -cf archive.tar file1 file2
tar -cf archive.tar dir/
tar -czf archive.tar.gz dir/

### 2 Show Detail in Archive File ###
# -t list
# -v verbose
# -f file

tar -tf archive.tar
tar -tvf archive.tar

### 3 Extract Archive File ###
# -x extract
# -z gzip, gunzip, ungzip
# -v verbose
# -f file

tar -xvf archive.tar
tar -xzvf archive.tar.gz

วันศุกร์ที่ 18 มีนาคม พ.ศ. 2565

(Shortcut) Install MariaDB Server 10.3 on Ubuntu 20.04

# update package and install
sudo apt update
sudo apt install mariadb-server mariadb-client

sudo mysql_secure_installation

sudo mysql -u root -p
# system will ask 2 password
# 1 linux user password
# 2 mysql root password

วันพฤหัสบดีที่ 1 กรกฎาคม พ.ศ. 2564

(Shortcut) Uncomplicated Firewall on Ubuntu 20.04

ref https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/ ref https://www.cyberciti.biz/faq/how-to-configure-firewall-with-ufw-on-ubuntu-20-04-lts/ sudo lsof -i:[port-number] sudo lsof -i -P -n | grep LISTEN sudo ufw status sudo ufw status numbered sudo ufw delete [number] sudo ufw enable sudo ufw disable sudo ufw allow 80/tcp comment 'accept Apache' sudo ufw allow 443/tcp comment 'accept HTTPS Connections' sudo ufw allow from [ip]

วันจันทร์ที่ 22 มีนาคม พ.ศ. 2564

Rsyslog ทำความรู้จักกับ Log และตั้งค่าให้ส่ง Log ไปเก็บยังเครื่อง Server

File Log ในระบบ Linux

เราจะต้องมีไฟล์ที่จะบันทึกการทำงานเพื่อใช้ในการตรวจสอบการทำงานและใช้เพื่อหาความผิดปกติที่เกิดขึ้นจากระบบ
Rsyslog มาจากคำว่า "The rocket-fast system for log processing"
Rsyslog เป็น Open Source ในระบบปฏิบัติการ UNIX และ Unix-like ใช้สำหรับส่งข้อมูล Log ผ่านทาง network

อ้างอิงจาก: https://www.rsyslog.com/, https://en.wikipedia.org/wiki/Rsyslog

Syslog

ใน syslog จะประกอบด้วย 3 ส่วน Facility, Priority และ Action โดยจากเขียนในรูปแบบตามนี้
Facility.Priority;Facility.Priority Action (; แทน และ)
Facility,Facility.Priority Action (, แทน หรือ)

วันศุกร์ที่ 18 กันยายน พ.ศ. 2563

[Ubuntu] การติดตั้ง OJS3 ใน Ubuntu 18.04

สรุปการติดตั้ง OJS3 (Open Conference System 3) ให้ทำการติดตั้ง Apache2, PHP7 และ MySQL ก่อน

การติดตั้ง Apache2 และ PHP7 เราสามารถติดตั้ง PHP7 ได้เลยโดยไม่ต้องใช้คำสั่งติดตั้ง Apache2 เพราะ PHP7 ต้องการ Apache2 อยู่แล้ว
และทำการติดตั้ง MySQL เสร็จแล้วก็ทำการตั้งค่า OJS3

 
apt install php php-mbstring php-xml php-mysql
apt install mysql-server

# ติดตั้งใช้งานครั้งแรก
mysql_secure_installation



วันเสาร์ที่ 16 พฤษภาคม พ.ศ. 2563

[Ubuntu] การติดตั้ง และ การใช้งาน Cron Jobs

การติดตั้ง Cron ก่อนอื่นให้เราเช็คดูก่อนว่ามีการติดตั้งลงไปที่เครื่องแล้วหรือยัง
dpkg -l cron

# cron installed

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version               Architecture    Description
+++-===============-====================-===============-==============================
ii  cron            3.0pl1-128.1ubuntu1  amd64           process scheduling daemon


เมื่อพบว่ายังไม่ได้ทำการติดตั้งให้เราทำการ Update Package ก่อนทำการติดตั้ง และเมื่อทำการติดตั้งแล้วให้เช็คว่า Cron ทำงาน
apt update
apt install cron

systemctl status cron

วันพฤหัสบดีที่ 28 พฤศจิกายน พ.ศ. 2562

การล้างข้อมูลในฐานข้อมูลและโหลด Config ใหม่ให้ DSpace CRIS

การล้างข้อมูลนั้นเราทำหลายครั้งก่อนที่เราจะใช้งาน DSpace CRIS จริงๆ เพราะว่าต้องทดลองใช้งานหลาย ๆ อย่าง จึงทำให้ฐานข้อมูลมีข้อมูลที่เราไม่ใช้จำนวนมาก
sudo su - postgres

psql dspace -c "DROP EXTENSION pgcrypto;"
exit;

sudo /data/dspace/bin/dspace database info
sudo /data/dspace/bin/dspace clean


sudo su - postgres
psql dspace -c "CREATE EXTENSION pgcrypto;"
exit;
# - load-cris-configuration: Load CRIS configuration from an XLS file
# - export-cris-configuration: Export CRIS configuration from an XLS file

sudo /data/dspace/bin/dspace load-cris-configuration -f /data/upload/configuration.xls

การ Load Registry ครั้งแรกเมื่อทำการ Load แล้วให้เราทำการ Restart Server ก่อน 1 ครั้งสำหรับ Registry Schema ใหม่
sudo /data/dspace/bin/dspace registry-loader -metadata /data/upload/patent-types.xml

วันอาทิตย์ที่ 24 พฤศจิกายน พ.ศ. 2562

DSpace CRIS แก้ DC Type ที่เป็น All Theses ขึ้น ???

ข้อมูลจาก: DSpace Tech Support



เมื่อทำการทดสอบใช้งาน DSpace CRIS หลังจากติดตั้งไปสักพัก เมื่อทำการเพิ่ม Item แล้วเลือก DC Type เป็น Theses เราจะพบว่าหน้าแรกที่ใช้สรุปว่ามี Item ประเภทไหนบ้าง เราจะเจอความผิดพลาดที่ว่า All Theses หาข้อความไม่เจอ

วันศุกร์ที่ 22 พฤศจิกายน พ.ศ. 2562

PHP ปรับค่า File Upload และค่า Timeout

ข้อมูลจาก: Sitepoint | A2Hosting | Strackoverflow | Mediatemplate

แก้ไขไฟล์ "php.ini" ใน "etc/php/5.6/apache2/php.ini" เสร็จแล้วให้ Restart Apache2
# รองรับการอัพโหลดไฟล์ที่ 300MB
upload_max_filesize = 300M

# รองรับการส่งไฟล์ผ่าน POST ที่ 300MB
post_max_size = 300M

# เพิ่มเวลาในการ Execution และ Input เป็น 600 วินาที
max_execution_time = 600
max_input_time = 600

# เพิ่มหน่วยความจำให้ PHP
memory_limit = 512M

วันอาทิตย์ที่ 10 พฤศจิกายน พ.ศ. 2562

การติดตั้ง DSpace CRIS 5 ใน Ubuntu 18.04

การเตรีมเครื่องติดตั้ง DSpace CRIS 5 เราจะทำตามขั้นตอนตามเว็บ โดยปัญหาที่เจอคือ OpenJDK เป็น Version 11 จะไม่สามารถใช้ Maven สั่ง Package ได้ให้เราทำการ ลง OpenJDK เป็น Version 8 ก่อนแล้วทำการติดตั้ง Maven ที่หลัง เพราะหากทำการติดตั้ง Maven ก่อนจะเป็นการเลือกเอา OpenJDK Version ล่าสุดมา
แล้วทำไมต้องใช้ OpenJDK Version 8 ? คือว่า Maven ตอนที่เราสั่ง Package มันจะต้องใช้ไฟล์ tools.jar ในของ Java ที่อยู่ใน Folder /lib/ ใน Java ซึ่งใน OpenJDK Version 9 ขึ้นไปจะไม่มีแล้ว อันนี้เราไม่รู้นะว่าทำไม ?
sudo apt install openjdk-8-jdk
sudo apt install ant git maven 

เสร็จแล้วก็ทำการลง Tomcat8 และ PostgreSQL แล้วทำการตั้งค่าตาม Manual แต่ Command อาจไม่ตรงตามนั้นแต่ก็ได้เหมือนกัน
sudo apt install tomcat8 postgresql postgresql-contrib

เมื่อเตรีมเครื่องพร้อมแล้วก็ทำตามขั้นตอนได้
การติดตั้ง PostgreSQL อ่านที่นี้, การติดตั้ง DSpace CRIS

วันจันทร์ที่ 15 เมษายน พ.ศ. 2562

Install MySQL 5.7 on Ubuntu 18.04

Install MySQL Server 5.7

การติดตั้ง MySQL Server 5.7

Reference: Install MySQL | Install phpMyAdmin
# Install MySQL Server
sudo apt update
sudo apt install mysql-server

# Check MySQL Status
sudo systemctl status mysql
# Initial Server
sudo mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No:
Please set the password for root here.

New password:

Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) :

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) :

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) :

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

 ... skipping.
All done!

วันศุกร์ที่ 12 เมษายน พ.ศ. 2562

Install PostgreSQL 11 on Ubuntu 18.04

การติดตั้ง PostgreSQL 11


*ถ้าไม่ต้องการติดตั้ง Version 11 จะลงตาม Version ที่มากับ Repository Linux ให้ข้ามไปตรง #Install PostgreSQL ได้เลยครับ

Official: PostgreSQL Installation
Reference: Install PostgreSQL, Install pgAdmin4, Getting Started
# Install PostgreSQL 
sudo apt update
sudo apt install wget gnupg2

Create the file /etc/apt/sources.list.d/pgdg.list and add repository
deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main
# Import repository signing key, then update package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt update

# Install PostgreSQL, ถ้าไม่ทำตามขั้นตอนข้างบนจะติดตั้งตาม Version ที่มากับ Repository ของ Linux
sudo apt install postgresql postgresql-contrib

# Check PostgreSQL Status
sudo systemctl status postgresql

ทำการทดสอบโดยใช้ user postgres
# Connect to PostgreSQL
sudo su - postgres
psql
-- Show your connection information

\connifo
-- You are connected to database "postgres" as user "postgres" 
-- via socket in "/var/run/postgresql" at port "5432".

-- Show help
\?

-- Quit
\q

วันพุธที่ 16 มกราคม พ.ศ. 2562

[Ubuntu] การใช้งาน Screen และ Terminal Multiplexer

ปกติแล้วเวลาเราทำการ Secure Shell เข้าไปเพื่อทำงานบ้างอย่าง พอเราออกมา Process พวกนั้นก็จะถูก Terminate ไปด้วย
หากเราต้องการจะให้มันทำงานต่อไปเรื่อยๆ แม้เราจะออกมาแล้วจะทำยังไง ผมได้ไปค้นหาข้อมูลดูก็เจอ 2 ตัวนี้คือ screen และ tmux
เท่าที่ผมรู้ตัว screen เป็นตัวเก่ามีมานานแล้ว พอลองไปเล่นที่เครื่องดูก็พบว่าติดตั้งไว้ให้อยู่แล้ว แต่พอหัดใช้สักพักรู้สึกงงๆ
ผมเลยลองเล่นอีกตัวที่เขาแนะนำมาคือ tmux ชื่อเต็มๆ คือ Terminal Multiplexer ครับ

วันอาทิตย์ที่ 30 ธันวาคม พ.ศ. 2561

[Ubuntu] วิธีการติดตั้ง และ การตั้งค่า Apache 2 ใน Ubuntu 18.04

คำสั่งที่ใช้ในการติดตั้ง

sudo apt install apache2

# สั่งให้เริ่มทำงาน และตั้งค่าให้เริ่มทำงานเมื่อเปิดเครื่อง
sudo systemctl start apache2
sudo systemctl enable apache2