Ubuntu 8.04 (Hardy Heron) và HP1020 printer (HOws To)

foo2zjs: a linux printer driver for ZjStream protocol

Download and Install

Click the link, or cut and paste the whole command line below to download the driver.

    $ wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz

Now unpack it:

Unpack:
    $ tar zxf foo2zjs.tar.gz
    $ cd foo2zjs

Now compile and install it. The INSTALL file contains more detailed instructions; please read it now.

Compile:
    $ make

Get extra files from the web, such as .ICM profiles for color correction,
and firmware.  Select the model number for your printer:

 $ ./getweb 1020

Install driver, foomatic XML files, and extra files:
    $ su			OR	$ sudo make install
    # make install

(Optional) Configure hotplug (USB; HP LJ 1000/1005/1018/1020):
    # make install-hotplug	OR	$ sudo make install-hotplug

(Optional) If you use CUPS, restart the spooler:
    # make cups			OR	$ sudo make cups

Then

 # system-config-printer
OR
Gnome-panel ==> System ==> Administration ==> Printting
printer-configuration

=> Click New Printer

select-connection

Choose OTher
Open Terminal -> Enter Command : lsusb
(Liệt kê usb device connect vào máy)

lsusb

Enter Command : hp-makeuri bus_number:device_number

hp-makeuri

Copy the Cups URI và Paste vào cừa sổ New Printer => Enter Device URI và Click Foward

new-printer

Click Foward



Click Foward


Apply => Done
Restart Ubuntu

Open Printing Database
foo2zjs driver
hp-makeuri utility
hp-setup

Linux exercises for examination - Updated !!

Day la 9 bai ma minh co de bai … con cac bai con lai…hoac co cho nao ko hieu thi cac ban cu comment thac mac cho minh hoac wa YM! billyduc1987 …. Chuc moi nguoi thi tot ^^

Vi co 10 bai nhung bai 4 va bai 9 bi trung nen mat 1 bai…ai co bai do thi send cho D, bai 8 va bai 10 phai chay = quyen root, 2 bai nay billy chua chay thu lai trong F9 vi may moi cai lai…mac cong xoa user…ban nao co may ao thi chay thu lai … va bao loi cho D biet de fix loi…giai thuat thi OK do !

1. Viết chương trình in ra n dòng như sau: (n truyền tham số; n=1..30).
VD: n=5
11111
22222
33333
44444
55555

Cần phải kiễm tra:
+ Nếu n < 1 thì báo lỗi và thoát chương trình.
+ Nếu n > 30 thì báo lỗi và thoát chương trình.

echo -n “Nhap n = “
read n
if [ $n -le 1 -o $n -ge 30 ]
then
echo “Error give n between (1 - 30)”
exit 1
else
for ((i=1;i<=n;i++))
do
for ((j=1;j<=n;j++))
do
echo -n “$i “
done
echo
done
fi

2. Hãy viết chương trình xuất ra trắng đen như bàn cờ quốc tế n x n (n nhập từ bàn phím)
Phần kiễm tra:
Không cần phải kiễm tra n nhập vào như thế nào.
VD: n được nhập = 9

