Tag Archives: console

HP10xx Hewlett-Packard LaserJet 1020 Debian Lenny (stable)

Tam naudosime:

heh, daugybe paketu prisidiegiau, tai nezinia ar kazko nepraleidau… (Galbut libusb, cupsys?)
Taigi pradzioje prisijunkim:


deb http://debian.mirror.vu.lt/debian squeeze main
deb-src http://debian.mirror.vu.lt/debian squeeze main


i byla: /etc/apt/sources.list.d/squeeze.list
tuomet susidiekime p910nd:


apt-get update
apt-get install p910nd


ir nepamirskime squeeze pasalinti is resursu: komandele:


rm /etc/apt/source.list.d/squeeze.list


Toliau mums beliko sudiegti draiveriukus musu printeriui ir paleisti spausdinimo demona…
Taigi p910nd spausdinimo demono konfiguravimas byloje: /etc/default/p9910nd


# Printer number, if not 0
P910ND_NUM=""
# Additional daemon arguments, see man 8 p910nd
P910ND_OPTS="-b -f /dev/usb/lp0 0"
# pas mane jis prisijunge prie device: /dev/usb/lp0 ;)

# Debian specific (set to 1 to enable start by default)
P910ND_START=1


Ir paleiskime si demona:


/etc/init.d/p910nd restart


Toliau parsisiuskime failiuka: sihp1020.dl ir issiarchyvuokime:


wget http://lpic.lt/wp-content/uploads/2010/08/sihp1020.dl.tar.bz2
bunzip2 sihp1020.dl.tar.bz2
tar -xf sihp1020.dl.tar


tuomet numeskim si firmware’a musu printeriui:


cat sihp1020.dl > /dev/usb/lp0


Kaip minejau /dev/usb/lp0 i cia prisilinkino mano usb printeriukas 🙂
toliau 🙂 kas?
lyg ir reiktu tiesiog uzeiti i http://localhost:631 ?

Norint, kad ikisus USB laideli dar reiktu nukopinti skripta a i /usr/sbin/hplj1020 taigi byla a:


#!/bin/sh

if [ -f /tmp/busy-prn ]; then
exit 99
fi

touch /tmp/busy-prn

sleep 2

D=$(awk '/Manufacturer/ {print $2} ' /proc/bus/usb/devices | grep -v Linux | wc -l)

if [ $D == 1 ]; then
# No daemon running
# Start daemon if printer is attached
if [ -e /dev/usb/lp0 ]; then
/etc/init.d/p910nd start
sleep 1
cat /root/sihp1020.dl > /dev/usb/lp0
fi
else
if [ $D == 0 ]; then
# No Printer attached but daemon running
# Kill daemon
/etc/init.d/p910nd stop
fi
fi

# Kill the spare process //hid3

kill `pidof p9100d | awk '{print $2}'`

rm -f /tmp/busy-prn


Ir kopijavimas:


cp a /usr/sbin/hplj1020


Lyg ir tiek ;)

External link:
https://answers.launchpad.net/ubuntu/+source/hplip/+question/45032

telnet i ftp (telnet into ftp server)

prisijunkime prie ftp serverio:
telnet IP 21
Gauname atsakyma:
220 ProFTPD 1.3.1 Server (ProFTPD) [xx.xx.xx.xx]
Irasome:
USER anonymous
Atsakymas:
331 Anonymous login ok, send complete email address as your password
Pateikiame pass:
PASS blogger@webdigi.co.uk
Atsakymas:
230 Anonymous access granted, restrictions apply
Pakeiciam darbini kataloga servery:
CWD ietf/ftpext/
Atsakymas:
250 CWD command successful
Nusistatome pasyva:
PASV
Atsakymas:
227 Entering Passive Mode (xx,xx,xx,xx,151,31).
Parsisiuskime failiuka:
RETR ftpext-charter.txt
Atsiuntimas:
150 Opening ASCII mode data connection for ftpext-charter.txt (6060 bytes)
226 Transfer complete

Iseiname:
QUIT
Goodbye:
221 Goodbye.

Tuomet noredami parsisiusti failiuka turime prisijungti kita telneta prie passive port’o. Kaip jau spejote pastebeti kai ivedeme passive gavome eilute:227 Entering Passive Mode (xx,xx,xx,xx,151,31). kaip matome, pirmi keturi yra IP adresas o like portui generuoti skirti skaiciai: 151 * 256 + 31 = 38687. Taigi prisijunkime:
telnet xx.xx.xx.xx 38687
Kiekviena komanda yra vykdoma i atskira porta 😉 kiekviena karta reik skaiciuotis portus ir nusistatyti pasv 😉

