14 August 2024

Router'dan PPPoE Bilgileri Öğrenme

 Öncelikle, router'dan bağlantı yapılacak bir PC gerekli.

32 bit işlemcili ise ubuntu-16.04.6-server-i386.iso,

64 bir işlemcili ise herhangi bir ubuntu server sürümü indirilip, rufus ile USB'ye yazdırılır ve kurulum yapılır.



Sonra sırasıyla;

"apt install pppoe"

komutu girilir.

Aşağıdaki dosya yeniden düzenlenir;

 

# /etc/ppp/options

require-pap
login

# LCP settings
lcp-echo-interval 10
lcp-echo-failure 2

# Always Show Password
show-password

# Debug enable
debug

# PPPoE compliant settings
noaccomp
default-asyncmap
mtu 1492

# Log All
logfile /var/log/pppoe-server.log

# ---<End of File>--- 

 

"ifconfig -a" ile kullanılan adaptorun adı alınır.

"screen" ile bir background penceresi açılıp;

"pppoe-server -F -I ens3 -O /etc/ppp/options" komutu girilip, screen'den çıkılır.

Router ile PC ethernet bağlantısı kurularak, router açılır.


"cat /var/log/pppoe-server.log" komutu ile log kontrol edilir.

Kullanıcı adı ve şifresi logda görünecektir.

Log dosyası oluşmuyorsa, manuel olarak oluşturulabilir.



 

 

07 August 2024

Access Windows File System From Ubuntu Server ( 20.04, 22.04, 24.04 )

sudo apt-get update
sudo apt-get install cifs-utils


sudo mkdir /mnt/windows2012-share


sudo mount -t cifs "//192.168.10.212/C$/Users/Administrator/Desktop/Bilgi Aktar TFT" /mnt/windows2012-share -o username=administrator,password='Lxxxxxxxxxxx!',iocharset=utf8,file_mode=0777,dir_mode=0777



sudo nano /etc/fstab

 add line below:

//192.168.10.212/C$/Users/Administrator/Desktop/Bilgi\040Aktar\040TFT /mnt/windows2012-share cifs username=administrator,password='Lxxxxxxxxxxx!',iocharset=utf8,file_mode=0777,dir_mode=0777 0 0



And then:
write a file read script and do the jobs.

Backup Multiple MySQL Tables Into One Single Compressed File

 #!/bin/bash

# Set variables
DB_NAME="usakbasari"
OUTPUT_FILE="/var/www/citizen_tables_backup.sql.gz"
TABLES_FILE="/tmp/citizen_tables.txt"

# Prompt for MySQL password
echo -n "Enter MySQL root password: "
read -s MYSQL_PASSWORD
echo

# Fetch the list of tables
mysql -u root -p$MYSQL_PASSWORD -N -e "SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = '$DB_NAME' AND TABLE_NAME LIKE 'citizen_%'" > $TABLES_FILE

# Create or clear the output file
> $OUTPUT_FILE

# Read the table names and back up in chunks
while read -r TABLE; do
    echo "Backing up $TABLE..."
    mysqldump -u root -p$MYSQL_PASSWORD $DB_NAME $TABLE | gzip >> $OUTPUT_FILE
done < $TABLES_FILE

echo "Backup complete: $OUTPUT_FILE"

29 April 2017

How to Install HP LaserJet m1132 Printer on Ubuntu Server

Most of the Linux distributions include the Hewlett-Packard’s Linux Imaging and Printing (HPLIP) software that works perfectly in the *NIX Server Systems. HPLIP provides tools for managing the printers available in the system. For instance, the tool hp-setup adds new printers to the system configuring their parameters, among others, automatically installing required packages depending on the distribution running in the system. So far, everything is perfect.

