Wednesday, September 18, 2013

Yummy yum for CentOSians

Lets say someone wants to install a package, or update a package or just wanted to check if there is any update of a package. The command "yum" would be pretty helpful for them. The basic syntax for yum would be like below:

yum install
Used to install the latest version of a package or group of packages.

yum update
Used to update the specified packages to the latest available version.

yum update stuck due to broken package: (Lets say due to firefox and java packages)

                                  vi /etc/yum.conf --> In main section add below line:
                                  exclude=firefox* java*

Then run the update again like below:
                                  yum update --skip-broken

yum check-update
This command allows you to determine whether any updates are available for your installed packages. yum returns a list of all package updates from all repositories if any are available.

yum localinstall
Used when using yum to install a package located locally in the machine

yum provides
Used to determine which packages provide a specific file or feature.

yum search
This command is used to find any packages containing the specified keyword in the description, summary, packager and package name fields of RPMs in all repositories.

To search for a specific package by name, use the list function. To search for the package tsclient, use the command: (provide root's password when prompts)

su -c 'yum list tsclient'

What about uninstalling a package? Yes yum will again help you in this regard.

yum remove
Used to remove specified packages, along with any other packages dependent on the packages being removed.

By default, yum is configured through /etc/yum.conf.

cat /etc/yum.conf

[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800

[myrepo]
name=RHEL 5 $releasever - $basearch
baseurl=http://local/path/to/yum/repository/
enabled=1
A typical /etc/yum.conf file is made up of two types of sections: a [main] section, and a repository section. There can only be one [main] section, but you can specify multiple repositories in a single /etc/yum.conf.

Tuesday, August 20, 2013

Extract rpm/jar/tar/iso in Windows 7

Windows 7-Zip from All Programs Menu
How about extracting .rpm/iso/tar/jar files on windows 7 machine?

Once of the best utilities i have come across in recent years in 7-Zip. I was particularly interested in jar, tar, iso and rpm files extraction. Other than these four  extensions, 7-Zip supports a number of other compression and non-compression archive formats (both for packing and unpacking) including 7z, ZIP, GZip, bzip2, xz and WIM. The utility also supports unpacking APM, ARJ, CHM, cpio, DEB, FLV, JAR, LHA/LZH, LZMA, MSLZ, onepkg, RAR, RPM, smzip, SWF, XAR and Z archives and CramFS, DMG, FAT, HFS, ISO, MBR, NTFS, SquashFS, UDF and VHD disk images.

7-Zip can open some MSI files, allowing access to the meta-files within along with the main contents. Some Microsoft CAB (LZX compression) and NSIS (LZMA) installer formats can be opened. Similarly, some Microsoft executable programs (.EXEs) which are self-extracting archives or otherwise contain archived content (e.g., some setup files) may be opened as archives.

The utility can be downloaded from here:
http://www.7-zip.org/download.html

Monday, August 12, 2013

fuser and pfiles: lsof equivalent in Solaris

Lets talk about lsof. It displays information about files which are opened by running(active) processes. An open file may be a regular file like text file or any script, directory, NFS file, block special file, character special file, shared library, regular pipe, named pipe, symbolic link, socket, anything. In Unix, we consider everything is a file, so you can think of how incredibly smart utility lsof is. Generally it is supplied with Linux.

But the question is, what is its Solaris equivalent? 

After some hit and misses i have managed to run an equivalent command. fuser. The fuser syntax that worked for me is :

sudo fuser -vm / 2>&1 | awk '$3 ~ /f|F/' | less

Another one is pfiles. It is not necessarily supplied with the default package.

pfiles /proc/*

Sunday, July 28, 2013

Run fsck on a filesystem to repair it..


fsck -y -o b=32 /filesystem

This will repair the corrupted file system to its best and restore the data in /filesystem/lost+found directory. Data in this directory will have "#inode name" nomenclature. From there the data can be copied back to the filesystem. Ofcourse the techie who is repairing the FS must have prior knowledge about the directory structure in filesystem otherwise he would not be able to decide where to copy which file from lost+found directory. 

Note: This is system administrator's work, so please do not run mount/umount/fsck sort of commands with minimal knowledge. The fsck command can have other parameters as well. So depending on the need of the work, one can decide the exact fsck command. Above fsck command is most generic one i came across and applied while **working on real time issues**. Also please keep in mind that the filesystem has to be unmounted first (umount /filesystem) then run fsck and then mount (mount /filesystem /mountpoint) the filesystem back if properly repaired. Then only you will be able to see the files for restore in /lost+found directory.

Wednesday, July 17, 2013

Mount ISO image in Linux

Getting a lot of emails regarding mounting ISOs in linux. Please use the following steps in order to mount the image to FS.

Procedure to mount ISO images in Linux.

1) Login as a root user:
$ su -

2) Create a mount point:
# mkdir -p /mnt/disk

3) Mount iso file called mountthisdisk.iso:
# mount -o loop mountthisdisk.iso /mnt/disk

4) Verify it:
# cd /mnt/disk
# ls -l

In case you have not noticed "loop" in the mount command, let me tell you that A loop device is a pseudo-device that makes a file accessible as a block device. Loop devices are often used for CD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory using above commands.

Monday, February 18, 2013

Find files which are older than 15 minutes in Linux and Solaris..


The below example is for moving (mv) files, same can be changes easily for rm, ls, cp etc. One has to make change in xargs paramaeter.

In LINUX:
=========

find /path_to_directory/ -name "*.rpt" -type f -mmin +15 | xargs -I {} mv {} /target_directory_path/


In Solaris:
===========

#! /usr/bin/sh

#### Create a reference file minute_test
touch /path_to_directory/minute_test

#### Make minute_test 15 minutes old
sleep 900

#### Move all .rpt files to some other directory which are older than reference file minute_test
find /path_to_directory/ -name "*.rpt" -type f -newer minute_test | xargs -I {} mv {} /target_directory_path/

#### Remove reference file
rm -f /path_to_directory/minute_test


 

Blogger news

Blogroll