Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, May 14, 2011

PDF editor for manipulating PDF on LINUX

Adobe Acrobat is a commercial tool for manipulating PDFfiles. I used CUPS - Printing system export PDF files. I also tried gv for the same purpose. However, I had to complete theprocessing of PDF documents. My research ended with the software pdfedit free and open source editor for manipulatingPDF documents. The software GUI and CLI (command line)interface.

This software also supports scripting and almost anything can be scripted. PDFedit is a low-level tool for users. You can use this software:
=> To write / create / edit PDF files.
=> Print PDF files.
=> Save PDF files.
=> Export PDF files to XML etc.

Install PDFEdit

If you are using Debian or Ubuntu Linux, enter:
$ sudo apt-get install pdfedit

Start Editing PDF Files with PDFEdit editor

To start PDFEdit, type:
$ pdfedit /path/to/pdf.file &
$ pdfedit &

PDFEdit Linux freeware pdf writer software
( Fig 01: PDFedit ~ Linux PDF maker in action [click to enlarge the image] )

Other Linux pdf maker / writer software

During my research I came across other apps to edit PDFs. I hope you will find following tools useful:

=> scribus - Open Source Desktop Page Layout / desktop publishing (DTP) application software. It works under Linux, Mac and Windows computer. This software is another good alternative to PDFEdit. Just open file using open option and you can edit PDF file. You can install scribus using apt-get command:
$ sudo apt-get install scribus

To use scribus to edit PDF files:
Start scribus > New File > Insert > Image > Double click > Select PDF file

=> flpsed - a WYSIWYG pseudo PostScript editor. This software is very fast and light weight. To install flpsed, enter:
$ sudo apt-get install flpsed
To edit file, enter:
$ flpsed /path/to/pdf-file.pdf &

=> Gimp - I've also used gimp for editing pdf files. However, you need basic knowledge of gimp itself for editing pdf files. GIMP is almost installed on all Linux distribution. Please note that GIMP is not elegant solution for editing pdf files.

Online PDF manipulation tool

Finally, you can always use the Internet to modify PDF files using a web browser. [pdfescape.com]

Conclusion

PDFEdit is the best free open source software for for Linux / Unix-like operating systems. However, it does not support editing protected or encrypted PDF files.

Monday, February 14, 2011

USB MODEM in Damn Small linux

1.Plug in the modem
2. in dmesg you will see a storage device added
3. do lsusb
4. Do modprobe usbserial vendor=xx product=xx (enter the numbers you found in lsusb, for mine it was 0x12d1 with 0x1300)
5. in dmesg you will see 2 serial ports were added (if not, or you only see one.. it might you you dont have usb 2 or your pc is to slow)
6. Put the wvdial.conf script below and make sure you have downloaded the wvdial.dsl file.
7. Start with wvdial hsdpa and you are online.

This information is for a telfort subscription! It took me a while to get the right wvdial.conf, but this should do it.

# wvdial for Vodacom Data. Created by Tazz_tux
# Version 1.0

# Change Log:
#
# Added support for HSDPA.
# Added Headers and version control.

[Dialer Defaults]
Phone = *99***1#
Username = internet
Password = internet
Stupid Mode = 1
Dial Command = ATDT

[Dialer hsdpa]
Modem = /dev/ttyUSB0
Baud = 460800
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init5 = AT +CGDCONT=1,"IP","internet"
ISDN = 0
Modem Type = Analog Modem

Sunday, February 6, 2011

Instalasi OpenVPN Client in Linux

Install aplikasi GUI utuk client

# apt-get install kvpnc
# apt-get install network-manager-openvpn openvpn

Copy setting OpenVPN

# cp -Rf /usr/share/doc/openvpn/examples/easy-rsa/* /etc/openvpn/

Pada Ubuntu Hardy 8.04 tampaknya ada beberapa versi konfigurasi, kita dapat menggunakan salah satu dengan cara

# cp -Rf /etc/openvpn/2.0/* /etc/openvpn/

Selanjutnya lakukan langkah berikut, yang sama dengan versi lainnya

# cd /etc/openvpn
# mkdir /etc/openvpn/keys

Lakukan langkah berikut

# vi vars
# , ./vars
# ./clean-all

Atau copy file /etc/openvpn/vars dari Server. Copy key client dari Server

