Tuesday, November 27, 2012

Restart network service in Ubuntu

Here’s how to restart the network service on Ubuntu without restarting the OS
:~$ sudo /etc/init.d/networking restart

How to install Google Chrome on Fedora 16

Fedora 16 just came out and here’s how to get Google Chrome on it.
Start by creating a repository file for Google called google.repo and place it in /etc/yum.repos.d/ .
sudo vim /etc/yum.repos.d/google.repo

Add the lines below into the repository file. google.repo
[google-chrome]
name=google-chrome - 64-bit
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub

Update yum,
sudo yum update
Search for Google Chrome,
sudo yum search google-chrome
Install Google Chrome Stable
sudo yum install google-chrome-stable
If you prefer the beta like me then run,
sudo yum install google-chrome-beta

How to get Hard Disk Details on Linux

Here’s a quick way to find out more about your hard disk. You can get the serial number, part number, firmware level, size and much more. Just see the sample below.
hdparm -I [device]
hdparm -I /dev/sda
[danesh@pandora Movies]$ sudo hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: WDC WD2500JS-75NCB3
Serial Number: WD-WCANKF265386
Firmware Revision: 10.02E04
Standards:
Supported: 7 6 5 4
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 488281250
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 238418 MBytes
device size with M = 1000*1000: 250000 MBytes (250 GB)
cache/buffer size = 8192 KBytes
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, with device specific minimum
R/W multiple sector transfer: Max = 16 Current = 16
Recommended acoustic management value: 128, current value: 128
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* NOP cmd
* DOWNLOAD_MICROCODE
Power-Up In Standby feature set
* SET_FEATURES required to spinup after power up
SET_MAX security extension
* Automatic Acoustic Management feature set
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Native Command Queueing (NCQ)
* Host-initiated interface power management
* Phy event counters
DMA Setup Auto-Activate optimization
Device-initiated interface power management
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT Long Sector Access (AC1)
* SCT LBA Segment Access (AC2)
* SCT Error Recovery Control (AC3)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
unknown 206[12] (vendor specific)
Security:
Master password revision code = 65534
supported
not enabled
not locked
frozen
not expired: security count
not supported: enhanced erase
Checksum: correct

How can non root users mount and unmount in Linux

File systems / partitions are normally managed by root and only root would be able to mount or un-mount.
However, if you want everyone on your machine to have the same privilege for a specific mount point, this is how you can do that.
Add “user” to the mount options for the desired mount point in your /etc/fstab file. In my case “/media/music”
I changed mine from
//192.168.1.200/Music /media/music rw,noauto 0 0

to
//192.168.1.200/Music /media/music cifs user,rw,noauto 0 0

How to configure a static ip in Linux

This is a newbie question I get quite often.
Configuring your Linux machine to run on a static IP is easy. Tools like system-config-network and netconfig provide you simple GUIs to do this.
For today, I’ll show you how to do this from the command line instead.
Navigate to /etc/sysconfig/network-scripts/

[root@baboo]# cd /etc/sysconfig/network-scripts/

Every network interface will have it’s own interface script file. eth0,eth1,eth2 and so on. Vi the ifcfg-eth0 interface script file for interface eth0. Replace the contents of the ifcfg-eth0 file with the parameters below.
[root@baboo]# vi ifcfg-eth0.

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
HWADDR=00:0F:22:71:0A:53
USERCTL=no
USERCTL=no

If you want to switch back to DHCP, repeat the steps above and replace the contents of the ifcfg-eth0 file with the parameters below.
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0F:20:71:0A:50
ONBOOT=yes
TYPE=Ethernet
DHCP_HOSTNAME=klmdrpdr01p.klm1.netcel360.com

Restart your interface to apply the changes.

[root@baboo]#ifdown eth0
[root@baboo]#ifup eth0

To update your dns server settings, modify the /etc/resolv.conf.
[root@baboo]# vi /etc/resolv.conf
Replace the contents of the resolv.conf file with the parameters below. The first parameter “search” is your search path followed the nameserver parameters which hold the IPs for your primary and secondary DNS servers.

search example.com
nameserver 192.168.0.5
nameserver 192.168.0.6

Monday, November 26, 2012

Iframe with 100% Height

Ever wonder how to create an iframe that fills the entire height (and width) of a page?
You probably tried writing something like:
<iframe width=100% height=100%></iframe>
and expected the iframe to fill up whatever it could.
The width=100% does what you expected and fills up the entire width of the page, but the height just stays about 200px.

Here's some easy JavaScript to do exactly this:


Put this in the head of your page:
<script language="JavaScript">
<!--
function resize_iframe()
{

 var height=window.innerWidth;//Firefox
 if (document.body.clientHeight)
 {
  height=document.body.clientHeight;//IE
 }
 //resize the iframe according to the size of the
 //window (all these should be on the same line)
 document.getElementById("glu").style.height=parseInt(height-
 document.getElementById("glu").offsetTop-8)+"px";
}

// this will resize the iframe every
// time you change the size of the window.
window.onresize=resize_iframe; 

//Instead of using this you can use: 
// <BODY onresize="resize_iframe()">


//-->
</script>
And inside your page's body create the iframe tag:
<iframe id="glu" width="100%" onload="resize_iframe()">
</iframe>

Sunday, November 25, 2012

How to Mount a Remote Folder using SSH on Ubuntu

Connecting to a server across the internet is much more secure using SSH. There is a way that you can mount a folder on a remove server using the SSHFS service.
There are quite a few steps that you’ll have to follow, so get ready and open a terminal window.
First we’ll install the module:
sudo apt-get install sshfs
Now we will use the modprobe command to load it
sudo modprobe fuse
We’ll need to set up some permissions in order to access the utilities. Replace <username> with your username.
sudo adduser <username> fuse
sudo chown root:fuse /dev/fuse
sudo chmod +x /dev/fusermount
Since we’ve added ourselves to a user group, we need to logout and back in at this point before we continue.
Now we’ll create a directory to mount the remote folder in. I chose to create it in my home directory and call it remoteserv.
mkdir ~/remoteserv
Now we have the command to actually mount it. You’ll be prompted to save the server key and for your remote password.
sshfs <username>@<ipaddress>:/remotepath ~/remoteserv
Now you should be able to cd into the directory and start using it as if it was local.
geek@ubuntuServ:~/remoteserv$ ls -l
total 16
drwxr-xr-x 1 951247 155725 4096 2006-12-13 13:30 howtogeek.com
drwxr-sr-x 1 root root 4096 2006-09-11 06:45 logs
drwx—— 1 951247 155725 4096 2006-08-11 16:09 Maildir
drwxrwxr-x 1 951247 155725 4096 2006-10-29 02:34 scripts