แสดงรายละเอียดระบบปฎิบัติการที่ใช้งาน OS
$ lsb_release -a
แสดงรายละเอียดระบบปฎิบัติการที่ใช้งาน OS
$ lsb_release -a
เทคนิค linux ในการลบช่องว่างชื่อไฟล์เอกสาร
Removing Spaces from Filename with Specific File Extension
find . -type f -name "* *.xml" -exec bash -c 'mv "$0" "${0// /_}"' {} \;
เอกสารการใช้งาน
https://www.linuxshelltips.com/remove-spaces-filenames-linux/
เทคนิคคำสั่ง linux ค้นหาไฟล์เอกสารที่แก้ไขใน 1 วันหรือหลายวัน
find /home/dnyce/Documents/Work/LinuxShellTips/September -mtime -1 -ls
การค้นหาไฟล์ที่แก้ไข 3 วันที่ผ่านมา
find /home/dnyce/Documents/Work/LinuxShellTips/September -mtime -3 -ls
คำสั่งในการค้นหาข้อความและแทนที่ข้อความในไฟล์เอกสาร
sed -i 's/[THE_OLD_TERM]/[THE_NEW_TERM]/' [TARGETED_FILE]
sed -i 's/LinuxShellTips/this site/' test.txt
หรือ
sed -i 's/[THE_OLD_TERM]/[THE_NEW_TERM]/g' [TARGETED_FILE]
sed -i 's/this site/LinuxShellTips/g' test.txt
การแสดงไฟล์ เรียงตามขนาดไฟล์ใหญ่สุด
ls -lhS
การแสดงไฟล์ เรียงตามวันที่ปัจจุบันไปหาอดีต
ls -lhrS
การติดตั้ง Ripgrep ใช้สำหรับคนหาข้อความในไฟล์เอกสาร
sudo apt-get install ripgrep
คำสั่งค้นหาข้อความในไฟล์เอกสาร
rg 'question' LinuxShellTips.md
คำสั่งค้นหาแบบหลายข้อความในไฟล์เอกสาร
rg -e 'user' -e '8' LinuxShellTips.txt
คำสั่งในการค้นหาบรรทัดว่า Empty Lines และลบในไฟล์เอกสาร
grep -v '^[[:space:]]*$' i_have_blanks.txt
หรือ
grep '\S' i_have_blanks.txt > tmp.txt
หรือใช้คำสั่ง sed
sed '/^[[:space:]]*$/d' i_have_blanks_too.txt
auto eth0
iface eth0 inet static
address 192.168.1.128
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
$ sudo vi /etc/resolvconf/resolv.conf.d/basesearch (domain name)
nameserver 8.8.8.8
nameserver 8.8.4.4
# Install prerequisites
sudo apt-get install php-dev libmcrypt-dev gcc make autoconf libc-dev pkg-config
# Compile mcrypt extension
sudo pecl install mcrypt-1.0.1
# Just press enter when it asks about libmcrypt prefix
# Enable extension for apache
echo "extension=mcrypt.so" | sudo tee -a /etc/php/7.2/apache2/conf.d/mcrypt.ini
# Restart apache
sudo service apache2 restart
$ sudo phpenmod mcrypt<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All <--- เพิ่มบรรทัดนี้เข้าไป
....
$ sudo systemctl restart apache2AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
$ sudo htpasswd -c /etc/phpmyadmin/.htpasswd usernameallow_writeable_chroot=YES
เพื่อให้สามารถ lock home directory ได้ผ่าน port 21
sudo apt install ntpdate
sudo vi /etc/cron.daily/ntpdate
#!/bin/sh
ntpdate NTP_SERVER >> /tmp/ntpdate.log
chmod +x /etc/cron.daily/ntpdate
sh /etc/cron.daily/ntpdate
sudo apt-get --version
sudo apt-get -o Acquire::ForceIPv4=true update
sudo vi /etc/apt/apt.conf.d/99force-ipv4
Acquire::ForceIPv4 "true";