Neo
This user hasn't shared any biographical information
Posts by Neo
How to find list of installed files of an RPM
Nov 4th
The rpm -q -l can be used to get the list of files installed by an installed RPM. The following example finds the files installed by bash RPM.
[neo@techpulp ~]# rpm -aq | grep bash bash-3.2-18.fc8 [neo@techpulp ~]# rpm -q -l bash-3.2-18.fc8 /bin/bash /bin/sh /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc /usr/bin/bashbug-32 /usr/share/doc/bash-3.2 /usr/share/doc/bash-3.2/CHANGES .... /usr/share/man/man1/unset.1.gz /usr/share/man/man1/wait.1.gz [neo@techpulp ~]#
How to find which RPM owns an installed file
Nov 4th
The ‘rpm -q -f’ command can be used to identify RPM to which an installed file belongs to. The following example queries RPM database to find the RPM that own /usr/bin/kompare file.
[neo@techpulp ~]# rpm -q -f /usr/bin/kompare kdesdk-3.5.8-2.fc8 [neo@techpulp ~]#
If the file doesn’t belong to any RPM it displays a message as shown below.
[neo@techpulp ~]# rpm -q -f /home/neo/myfile.txt file /home/neo/myfile.txt is not owned by any package [neo@techpulp ~]#
How to find the list of installed RPMs
Nov 4th
The “rpm -aq” command can be used to query the list of RPMs installed in the system.
[neo@techpulp ~]# rpm -aq gnu-regexp-1.1.4-10jpp.3.fc8 java_cup-manual-0.10-0.k.6jpp.1 ql2200-firmware-2.02.08-1.fc8.1 popt-1.12-3.fc8 freetype-2.3.5-3.fc8 sed-4.1.5-9.fc8 libattr-2.4.38-1.fc8 device-mapper-1.02.22-1.fc8 libIDL-0.8.9-1.fc8 .... python-xlib-0.13-3.fc7 qt-designer-3.3.8b-2.fc8 [neo@techpulp ~]#
You can use ‘grep‘ command to search for a particular RPM in the list as shown below. In this example, we are trying to find if the GIMP package is installed in the system.
[neo@techpulp ~]# rpm -aq | grep gimp gimp-libs-2.4.0-0.rc3.2.fc8 xsane-gimp-0.994-4.fc8 gimp-2.4.0-0.rc3.2.fc8 [neo@techpulp ~]#
Where is my NetMeeting in Windows XP
Nov 3rd
The NetMeeting application is not directly visible in either start-menu shortcut or desktop shortcut. But NetMeeting application will be installed as part of standard Windows XP installation. So there is no need to download NetMeeting from Microsoft Download Center and install. Moreover if you download NM30.EXE from Microsoft Download Center and try to install it on Windows XP it will say that its version is not compatible with this version of Windows. It is because NM30.EXE is intended for Windows 2000 etc.
Basically NetMeeting is already there in your installation and it’s just that you need to configure it before it More >
Why my Unix/Linux VNC session shows only xterm instead of full desktop
Nov 3rd
The default VNC startup script (~/.vnc/xstartup) doesn’t include any commands to start standard desktops like KDE or GNOME. It contains commands to start primitive TWM as window manager and one xterm terminal as application. The following will be the typical startup file for VNC in Fedora systems.
[neo@neo.techpulp.com ~/.vnc]$ cat xstartup #!/bin/sh # Uncomment the following two lines for normal desktop: # unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm &
You can change the line More >
How to clean multiple sub-directories in Makefile
Oct 23rd
The following example assumes that all sub-directories are listed in $(SUBDIRS) variable. All the entries in $(SUBDIRS) can be iterated using a “for” loop as shown below and “make clean” can be run in each directory.
SUBDIRS = dir1 dir2 dir3 clean: for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
Note that if you doing are copy-n-paste of the above snippet, the “for” statement should be indented with a TAB. Otherwise it will result in make error.
In the above example “clean” rule can be replaced with any other rule.
The -C option tells GNU make to change to a specific directory before reading the More >
Arithmetic operation using double parentheses construct in Bash
Oct 18th
The following script illustrates how double parentheses can be used to do arithmetic operations.
#!/bin/sh (( a = 23 )) echo "a (assign value) = $a" (( ++a )) echo "a (after ++a) = $a" (( --a )) echo "a (after --a) = $a" (( a++ )) echo "a (after a++) = $a" (( a-- )) echo "a (after a--) = $a" echo (( b = a>30?12:20 )) echo "If a > 30, then b = 12, else b = 20." echo "b = $b " echo
The following is output of the above script.
[neo@techpulp ~]# sh dpara.sh a (assign value) = More >
How to determine if a string contains a validate IP address in C
Oct 18th
Any valid IP address consists of four numbers separated by three period (.) characters and each number ranges from 0-255 inclusive. An example IP address is “125.231.167.234″. The string function sscanf can be used to extract the four numbers and then validate each number for the range 0-255. Then use strcmp to further validate with reconstructed ip string.
The following function returns 0 if the IP address is invalid and 1 if valid.
int is_valid_ip(const char *ip_str)
{
unsigned int n1,n2,n3,n4;
if(sscanf(ip_str,"%u.%u.%u.%u", &n1, &n2, &n3, &n4) != 4) return 0;
if((n1 != 0) && (n1 <= 255) && (n2 <= 255) && (n3 More > How to generate random/temporary file name using mcookie command
Oct 17th
The mcookie shell command is used to generate magic cookie for xauth. It throws a md5sum like output and the basic usage is as shown below.
[neo@techpulp ~]# mcookie 5f8dbb14e7eb4db75428017585115feb [neo@techpulp ~]#
Now let us use the output of mcookie command and form a random file name for temporary usage. In the following script, we use first characters of the random string printed by mcookie to form a random file name. The randfile() function takes prefix and suffix of the temporary file name and returns a temporary file name after checking for its existence.
#!/bin/bash
function randfile
{
while [ 1 ];
do
MCOUT=`mcookie`
TNAME="$1""${MCOUT:0:5}""$2"
if [ ! More > 

Recent Comments