Wednesday, May 5, 2010

Some Linux Tips




1) How to export DISPLAY on windows comp from a linux comp which is accessible from some router linux comp(for windows users only)

Suppose you are working on 10.8.11.1 and you go to 10.8.11.3 via 10.8.11.2, then to open graphical applications of 10.8.11.3 on 10.8.11.1, follow these steps:

1. start Xwin32 (on 10.8.11.1)
2. ssh to 10.8.1.2
3. export DISPLAY=10.8.11.1:0.0
4. vncserver (it will promt for a passwd, set the passwd)
5. start remote destop connection as server 10.8.11.2:1
6. xhost + (on 10.8.11.2)
7. ssh to 10.8.11.3 from 10.8.11.2
8. export DISPLAY=10.8.11.2:1 (on 10.8.11.3)
9. start any application.

2) How to get access of windows partitions in linux

As root, edit the file /etc/fstab e.g. let your windows C drive partition is /dev/hda1 and it is 'fat 32' file system. So to mount the C partition in /windows/C directory, in the /etc/fstab file, make an entry as
/dev/hda1     /windows/C    vfat   umask=0000  0 0
Note that umask=0000 will give write permissions to every user. To give write permission only to root, replace by
umask=0002

3) How to use mount command

a) To mount a hard disk partition
$mount -t <filesystem> -o <options> <device> <dir>
e.g. If you want to mount C partition as above, type as root
$mount -t vfat -o rw /dev/hda1 /windows/C

b) To mount an already visible directory to another place, type
$mount --bind <old-dir> <new-dir>

c) How to mount or extract .iso file in linux
As super user type
$mount -o loop -t iso9660 isofile mount_place

d) To mount nfs filesystem, e.g. mount /windows/C of 10.8.1.22 on your machine at /piyush/c, type
$mount -t nfs 10.8.1.22:/windows/C /piyush/c
For this, the comp 10.8.1.22 should have given you the permissions.

3)How to change encoding of media files

Use mencoder
$mencoder <input-file> -oac <audio-output-format> -ovc <video-output-format> -o <output-filename>

audio-output-format option is given as

    -oac copy     no encoding, just streamcopy
    -oac pcm     encode to uncompressed PCM
    -oac mp3lame     encode to MP3 (using Lame)


video-output-format is given as

     -ovc copy       no encoding, just streamcopy
     -ovc divx4       encode to DivX4/DivX5
     -ovc rawrgb       encode to uncompressed RGB24
     -ovc lavc       encode with a libavcodec codecs

To cut a movie file give the following command
$mencoder <input-file> -ss <start-position> -endpos <end-position> -o <output-filename>-oac <audio-output-format> -ovc <video-output-format> -o <output-file>

here end-postion can be given as
     -endpos 56       encode only 56 seconds
     -endpos 01:10:00       encode only 1 hour 10 minutes
     -endpos 100mb       encode only 100 MBytes
for start-position
     -ss 56       encode from 56 sec
other options are similar as above.

for more option type
$man mplayer

5) How to set an environmental variable/How to add path

$ PATH=$PATH:<path you want to set>
So if you want to set this path for all users then put this line in
/etc/rc.local in redhat and
/etc/init.d/boot.local in suse.

6)To send message from linux to windows

$ smbclient -M <hostname> -I <ip-address>
And to find hostname
$ nmblookup -A <ip-address>

7) How to build an rpm

a) from SRPM
Install the .src.rpm file this way:
$ rpm -i somepackage-1.0-1.src.rpm

This will create files in /usr/src/redhat/SOURCES and a .spec file in /usr/src/redhat/SPECS.
Then go the SPECS directory and give the command to build the RPM:
$ cd /usr/src/redhat/SPECS
$ rpmbuild -bb somepackage.spec

b) from source package

When a source archive (e.g., somepackage-1.0.tar.gz) contains a .spec file, one can give the following command to build the RPM without having to deploy the archive:

$ rpmbuild -tb somepackage-1.0.tar.gz

Give the -ta option instead if you also want to build the SRPM.

8) How to install fonts

One can install fonts in various ways.
a) type

$ xset fp+ <directory-path-of-font>
$ xset fp rehash

in this case u should have fonts.dir file in the directory.
this is a temporary way of installing fonts. u have to give these commands every time u start ur X-server.

b) Use font installer in control centre(not available in redhat)

c) Type as root
$ /usr/sbin/chkfontpath --add $ fc-cache
this doesn't work with suse but works well in redhat.

d) in /etc/X11/XF86Config file (in redhat XF86Config-4 file), in Section "Files" add the line

FontPath "<dir-path>"

and restart ur X-server. this works well in suse.

to check the list of installed fonts, type
$ xlsfonts

9) How to make an iso image

To make an ISO from your CD/DVD, place the media in your drive but do not mount it. If it automounts, unmount it.

$ dd if=/dev/dvd of=dvd.iso # for dvd
$ dd if=/dev/cdrom of=cd.iso # for cdrom
$ dd if=/dev/scd0 of=cd.iso # if cdrom is scsi

To make an ISO from files on your hard drive, create a directory which holds the files you want. Then use the mkisofs command.

$ mkisofs -o /tmp/cd.iso /tmp/directory/

This results in a file called cd.iso in folder /tmp which contains all the files and directories in /tmp/directory/.

No comments:

Post a Comment