The tool hp-setup installs the HP driver of CUPS, but it also requires a binary plugin to order to operate. The driver and the plugin both are usually installed without problems in your favorite distro. However, after the installation, when you try to print you may be warned that it is not possible, whereas the print server issues error messages (e.g., missing permissions, plugin errors, CUPS errors). These messages depend on the system and they may vary in, e.g., CUPS version, printer model or whatever is wrong. However, the real problem is based on the fact that the plugin downloaded/used by HPLIP is ONLY compiled for 32-/64-bit x86-based systems and, as you probably know, Raspberry PI is ARM-based architecture. Consequently, the plugin downloaded by hp-setup will not properly work in our UNIX server systems, while HPLIP does not recompile such a plugin for ARM-based architecture.

While we are waiting for HPLIP to include the plugins compiled for ARM processors, we can compile an open-source driver that supports our HP printer. I am talking about the driver foo2zjs which supports the protocol foo2xqx that our printer supports too. This driver is free software and was developed originally for the HP Laserjet M1005 MFP and similar printers. In particular, the HP M1132 MFP is also supported, so it can be used for our UNIX server to print.

The steps to compile the driver foo2xqx are below:

1-)Login to your server using ssh.
2-)wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz
3-)tar zxvf  foo2zjs.tar.gz
3-)cd foo2zjs
5-)make
6-)sudo make install
7-)sudo make cups

*some expediencies can be missing like "dc". You'll see the error while making cups.
You may install missing percipience with "apt-get install dc" on your ubuntu server, than make command again.

Once the source code compiles without errors, we must use the CUPS web-based GUI to configure the driver foo2xqx. The steps to configure the driver foo2xqx are the following:

Open the web browser and go to the “http://serverIP:631”.
Assuming you are logged to your server, go to Administration -> Add printer
Select local printers “HP LaserJet Professional M1132 MFP (HP LaserJet Professional M1132 MFP)”, and click on “Continue”. Assuming your M1132 is switched on and its USB cable is connected to the server. Otherwise, CUPS will not appropriately  detect your printer and show such message.
In the Connection field, you must indicate the USB protocol (i.e., usb://HP/…). If you were using the HPLIP driver, you would specify the HP protocol (i.e., hp://HP//…). Since you are using the open source driver, you must specify the first one. For your particular case (you may have another serial number so use yours):
usb://HP/LaserJet%20Professional%20M1132%20MFP?serial=00000000…...R1a
Remember to tick “Share this printer” and click on Continue.
Fill in the field Name (e.g., server_printer) that is compulsory. Description and Location are optional.
Now search for the appropriate PPD file clicking on “Provide a PPD file” and select the file HP-LaserJet_Pro_P1102.ppd deployed with the file foo2zjs.tar.gz (**). Click on “Add printer” and “Set default for printer”
Go to “Printers”, select your printer and send to print a test page thru “Maintenance” -> “Print test page” -> Go

If everything goes well, after 20 seconds approximately, you must hear the amazing noise that your printer makes when it start to print.

(**) If you are using MS Windows systems, copy the foo2zjs.tar.gz file and get the "HP-LaserJet_Pro_P1102.ppd" from .gz archieve, than use it.

04 July 2016

Submit Multiple Forms with One Button

Birden Fazla HTML Form Yönetimi


Aşağıdaki örnekte, birden fazla form elementi içeren sayfalarda, tek bir button ile toplu olarak istediğimiz sayfaya POST edeceğiz. Buradaki mantık; form içeriğindeki elementleri, JQUERY yardımı ile ekstra bir form içeriğine çağırıp, verileri tek bir form altında toplayıp öyle POST etmek.

Öncelikle index(.html, .php vs.) sayfamızı oluşturup, içine bu kodları yazıyoruz.


<html>
<head>
<!-- sistemimizdeki jquery dosyasini cagiriyoruz-->
<script type="text/javascript" src="jquery-latest.js"></script>

<!--
Bu fonksiyon ile, form1 ve form2 ID sine sahip, içeriğinde input, select, textarea gibi form elementlerinin değerlerini aliyoruz, ve birlesik_form ID'li formun içindeki hidden elemente atıyoruz.
-->
<script type="text/javascript">
    function form_birlestir() {
        $yeniform= $("#birlesik_form");
        $("#form1 input, #form2 input, #form1 select, #form2 select, #form1 textarea, #form2 textarea").each(function(){
            $yeniform.append("<input type='hidden' name='"+$(this).attr('name')+"' value='"+$(this).val()+"' />");
        });
}
</script>

</head>
<body>
<form id="form1">
    <input type='text' name='f1a' />
    <input type='text' name='f1b' />
</form>
<form id="form2">
<input type='text' name='f2a' />
<input type='text' name='f2b' />
</form>

<form id="birlesik_form" action="post.php" method="POST" onsubmit="form_birlestir(); return true;">
<input type="submit" />
</form>
</body>
</html>

Sonuçları görmek için post.php sayfamızı oluşturup, içine bu kodları yazıyoruz.


<?php
foreach($_POST AS $key=>$val) {
echo $key.":".$val."<br>";
                       }
?>










04 June 2016

Some Usefull Linux Terminal Commands

Bazı Faydalı Linux Komutları

1-)
[EN]Sometimes you may want to take a look at a file, only to the first lines of it, this is specially useful when you are watching at CSV files that you may be using to work with MySQL or PosgreSQL databases, in this cases what we need is to look at the head of the file to see its structure, but not all the file. To do this we use the head command.

