2014 m. gegužės 29 d., ketvirtadienis

Skriptas suspaudžiantis pdf dokumentus

gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -sOutputFile=Output.pdf 1.pdf

  • /screen selects low-resolution output, and the lowest file-size.
  • /ebook selects medium-resolution output, with a medium file-size.
  • /printer and /prepress are both the high-resolution options, which is mainly used for printing PDFs. As you might have guessed, this option gives you the biggest file-size (yes, even bigger than your mother).

Literatūra:

http://jorge.fbarr.net/2012/11/29/reducing-pdf-file-size-in-linux/

2014 m. gegužės 28 d., trečiadienis

Ubuntu + Apache + php5 + mysql + phpmyadmin

APACHE

Pagrindinis failų talpinimo katalogas            /var/www/html/
# apt-get install apache2 # Debian apache instaliavimas
# yum install httpd # CentOS 6/7
# yum install "Web Server" # Visi CentOS 7 web serveriui reikalingi paketai

Paleidimas:

# systemctl enable httpd # Įgalinam servisą CentOS 7/Ubuntu - apache paketas.
# systemctl start httpd # Paleidžiam httpd servisą.
# systemctl staus httpd # Tikrinam httpd stausą.
# service httpd start start # CentOS 6.8
# /etc/init.d/httpd start 
# apache2ctl start                                

Perkrovimas:

# systemctl restart httpd.service # CentOS 7/Ubuntu - apache paketas.
# service httpd restart # CentOS 6.8  
# /etc/init.d/httpd restart                    
# apache2ctl restart                                           

Stabdymas:

# systemctl stop httpd.service # CentOS 7/Ubuntu - apache paketas.

# service httpd stop # CentOS 6.8  
# /etc/init.d/apache2 stop 
# apache2ctl stop                            


Apache konfiguracijos tikrinimas:

# apachectl configtest
# apachectl graceful

Teisių priskirimas apache vartotojui, kad galėtų kurti ir keisti dokumentus:
# chown -R www-data:www-data /var/www/ # Ubuntu

# chown -R apache:apache /var/www/ # CentOS


PHP diegimas

Ubuntu

# apt-get install php5
# apt-get install libapache2-mod-php5
# /etc/init.d/apache2 start /stop/restart

# apachectl start /stop/restart

CentOS 6/7

# yum install php

conf.d/ kataloge atsirado naujas modulis.
Perkraunam httpd, tam kad įsigaliotų naujas modulis.
# systemctl restart httpd

# tree /etc/httpd/conf.d/
├── autoindex.conf
├── main.conf
├── manual.conf
├── moodle.conf
├── php.conf * 
├── README
├── userdir.conf
└── welcome.conf

PHP Direktyvos:

Siuntimo maksimalus dokumento dydis 2MB.
upload_max_filesize 

Dokumentų siuntimo į serverį dydis, neturėtų būti mažesnis už "upload_max_filesize".
post_max_size

Numatytoji reikšmė apie 13s. Siunčiant didesnį dokumentą laiką reiktų pakeisti didesne reikšme.
max_execution_time

php informacija per komandinę eilutę.
php -i

php konfigūracijos keitimas.
vim /etc/php.ini

php atvaizdavimas puslapyje.

#file:/var/www/html/info.php
<?php
 phpinfo();
?>

mysql diegimas

CentOS 6

# yum install mysql-server php php-mysql

CentOS7

Reikalingas php modelis, kad php galėtų bendrauti su mysq.
# yum install php-mysql mariadb mariadb-server

# systemctl status mariadb.service # tikrinam servisą
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Įgalinam ir paleidžiam mysql servisą.
# systemctl enable mariadb.service
# systemctl start mariadb.service

Apsaugom duomenų bazę.
# mysql_secure_installation
/usr/bin/mysql_secure_installation

Pavyzdys, kaip kurti mysql db ir vartotojus per cli.
# mysql -u root -e "create database wordpress; GRANT ALL PRIVILEGES ON wordpress.* TO username@localhost IDENTIFIED BY 'password'"