# scp -r root@192.168.0.3:/etc/openvpn/keys/ca.crt /etc/openvpn/keys
# scp -r root@192.168.0.3:/etc/openvpn/keys/user1.crt /etc/openvpn/keys
# scp -r root@192.168.0.3:/etc/openvpn/keys/user1.key /etc/openvpn/keys


Menjalankan VPN Client (client.conf from www.openvpn.org)

# openvpn --config /etc/openvpn/client.conf


Contoh Client.conf adalah sebagai berikut,

# vi /etc/openvpn/client.conf

isinya kurang lebih

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client
# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
; dev tap
dev tun
# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
; dev-node MyTap 
# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp 
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
;remote my-server-1 1194
;remote my-server-2 1194
remote 192.168.0.3 1194
# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random
# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite
# Most clients don't need to bind to
# a specific local port number.
nobind
# Try to preserve some state across restarts.
persist-key
persist-tun
# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]
# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings
# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca keys/ca.crt
cert keys/client.crt
key keys/client.key
# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server".  This is an
# important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server".  The build-key-server
# script in the easy-rsa folder will do this.
;ns-cert-type server
# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1
# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x
;cipher AES-128-CBC
# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
; comp-lzo
# Set log file verbosity.
verb 3
# Silence repeating messages
;mute 20

 

Cara menjalankan VPN client dengan client.conf (from www.openvpn.org)

# openvpn --config /etc/openvpn/client.conf

Using network manager (nm-applet) in KDE4

As of now knetworkmanager is not available for KDE4, and those of us using NetworkManager are going to have to settle with gnome's version of the network manager applet: nm-applet

First of you need to install networkmanager, read more on that here.

Once it's installed you need to set it up to run as a daemon, i.e. add it to /etc/rc.conf, and remove network:

DAEMONS=(syslog-ng networkmanager netfs crond alsa hal fam kdm)