[TR]Bazı durumlarda (.sql dosyalarına gözatmak, büyük dosyaların tamamını açmadan kontrol etmek, log dosyalarını kontrol etmek vs.) büyük boyutlu dosyaları ya da tamamını açmanın sıkıntılı olduğu durumlarda, bir dosyanın baştan belli satırlarına göz atmak isteyebilirsiniz. Bu gibi durumlarda;

root@mylinux:~# head -10 xxx.sql (first 10 lines of -xxx.sql- dosyasının ilk 10 satırına bakmak için)

2-)
[EN]Last 10 lines of a file
[TR]Dosyanın son 10 satırı için;

root@mylinux:~# watch tail -n 10 mylogfile.log


(*) Will be updated periodically.
(*) Düzenli olarak güncellenecektir.




03 June 2016

MySQL - Export and Import .sql Files

MySQL - Yedekleme ve Geri Yükleme İşlemleri


A-) Backup (Yedekleme Örnekleri)


1-) Tek  Database'in db_backup.sql dosyasına yedeklenmesi

$ mysqldump -u root -p db_adi > db_backup.sql

2-) Tüm Databaselerin all_db_backup.sql dosyasına yedeklenmesi

$ mysqldump -u root -p --all-databases > all_db_backup.sql

3-) MyDB içindeki t1 ve t2 adlı tabloların t_1_2_backup.sqldosyasına yedeklenmesi

$ mysqldump -u root -p MyDB t1 t2 > MyDB_t_1_2_backup.sql

4-) MyDB içindeki tüm tabloların sıkıştırılarak yedeklenmesi

$ mysqldump -u root -p MyDB | gzip > MyDB_backup.sql.gz

5-) Erişime açık uzak sunucudaki MyDB'yi yedekleme

$ mysqldump -P 3306 -h xxx.xxx.xxx.xxx -u root -p MyDB > db_backup.sql

(*) Örneklemelerde MySQL'e root kullanıcı adı ile login olunmuştur. CentOS gibi bazı işletim sistemlerinde, default olarak root aktif olmayabilir. Kod örneklerini kendi kurulumunuza göre düzenlemelisiniz.

B-) Restore (Yedekten Yükleme Örnekleri)

1-) data1.sql dosyasının database1 veritabanına yüklenmesi

$ mysql -u root -p -h localhost database1 < data1.sql

2-) data1.sql dosyasının, yerel ya da uzaktaki veritabanına IP üzerinden aktarımı

$ mysql -u root -p -h xxx.xxx.xxx.xxx database1 < data1.sql

3-) data1.sql dosyasının, yerel ya da uzaktaki veritabanına Hostname üzerinden aktarımı

$ mysql -u root -p -h mydomain.domain.com database1 data1.sql
 
4-) gunzip -c /var/www/citizen_tables_backup.sql.gz | mysql -u root -p your_database_name

27 May 2016

VMware - Adjusting The Pre-created HDD Size

VMware - Mevcut ve Aktif Disk Boyutunu Değiştirmek