telnet i pasta (telnet into smtp server)

Telnetiname i pasta:
telnet mail.domain.ext 25
Gauname pranesima:
Trying ???.???.???.???...
Connected to mail.domain.ext.
Escape character is '^]'.
220 mail.domain.ext ESMTP Sendmail ?version-number?; ?date+time+gmtoffset?

Valio mes viduje. Pasisveikinkime ir pasakykime kokis musu domenas:
HELO local.domain.name jei norime Extended : EHLO local.domain.name
Turetu atsakyti:
250 mail.domain.ext Hello local.domain.name [loc.al.i.p], pleased to meet you
Dabar turime parasyti savo email:
MAIL FROM: mail@domain.ext
Atsakymas:
250 2.1.0 mail@domain.ext... Sender ok
Rasome kam:
RCPT TO: mail@otherdomain.ext
Gauname atsakyma:
250 2.1.0 mail@otherdomain.ext... Recipient ok
Tuomet kompouzinam laiska:
DATA
Subject:-antraste cia-
bla bla bla
bla bla bla
.

Pabaigiam laiska tasku ir gauname atsakyma:
250 2.0.0 ???????? Message accepted for delivery
Tuomet pabaigiam sesija:
QUIT
Gauname atsakyma:
221 2.0.0 mail.domain.ext closing connection
Connection closed by foreign host.

conky – system monitoring

Sveiki,

Pastaruoju metu radau naują programėlę. Gal matėte screenshots (pvz tokius). Taigi tokį vaizdą galite pasiekti ir jūs. Tokia programėlė yra Conky. Jos pagalba galite sužinoti kokia programa užima daugiausia atminties, RAM ir pan.

Man yra tekę naudoti top, ntop, munin, bandwidthd. Žinoma, jie yra visai kitokio pobūdžio. ir tik conky leidžia informaciją patalpinti ant darbalaukio.

Taigi, kai jį įsidiegti:


# aptitude install conky


Konfigūracinis failas:


$ vi ~/.conkyrc


Failo turinys:


alignment top_right
background no
border_width 1
border_margin 4
cpu_avg_samples 2
default_color white
default_outline_color white
#default_shade_color white
default_shade_color yellow
draw_borders yes
draw_graph_borders yes
draw_outline no
draw_shades no
font 6x10
gap_x 5
gap_y 20
minimum_size 5 5
net_avg_samples 2
no_buffers yes
out_to_console no
#own_window yes
own_window no
own_window_class Conky

own_window_type normal
#own_window_type override
own_window_transparent yes
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer no
show_graph_scale no
show_graph_range no

