Posts

Showing posts with the label linux

Change MAC Address In Linux

Here we will see a technique  how to spoof MAC address in Linux . MAC address spoofing is changing the Media Access Control (MAC) address of the network interface card (NIC). First of all let me tell you that the MAC address or the Hardware address is inbuilt and is actually burnt into your NIC interface card at the time of manufacturing. It is unique worldwide and cannot be changed permanently by the use of any kind of software. That being said, however we can change it temporarily to suit our needs. The method described here can be used in RHEL, CentOS and Ubuntu as well. MAC address is 48 bits hexadecimal address. Before directly changing the address you need to find out the current MAC address of your network card by using the command # ifconfig | grep HWADDR It will give you output as eth0 Link encap:Ethernet HWaddr 00:21:5A:9B:00:F0 The MAC address in this case is 00:21:5A:9B:00:F0 How to spoof / change MAC address in Linux To change it use the ifconfig...

How to Verify a Linux is 32-Bit or 64-Bit?

To verify if a system is 32 bit versus 64 bit you can use the uname command. Below are examples of using the uname command from the CLI on a 32 bit system followed by using the uname command on a 64 bit system. 32 Bit CentOS Linux Server 1 [root@server ~] # uname -a 2 Linux server1.example.com 2.6.18-92.1.13.el5 #1 SMP Wed Sep 24 19:33:52 EDT 2008 i686 i686 i386 GNU/Linux 64 Bit CentOS Linux Server 1 [root@server ~] # uname -a 2 Linux server.example.com 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:35:07 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux As you can see above the 64 bit server will show x86_64 numerous times after the install date and time. The 32 bit system will show i686 and i386 after the install date and time. So it is very easy to verify if a system is 32 bit versus 64 bit using the “uname -a” command from a shell.

VNC Server On Ubuntu

#sudo apt-get install vnc4server Now setup a password to login using the following command. It will prompt to setup a password and verify it #vncpasswd Than run the vnc server using #vncserver :1 Now before you proceed kill it once using #vncserver -kill :1 Now open the config file from .vnc/xstartup or ~/.vnc/xstartup using editor .vnc/xstartup  Than uncomment the line which says unset SESSION_MANAGER And add sh to the line below it like this exec sh /etc/X11/xinit/xinitrc Exit the file and run the command as below  #vncserver :1 -depth 16 -geometry 1024×768 connect using <ip-addr>:1 (:1 is for the vnc server window) You now have GUI access to your server.

Reinstalling GRUB 2 from LiveCD

If you cannot boot from GRUB 2 and need to reinstall it, here is the simple method. For more details or for advanced options, refer to the Ubuntu community documentation here: Grub2 - Reinstalling GRUB 2 : Boot the Ubuntu Live CD (Try without installing). From the Desktop, open a terminal - Applications, Accessories, Terminal. Determine your normal system partition - `sudo fdisk -l` (That is a lowercase L) If you aren't sure, run `df -Th`. Look for the correct disk size and ext3 or ext4 format. Mount your normal system partition: Code: sudo mount /dev/sdXY /mnt If you aren't sure if you mounted the correct partition, once it's mounted run "nautilus /mnt" to inspect the partition. If it is the correct partition, you should see the normal Ubuntu folders such as /bin, /boot, /etc, /home, etc Example: sudo mount /dev/sd a1 /mnt Note: The partition to mount is normally the partition on which Ubuntu was installed: sda1, sdb5, etc. If you have a ...

i-nodes In Linux

Image
What is inode? In  computing , an  index-node  (inode) is a  data structure  on a traditional  Unix -style  file system  such as  UFS . An inode stores all the information about a regular  file ,  directory , or other  file system  object, except its data and name. (as defined in Wikipedia) The Inode is a pivitol structure within the Unix filesystem. The purposes of an inode is to hold all the information about a file you would normally expect to see in a directory entry on another system - file size, location, access & modification times, ownership, etc. To exist in a filesystem every file must have a inode. Directories, symbolic links, device files and pipes all have inodes. When the inode table is full so is your filesystem, no matter what 'df' is saying about the amount of free space. The size of the inode table is fixed when it is created, there is no command to extend it. Solari...

Using tar to compress folders in Unix

To compress : tar -cf pictures.tar pics/; gzip pictures.tar Or if you want to combine the gzip and the tar creation in one command: tar -czf pictures.tar.gz pics/ To decompress : gunzip pictures.tar.gz; tar -xvf pictures.tar

Compiling The Linux Kernel

Image
Dependencies To compile Linux Kernel the following are required to be installed. gcc latest version, ncurses development package and system packages should be up-to date To install the dependencies run the following commands in terminal and type the password for the user, when prompted. For gcc $ sudo apt-get install gcc For ncurses development package $ sudo apt-get install libncurses5-dev After installing the above packages then update your system by running the following command Update To download the latest kernel go to kernel.org  and download the latest stable version. Once the download complete move to the directory where you have downloaded the kernel package “ linux-3.1.5.tar.bz2 “. Now extract the tar file to the location “ /usr/src/ “. To move to the directory, for example if the downloaded package is in your Downloads directory. Use the below command. $ cd Downloads/ To extract the tar file run the following comm...

Zipping A Directory In Linux

Zip is a compression and file packaging utility for Unix. This utility is installed by default on most Linux computers. he program is useful for packaging a set of files for distribution; for archiving files; and for saving disk space by temporarily compressing unused files or directories. To zip directory called MyDir in your home directory (/home/MyDir), type the following command: $ zip -r mydir.zip /home/MyDir

SSH login without password

SSH login without password Aim: You want to use Linux and OpenSSH to automize your tasks. Therefore you need an  automatic  login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call  ssh  from a within a shell script. How to do it: First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase: a@A:~> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/a/.ssh/id_rsa): Created directory '/home/a/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/a/.ssh/id_rsa. Your public key has been saved in /home/a/.ssh/id_rsa.pub. The key fingerprint is: 3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A Now use  ssh  to create a directory  ~/.ssh  as user b on B. (The directory may already exist, which is fine): a@A:~> ssh b@B...

Configuring iSCSI Volume in Ubuntu/Linux

The other day i got  Dell  EqualLogic  PS6000  Series SAN box to experiment on.  For windows it was pretty straight forward using the iSCSI tool present in administrative tools.  I wanted to try it on Linux so i searched a bit and at last formatted & mounted it on Ubuntu. Here are the steps that i followed. Follow the steps to configure iSCSI volume on ubuntu (i tried on 11.10): 1)  You need to install open-iscsi package :       #sudo apt-get install open-iscsi 2) Now you need to run discovery agains t the iscsi host:       # iscsiadm -m discovery -t sendtargets -p <iscsi server ip address> eg: If 192.168.11.110 is the ip address of iscsi server       # iscsiadm -m discovery -t sendtargets -p 192.168.1.110 OR       # iscsiadm --mode discovery --type sendtargets --portal 192.168.11.110 3)  Note down the record id (such as iqn.xxxxxxxxxx...