UPDATE:25.03.2022

ubbuntu 18.04<=

 

# We need to resize the logical volume to use all the existing and free space of the volume group
$ lvm
lvm> lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
lvm> exit

# And then, we need to resize the file system to use the new available space in the logical volume
$ resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 58
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 120784896 (4k) blocks long.

# Finally, you can check that you now have available space:
$ df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              786M  1.2M  785M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  454G  3.8G  432G   1% /

 ------------------------------------------------------------------

 

 


Daha önce, VirtualBox üzerindeki sanal HDD boyutunu nasıl değiştirebileceğimizi görmüştük. Şimdi ise, VMware Sanal Makinası üzerinde kurulu *NIX sistemlerde, aynı işlemin nasıl yapılacağını göreceğiz.

1-) Öncelikle *NIX sistemimize terminalden erişip, "df -hT" komutu ile disk yapımızı, kullanılan ve boşta olan alanlar ile bölüm formatlarını inceleyeceğiz. 



2-) Sonraki aşamada, ESXi / Vcenter sunucumuza bağlanıp, boyutunu değiştirmek istediğimiz sanal makinaya ait hard disk boyutunu belirliyoruz.



3-) Partitioning için gerekli olan Gparted.iso canlı yansımasını http://gparted.org/download.php adresinden indirebilirsiniz. Bu aşamada işlemleri hızlandırmak adına, iso dosyasını bilgisayarınız yerine ESXi / Vcenter sunucunuza indirebilirsiniz. Bu işlemi yapabilmek için, ESXi sunucunuza erişim yetkinizin olması gerekiyor.

ESXi sunucumuza terminalden giriş yapıyoruz.


Resimdeki örnekte, ISO yansımaları için kullandığım yol, /vmfs/volumes/datastore1/ISOs olduğu için, "cd" komutu ile, GParted.iso dosyasını indirmek istediğimiz klasöre gidiyoruz. Bu yol sizin yapılandırmanıza göre değişebilir.

.ISO yansımalarını indirdiğimiz klasöre girdikten sonra, http://gparted.org/download.php adresinden güncel ve stabil ISO yansımasını indiriyoruz.

Dosyası sunucuya direk indirmek için;

"wget" komutu ile aktif linki belirtiyoruz.

Örnek ; "wget http://downloads.sourceforge.net/gparted/gparted-live-0.26.0-2-i686.iso"

4-) ISO dosyası sunucumuza indikten sonra, VMware üzerinden ISO dosyamızı sanal CD sürücümüze bağlıyoruz ve sistemi CD ile başlatıyoruz.(Boot esnasında ESC tuşu ile Boot Menu'ye girebiliyoruz)



5-) GParted Live başlangıcında aşağıdaki ekran çıkacaktır. Default seçenek ile devam ediyoruz.

6-) GParted Live (Default Settinfs) ile devam edildikten sonra karşımıza çeşitli sorular gelecektir. Bunlar Keymap, dil gibi seçenekler. Hepsini ENTER ile default seçeneklerle geçiyoruz. Bunlardan sonra karşımıza aşağıdakine benzer bir ekran gelecektir.


7-) Bu aşamada, daha önce ESXi/Vcenter istemcisi ile değiştirdiğimiz HDD boyutunun fazlalık olan kısmı, unallocated olarak görünecektir. Örnekte sda5 olarak listelenen kısım, genişletilecek olan kısımdır. Bu noktada dikkat etmemiz gereken, sda5'in içinde olduğu ana logical partitionu genişletmektir. Örnekte extented partition olarak görünen, sda2'dir. Bu partitiona sağ tıklayıp, resize/move seçeneği ile, genişletmek istediğimiz boyuta getiriyoruz. İşlemi bitirdikten sonra Apply seçeneği ile işlemleri uygulayıp, GParted uygulamasında çıkıyoruz ve tekrar *NIX sistemimize login oluyoruz.

8-) Terminale tekrar eriştikten sonra;

"cd /dev/mapper" komutu girerek, sonrasında "ls" ile dosya ve diznleri listeliyoruz.