TEXT
${scroll 26 $nodename - $sysname $kernel on $machine | }
$hr
${color lightgrey}Uptime:$color $uptime ${color lightgrey}- Load:$color $loadavg
${color lightgrey}CPU Usage:${color} $cpu% ${cpubar}
${color lightgrey}RAM Usage:$color $mem/$memmax - $memperc% ${membar}
${color lightgrey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar}
${color lightgrey}Processes:$color $processes ${color grey}Running:$color Ėrunning_processes
$color$stippled_hr
${color lightgrey}eth0:Down:${color #8844ee} ${downspeed eth0} k/s${color lightgrey} ${offset 51}eth0:Up:${color #22ccff} ${upspeed eth0} k/s
${color #0000ff}${downspeedgraph eth0 32,150 ff0000 0000ff} ${color #22ccff}${upspeedgraph eth0 32,150 0000ff ff0000}
${color lightgrey}File systems:
/ $color${fs_used /}/${fs_size /} ${fs_bar /}
${color}Name PID CPU% MEM%
${color red}${cpugraph 0000ff 00ff00}
${color #ddaa00} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
${color}Mem usage
${color green}${memgraph 0000ff 00ff00}
${color #ddaa00} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${color lightgrey} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${color lightgrey} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
$stippled_hr

${color #ddaa00}Port(s)${alignr}#Connections
$color Inbound: ${tcp_portmon 1 32767 count} Outbound: ${tcp_portmon 32768 65535 count}${alignr}ALL: ${tcp_portmon 1 65535 count}
${color #ddaa00}Inbound Connection ${alignr} Local Service/Port$color
${tcp_portmon 1 32767 rhost 0} ${alignr} ${tcp_portmon 1 32767 lservice 0}
${tcp_portmon 1 32767 rhost 1} ${alignr} ${tcp_portmon 1 32767 lservice 1}
${tcp_portmon 1 32767 rhost 2} ${alignr} ${tcp_portmon 1 32767 lservice 2}
${tcp_portmon 1 32767 rhost 3} ${alignr} ${tcp_portmon 1 32767 lservice 3}
${tcp_portmon 1 32767 rhost 4} ${alignr} ${tcp_portmon 1 32767 lservice 4}
${tcp_portmon 1 32767 rhost 5} ${alignr} ${tcp_portmon 1 32767 lservice 5}
${tcp_portmon 1 32767 rhost 6} ${alignr} ${tcp_portmon 1 32767 lservice 6}
${tcp_portmon 1 32767 rhost 7} ${alignr} ${tcp_portmon 1 32767 lservice 7}
${tcp_portmon 1 32767 rhost 8} ${alignr} ${tcp_portmon 1 32767 lservice 8}
${tcp_portmon 1 32767 rhost 9} ${alignr} ${tcp_portmon 1 32767 lservice 9}
${color #ddaa00}Outbound Connection ${alignr} Remote Service/Port$color
${tcp_portmon 32768 65535 rhost 0} ${alignr} ${tcp_portmon 32768 65535 rservice 0}
${tcp_portmon 32768 65535 rhost 1} ${alignr} ${tcp_portmon 32768 65535 rservice 1}
${tcp_portmon 32768 65535 rhost 2} ${alignr} ${tcp_portmon 32768 65535 rservice 2}
${tcp_portmon 32768 65535 rhost 3} ${alignr} ${tcp_portmon 32768 65535 rservice 3}
${tcp_portmon 32768 65535 rhost 4} ${alignr} ${tcp_portmon 32768 65535 rservice 4}
${tcp_portmon 32768 65535 rhost 5} ${alignr} ${tcp_portmon 32768 65535 rservice 5}
${tcp_portmon 32768 65535 rhost 6} ${alignr} ${tcp_portmon 32768 65535 rservice 6}
${tcp_portmon 32768 65535 rhost 7} ${alignr} ${tcp_portmon 32768 65535 rservice 7}
${tcp_portmon 32768 65535 rhost 8} ${alignr} ${tcp_portmon 32768 65535 rservice 8}
${tcp_portmon 32768 65535 rhost 9} ${alignr} ${tcp_portmon 32768 65535 rservice 9}
${tcp_portmon 32768 65535 rhost 10} ${alignr} ${tcp_portmon 32768 65535 rservice 10}
${tcp_portmon 32768 65535 rhost 11} ${alignr} ${tcp_portmon 32768 65535 rservice 11}
${tcp_portmon 32768 65535 rhost 12} ${alignr} ${tcp_portmon 32768 65535 rservice 12}
${tcp_portmon 32768 65535 rhost 13} ${alignr} ${tcp_portmon 32768 65535 rservice 13}
${tcp_portmon 32768 65535 rhost 14} ${alignr} ${tcp_portmon 32768 65535 rservice 14}
${tcp_portmon 32768 65535 rhost 15} ${alignr} ${tcp_portmon 32768 65535 rservice 15}
${tcp_portmon 32768 65535 rhost 16} ${alignr} ${tcp_portmon 32768 65535 rservice 16}
${tcp_portmon 32768 65535 rhost 17} ${alignr} ${tcp_portmon 32768 65535 rservice 17}
${tcp_portmon 32768 65535 rhost 18} ${alignr} ${tcp_portmon 32768 65535 rservice 18}
${tcp_portmon 32768 65535 rhost 19} ${alignr} ${tcp_portmon 32768 65535 rservice 19}

Ir paleidžiame programą mūsų naudotoju.

backup script bash tar bzip2

touch /backup.sh
mkdir /backup
chmod a+x /backup.sh

#!/bin/bash
cd /backup
file="`date +%Y%m%d-%H%M%S`.tar"
#echo $file
tar -cf new.backup/$file folder_to_backup
cd /backup/new.backup
bzip2 -zq9 $file
#rm $failas
echo "backed up `date` \n" >> /backup/backup.made
#remove older then 3 days to /backup/old.backup
find -type f -mtime +3 -exec mv {} ../old.backup/ \;
cd ../old.backup
# completely remove backups, older then 7 days
find -type f -mtime +7 -exec rm -f {} ../old.backup/ \;

enlightenment repozitoriju diegimas debian terpei

Žinau, jūs jau daugybe kartų esate girdėję apie enlightenment aplinką. Tikriausiai esate ją ir išbandę debian repozitorijuose?! Deja, tokie bandymai būna nelabai vykę. Dažniausiai įsidiegia e16, o jeigu ir e17 tai be visų galimų modulių… o tuo tarpu prisidėję į resursus http://packages.enlightenment.org/ resursą mes galėsime pasisipūsti vieną iš naujausių versijų ir ne tik naujausių, bet ir PILNĄ, kas yra labiausiai aktualu.
Taigi atsidarome failiuką /etc/apt/sources.list su jūsų pamegtu teksto redaktorium:
# vi /etc/apt/sources.list
Tuomet įrašome ten eilutę:
deb http://packages.enlightenment.org/debian lenny main extras

Tuomet pridedame repozitorijaus raktą ir paleidžiame atnaujinimą paketų sąrašo:
# wget http://packages.enlightenment.org/repo.key -o /tmp/b && apt-key add /tmp/b && rm /tmp/b && apt-get update

Taip pat jums bus smalsu žvilgtelt čia

date – getting time to your needs

hello, how to get time to see what time is now in linux command prompt? simply:
$ date
Mon May 10 15:56:05 EEST 2010
But i need with no spaces and colons… i use all mighty sed 🙂

$ date | sed 's/\ /_/g' | sed 's/:/-/g'
Mon_May_10_15-56-31_EEST_2010
Hurray!?! No! I still need something else: YYYY-MM-DD HH:mm:ss howto get it? simply:
$ date +%Y-%m-%d\ %H:%M:%S
2010-05-10 15:57:01
How to set the date? simply:
$ date +%Y-%m-%d.%H:%M:%S -s "2010-05-03.12:56:01"
$ date
Mon May 3 12:56:05 EEST 2010

for setting up time you can simply get ntp (network time protocol) to sync your clock with pool severs 😉

mounting ftp in bash

In english
Kaip prijungti ftp serveri kaip lokalų katalogą?
Paieškojus radau keletą sprendimų, juos visus išbandžiau, ir priėjau išvadų, kad lyg ir patogiausias būdas tai pasinaudojus curlftpfs. Įdiekite jį pasinaudodami aptitude ar betkokį kitą paketų valdymo įrankį. (Papildomai apie curlftpfs_*.deb)
Taigi, mes jau galime prisijungti direktoriją prie ftp serveriuko, kaip tai padaryti?

Prijungimui per fstab įgyvendinti mums reikia atlikti 2 veiksmus:

  • pridėti įrašą į /etc/fstab
  • sukurti mount.curlftpfs

Taigi pridedame įrašą į /etc/fstab


ftpusername:ftppassword@ftp.site.address /path/to/mountpoint curlftpfs rw,allow_other,uid=userid,gid=groupid 0 0


ir tuomet sukuriame mount.curlftpfs tam, kad mount suprastų ką ir kaip reikia prijungti naudojant curlftpfs failų sistemą.


# ln -s `which curlftpfs` /sbin/mount.curlftpfs


Ir antrasis būdas tiesiog kiekvieną kartą paleidžiant OS prijungti pasinaudojant curlftpfs ftp direktoriją, deja jeigu mes neturėsime krovimosi metu tinklo, mum nepavyks prisijungti šio resurso. Taigi paprasčiausiai įdedame eilutę:


curlftpfs ftpusername:ftppassword@ftp.site.address /path/to/mountpoint/


Žinoma, neturint tinklo abiem atvejais negalėsime prisijungti prie ftp resurso, bet pirmuoju būdu atsiradus tinklui, galėsime tiesiog įrašyti: mount /path/to/mountpoint
ir resursas bus automatiškai prijungtas.


How to mount some ftp resource to my Debian box?
After doing some searches i have found some ways, i have tried them and wrote down the way i liked using curlftpfs. aptitude or apt-get it from curlftpfs_*.deb repositories or compile it from sources, what ever you like. After you have installed these you may choose howto mount our ftp to /path/to/mountpoint.

connecting using fstabwe wil need to make 2 steps:

  • add a row to /etc/fstab
  • create mount.curlftpfs

So let’s add some line to /etc/fstab


ftpusername:ftppassword@ftp.site.address /path/to/mountpoint curlftpfs rw,allow_other,uid=userid,gid=groupid 0 0


last step is to let mount recognize the filesystem type


# ln -s `which curlftpfs` /sbin/mount.curlftpfs


And the second one is just to add a row to /etc/rc.local file.


curlftpfs ftpusername:ftppassword@ftp.site.address /path/to/mountpoint/


Of course both ways will not work if we will not have active connection at startup. But using fstab way you can easily mount it: mount /path/to/mountpoint

External links:
some more info on forums