Darbas su duomenų bazėmis.

Kaip automatiškai įjungti mysql, apache po perkrovimo ?

# chkconfig --list | egrep "http|mysql" # Tikrinam servisus
# chkconfig httpd on && chkconfig mysqld on # Įgalinam servisus

CentOS6
chkconfig mysqld on
chkconfig httpd on

CentOS7
chkconfig mariadb on
chkconfig httpd on

phpadmin

# apt-get -y install mysql-server
# apt-get -y install phpmyadmin

# dpkg-reconfigure phpmyadmin # phpadmin perkonfigūravimas

curl

# apt-get install curl libcurl3 libcurl3-dev php5-curl

Ugniasienė ir iptables su RHEL6/7:

Redhad 7 firewall nustatymus galima pakeisti, Firewall gui programoje.

Redhad 6 ar senesnėse versijose taisyklės turi būti įrašytos:  /etc/sysconfig/iptables kataloge:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

Arba komanda:
sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT
sudo service iptables save #išsaugome pakeitimus

Cenos7 httpd konfigūraciniai dokumentai:

[root@localhost httpd]# tree
.
├── conf
│   ├── httpd.conf
│   └── magic
├── conf.d
│   ├── autoindex.conf
│   ├── manual.conf
│   ├── README
│   ├── userdir.conf
│   └── welcome.conf
├── conf.modules.d
│   ├── 00-base.conf
│   ├── 00-dav.conf
│   ├── 00-lua.conf
│   ├── 00-mpm.conf
│   ├── 00-proxy.conf
│   ├── 00-systemd.conf
│   └── 01-cgi.conf
├── logs -> ../../var/log/httpd
├── modules -> ../../usr/lib64/httpd/modules
└── run -> /run/httpd

conf -pagrindiniai konfigūraciniai failai
conf.d - nustatymai, kur bus virtualus hostai ir modeliai kuri užkrauna apache, pvz:, php.
logs -> simboliniai linkai

Ubuntu 16.04 apache2/ konfigūraciniai dokumentai:

/etc/apache2 $ tree
.
├── apache2.conf
├── conf-available
│   ├── charset.conf
│   ├── javascript-common.conf
│   ├── localized-error-pages.conf
│   ├── other-vhosts-access-log.conf
│   ├── security.conf
│   └── serve-cgi-bin.conf
├── conf-enabled
│   ├── charset.conf -> ../conf-available/charset.conf
│   ├── localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
│   ├── other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
│   ├── security.conf -> ../conf-available/security.conf
│   └── serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf
├── envvars
├── magic
├── mods-available
│   ├── access_compat.load
│   ├── actions.conf
│   ├── actions.load
│   ├── alias.conf
│   ├── alias.load
│   ├── allowmethods.load
│   ├── asis.load
│   ├── auth_basic.load
│   ├── auth_digest.load
│   ├── auth_form.load

...
│   ├── status.conf -> ../mods-available/status.conf
│   └── status.load -> ../mods-available/status.load
├── ports.conf
├── sites-available
│   ├── 000-default.conf
│   └── default-ssl.conf
└── sites-enabled
    └── 000-default.conf -> ../sites-available/000-default.conf


Virtualaus hosto kūrimas

CentOS7 /etc/httpd/conf.d/moodle.conf

<VirtualHost *:80>
ServerName "192.168.56.111"
DocumentRoot "/var/www/http/moodle"
</VirtualHost>

<VirtualHost *:80# "*" rodo visus ip adresus,  :80 -  priskiria portą.
ServerName - # vardas kuriuo bus bus atpažintas virtualus host.
DocumentRoot - Nurodo kur talpinami pirminiai tinklapio dokumentai.

Dabar serveryje galima bus prieiti prie localhost/moodle puslapio.

SSL konfigūravimas:

CentOS7
# yum install mod_ssl 