Örnekte root ve swap'a ait bağlantılar gözükmektedir.


Kullanacağımız kısım elbette root kısmı olacaktır.
Bu noktada; 

"lvextend /dev/mapper/owncloud--vg-root /dev/sda5" komutunu girdikten sonra,

"resize2fs /dev/mapper/owncloud--vg-root" komutunu da girerek işlemi bitiriyoruz.


Sunucumuza "reboot" komutunu girip sonra "df -hT" ile kontrol ettiğimizde, artık HDD boyutunun istediğimiz gibi göründüğünü göreceksiniz.

(*) Bu işlemlerde yeterli tecrübeye sahip değilseniz, öncelikle test sunucularda denemeler yapmanızı, ve yedeklerinizi almanızı tavsiye ederim.

Hepinize iyi çalışmalar dilerim.




21 April 2016

VirtualBox - Adjusting The Pre-created HDD Size

VirtualBox - Mevcut ve Aktif Disk Boyutunu Değiştirmek


Windows işletim sistemlerinde yüklü Oracle VirtualBox üzerinde, daha önceden oluşturduğunuz sanal makinaların, disk kapasiteleri daha sonradan yetersiz gelebilir.

Hatta VMware'deki Thin-Provision ya da VirtualBox'ta Dynamic Disk Size özellikleri ile kurulmuş olsa dahi.

Aşağıdaki örnekte, Virtualbox üzerinde kurulu sanal makinaların, data güvenliğini riske etmeden nasıl genişleteceğimizi görüyoruz.


Windows işletim sisteminde Başlat/Çalıştır (WindowsKey+R) ile açılan kutuya CMD yazıp komut satırına düşüyoruz.

Daha sonra VirtualBox'umuzun kurulu olduğu dizine gidiyoruz(*);

1-) cd "C:\Program Files\Oracle\VirtualBox"


(*) Bu örnekte 64 bit işletim sistemi üzerinde kurulu,  64 bit VirtualBox ile çalıştık. 32 Bit sürümlerde, "Program Files(x86)" dizininde kurulu olacaktır.

2-) Bu adımda, VirtualBox'un terminali VBoxManage ile çalışacağız.

Önceki adımda Virtualbox'un kurulu olduğu dizine eriştik. Kontrol amaçlı olarak, Windows Explorer/Dosya Gezgini ile eriştiğimiz klasörde "VBoxManage.exe" dosyasının olduğunu teyit edip, terminale ağağıdaki komutu giriyoruz. Bu komutta, kapasitesini değiştirmek istediğiniz .vdi uzantılı diskimizi belirtiyoruz.

VBoxManage modifyhd “D:\VirtualBox VMs\Windows7\Windows7.vdi” --resize 25000



25000 olarak girdiğimiz değer, Megabyte cinsindedir. kendi durumunuza göre satırı düzenleyebilirsiniz.

Bundan sonraki aşama artık işletim sistemine, genişletilen alanı tanımlamak.
Eğer işletim sisteminiz MS Windows sürümlerinden biriyse;

Başlat/Çalıştır'a "diskmgmt.msc" yazıp Enter'liyoruz.
Burada, diskimizin genişletilen bölümü "Unallocated" olarak gözükecektir.
Bu alana Sağ Tıklayıp Yeni Birim/Birincil Bölüm oluşturabilirsiniz.
Windows'a yeni birim için hangi harfi kullanacağını da belirttikten sonra, yeni birime format atarak kullanmaya başlayabilirsiniz.

3.Parti bazı yazılımlarla (Ben MiniPartition Tool tercih ediyorum) aktif işletim sisteminin bulunduğu partition ile yeni oluşturduğunuz alanı birleştirip(merge fonksiyonu), tek partition olarak kullnabilirsiniz.

Eğer işletim sisteminiz *NIX dağıtımlarından biriyse, sonraki yazımızda bu konuyu işleyeceğiz.

VBoxManage ile yapabileceklerimiz ile ilgili olarak, daha sonra farklı işlemleri inceleyeceğiz.

Hepinize iyi çalışmalar dilerim.