Linux how to

From CSWiki
Jump to navigation Jump to search

Practical instructions on how to go about doing things in Linux. This is about the Fedora Linux.

How to extend an xfs filesystem

  • xfs filesystems must be mounted to be extended. There is no need to unmount
  • usually an xfs fileystem occupies all of its logical volume so the extension of a filesytem involves first the expansion of the logical volume and then the extension of the filesystem
  • expanding the logical volume
  • lvextend -L +5G /dev/Volume00/data-lv00 - this will add 5GB on logical volume /dev/Volume00/data-lv00
  • xfs_growfs /NewFS - this will extend the filesystems on the previously extended LV to occupy it completely. The filesystem is mounted on /NewFS in this case.

More on how to operate the Logical Volume Manager (LVM) is found here

How to extend an ext3 file system

Note: A mounted ext3 file system cannot be extended. Unmount it before proceeding. This restriction has been corrected in FC6 where you can extend a mounted file system by using the resize2fs command.

  • Unmount the file system
  • expand the logical volume containing the file system
  • lvextend -L +2G /dev/Volume00/lvol00 - this will add 2GB on logical volume /dev/Volume00/lvol00
  • do an fsck on the file system (this is required)
  • e2fsck /dev/Volume00/lvol00
  • extend the filesystem to the logical volume limits
  • resize2fs /dev/Volume00/lvol00
  • remount file system

How to set system-wide environment variables

  • To set a system-wide variable we have to provide both sh and csh versions of profile.d scripts. These scripts are executed each time a user is logging in to the system. The sh version is executed for users with sh, bash, and zsh shells. The csh-shell version is executed with csh and tcsh shells. As an example let's see how we can set JAVA_HOME environment variable.
  • sh version
  1. Create a file java.sh under /etc/profile.d
  2. Add the following to the file:
 export JAVA_HOME=/usr/lib/jvm/jre-1.5.0-sun
  • csh version
  1. Create a file java.csh under /etc/profile.d
  2. Add the following to the file:
 set JAVA_HOME= (/usr/lib/jvm/jre-1.5.0-sun)
  • Note: In both cases we assume that java is installed under /usr/lib/jvm/jre-1.5.0-sun, so make sure you enter the correct directory for your system.

How to install Sun JAVA

  • 1. Download the latest JDK version from Sun. Choose the "Linux self-extracting file" version (not the RPM version).
  • 2. Make sure the "rpm-build" package is installed:
 yum install rpm-build
  • 3. Move the JDK to the RPM Building Source directory:
 mv jdk-* /usr/src/redhat/SOURCES/
  • 4. Download the Source RPM from JPackage. Make sure you choose the same version as the JDK you downloaded in step 1.
  • 5. Build the Java RPM using the file that you just downloaded:
 rpmbuild --rebuild java-*src.rpm
  • 6. After the build the RPMs can be found in /usr/src/redhat/RPMS/i586/. You can install them using yum:
 yum -y localinstall /usr/src/redhat/RPMS/i586/java-1.5.0-sun-*
  • 7. If you want to enable the Java plugin for your web browser do the following:
 ln -s $JAVA_HOME/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/
  • 8. Make sure that the old X11 libraries are installed, or Java will crash your web browser:
 yum install xorg-x11-deprecated-libs

How to install Flash plugin

  • Setup Macromedia yum repository by editing the /etc/yum.repos.d/macromedia.repo file:
 [macromedia]
 name=Macromedia for i386 Linux
 baseurl=http://macromedia.rediris.es/rpm/
 enabled=1
 gpgcheck=1
 gpgkey=http://macromedia.mplug.org/FEDORA-GPG-KEY
  • Install the plugin using yum:
 yum -y install flash-plugin
  • Note: If the Macromedia license agreement does not appear you may have to run /usr/lib/flash-plugin/setup install. At the time of this writing there is a bug in Flash plugin that prevents it from displaying normal text in FC5. To resolve this follow the instructions describe at Macromedia's FAQ.

How to sign your RPM packages with GPG key

  • 1. Generate your own gpg key pair. For more information have a look at FedoraNEWS.ORG
  • 2. Use rpm command as shown below to sign your packages
 rpm --addsign file_name.rpm

If the file is already signed, then you can use --resign option to sign it with your signature. To check signatures, simply use --checksig option.

How to clone Fedora Core X system

  • 1. Use Acronis True Image to clone the hard disk.
  • 2. Boot your system using Fedora Rescue CD.
  • 3. When you prompted to mount your Linux installation make sure you select continue. This will mount your system under /mnt/sysimage.
  • 4. Type the following command to make your system the root environment:
 chroot /mnt/sysimage
  • 5. Re-install GRUB by typing:
 /sbin/grub-install /dev/VolGroup00/LogVol00
  • Note: We assume that your system has the file system structure recommended in our Linux installation guide. If your system has a different file system structure, then use the command df -k to find the root location and edit the above command accordingly.