Ranktas yra sugeneruojamas kai įdiegiamas mod_ssl paketas ir patalpinamas:
/etc/pki/tls/private/localhost.key  - raktas
/etc/pki/tls/certs/localhost.crt   - sukuriamas self-signed sertifikatas, panaudojant raktą.

Konfigūracinėje rinkmenoje reikia pakeisti SSLCertificateFile ir SSLCertificateKeyFile
/etc/httpd/conf.d/ssl.conf 


- www Pagrindinė .conf rinkmena Paketo pavadinimas
Cenos 6/7 /var/www/html/ /etc/httpd/conf/httpd.conf httpd
Ubuntu 16.04 /var/www/html/ /etc/apache2/apache2.conf apache2

Kitos konfigūracijos.
Apache raidžių jautrumo išjungimas Ubuntu serveriui.
Darbas su duomenų bazėm.
Kaip leisti priėjimą iš remote.

2014 m. gegužės 27 d., antradienis

nmap pavyzdžiai


Skanavimas veikia, kai srautą blokuoja ugniasienė, skenuojamas 21 portas

$ sudo nmap -p 21 x.x.x.x -PN

Skenuoja 192.168.1.0 potinklį ir nurodo veikiančius įrenginius.

$ sudo nmap -sP 192.168.1.0/24


Domanai

Skenuoja domeno portus ir pateikia whois informaciją

$ nmap --script whois test.lt