Furthermore you have to exclude the interfaces you intend to use with networkmanager (also in /etc/rc.conf e.g.:

INTERFACES=(!eth0 !wlan0)

When that's done you need to install gnome-network-manager

# pacman -S gnome-network-manager

Then add yourself to the network group:

# usermod -g network your_username

And that should do it, you can now run nm-applet as a normal user, and switch between wireless and wired network without modifying rc.conf every time.

Saturday, February 5, 2011

How To Repair MBR And Boot Into Linux

There are times when you inadvertently overwrite your Master Boot Record. The end result being that you are unable to boot into Linux. This is especially true when you are dual booting between windows and Linux OSes. Once when I was working in Windows XP, I accidentally clicked the hibernate button instead of shutdown. And windows somehow overwrote my MBR which housed the GRUB boot loader. At such times, it pays to have this cool tip at hand.

This is what you do to restore the GRUB boot loader when faced with the above problem. First you need a Linux distribution CD. If you are using Fedora (RedHat) then the first CD is sufficient. But you may also use any of the live CDs like Knoppix, Ubuntu Live CD and so on.

With Fedora CD
Boot your computer with the first CD of Fedora in your CD drive (You have to enable your PC to boot from the cdrom, which you can set in the BIOS settings). At the installation boot prompt that you get, enter the following command:
boot: linux rescue
... and press Enter. The installer will ask you a few questions like the language you would like to use, the type of keyboard etc. Then, if you have linux previously installed on your machine, the Fedora installer will automatically detect it and mount it in the /mnt/sysimage directory. Once the linux partition is mounted, you are dropped into the command shell prompt. The next step is to make your newly mounted directory the root (or parent) directory. This you do by running the chroot command as follows:
# chroot /mnt/sysimage
# _
Now you are in the shell with respect to the parent directory which is the linux partition on your harddisk.

From here, the steps needed depends on which bootloader you are using. You have to have a fair idea what is the device node of your harddisk partition housing your MBR. In most cases, it is /dev/hda if you have an IDE harddisk. But if you have a SCSI harddisk, it will be /dev/sda.

Restoring GRUB
Execute the following command :
# grub-install /dev/hda
... to install GRUB boot loader on to your MBR. And then type exit to reboot the machine. Now your GRUB boot loader is fixed.

Restoring LILO
LILO stands for LInux LOader which was the boot loader used before GRUB was developed. It is fairly cryptic and is the default bootloader prior to and in RedHat 7.0 .
Here you just type the command :
# /sbin/lilo
... to install the bootloader on to the MBR.

If you don't have a Fedora CD, then you need not despair. You can also repair the boot loader using one of the numerous live CDs available.

Using Knoppix CD to repair the boot loader
Here you have to boot into knoppix (either GUI mode or text mode). Once you are logged in, fire up a terminal (in GUI mode) and type the following commands:
$ su -
# fdisk -l
This will list your hard disk partition information. From the listing, you can know in which partition you have linux installed. Now you have to mount the partition which contains the linux filesystem. For the sake of this discussion, let us assume it is /dev/hda3 .
# mount -t ext3 -o rw /dev/hda3 /mnt
#_
Now your linux partition is mounted at /mnt . Next you have to use the chroot command as follows:
# chroot /mnt
#_
The rest of the steps are the same as listed above for Restoring GRUB and LILO boot loaders.

Update (August 01 2007) : Many have said when they run the grub-install command after following the above steps, they get an error saying that /dev/hda is missing. The most probable reason is that when you chroot to the mount location, it does not have a copy of the device nodes on your machine. Here is a solution for that. If you have installed Linux with /boot, /usr and / in different partitions then the above method may not get the desired results and running the grub-install /dev/hda command after running chroot might give the error that there is no /dev/hda. This is because you have mounted only one of the partitions which houses '/' . And the error tells you that it cannot find the device nodes. In this scenario you can do the following :

Lets say I have Linux installed with / in /dev/hda2, /boot in /dev/hda1 with an ext3 filesystem. I boot using a Live CD as described above and then mount the partitions as follows :
# mount  -t ext3  /dev/hda2  /mnt

# mount -t ext3 /dev/hda1 /mnt/boot
Remember that you are mounting the boot partition into the boot directory inside /mnt. Now mount the proc filesystem of your liveCD as follows (This is really an optional step):
# mount -t proc  none  /mnt/proc
Finally bind the device nodes build by your liveCD to the /mnt/dev location as follows :
# mount  -o bind /dev  /mnt/dev
Now you can chroot to the /mnt location and run the grub-install command as described above.
# chroot /mnt
# grub-install /dev/hda
Please note: This updated method is applicable only if you have a Linux installation spread across multiple partitions. If you have installed Linux in a single partition, the first and second step works flawlessly. At least it works for me.

Thursday, February 3, 2011

Reverse Proxy with ModProxy

I have added a new two months poll on this blog. It's about a normal questions about what actions will you do when the next Slackware release is available. I don't know when will that time be, but based on past experience, it should be coming soon enough, which makes me confident that it will be released before this poll ended in April.

So, see the Changelog if you are curious about what will be included in the next Slackware and if you can't wait for the final release, you can also upgrade to -Current or download the latest ISO which contains Slackware-Current updates (ask Google for it, as Slackware only provides you with the official release, not a snapshot or even RC release).

Monday, January 31, 2011

Display Past Date and Time

Following are various ways to display a past date and time: 
 
$ date --date='3 seconds ago' 
Thu Jan  1 08:27:00 PST 2009 
 
$ date --date="1 day ago" 
Wed Dec 31 08:27:13 PST 2008 
 
$ date --date="1 days ago" 
Wed Dec 31 08:27:18 PST 2008 
 
$ date --date="1 month ago" 
Mon Dec  1 08:27:23 PST 2008 
 
$ date --date="1 year ago" 
Tue Jan  1 08:27:28 PST 2008 
 
$ date --date="yesterday" 
Wed Dec 31 08:27:34 PST 2008 
 
$ date --date="10 months 2 day ago" 
Thu Feb 28 08:27:41 PST 2008 

Display Current Date and Time in a Specific Format

Following are different ways of displaying the current date and time in 

various formats: 

$ date 

Thu Jan  1 08:19:23 PST 2009 

 

$ date --date="now" 

Thu Jan  1 08:20:05 PST 2009 

 

$ date --date="today" 

Thu Jan  1 08:20:12 PST 2009 

 

$ date --date='1970-01-01 00:00:01 UTC +5 hours' +%s 

18001 

 

$ date '+Current Date: %m/%d/%y%nCurrent Time:%H:%M:%S' 

Current Date: 01/01/09 

Current Time:08:21:41 

 

$ date +"%d-%m-%Y" 

01-01-2009 

 

$ date +"%d/%m/%Y" 

01/01/2009 

 

$ date +"%A,%B %d %Y" 

Thursday,January 01 2009 

 

Following are the different format options you can pass to the date 

command: 

o    %D   date (mm/dd/yy) 

o    %d   day of month (01..31) 

o    %m   month (01..12) 

o    %y   last two digits of year (00..99) 

o    %a   locale’s abbreviated weekday name (Sun..Sat) 

o    %A   locale’s full weekday name, variable length 

(Sunday..Saturday) 

o    %b   locale’s abbreviated month name (Jan..Dec) 

o    %B   locale’s full month name, variable length 

(January..December) 

o    %H   hour (00..23) 

o    %I   hour (01..12) 

o    %Y   year (1970…) 

 

Friday, January 21, 2011

Set Hardware Date and Time

Before setting the hardware date and time, make sure the OS date and time 
is set appropriately as shown in the set-system-date-and-time
 
Set the hardware date and time based on the system date as shown below: 
 
# hwclock –systohc 
 
# hwclock --systohc –utc 
 
Use hwclock without any parameter, to view the current hardware date and 
time: 
 
# hwclock 
 
Check the clock file to verify whether the system is set for UTC: 
 
# cat /etc/sysconfig/clock 
 
ZONE="America/Los_Angeles" 
UTC=false 
ARC=false 

Set System Date and Time

To change the system date use:  
 
# date {mmddhhmiyyyy.ss} 
 
o    mm – Month 
o    dd – Date 
o    hh – 24 hour format 
o    mi – Minutes 
o    yyyy – Year 
o    ss – seconds 
 
For example, to set system date to Jan 31st 2008, 10:19 p.m, 53 seconds 
 
# date 013122192009.53 
 
You can also change system date using set argument as shown below. 
 
# date 013122192009.53 
 
# date +%Y%m%d -s "20090131" 
 
# date -s "01/31/2009 22:19:53"  
 
# date -s "31 JAN 2009 22:19:53" 
 
# date set="31 JAN 2009 22:19:53" 
 
To set the time only: 
 
# date +%T -s "22:19:53" 
 
# date +%T%p -s "10:19:53PM" 

Thursday, January 20, 2011

Use “shopt -s cdspell” to automatically correct mistyped directory names on cd

Use shopt -s cdspell to correct the typos in the cd command automatically as 
shown below. If you are not good at typing and make lot of mistakes, this will 
be very helpful. 
 
# cd /etc/mall 
-bash: cd: /etc/mall: No such file or directory 
 
# shopt -s cdspell 
 
# cd /etc/mall 
 
# pwd 
/etc/mail 
 
[Note: By mistake, when I typed mall instead of mail, 
          cd corrected it automatically] 

Use dirs, pushd and popd to manipulate directory stack

You can use directory stack to push directories into it and later pop directory 

from the stack. Following three commands are used in this example. 

o    dirs: Display the directory stack 

o    pushd: Push directory into the stack 

o    popd: Pop directory from the stack and cd to it 

Dirs will always print the current directory followed by the content of the 

stack. Even when the directory stack is empty, dirs command will still print 

only the current directory as shown below. 

# popd 

-bash: popd: directory stack empty 

 

# dirs 

~ 

 

# pwd 

/home/ramesh 


How to use pushd and popd? Let us first create some temporary directories 

and push them to the directory stack as shown below. 

 

 

# mkdir /tmp/dir1 

# mkdir /tmp/dir2 

# mkdir /tmp/dir3 

# mkdir /tmp/dir4 

 

# cd /tmp/dir1 

# pushd . 

 

# cd /tmp/dir2 

# pushd . 

 

# cd /tmp/dir3 

# pushd . 

 

# cd /tmp/dir4 

# pushd . 

# dirs 

/tmp/dir4 /tmp/dir4 /tmp/dir3 /tmp/dir2 /tmp/dir1 

 

[Note: The first directory (/tmp/dir4) of the dir 

command output is always the current directory and not 

the content from the stack.] 

 

# dirs 

/tmp/dir4 /tmp/dir4 /tmp/dir3 /tmp/dir2 /tmp/dir1 

 

[Note: The first directory (/tmp/dir4) of the dir 

command output is always the current directory and not 

the content from the stack.] 

 

At this stage, the directory stack contains the following directories: 

 

/tmp/dir4 

/tmp/dir3 

/tmp/dir2 

/tmp/dir1 

 

The last directory that was pushed to the stack will be at the top. When you 

perform popd, it will cd to the top directory entry in the stack and remove it 

from the stack. As shown above, the last directory that was pushed into the 

stack is /tmp/dir4. So, when we do a popd, it will cd to the /tmp/dir4 and 

remove it from the directory stack as shown below. 

 

# popd 

# pwd 

/tmp/dir4 

 

[Note: After the above popd, directory Stack Contains: 

/tmp/dir3 

/tmp/dir2 

/tmp/dir1] 

 

# popd 

# pwd 

/tmp/dir3 

 

[Note: After the above popd, directory Stack Contains: 

/tmp/dir2 

/tmp/dir1] 

 

# popd 

# pwd 

/tmp/dir2 

 

[Note: After the above popd, directory Stack Contains: 

/tmp/dir1] 

 

# popd 

# pwd 

/tmp/dir1 

 

[Note: After the above popd, directory Stack is empty!] 

 

# popd 

-bash: popd: directory stack empty 


Wednesday, January 19, 2011

Use CDPATH to define the base directory for cd command

If you are frequently performing cd to subdirectories of a specific parent 
directory, you can set the CDPATH to the parent directory and perform cd to 
the subdirectories without giving the parent directory path as explained 
below. 
 
[ramesh@dev-db ~]# pwd 
/home/ramesh 
 
[ramesh@dev-db ~]# cd mail 
-bash: cd: mail: No such file or directory 
 
[Note: This is looking for mail directory under current 
directory] 
 
[ramesh@dev-db ~]# export CDPATH=/etc 
[ramesh@dev-db ~]# cd mail 
/etc/mail 
 
[Note: This is looking for mail under /etc and not 
under current directory] 
 
[ramesh@dev-db /etc/mail]# pwd 
/etc/mail 
 
To make this change permanent, add export CDPATH=/etc to your 
~/.bash_profile 
Similar to the PATH variable, you can add more than one directory entry in 
the CDPATH variable, separating them with : , as shown below. 
 
export CDPATH=.:~:/etc:/var 
 
This hack can be very helpful under the following situations: 
o    Oracle DBAs frequently working under $ORACLE_HOME, can set 
the CDPATH variable to the oracle home 
o    Unix sysadmins frequently working under /etc, can set the 
CDPATH variable to /etc 
o    Developers frequently working under project directory 
/home/projects, can set the CDPATH variable to /home/projects 
o    End-users frequently accessing the subdirectories under their 
home directory, can set the CDPATH variable to ~ (home 
directory)  

Monday, January 17, 2011

Linux Kernel 2.6.37 Released

Another year has passed and thus another new kernel release by Linus. As expected, Linus finally released the final Linux Kernel 2.6.37 as of today after having several RC release before Christmas and eventually it didn't make it as Christmas gift for everyone, so let's just consider this as a new year gift. Fair enough.

At this moment, the link on Kernel.org hasn't showed up, but you can still download it by clicking on this link. More information about what has been included in this release in human-friendly language can be seen inKernelNewbies (give some tim to update the page as the kernel has just been released).

Now, time to look for patches for NVidia and VMWare if i wanted to compile this kernel Yahoo

Thursday, January 13, 2011

open port in microtik

Mikrotik on setting the default to open five ports to access the server, to see the open ports can use the command: 

/ip service pr
It will look something like this 

 

01[admin@MikroTik] > /ip service pr
02Flags: X - disabled, I - invalid
03 #   NAME               PORT  ADDRESS
04 0   telnet             23    0.0.0.0/0
05 1   ftp                21    0.0.0.0/0
06 2   www                80    0.0.0.0/0
07 3   ssh                22    0.0.0.0/0
08 4 X www-ssl            443   0.0.0.0/0
09 5 X api                8728  0.0.0.0/0
10 6   winbox             8291  0.0.0.0/0


suppose we want to close the ports for telnet, the command used is: 

 

 

1/ip service set telnet disabled=yes


ketik :

 

1/ip service pr


and shall appear the sign x in the telnet, as in www-ssl and API. 
want to open the port if disabled = no 

 

1/ip service set telnet disabled=yes

   Cwim