Pages

Unixbhaskar's Blog

Thursday, September 20, 2012

Best possible way to Systemd's transition from /lib to usr/lib on Arch Linux


Okay,I seriously had struggle(due to my lack of brilliance) for this transition ,once I update one regular update on Arch Linux by ignoring glibc like previous time.And only found out that kernel image creation is not possible. Because the kernel module location has changed with new kernel with systemd.So ,it was trowing "module not found error"..irk..

And I was trying to do it from chroot environment on Fedora and Gentoo.

After several hours of brain scratching and hover through different forum thread at Arch Linux site;I landed on a wiki page ,which solve the mystery.

The simplest possible way to do this transition from chroot environment is below:



pacman -Syv
pacman -S busybox rsync
rsync -rapv /lib/ /usr/lib/
mv /lib/ /lib.backup/
busybox ln -s /usr/lib/ /lib
# rm -rf /usr/lib/modules/
ldconfig
pacman -Suv
pacman -Sf glibc linux
rm -rf /lib.backup/



And please do it sequentially.Period.

If you don't do that, then the glibc and as well the system will be broken for ever for the new kernel which run systemd for boot.You just cannot create or make the new kernel image by running mkinitcpio! which was the case with me.

Hope this will help.

Cheers!
Bhaskar



Tuesday, August 21, 2012

Create batch accounts of user automated way

I wrote a little and mundane script long time back to solve my purpose to create bunch of user accounts on specific host.

Here is the script:
#!/bin/bash
# This script is meant to run when we create a bunch of user account of any specified host.
#Backup important file before doing anything.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2,
# or at your option any later version, as published by the
# Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.


PASSWDFILE="/etc/password"

GROUPFILE="/etc/group"

SHADOWFILE="/etc/shadow"

DATE=`date`

USERFILE="THis file should have the form of password file like username:password:UID:GID:gecos:shell"

cd /etc ;pwd

cp -v $PASSWDFILE $PASSWDFILE.$DATE

echo " Password file backed up.."

cp -v $GROUPFILE $GROUPFILE.$DATE

echo " group file backed up.."

cp -v $SHADOWFILE $SHADOWFILE.$DATE

echo "shadow file backed .."


/usr/sbin/newusers $USERFILE

echo " Done"

echo " Forcing user to change their password upon first login.."

for i in $USERFILE

do

/usr/sbin/chage -d 0

echo $i

done


If you feel ,you can suggest me the enhancement.

Hope this will help.

Cheers!
Bhaskar

Wednesday, July 11, 2012

How to fix shell "permission denied" error

I believe everyone,who works on terminal for certain length of time come across this error sometime.

Very trivial topic so the fixing is also very trivial too.

Once you tried to logged into the shell you get the "permission denied" error on the console but get the shell prompt and most importantly you can not do a "ls" and other stuff too.

But you can login to the shell as root fine..without any error..it's the normal user that is getting it!!

So it signifies, something wrong with the way disk has been mounted.But once you give the correct flags with the mount it will work..but once you reboot it will started to react in same manner i.e erroneously.

How to do it right?

simple, put an entry like this in /etc/rc.local(that is file executed last at boot stage)

chown -R username:groupname disk-partition

I have had multiple disk partitions and I did that.

and make /etc/rc.local file executable by doing a chmod. Additionally check for /etc/nologin file..if that is present..then it might hinder you to get in.Double check the shell you are trying to use is exists.

That's all you need to do..next reboot it should be good.

Tip: Be careful about /dev/null! if the permission of this file get changed ;you might get the "permission denied" error too on console.So,you need to fixed that by running "mknod" to recreate it and assign the correct permission to this file.Normally it should look like this:

ls -al /dev/null
crw-rw-rw- 1 root root 1, 3 Jul 11 08:34 /dev/null


Udev plays a role to determine the right thing about those.So keep an eye on Udev related matters on system.


Hope this will help.

Cheers!
Bhaskar

Monday, April 23, 2012

Read the contents inside a RAM

In this post I will show you ,how you can see what is holding in your system RAM at the present moment.

Here is what you need to do :
bhaskar@GentooLinux_12:11:22_Mon Apr 23:~> sudo strings /dev/mem | less

And the outcome from my laptop is below:

