Welcome to CodeGlobe. CodeGlobe provides free source code, tutorials and latest useful technology news.
Tuesday, July 28, 2009
linux minicom
this is some what similar to the hyperterminal in windows
which also used for modem communications
configure minicom
minicom -s
set device(eg, ttyS0,) set baudrate say (9600 or parity hardware flow control etc).and etc...
save the configuration file
and in the root prompt
enter command
minicom
will connect device which you configured in the minicom.
(router interface with linux mechine is also done using minicom)
Monday, July 27, 2009
hacking root shell in linux
we need to edit the grub(editing grub is described in previous posts) bootup screen using press 'e' place the end of the line as following
init=/bin/sh
enter and press 'b' for boot
after boot you will get a shining root shell "#"!!
in this above procedure we could bypass the init proces to a shell from what it does in normal.
in this point we didn't mount any file system. (manually mount if it required.normally dont need)
for checking the read right permission for the file system use touch utility
touch something
if it is given an error message then you dont have write permission to the file system.
to gain the filesystem read write permission u need to remount it as follows
mount -o remount,rw /
after that you can do anything as root!!!eg. change the root password. placing commands in inittab etc...remember dont press ctrl+D it will kill the shell causing kernel panic.
ls commands in linux
the common nature of the ls commads are listing operation here there are...
ls- list contents (commonly used).
lsof- list the opened files which is used by the running process.
lsusb-list the usb devices connected to the system.
lsmod-list the modules which is loaded in the running kernel.
lspci-list the pci(Peripheral Component Interconnect) devices (use lspci -vvx to get meaning full data othere wise expert can understand it).
lsattr-to list attributes of a file(attributes like immutable field)
lshal-list hal(Hardware Abstraction Layer, HAL which is a piece of software that provides a view of the various hardware attached to a system)devices
cheers.......
Sunday, July 26, 2009
Change the Linux root password from single user mode
1. Boot up your Fedora 10 system, on the boot up splash screen press and hold shift key until you enter the GRUB screen
Press and hold "shift" key here and wait until GRUB boot menu screen appear
2. if you have multiple operating system installed, you may have to select the Fedora 10 by using the 'up' and 'down' key... then hit the 'e' key to enter GRUB editing mode
3. Use the 'up' and 'down' key again, select the 'kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 rhgb quiet', and the hit the 'e' key again to edit the grub command line.
4. The below screen appear after you hit the 'e' key, now notice that you mouse cursor at the end of line 'kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 rhgb quiet'.
5. Change at the end of the line that say 'rhgb quiet' to 'linux single'
From : kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 rhgb quiet
To : kernel /vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=27f6ac23-638f-439a-8a97-2baaf6a32922 linux single
hit 'Enter' key after finish enter the 'linux single' at the end of kernel line, as show on GRUB.
6. Hit the 'b' key to boot the selected kernel and start the boot process to Linux single user mode.
7. After you hit the 'b' key, the Fedora 10 should reboot and then enter the single user mode and should give you root shell terminal without prompt any password field or ask for password.
Issue passwd command to change root user password on Fedora 10 after we finish the procedure to enter the Linux single mode as show on step by step example above.
[root@fedora /]# passwd <-- Start type in 'passwd' command and hit Enter key
Changing password for user root.
New UNIX password:
passwd: all authentication tokens updated successfully.
Then reboot the system and start using the new root password for your Fedora 10 system
[root@fedora /]# reboot <-- Type in 'reboot' command and hit Enter key to start reboot Fedora system
website development hosting cochin - Kerala IT solution providers, Kochi
Thursday, July 23, 2009
Booting another bootloader(grub,lilo,ntldr....) from grub
eg.
Suppose main grub installed on /dev/sda1 and the second os is installed on /dev/sda2
in /boot/grub/grub.conf or /boot/grub/menu.lst (which is grub configuration file)
add as following
title Linux 2 on /dev/sda2
root (hd0,1)
# or use rootnoverify (hd0,1)
#rootnoverify is same as root but don't attempt to mount the partition.
chainloader +1
.
Wednesday, July 22, 2009
Bluetooth command line operations in linux
hciconfig
- Gives info about the bluetooth hci on your pc
- Ensure the device is up and running and has required scan modes
- hcitool dev should also give some of this info
hcitool inq and hcitool scan
- Gives info about or rather identifies nearby bluetooth devices
hcitool info
- BTAddr refferes bluetooth address.
- Get info about remote bluetooth device
l2ping
- One way to see if we can communicate with a remote bluetooth device
sdptool browse
- Gives info about the services provided by a remote bluetooth device
obexftp –nopath –noconn –uuid none –bluetooth
- Allows one to send file without specifying the pin on the remote device side
- The OPush channel number for device is got from sdptool above
passkey-agent –default
- Pin specified here is what the remote BT device should provide
or its user enter on that device when requested.
obexftp -b
- Allows one to put a file onto the specified BT device
- obexftp could also be used to get or list the files on the BT device
- also allows one to identify a nearby BT device by just giving -b option
obexpushd
- Allows one to recieve files sent from a bluetooth device.
- Depending on who started it, the recieved files will be stored in the corresponding home directory
Note: The old style pin_handler doesn’t work with latest bluez(is a protocol stack for linux), you require adbus based passkey handler and there is one provided by default by bluez-utils
called passkey-agent
Tuesday, July 21, 2009
Change file attribute in Linux
Make a file readonly, ie nobody, even root, can make changes to a file:
This can be done by using the "chattr" command and "i" attribute.
[root@odcclient6 Desktop]# chattr +i test.txt
you can view the attribute of the file using this command lsattr.
To remove the attribute use this command "chattr -i"
Cheers...............
Find encoding of given file linux
by simply using this command
file filename
eg:
vimal@TECH-10:~$ file vimal
vimal: ASCII text
Monday, July 20, 2009
linux shell script for find and replace strings in a directory
#check for required parameters
if [ ${#1} -gt 0 ] && [ ${#2} -gt 0 ];
then
for f in `find -type f`;
do
if grep -q $1 $f;
then
cp $f $f.bak
echo "The string $1 will be replaced with $2 in $f"
sed s/$1/$2/g < $f.bak > $f
rm $f.bak
fi
done
else
#print usage informamtion
echo usage incorrect.try findscript string1 string2
echo special characters forwarded with slash
Thursday, July 16, 2009
To load modules on startup LINUX
we will make(build or compile) our modules using the help of make utility on linux.
this utility or cammand uses Makefile as its input for compiling or building modules.
after build the modules we will get our executable module as
(make modules install for compiling kernel also install all modules in /lib/modules/uname -r/kernel directory)
modulename.ko
if we want to load module ,
insmod modulename.ko
there are somany issues for this modules are depended on another module.
if say our module modulename.ko is depended on module1.ko and module2.ko
in this case we want to load
insmod module1.ko
insmod module2.ko
insmod modulename.ko
to simplify this task we have a modprob utility
we could set dependency in a file /lib/modules/($SHELL uname -r)/modules.dep
modprobe actually uses insmod to insert module in a running kernel.
the entry in modules.dep is like as follows
/lib/modules/2.6.26-1-686/kernel/mymodule.ko: /lib/modules/2.6.26-1-686/kernel/module1.ko /lib/modules/2.6.26-1-686/kernel/module1.ko
(eg: modulename : (colon) first dependency (space)second dependacy (space) etc....)
syntax is important!!!
use command
modprobe mymodule.ko
it will automatically add module1.ko and module2.ko automatically
lets come to the context if we want to load it on startup we will have to configure modprobe. For that we could use /etc/modprobe.conf or /etc/modules.conf or /etc/modules according to different distributions of linux
/etc/modules.conf uses 2.4 and earlier version now we are popular 2.6 kernel so it is modeprobe.conf(/etc/modprobe.d/)
add a single line to that file will load the module on the startup
just add
at the end of line
mymodule
it is very easy to play with modprobe.conf there is a command line interface also there.
man modprobe ,for more information!
we could set aliases for our modules in this file
hope u get some idea about how load module into running kernel at runtime....
regards
Nat Rule for IPTABLES
This is simple script for nat rule in ip tables. Just make changes in the script and run it. After running the script do the following.
service iptables save
service iptables restart
cheers....... :-)
Download -
Note: Make a copy of your current rule [/etc/sysconfig/iptables] before executing this.
Tuesday, July 14, 2009
change screen resolution of linux pc command line
[root@localhost] xrandr
will display the compatible resolutions
u can set a resolution by
[root@localhost] xrandr -s 1024*768
Monday, July 13, 2009
Take Screenshot Using Linux Command
command - import
[root@odcclient6 Setup]# import -trim /root/Desktop/test.jpg
Cheers.................... :-)
Linux Funny Commands
If you want to know what is the use of cd command just type in console
[sujith@odcclient6 bin]$ whatis cd
cd (1p) - change the working directory
cd [builtins] (1) - bash built-in commands, see bash(1)
NOTE: Some times you may have to build the database first by running "/usr/sbin/makewhatis".
Here comes the fun :
[sujith@odcclient6 bin]$ cd /usr/bin
[sujith@odcclient6 bin]$ ls | xargs whatis | less
[ls = list directory contents, xargs = build and execute command lines from standard input]
Command to check whether the sytem is alive or not
fping is a ping like program which uses the (ICMP) echo request to determine whether an ip is up or not.
fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping.
Working
fping will send out a ping packet and move on to the next host in a round-robin fashion.
If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or retry limit it will be considered unreachable.
Unlike ping, fping is meant to be used in scripts . Really helpful when we need to set the status of the a particular host in our applications.
Download Link
http://linux.softpedia.com/progDownload/fping-Download-10469.html
download and install the software. Type fping -h will list out the various parameters.
Example shell script
#!/bin/sh
status=`fping 192.168.0.88 | cut -d ' ' -f 1`
if [ $status != "alive" ]
then
echo 'Server Down. Please check the network'
fi
Wednesday, June 3, 2009
Adding NTFS support to Linux
The latest stable version of NTFS-3G can be found at http://www.ntfs-3g.org/
NTFS-3G uses FUSE lib ( Filesystem in Userspace ). FUSE provides set of functions to implement file system in a userspace program.
The latest version of FUSE can be found at http://fuse.sourceforge.net/
Installation:
Download NTFS-3G and FUSE from above links
Untar FUSE
Install fuse with following command
#./configure
# make
# make install
Untar NTFS-3G package then type
#./configure
# make
# make install
If there is no error in the installation, ntfs drive can be mounted in read/write mode
mount the drive with -t ntfs-3g option as follows:
# mount /dev/sda1 -t ntfs-3g /mnt/win