Starting Nmap 6.40 ( http://nmap.org ) at 2014-06-26 15:04 EEST
Nmap scan report for test.lt (195.8.218.22)
Host is up (0.0084s latency).
rDNS record for 195.8.218.22: domains.domreg.lt
Not shown: 996 filtered ports
PORT    STATE SERVICE
43/tcp  open  whois
53/tcp  open  domain
80/tcp  open  http
443/tcp open  https

Host script results:
| whois: Record found at whois.ripe.net
| inetnum: 195.8.218.0 - 195.8.219.255
| netname: DOMREG_LT
| descr: Kauno Technologijos Universitetas
| country: LT
| orgname: Kauno Technologijos Universitetas
| organisation: ORG-KTU2-RIPE
| email: hostmaster@domreg.lt
| person: Tomas Mackus
|_email: tomas@domreg.lt

Ieško su domenu susijusius pašto adresus

nmap -p80 --script http-email-harvest test.lt

Starting Nmap 6.40 ( http://nmap.org ) at 2014-06-26 15:02 EEST
Nmap scan report for test.lt (195.8.218.22)
Host is up (0.0047s latency).
rDNS record for 195.8.218.22: domains.domreg.lt
PORT   STATE SERVICE
80/tcp open  http
| http-email-harvest:
| Spidering limited to: maxdepth=3; maxpagecount=20; withinhost=test.lt
|_  hostmaster@domains.lt


zenmap išankstiniai nustatymai, ačiū Jerret
  •     Intense Scan (-T4 -A -v)
  •     Intense Scan plus UDP (-sS -sU -T4 -A -v)
  •     Intense Scan, all TCP Ports (-p 1-65535 -T4 -A -v)
  •     Intense Scan, no PING (-T4 -A -v -Pn)
  •     Ping Scan (-sn)
  •     Quick Scan (-T4 -F)
  •     Quick Scan Plus (-sV -T4 -O -F --version-light)
  •     Quick Traceroute (-sn --traceroute)
  •     Regular Scan (no options are used)
  •     Slow Comprehensive Scan (-sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script "default or (discovery and safe)")
Kaip ištrūkti iš apriboti apvalkalo su nmap?

$ echo "os.execute('/bin/sh')" > x.nse
$ sudo nmap –script=x.nse

2014 m. gegužės 12 d., pirmadienis

Nerodo usb rakto

Problema:
Įdėjus USB raktą, jo nerodo, pavyko užkrauti naudojant šias komandas:


Sprendimas:

$ sudo fdisk -l
Device Boot Start End Blocks Id System
/dev/sdb1 * 8064 30719999 15355968 c W95 FAT32 (LBA)


Sukuriam Mount Point:

$ sudo mkdir /media/external

Uždedam USB:

$ sudo mount -t vfat /dev/sdb1 /media/external -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

Nuimam USB:

$ sudo umount /media/external
arba
$ sudo umount /dev/sdb1

2014 m. gegužės 8 d., ketvirtadienis

Synology prieiga iš išorės - WebDAV

Pirmiausiai aktyvuojam WebDAV nustatymus:

Jei naudojate maršrutizatorių, kuris dalina DHCP adresus, reikės peradresuoti 5005 prievadą.
Daugiau informacijos galite rasti čia:
(http://www.synology.com/en-us/support/tutorials/456)

Windows 7

Kad galima būtų prijungti tinko diską (angl.Map network drive), reiks atlikti tolesnius pakeitimus.

  • Pakeisti BasicAuthLevel reikmę į "2", antraip neleis prisijungti, numatytoji reikmė būna - "1".
  • FileSizeLimitInBytes reikšmę pakeisti į (hex. 0xffffffff), kad leistų didesnių failų perkėlimą

 Kelias:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WebClient\Parameters\

BasicAuthLevel reikšmės:

    0 - Basic authentication disabled
    1 - Basic authentication enabled for SSL shares only
    2 or greater - Basic authentication enabled for SSL shares and for non-SSL shares


Kad įsigaliotų nustatymai pekraukite WebClient servisą.

Dabar galima pridėti diską:




Ubuntu 14.04 LTS

Atsidarom failų naršyklę:


 Suvedam serverio adresą su WebDAV prievadu pvz>(dav://serveris:portas ):





Literatūra:

http://chee-yang.blogspot.com/2010/09/microsoft-windows-and-webdav.html
http://www.qnap.com/index.php?lang=en&sn=4503
http://www.v-front.de/2013/02/my-owncloud-adventures-part-2.html
https://support.microsoft.com/kb/900900/en-us

2014 m. gegužės 6 d., antradienis

Firefox kūrėjų įrankių juosta

Kaip įjungti firefox developer toolbarą?

Shift + F2

Komandos:

screenshot  --fullpage   <> Išsaugo visą svetainę kaip nuotrauką.




 screenshot  <> Išsaugo matomą lauką, kaip nuotrauką.

Linux terminalo spalvos ir kodai

Terminalo nustatymus galima keisti dokumente:
gedit ~/.bashrc

Kaip įjungti terminalo spalvas?Spaudžiam Ctrl+F ir ieškom 
#force_color_prompt=yes” eilutės
Nutrinam "#", ir išsaugom.

Bashrc perkrovimas iš terminalo.
source ~/.bashrc
. ~/.bashrc  
Terminalo spalvų kodai.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;39m\]  - balta
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\] - raudona
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\] - geltona
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m\] - mėlina


Terminalo spalvos kodai.

Pagrindiniai terminalo kodai.

Teksto ir fono spalvinimo pvz.

#man colors
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;37m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'

#bash colors
bold=$(tput bold)
normal=$(tput sgr0)
RED=$'\e[0;31m'
GREEN=$'\e[0;32m'
YELLOW=$'\e[1;33m'
CYAN=$'\e[0;36m'
PURPLE=$'\033[0;35m'

NC=$'\033[0m' # No Color

Paimta Iš .bashrc.

Literatūra:
http://excid3.com/blog/ubuntu-color-terminal/
http://linuxcommand.org/tlcl.php

2014 m. gegužės 5 d., pirmadienis

Kaip konvertuoti iš pdf į excel

Galite naudoti - (https://www.pdftoexcelonline.com/) svetainę,
Reikia pasirinkti dokumentą(pdf)- "Select File"
Įvesti e-pašto adresą. ir paspausti "Convert It"
Sukonvertavus į excel formatą, atsius laišką, laišką, kuriame reiks paspausti nuorodą.