echo -n “Nhap n = “
read n
echo
t=0
for((i=1;i<n;i++))
do
t=`expr $i % 2`
if [ $t -eq 1 ]
then
for((j=1;j<n;j++))
do
echo -e -n “33[47m "
echo -e -n "33[40m "
done
echo -e "33[0m "
else
for((j=1;j<n;j++))
do
echo -e -n "33[40m "
echo -e -n "33[47m "
done
echo -e "33[0m "
fi
done
echo -e "33[0m "

3. Hãy cho biết giá trị của n! (n truyền từ tham số n >= 0) VD:
Nếu n=0 ==> n!=1
Nếu n=1 ==> n!=1
Nếu n=2 ==> n!=2
Nếu n=3 ==> n!=6
Nếu n=4 ==> n!=24
...

Cần phải kiễm tra:
+ Nếu không có tham số nào thì báo lỗi và thoát chương trình.
+ Nếu n < 0 thì báo lỗi và thoát chương trình.

echo -n "Nhap n giai thua = "
read n
if [ $n -le 1 ]
then
echo “n! = 1″
else
gt=1
i=1
while [ $i -le $n ]
do
gt=`expr $gt \* $i`
i=`expr $i + 1`
done
echo “n! = $gt”
fi

5. Sử dụng vòng lập for để in “1. Hello Word” n lần (n = 0..100) . với n truyền tham số.
Cần phải kiễm tra:
+ Nếu n < 0 thì báo lỗi và thoát chương trình.
+ Nếu n > 100 thì báo lỗi và thoát chương trình.

echo -n “Nhap n = “
read n
if [ $n -gt 100 -o $n -lt 0 ]
then
echo “Error…Give number between 0 -> 100 please”
exit 1
else
for ((i=1;i<=n;i++))
do
echo “$i. Hello World”
done
fi

6. Viết chương trình nhận vào 2 số a, b. Cho biết tích 2 số a * b là bao nhiêu.
Cần phải kiễm tra:
+ Nếu không đủ tham số thì báo lỗi và thoát chương trình.

if [ $# -lt 2 -o $# -gt 2 ]
then
echo “Error…give 2 number for multiply”
exit 1
else
echo “Tich $1 * $2 = `expr $1 \* $2`”
fi
7. Viết chương trình in bảng cửu chương n (n = 1..10) (n truyền từ tham số. Nếu không có tham số nào thì default n = 2 Nếu có tham số nhưng không thuộc từ 1..10 thì báo lỗi và thoát chương trình.
Cần phải kiễm tra:
+ Nếu n < 1 thì báo lỗi và thoát chương trình.
+ Nếu n > 10 thì báo lỗi và thoát chương trình.

if [ $# -eq 0 ]
then
n=2
elif [ $# -gt 1 ]
then
echo “Error…Give 1 number for multiply number”
exit 1
else
n=$1
fi
if [ $n -lt 1 -o $n -gt 10 ]
then
echo “hehe…we give u only 1 to 10″
exit 1
else
for((i=1;i<=10;i++))
do
echo “$n * $i = `expr $n \* $i`”
done
fi

8. Viết chương trình:
+ tạo các thư mục /g1
/g2
/g1/u1
/g1/u2

+ Tạo 2 user (user1 và user2) và 2 nhóm (g1 và g2).
+ Cấp quyền cho user1 toàn quyền trên /g1/u1
+ Home dir của user2 là /g1/u2
+ nhóm g2 toàn quyền trên thư mục /g2
+ Nhóm khác chỉ đọc trên thư mục /g2

Phần kiễm tra:
+ Không cần phải kiểm tra gì cả.

mkdir /home/g1
mkdir /home/g1/u1
mkdir /home/g2
mkdir /home/g1/u2
groupadd g1
groupadd g2
useradd -p hihi -d /home/g1/u1 -g g1 u1
chown u1 /home/g1/u1
useradd -p hehe -d /home/g1/u2 -g g1 u2
chgrp g2 /home/g2
chmod 744 /home/g2

chay bai 8 bang quyen root (su -) ./bai8
9. Viết chương trình nhận vào 1 tham số tên của bạn và 1 tham số đường dẫn tên file, rồi xuất ra màn hình nhiều dòng của file , mỗi dòng đều có cấu trúc: : nội dung dòng i”. Với được truyền từ tham số đầu tiên, tên file được truyền tiếp theo.
Cần phải kiễm tra:
+ Nếu thiếu 1 trong những tham số thì báo lỗi và thoát chương trình.
+ Nếu file không tồn tại báo lỗi và thoát chương trình.

if [ $# -lt 2 -o $# -gt 2 ]
then
echo “Error…Give $1 = yourname … give $2 = yourpath”
exit 1
else
name=$1
path=$2
while read linei
do
echo “$linei — $name — $path”
done < $path
fi

./bai9 yourname ./yourpath          ex: ./bai9 billyduc ./text.txt

text.txt

haha
hehe
hihi
hoho
huhu

10. Tạo n user va n/2 nhóm (n nhập từ bàn phím với n > 0 và chẳn): user1 user2 : nhom1; user3, user4: nhom 2.

Cần phải kiễm tra:
+ Nếu không có tham số nào thì báo lỗi và thoát chương trình.
+ Nếu n <= 0 thì báo lỗi và thoát chương trình.

if [ $# -ne 1 ]
then
echo “Error…Give 1 arguments : an even number”
exit 1
else
n=$1
t=`expr n % 2`
if [ $n -lt 1 -a $t -eq 1 ]
then
echo “Error..give even number”
exit 1
else
for((i=1;i<=t;i++))
do
groupadd g$i
j=`expr $i * 2 - 1`
useradd -g g$i u$j
j=`expr $i * 2`
useradd -g g$i u$j
done
done
fi
fi

The End !!
Updated - 2 bai cuoi
# sort danh sach gom nhieu truong khac nhau
if [ ! -e $1 ]
then
echo “File $1 not found”
exit 1
else
tr -s ‘\t’ ‘ ‘ /tmp/sortfile.$$#
while read dong
do
sotu=`echo $dong | wc -w`
holot=`echo $dong | cut -d : -f1`
ten=`echo $dong | cut -d : -f2`
misc=`echo $dong |cut -d : -f3-$sotu`
echo “$ten : $holot : $misc” >> /tmp/sortfile.$$
done
sort /tmp/sortfile.$$ |
while read i
do
sotu=`echo $i | wc -w`
ten=`echo $i | cut -d : -f1`
holot=`echo $i | cut -d : -f2`
misc=`echo $i |cut -d : -f3-$sotu`
echo “$holot $ten $misc”|tr -s ‘\t’ ‘ ‘>> ketquadiem
done
cat ketquadiem
#cat /tmp/sortfile.$$
fi

./baicuoi1 tendanhsach (chay file bai cuoi)

file danh sach
Nguyen Thi Kim : Phuong : TH0003 : 5
Tran Ngoc : Phuc : Th006 : 10
Nguyen Nhat : Quang : TH001 : 8
Nguyen Cong : Tam : TH0010 : 4
Phan Duc : Anh : TH0010 : 7

##################################
#baicuoi2
if [ $# -ne 2 ]
then
echo “Error..Give me one name to find mark and give mark list”
exit 1
else
grep -i $1 $2
fi
#####################################
./baicuoi2 tencantim danhsachcantim
ex: ./baicuoi2 billyduc ketqua.txt

Bravo ^^ Have anyquestion ?? Send it to me ^^

Moving Around With vim (keyboard short cuts)

Moving around with vim.

Open any file, for example
$ vim /etc/httpd/conf/httpd.conf

1. Go to the first line
gg or 1 shift g or :0 (zero) Enter

2. Go to the last line.
Shift g or :$ Enter

3. Go to line 8
8 shift g

4. To scroll down one screen
Ctrl f

5. To scroll up one screen
Ctrl b

6. First position on line
0(zero)

7. Last position on line
$

8. Go to matching parenthesis
%

9. Right, left, up, down respectively.
l, h, k, j
Or You can also use arrow keys

10. Where Am I?
Ctrl g
Note: previous command works in command mode

From : Nixcraft

rpm and yum rescue tips on Fedora

You have to be careful when you run yum update and yum install, DON’T force kill it, kill -9 or pkill -9. Those action are consider very dangerous, may lead you to losing certain files. Seriously, I hate yum, when I really wanna cancel the process in the middle, by hitting ctrl+c doesn’t really work! So, I do pkill -9, and I bare the consequences!

Some binaries are missing although the rpm query indicates those packages are successfully installed; some icons are missing, and I have no idea what’s wrong, I almost lose hope to reinstall everything. Thanks to my comrades Kagesenshi guiding me through finding the cause and I eventually fix it. Now, I share what I have done during the rescue.

First, let us look at how you can know better of what was installed in your system. With rpm query command lines, you can find out a lots of information.

Query All:

rpm -qa

This is what people usually do, combines with grep you can check whether a particular package is it install into your system.:

rpm -qa | grep mplayer

It takes sometimes if your system installed with tons of packages, you can also ignores the ‘a’ if you know the package name:

rpm -q mplayer

What files the particular package contains:
This is very important, sometimes the binary do not appear as the same as package name, for example: vim. And sometimes the package contains more than one binary.

rpm -qs vim-enhanced-7.1.245-1.fc8

normal        /etc/profile.d/vim.csh
normal        /etc/profile.d/vim.sh
normal        /usr/bin/ex
normal        /usr/bin/rvim
normal        /usr/bin/vim
normal        /usr/bin/vimdiff
normal        /usr/bin/vimtutor
normal        /usr/share/man/man1/rvim.1.gz
normal        /usr/share/man/man1/vimdiff.1.gz
normal        /usr/share/man/man1/vimtutor.1.gz

This binary is from which package?
This is also important, as sometimes I know the binary name but I do not know what package it bundle with, for example: ifconfig. To check for this, I need to specified absolute path of the binary, therefore i use which.

rpm -qf `which ifconfig`
net-tools-1.60-84.fc8

Ok, now lets look at one of the yum utils command, package-cleanup.
package-cleanup allows you to detects package duplication, performs clean up and also checks on the missing dependency packages etc.

Any dependency problems?

package-cleanup --problems

Any duplication packages?

package-cleanup -d

Clean up those duplicated packages.

package-cleanup --cleandupes

If yum crashed, or interrupted halfway, you may try this to resume those yum transaction.

yum-complete-transaction

Sometimes, when rpm returns the result state that you have installed certain packages, some binaries might be missing if yum is been interrupted during installation process. For my case, my nm-applet binary was missing, nm-applet is bundle in NetworkManager-gnome package, but rpm query indicates my system was installed with NetworkManager-gnome.

Therefore, goes back to rpm, I verify all the packages to ensure all binaries from those packages was still there.

rpm -Va > rpmva.txt

Store that into a file, I will need that info to rescue my system. Here is a portion of the output:

...
missing   /usr/share/devhelp/images
missing   /usr/share/devhelp/images/book_closed.png
missing   /usr/share/devhelp/images/book_open.png
missing   /usr/share/devhelp/images/helpdoc.png
missing   /usr/share/devhelp/ui
missing   /usr/share/devhelp/ui/window.ui
S.5....T c /etc/passwd
...

You only want to focus on packages that its binaries are missing, therefore, perform awk to filter it.

awk ' $1 ~ /^missing$/ {print $2}' rpmva.txt > rpm-filemissing.txt

With missing file information, you can obtain package’s name by rpm -qf. The same package ’s name may appear multiple times, you can use uniq to filter it.

rpm -qf `cat rpm-filemissing.txt` | uniq > pkg-reinstall.txt 

WARNING! Make sure you have internet access! check the package list, removes yum from the list or you can download yum rpm from the internet first, you are going to perform rpm removes on next step, after that yum the packages from the internet.

1. Removes problem’s rpm!

rpm -e --nodeps `cat pkg-reinstall.txt`

2. Clean all rpm cache downloaded by yum (optional)

yum clean all

3. Reinstall those packages!

yum -y install `cat pkg-reinstall.txt`

4. Check again to make sure all solves!

rpm -Va; package-cleanup --problem

From: Linuxbyexample