# Archive for category Linux

### Kopete and Latex

Latex has been the best typesetting software ever made. I have always preferred it for any type of document. Latex has been very useful in case you want to use many mathematical formulas in the document. Sometimes, though rarely :D, we need to use mathematical expressions in our chat conversation. I was wondering if any messenger provides the \Latex support in the chat window. Then I found kopete’s ” KopeTeX” plugin allows Kopete to render Latex \
formulas in the chat window. The sender must enclose the formula between two \$ signs. \
ie: $$formula$$ +This plugin requires ImageMagick convert program installed in order.

For example: for T= 2 PI /OMEGA

$$T=2\frac{\pi}{\omega}$$

Here are the easy steps to get Debian installed in your system :

1-Get the Debian-Installer Loader from here

2-Run the installer

Reboot the system:

Start to launch Debian-Installer

Lovely Debian-Installer interface

Check here for ubuntu

### Recover the deleted file!

A file as it appears somewhere on a Linux file system is actually just a link to an inode, which contains all of the file’s properties, such as permissions and ownership, as well as the addresses of the data blocks where the file’s content is stored on disk. When you rm a file, you’re removing the link that points to its inode, but not the inode itself; other processes (such as your audio player) might still have it open. It’s only after they’re through and all links are removed that an inode and the data blocks it pointed to are made available for writing.

This is where the Linux process pseudo-filesystem, the /proc directory, comes into play. Every process on the system has a directory here with its name on it, inside of which lies many things — including an fd (“file descriptor”) subdirectory containing links to all files that the process has open. Even if a file has been removed from the file system, a copy of the data will be right here:

/proc/process id/fd/file descriptor

Here is a live example:

create a file which you can delete.

[root@DeathStar mystuff] man lsof > myfile [root@DeathStar mystuff]less myfile and press Ctrl+Z so that it maintains fd open. [root@DeathStar mystuff]# rm myfile rm: remove regular file myfile'? y removed myfile' [root@DeathStar mystuff]# lsof |grep myfile less 23772 root 4r REG 8,2 113086 523412 /home/pankaj/mystuff/myfile (deleted) [root@DeathStar mystuff]# ls -l /proc/23772/fd/4 lr-x------ 1 root root 64 Jun 14 12:57 /proc/23772/fd/4 -> /home/pankaj/mystuff/myfile (deleted) [root@DeathStar mystuff]# cp -a /proc/23772/fd/4 myfile.wrong /proc/23772/fd/4' -> myfile.wrong' [root@DeathStar mystuff]# ls -l myfile.wrong lrwxrwxrwx 1 root root 37 Jun 14 13:00 myfile.wrong -> /home/pankaj/mystuff/myfile (deleted) [root@DeathStar mystuff]# cp /proc/23772/fd/4 myfile.saved /proc/23772/fd/4' -> myfile.saved' [root@DeathStar mystuff]# vi myfile.saved

and here is an obvious way to know which all files you can recover!

lsof | grep deleted

Reference:linux.com

### Linux kernel parameters !

There are various parameters which can be passed to Linux kernel at the boot time. There parameters inform kernel about different hardware parameters.You may need the parameter passing to kernel in the following cases:

1-If you think your Linux box can be made more effective in terms of performance by overriding few default hardware parameters.

2-Very helpful in troubleshooting the Linux box.

3-Some hardware parameter that can not be determined by the kernel by its own.

The kernel command line syntax
 parameter_name=value1,value2,value3…

Where,

* parameter_name : Keyword name, for example, init, ro, boot etc

Ten common Boot time parameters

init

This sets the initial command to be executed by the kernel. Default is to use /sbin/init, which is the parent of all processes.
To boot system without password pass /bin/bash or /bin/sh as argument to init
init=/bin/bash

single

The most common argument that is passed to the init process is the word ’single’ which instructs init to boot the computer in single user mode, and not launch all the usual daemons
root=/dev/device 
This argument tells the kernel what device (hard disk, floppy disk) to be used as the root filesystem while booting. For example following boot parameter use /dev/sda1 as the root file system:
root=/dev/sda1 
If you copy entire partition from /dev/sda1 to /dev/sdb1 then use
root=/dev/sdb1
ro

This argument tells the kernel to mount root file system as read-only. This is done so that fsck program can check and repair a Linux file system. Please note that you should never ever run fsck on read/write file system.
rw

This argument tells the kernel to mount root file system as read and write mode.
panic=SECOND

Specify kernel behavior on panic. By default, the kernel will not reboot after a panic, but this option will cause a kernel reboot after N seconds. For example following boot parameter will force to reboot Linux after 10 seconds
panic=10 maxcpus=NUMBER

Specify maximum number of processors that an SMP kernel should make use of. For example if you have four cpus and would like to use 2 CPU then pass 2 as a number to maxcpus (useful to test different software performances and configurations).
maxcpus=2 debug

Enable kernel debugging. This option is useful for kernel hackers and developers who wish to troubleshoot problem
selinux [0|1]

Disable or enable SELinux at boot time.

* Value 0 : Disable selinux * Value 1 : Enable selinux

raid=/dev/mdN

assembly of RAID arrays at boot time. When md is compiled into the kernel (not as module), partitions of type 0xfd are scanned and automatically assembled into RAID arrays. This autodetection may be suppressed with the kernel parameter “raid=noautodetect”.

As of kernel 2.6.9, only drives with a type 0 superblock can be autodetected and run at boot time.
mem=MEMEORY_SIZE

Force usage of a specific amount of memory to be used when the kernel is not able to see the whole system memory or for test. For example:
mem=1024M

### iptables

iptables is an application program which allows system administrator to
control incoming and outgoing traffic on basis of various parameters of packet.

It can also be used to access the traffic on the basis of day,time.
Suppose IIIT-A administration decides that the FTP service (172.31.2.40) should be
available only on Sunday between 6:00 pm to 11:59 pm.I might be using the
following tool for that 😛
iptables [-t table] -[AD] chain rule-specification [options] iptables [-t table] -I chain [rulenum] rule-specification [options] iptables [-t table] -R chain rulenum rule-specification [options] iptables [-t table] -D chain rulenum [options] iptables [-t table] -[LFZ] [chain] [options] iptables [-t table] -N chain iptables [-t table] -X [chain] iptables [-t table] -P chain target [options] iptables [-t table] -E old-chain-name new-chain-name 
In this case:
 iptables RULE -m time –timestart TIME –timestop TIME –days DAYS -j ACTION

–timestart value
Match only if it is after value (Inclusive, format: HH:MM ; default 00:00).

–timestop value
Match only if it is before value (Inclusive, format: HH:MM ; default 23:59).

–days listofdays
Match only if today is one of the given days. (format: Mon,Tue,Wed,Thu,Fri,Sat,Sun ; default everyday)

–datestart date
Match only if it is after date (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]] ; h,m,s start from 0 ;
default to 1970)

–datestop date
Match only if it is before date (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]] ; h,m,s start from 0 ;
default to 2037)

iptables -A INPUT -p tcp -s 0/0 --sport 513:65535 -d 172.31.2.40 --dport 21 -m state --state NEW,ESTABLISHED -m time --timestart 18:00 --timestop 23.59 -days Sun -j ACCEPT