ZRr=
`|f
\|f1
GRUB
Geom
Hard Disk
Read
Error
ZRr=
`|f
\|f1
GRUB
Geom
Hard Disk
Read
Error
loading
Geom
Read
Error
WVS1
[^_]
[^_]
>G9}
Ft51
D[^_]
[^_]
[^_]
Y_^+
RBRPQR
ZYs
(hd0,msdos2)/grub2
t)PS
USRf
fSfRQ
[_^]
UQPSVWR
_^[XY]
WVS1
[^_]
<,u; PAMS PAMSu [^_] [^_] [^_] u SSh, QQh< [^_] VVPh_ SSQht RRPh (<-t PWQh [^_] (<-t PQRh [^_] [^_] [^_] RPWh [^_] SSh/ PPhC PPhe t$QP [^_]Z [^_]Z s SSh% PPh6 [^_] [^_] (Ph] PPhn [^_] [_t3 [^_] [[t>
[^_]
[^_]
[^_]
4RPh
3w RRh
ELFu
PPh9
PPh\
PPhr
C09E
C09E
C09E
C09E
C09E
QPhY
t"RR
[^_]
[^_]
>PVWh
[^_]
[^_]
,[^_]
[^_]
RRhP
8(uB
PPh@
[^_]
RRhL
[^_]
>/t
[^_]
VVhq
[^_]
8+t 1
8+u< s VVh [^_] [^_] [^_] PPhP 8mimgu [^_] [^_]Z [^_] Y[^] WVSW ^[^_] ZY[^_] SWvP ^[^_] [^_] [^_] $[^_] [^_] u
Entering rescue mode...
grub_abort
grub_bios_interrupt
grub_boot_drive
grub_chainloader_real_boot
grub_checkkey
grub_command_list
grub_current_context
grub_device_close
grub_device_iterate
grub_device_open
grub_disk_ata_pass_through
grub_disk_close
grub_disk_dev_iterate
grub_disk_dev_register
grub_disk_dev_unregister
grub_disk_firmware_fini
grub_disk_firmware_is_tainted
grub_disk_get_size
grub_disk_open
grub_disk_read
grub_disk_write
grub_divmod64_full
grub_dl_get
grub_dl_head
grub_dl_load
grub_dl_load_file
grub_dl_ref
grub_dl_unload
grub_dl_unref
grub_env_export
grub_env_find
grub_env_get
grub_env_iterate
grub_env_set
grub_env_unset
grub_err_printed_errors
grub_errmsg
grub_errno
grub_error
grub_error_pop
grub_error_push
grub_exit
grub_fatal
grub_file_close
grub_file_read
grub_file_seek
grub_free
grub_fs_autoload_hook
grub_fs_list
grub_fs_probe
grub_get_rtc
grub_get_time_ms
grub_getkey
grub_gettext
grub_isprint
grub_isspace
grub_list_push
grub_list_remove
grub_machine_fini
grub_machine_mmap_iterate
grub_malloc
grub_memalign
grub_memcmp
grub_memmove
grub_memset
grub_millisleep
grub_mm_base
grub_module_iterate
grub_named_list_find
grub_parser_cmdline_state
grub_parser_split_cmdline
grub_partition_get_name
grub_partition_iterate
grub_partition_map_list
grub_partition_probe
grub_pit_wait
grub_print_error
grub_printf
grub_printf_
grub_prio_list_insert
grub_puts_
grub_pxe_call
grub_real_dprintf
grub_realloc
grub_reboot
grub_refresh
grub_register_command_prio
grub_register_variable_hook
grub_snprintf
grub_stpcpy
grub_strchr
grub_strcmp
grub_strcpy
grub_strdup
grub_strlen
grub_strncmp
grub_strncpy
grub_strndup
grub_strrchr
grub_strstr
grub_strtoul
grub_strtoull
grub_strword
grub_term_inputs
grub_term_inputs_disabled
grub_term_outputs
grub_term_outputs_disabled
grub_term_poll_usb
grub_unregister_command
grub_vprintf
grub_vsnprintf
grub_xasprintf
grub_xputs
grub_xvasprintf
grub_zalloc
memcpy
no gzip magic found
vga=791 is deprecated. Use set gfxpayload=1024x768x16,1024x768 before linux command instead.
no gzip magic found
Intel(R)Sandybridge Mobile Graphics Chipset Accelerated VGA BIOS
Intel Corporation
Intel(R)Sandybridge Mobile Graphics Controller
Hardware Version 0.0
A wHq}
s} K
!nr'
'Dj"f
w_{{
.}#
'8|+
|B&Y
f87N,
:N_>
3c#S?
;Q~P
%Iiil
:j )j#
npdZy
IU9#G
D*~1
x3&~
{JKK
( PT
0 5
8MJWP
133WH2
VESA
Intel(R)Sandybridge Mobile Graphics Chipset Accelerated VGA BIOS
Intel Corporation
Intel(R)Sandybridge Mobile Graphics Controller
Hardware Version 0.0
0 5
0 5
8MJWP
133WH2
WVS1
[^_]
[^_]
>G9}
Ft51
D[^_]
[^_]
[^_]
Y_^+
RBRPQR
ZYs
B>Sz~
,zD#i8
tX6p
.yn1
6lx3u
^Zm2
vXg{3
i[.b
uj!s
(ds&
O3L5
X 3vO
_iiZ
whvZ
qg?
mO''
y[hg4
wR;=
so_?
dOAj0X
zp}c\K~[
qRpd5
/o]`
D&X+
kfv[q
4t7M
.o#K &u
xn-9
aua*
]oS|(
8vzw
l[M(
@\!$
t,MEH
[NUe
iBi&
1.<& {I_6 (#lD .G;S ,ptl "(,B } 8+.O| Yo_g9m Pi&S C:9V `^[Ui ?cht xkpl !F{5 m UWw 6gK! ,- | ]-rB .Ywk t/{6 byX| jJ2& h*S& gOl".a {6_UE ru-L ^|xE, ^|oK :B:7 {0oR Ijg) 60Mq {/bn ey:h# x~mN n 5T4f }S+t Nen. x~+S& *HaY- TT8#B UJ;]h0 hnKd ] ?Y IU[~ A0K`D Sp"d HJ+~ 0$'%X 3]4@" I/Pl# 3\w^ ]W&@ u'ay 7kyn .xs6` A%Lxc BpUv gXJ,c U&L2OZ ~`8>Q_H
:WDH
f$S6
#q`E
nb%r
\;po
3i5~
|Vs-
T;t@
WN"K
HFcs
\U68
\A|?
|eI#
%Izg
3X1l
,lM;
|~4[8
#kO,*NgNt
Gd!o
D j"
^Fy!
\vz`
NfYBU
]gz1
\2g?
C@bi
T' Z52B
jtb{$p
fR{O_x
j>U`
~V/*A{k
.
.
.
.
$VBT SANDYBRIDGE-M d
BIOS_DATA_BLOCK
2098Intel(R)Sandybridge Mobile PCI Accelerated SVGA BIOS
Build Number: snm20980.dnq PC 14.34 12/22/2010 15:25:04
DECOMPILATION OR DISASSEMBLY PROHIBITED
Copyright (C) 2000-2003 Intel Corp. All Rights Reserved.
02468:<@BDFHJLPRTVXZ\ LFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelName 0@0p H?@0b 0@0p 0*x Q H?@0b @0 6 #@0 * q8-@X-6 0 5 LFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelNameLFP_PanelName+a fPfVfWf t[VfP ZYf;F rwfVWR . . . . . Diskette Drive Internal HDD USB Storage Device CD/DVD/CD-RW Drive Modular Bay HDD Onboard NIC Unknown device BIOS Setup Diagnostics eSATA CPU 1 Intel Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz To Be Filled By O.E.M. To Be Filled By O.E.M. To Be Filled By O.E.M. L1-Cache L2-Cache L3-Cache J1A1 PS2Mouse J1A1 Keyboard J2A2B Video J3A1 USB1 J3A1 USB2 J3A1 USB3 J5A1 J2B3 - CPU FAN J9E1 - SCAN MATRIX J9G1 - LPC SIDE BAND J2G1 - GFX VID . . . . DIMM_B BANK 2 Not Specified Not Specified Not Specified Not Specified vPro INTEL 0000 Dell Inc. 05/26/2011 Dell Inc. 0M516T .G2VKKP1.CN7016617J002I. To Be Filled By O.E.M. Dell Inc. Not Specified G2VKKP1 DELL2 OKP1 Dell Inc. Vostro 3350 Not Specified G2VKKP1 To be filled by O.E.M. 20110720 20110720 ATI Robson XT DIMM_A BANK 0 830B 35963CFC 0D111800 NT4GC64B8HB0NS-CG 110720 20110720 ptal ptalH ptalp ptal ptal pfr0 IFE$ $PMM G=fHf RSD PTR . . . . IBM COMPATIBLE IBM IS A TRADEMARK OF INTERNATIONAL BUSINESS MACHINES CORP. Dell System Vostro 3350 (C)1985-2009,American Megatrends, Inc.All Rights Reserved. $BV# A04$DEL R:EF8 !dhuS @t$j@ @((PP((PP,(-)*. AMIBIOS 080010 06/16/10(C)2010 American Megatrends, Inc. All Rights Reserved (C)2010 American Megatrends, Inc. 63-0100-000001-00101111-061610-Chipset 000-0-0000-00-00-0000-00-00-000 000-0-0000-00-00-0000-00-00-00-0 _TG_0AAAA000 AMIBIOS(C)2010 American Megatrends, Inc. BIOS Date: 05/26/11 10:52:20 Ver: 04.06.04 CCCC ???? <<<<


.... and many more...I have chopped out the rest for sake of brevity :-)

Hope this will help.

Cheers!
Bhaskar

Thursday, March 22, 2012

How to correct a small python code error!!

So, I was building a software which built on python2.6 version and I was exploiting it on CentOS 5.8.But when I ran the script I have come across that the script is throwing error and saying the syntax is invalid!! heck!

Although I have installed python2.6 separately on this box ...then what??

The error is ordinary :



sudo ./w3af_console -f
File "./w3af_console", line 108
rev = 0 if (a == 'HEAD') else -1
^
SyntaxError: invalid syntax


So , as next step I look into the script, which I should have done in first place and I couldn't.The problem lies in the first line of the script..as we all know that the shebang is the guide to system environment where the script are going to be interpreted.It was showing like this


#!/usr/bin/env python


Now I have corrected it ...as the software demands python2.6 ..so below..



#!/usr/bin/env python26



and Voila!!

Ordinary stuff right?? but tricky..might lead into long haul :)

Hope this will help.

Cheers!
Bhaskar

Tuesday, January 3, 2012

How to get over Gentoo's X display problem after update

Yep! I could have write the title more specific way,but let it go.So as normal routine I ran a worldsync on my Gentoo and bang! once I reboot the X was not coming up in-spite of having everything in place. What the heck!!!

Then,I realize that update make some enhancement to X and associated things are not getting updated with it.

So, instinctively poking at the log file tell me that "ABI version of so many thing ,related to X driver is mismatching with the server version" and then the obvious thing a little google search reveal that too.Something like this in log file shows:


38.004] (EE) module ABI major version (10) doesn't match the server's version (11)
[ 38.004] (II) UnloadModule: "vesa"
[ 38.004] (II) Unloading vesa
[ 38.005] (EE) Failed to load module "vesa" (module requirement mismatch, 0)
[ 38.005] (II) LoadModule: "fbdev"
[ 38.005] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[ 38.005] (II) Module fbdev: vendor="X.Org Foundation"
[ 38.005] compiled for 1.10.2, module version = 0.4.2
[ 38.005] ABI class: X.Org Video Driver, version 10.0
[ 38.005] (EE) module ABI major version (10) doesn't match the server's version (11)
[ 38.005] (II) UnloadModule: "fbdev"
[ 38.005] (II) Unloading fbdev
[ 38.005] (EE) Failed to load module "fbdev" (module requirement mismatch, 0)
[ 38.005] (II) intel: Driver for Intel Integrated Graphics Chipsets: i810,
i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G, 915G,
E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM, Pineview G,
965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33, GM45,
4 Series, G45/G43, Q45/Q43, G41, B43, B43, Clarkdale, Arrandale,
Sandybridge Desktop (GT1), Sandybridge Desktop (GT2),
Sandybridge Desktop (GT2+), Sandybridge Mobile (GT1),
Sandybridge Mobile (GT2), Sandybridge Mobile (GT2+),
Sandybridge Server, Ivybridge Mobile (GT1), Ivybridge Mobile (GT2),
Ivybridge Desktop (GT1), Ivybridge Desktop (GT2), Ivybridge Server
[ 38.005] (++) using VT number 7

[ 38.038] (EE) No devices detected.
[ 38.038]
Fatal server error:
[ 38.038] no screens found
[ 38.038]
Please consult the The X.Org Foundation support
at http://wiki.x.org
for help.
[ 38.038] Please also check the log file at "/var/log/Xorg.1.log" for additional information.
[ 38.038]




Now the time to rebuild the X11 drivers ,because I got new X server to match with it.Did it like this :



bhaskar@GentooLinux_15:11:04_Tue Jan 03:~> sudo emerge -1 $(qlist -IC x11-drivers)



That is numeric one to the emerge flag...means oneshot..means not put an entry in world file...

Once it finish I reboot the machine and voila...the X display come back!!

Hope this will help.

Cheers!
Bhaskar