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

วันจันทร์ที่ 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

วันพฤหัสบดีที่ 1 ตุลาคม พ.ศ. 2563

[Ubuntu] & [Linux Container]
NFS Kernel Server ต้น ๆ กับ การ Mount NFS ใน Container

[Ubuntu] NFS Kernel Server


คำสั่งที่ใช้ติดตั้ง NFS Server

sudo apt install nfs-kernel-server

sudo mkdir -p /mnt/nfs_share
sudo chown -R nobody:nogroup /mnt/nfs_share
sudo chmod 777 /mnt/nfs_share

sudo cp /etc/exports /etc/exports.bak
sudo nano /etc/exports

วันเสาร์ที่ 20 กรกฎาคม พ.ศ. 2562

Raspberry Pi Zero W กับการทำ Printer Server ด้วย CUPS

อยากได้ Printer ที่สั่งผ่าน WiFi ได้ ซึ่งเคยทำมานานแล้วครั้งหนึ่งแต่ตอนนั้นลง Driver ในตัว Pi เลยและสิ่งที่ไม่มีก็คือ Driver
ผ่านไปหลายปี ตอนนี้มี Pi Zero W อยู่สามตัวไม่ได้ทำอะไร ยังไม่ได้ทำเลยเอามาลองดูใหม่ว่าจะทำได้ไหมครั้งนี้
จากการ Search Google ก็พบกับคนที่ทำไว้แล้วก็เลยลองเข้าไปอ่านแล้วก็ทำตามเขาเลยครับ
ทำ Print Server ด้วย Raspberry Pi Zero W และขอขอบคุณเจ้าของบทความครับ

ปัญหาแรกที่เจอคือพยายาม Fix IP Address ของ WiFi ยังทำไม่ได้ ไม่รู้ว่าติดตรงไหน ขอข้ามไปละกันเดี๋ยวจะไม่ได้เริ่มสักที
***ตอนนี้ใช้ Fix IP ผ่านทาง Router แทน
# Update package และ ทำการ Install CUPS
sudo apt update
sudo apt install cups

# เราสามารถใช้คำสั่ง systemctl กับ cups ได้มี service ให้เหมือนกัน
# เช่น ดูสถานะของ cups ด้วยคำสั่ง sudo systemctl status cups

# แสดงข้อมูลของอุปกรณ์ด้วยคำสั่ง lpinfo
# lpinfo - show available devices or drivers

# sudo lpinfo -v
sudo lpinfo -v | grep usb:

# ข้อมูลอุปกรณ์ที่ต่อกับ Port USB ตามนี้ เราใช้ EPSON L360
direct usb://EPSON/L360%20Series?serial=5647444B3135373352&interface=1

# ทำการตั้งค่าอุปกรณ์โดนกำหนดชื่อ Destination และ URI ของ Printer เอาถึง Serials
# lpadmin - configure cups printers and classes
# sudo lpadmin -p {destination} -v {device-uri}

sudo lpadmin -p EPSONL360 -v usb://EPSON/L360%20Series?serial=5647444B3135373352

# จากนั้นดูข้อมูลสถานะของ Printer
# lpstat - print cups status information
# sudo lpstat -p {destination} -l
sudo lpstat -p EPSONL360 -l

# ปกติถ้าพึ่งใส่ข้อมูลจะเป็น Disable
printer EPSONL360 disable since Thu 18 Jul 2019 17:40:10 BST
        reason unknown

# ทำการ Enable Printer ด้วยคำสั่ง cupsenable
# cupsdisable, cupsenable - stop/start printers and classes
# sudo cupsenable {destination}
sudo cupsenable EPSONL360

# เสร็จแล้วลองดูข้อมูลเครื่อง Printer อีกครั้งด้วยคำสั่ง lpstat
sudo lpstat -p EPSONL360 -l

# ตอนนี้ Printer ของเราเป็น Enable แล้ว
printer EPSONL360 is idle.  Enable since Thu 18 Jul 2019 17:45:10 BST

วันจันทร์ที่ 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

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

Knowage 6.2 Installer in Ubuntu 18.04

I will follow this step for make sure it can work correctly


This video use Knowage 6.2.1 on Ubuntu 18 and Use Oracle JDK 8 and MySQL Server 5.7

Step 1. Install Java / Step 2. Configure System Variables

sudo apt install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt update

sudo apt install oracle-java8-installer
sudo apt install oracle-java8-set-default

# Setup JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export PATH=$JAVA_HOME/bin:$PATH

# Verify JDK is Installed
java -version

# java version "1.8.0_201"
# Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
# Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Reference: Command [add-apt-repository] Missing | Install Java 8 | Setup System Variables

วันเสาร์ที่ 2 มีนาคม พ.ศ. 2562

django==1.10 ตอน 2

การสร้าง Model

แก้ไขไฟล์ models.py ที่ Application
from django.db import models

# Create your models here.
class Topic(models.Model):
   top_name = models.CharField(max_length=264, unique=True)

   def __str__(self):
      return self.top_name

class Webpage(models.Model):
   topic = models.ForeignKey(Topic)
   name = models.CharField(max_length=264, unique=True)
   url = models.URLField(unique=True)

   def __str__(self):
      return self.name

class AccessRecord(models.Model):
   name = models.ForeignKey(Webpage)
   date = models.DateField()

   def __str__(self):
      return str(self.date)

# return value on admin interface

วันอังคารที่ 26 กุมภาพันธ์ พ.ศ. 2562

ติดตั้ง XFCE4 และ VNC4Server บน Ubuntu 18.04

Desktop GUI ใช้ xfce4
VNC Server ใช้ vnc4server
sudo apt install xfce4 xfce4-goodies xfonts-thai
sudo apt install vnc4server

ก่อนใช้งานครั้งแรกเราต้องสร้างรหัสผ่านสำหรับเชื่อมต่อ VNC Server เสร็จแล้วสั่งให้ VNC Server ทำงานหนึ่งครั้ง
เสร็จแล้วเราจะได้ไฟล์ xstartup ขึ้นมา จากนั้นทำการปิด VNC Server แล้วเข้าไป แก้ไขไฟล์ xstartup ใน ~/.vnc/xstartup
vncpasswd
vncserver
vncserver -kill :1

nano ~/.vnc/xstartup
#!/bin/bash
startxfce4 &

เมื่อทำการแก้ไขค่าเรียบร้อยแล้วให้ทำการ Save แล้วสั่งให้ VNC Server ทำงานอีกครั้ง
พิมพ์ ss -ltn เพื่อตรวจสอบว่ามี Port 5901 เปิดใช้งานอยู่ แสดงว่า VNC Server ทำงานแล้ว
vncserver
ss -ltn

วันศุกร์ที่ 22 กุมภาพันธ์ พ.ศ. 2562

Python3 กับ Virtual Environment / PIP

ติดตั้ง "python3" และ "python3-venv" ก่อนใช้งาน
sudo apt install python3 python3-venv

การสร้าง Virtual Enviroment
python3 -m venv [enviroment-name]

การ Activate ให้เราสั่ง source /bin/activate และ Deactivate เมื่ออยู่ใน venv แล้วให้พิมพ์ deactivate
source (venv)/bin/activate
decactivate