Tuesday, October 26, 2010

How to setup multimedia on CentOS-5

CentOS ships with basic sound support for audio content encoded with codecs for a variety of sound formats, including .wav and .ogg files. The alsa-utils and sox audio players are included for a cron or TUI environment; xmms is trivial to rebuild SRPMs. The popular full featured xmms player is omitted by the upstream, probably in light of the so-called Fraunhofer restrictions and non-free license requirements to address.
 


For those in jurisdictions not affected by such, the following procedures will describe how to setup multimedia support under CentOS 5. After completing the steps below, you should be able to play dvds on your computer. You'll also be able to view different media formats, for example Xvid, dvix, quicktime etc. You will also have mplayer integrated as a browser plugin which will allow you to view streaming video/audio content from within Firefox.
Some recommendations should be mentioned pertaining to the yum priorities plug-in. This will prevent accidentally overwriting packages from the base repositories. Also note the following needs to be performed as root user in a command line or terminal.


Please consider following the wiki document to assist in setting up the priorities plug-in, due to the fact that we are adding some third party repositories, described in the Priorities article.

Step 1: Add the RPMforge repo for your CentOS version (needed for majority of multimedia files)
 
See the RPMForge article on the wiki on how to do so.






Step 2: Add the Macromedia repo (optionally needed for flash)
 
rpm -Uhv http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm







 Flash is also installed from RPMforge below if you don't add Macromedia repository.

Step 3: Install multimedia applications (command line to install required packages)

 
The following steps will use the yum package manager to install all the binaries needed to have full multimedia support. Note there will be a lot of dependencies
 
yum install libdvdcss libdvdread libdvdplay libdvdnav lsdvd mplayerplug-in mplayer mplayer-gui compat-libstdc++-33 flash-plugin gstreamer-plugins-bad gstreamer-plugins-ugly gstreamer-ffmpeg libquicktime

Step 4: Installing w32Codecs (required for xvid and other proprietary formats)
 
wget www1.mplayerhq.hu/MPlayer/releases/codecs/mplayer-codecs-20061022-1.i386.rpm ; rpm -ivh mplayer-codecs-20061022-1.i386.rpm
wget www1.mplayerhq.hu/MPlayer/releases/codecs/mplayer-codecs-extra-20061022-1.i386.rpm; rpm -ivh mplayer-codecs-extra-20061022-1.i386.rpm

You should now have full multimedia and video support for most popular formats.
If you happen to have problems with playing video's (eg. the player crashes or you have no image), try to disable System > Preferences > Desktop Effects (Compiz) and see if that fixes your problems.

CentOS/Fedora forgotten password

What to do if you forgot the password for your CentOS/Fedora/Redhat machine?? Here are some simple steps to change back the password by entering into single user mode of your machine provided you do not forgotten your grub password if you have set it ;)

  1. Reboot your machine
  2. Press 'Esc' key once grub starts loading
  3. Select your kernel press 'e' on one of the kernel to edit the kernel parameter
  4. Press 'e' on the line that starts with 'kernel /vmlinuz...'
  5. Append ''single" or "1" at the end of the line
  6. Press 'Enter'
  7. Press 'b' to boot from the appended kernel
  8. You are now in the single user mode of your linux machine once you get to the shell. You can now change the password of your account using command passwd
  9. Reboot back your machine normally
  10. You can now log in to your machine using your new password

Setting up samba with password protection

To easily share your files to linux and windows clients, samba is still the preferred choice. In this guide I will show how to setup a samba server on centos 5 machine, that can be accessed only by certain people protected by password.

  1. Install samba on the server
    • # yum install samba
  2. Create the group that all the samba users will be contained in, for example 'samba'
    • # groupadd samba
  3. Create samba users and add it to the above group, which is in this example is 'samba'. Below is the example to create a user named 'user1' and add it to group 'samba'. Set the password for user1
    • # useradd user1 -g samba
    • # passwd user1
  4. Create the directory to be shared. In this example, i will use /home/shared. Change the ownership to root and group ownership to the 'samba' group. Change permission so that only user and group can read write and execute
    • # mkdir /home/shared
    • # chown -R root.samba /home/shared
    • # chmod -R 775 /home/shared
  5. Below is a simple setting of samba
    • [global] workgroup = samba
      server string = Samba Server
      security = user [shared_folder]
      comment = Sharing place
      path = /home/shared
      public = no
      writable = yes
      printable = no
      write list = @samba
      create mask = 0755
      force create mode = 0755
      directory mask = 0775
      force directory mode = 0775
    • What the above setting does basically is to setup /home/shared as samba shared directory but can only be accessed by user from group samba
  6. Add user/users to samba
    • # smbpasswd -a user1
  7. Start smb service, restart if it has already been started
    • # /etc/init.d/smb start
  8. 'user1' can now access the samba server using address 'smb://samba_server_ip_address/shared_folder' at any nautilus address bar. For windows client, you can see at your 'My Network Places' and find a workgroup named 'samba'

NFS quick howto for centos 5

To use nfs successfully, you have to configure the server and the client. In this example, the client is 192.168.0.3 and the server is 192.168.0.1. The folder to be shared is /home/sharing, and to be mounted to /mnt on the client

On the server
  1. Make directory that you want to use.
    • # mkdir /home/sharing
  2. Edit /etc/exports, insert the client machine's ip
    • # vi /etc/exports
      • Add this line:
        • /home/sharing 192.168.0.3/255.255.255.255(rw,sync)
      • Save
  3. Edit /etc/hosts.allow
    • # vi /etc/hosts.allow
      • Add this line:
        • portmap: 192.168.0.0/255.255.255.0
      • Save
  4. Start nfs and portmap
    • # /etc/init.d /nfs start
    • # /etc/init.d/portmap start
On the client
  1. Start portmap
    • # /etc/init.d/portmap start
  2. Mount the nfs folder
    • # mount 192.168.0.1:/home/sharing /mnt
  3. Check /var/log/messages for any error that might occur
    • # tailf /var/log/messages
  4. Use mount to check if the folder is mounted properly
    • # mount
      • This should be the output:
        • 192.168.0.1:/home/sharing on /mnt type nfs (rw,addr=192.168.0.1)
  5. Edit /etc/fstab to mount the shared folder on boot
    • # vi /etc/fstab
      • Add this line
        • 192.168.0.1:/mnt/sdb1/backup /mnt nfs rw,hard,intr 0 0
      • Save
You can use 'man exports' to see the options available for /etc/exports

List your hardware

If you want to view the hardware spec of your pc, you can use this command
--> lshwThis is how you see the hardware spec on your pc.



By default, this command is installed on ubuntu linux but not installed on Centos. You can use you tools like yum to install it
--> yum install lshw

How to format your flash drive

This is how you can format your flash drive(thumbdrive, pendrive) in any linux machine

1. To see what is the filesystem for your flashdrive
  • type -> df



2. Type -> mkfs /dev/sdb1
(The /dev/sdb1 is according to your outcome of the df command previously: refer above diagram)
This command will format the flash drive to ext3 format which is the default.
To format it to fat;
type -> mkfs -t vfat /dev/sdb1