December 7, 2015

Counting number of users in a group - Linux

Here is a small command to find number of users in particular group on a *nix system. An example for wheel group:


grep wheel /etc/group | fgrep -o , | wc -m

Now here's a catch, this command actually counts the commas in the line from the group file. So if there are 5 users in the group, the output will be 4. You will have to add a 1 to the output.

So when using it in scripts, one can use it like this:


VAR1=$(($(grep wheel /etc/group | fgrep -o , | wc -m) + 1))
echo $VAR1
5

Explanation:

First grep will print only the group and its members. The members are seperated by a comma. Next we print the commas using -o option and later count them using wc command. The second example will just add a 1 to it.

Let me know if you have a better idea for the same!

Labels: , , , , ,

September 5, 2014

Kickstart and Hostnames

The basic purpose to use kickstarts is to install numerous systems at a time with given para.
Configuring each system post install is tedious.
I found a workaround (that worked for me on Oracle Linux 6 and RHEL 6 and should most probably work for similar distros) to automate this task post install as well. If you know better solution, drop a comment below.

In the %post% section,

Add this:

 exec < /dev/tty6 > /dev/tty6 2> /dev/tty6  
 chvt 6  

This will switch to the 6th TTY and will drop into interactive shell. This allows installer to ask for information.

Let's try to ask for information:

 echo -n "Enter Hostname: "  
 read HOSTNAME1  
 echo -n "Enter IP Address: "  
 read IPADDR  
 echo -n "Enter Netmask: "  
 read NETMASK  
 echo -n "Enter Gateway: "  
 read GATEWAY  

Now that we have information, we can use the inbuilt cmd to configure the interface. I assumed first interface as eth0 (which it is in most cases. If you are not sure, you might want to add this to automation to detect what interface you have).


  echo -n "Applying network settings..."  
 echo "DeviceList.Ethernet.eth0.BootProto=static  
 DeviceList.Ethernet.eth0.IP=$IPADDR  
 DeviceList.Ethernet.eth0.Netmask=$NETMASK  
 DeviceList.Ethernet.eth0.Gateway=$GATEWAY  
 ProfileList.default.DNS.Hostname=$HOSTNAME1.domain.com  
 ProfileList.default.DNS.Domainname=domain.com" > /tmp/network-config  
 system-config-network-cmd -i -f /tmp/network-config &> /dev/null  
 service network restart &> /dev/null 

The system-config-network-cmd helps us import /tmp/network-config file.

Restarting network service later loads the new configuration.

To drop out of the TTY 6 and resume back to anaconda use chvt trick again:


 chvt 1  
 exec < /dev/tty1 > /dev/tty1 2> /dev/tty1  

Credits for chvt trick: Hintshop blog.

Labels: , , , ,

April 15, 2013

My Raspberry Pi Setup Part 1

The whole purpose to use raspberry pi in my house was to use it as a Bittorrent Downloader and File Server.

To know what Raspberry Pi is, go here:

http://www.raspberrypi.org/faqs

Raspberry Pi runs linux operating system. To know more about it, go here:

http://www.linux.com/learn
http://www.ibm.com/developerworks/linux/newto

I have it currently set up a simple set up as follows on my Model B RasPi.


Attached is:
1 16 GB Class 10 Transcend SD Card.
1 8 GB USB drive.
1 16 GB USB drive.
Network cable connected to my Router.
Power supply (Of course)

More powerful power supply will allow you to connect USB HDDs without additional power supply. For ex. if you connect a Samsung Phone Charger with 700 mA, you won't be able to connect external HDD without additional power supply.
I connected LG Charger that came with my Nexus 4, which produces 1.2 A output, seems to make my 1 TB WD external HDD work with the Pi.

Software Setup:
Raspbian OS (Previously I tried Arch, but I found raspbian nicer.)
LVM (Logical Volume Management)
Transmission BT
youtube-dl


Initial Configuration:

Installed Rasbian OS on my Pi. To know how to do that go here: 

http://elinux.org/RPi_Easy_SD_Card_Setup

By default, Raspberry Pi allows SSH access with the default username pi and password raspberry. I accessed it directly from the network.

Configure root password

 sudo passwd root  

command will allow you to change your root user password so that you can login using root account.
I always use root account and have never logged in using pi account.

Be careful. Logging in using root and performing incorrect operations may cause unstable OS or crash.


Configure Static IP address

To configure static IP address I simply edited my /etc/network/interfaces file that now looks like this:


 auto lo  
 iface lo inet loopback  
 iface eth0 inet static  
  address 192.168.0.10  
  netmask 255.255.255.0  
  gateway 192.168.0.1  
  dns-nameservers 124.124.5.140 8.8.8.8  

Then issued command

 service network restart  

Re-connected to my raspberry pi using new static IP address.

Update the pi

 apt-get update && apt-get -y upgrade  

Its always good to have this run first time, before you do anything.


The LVM setup

OK. The idea behind configuring LVM on my pi was nothing but to combine all the space available on different partitions to form a single logical volume and mount it at a single point, so that I can keep huge stuff inside single mount point.
Here's how my fdisk -l looks like:

Note: Removed information that is not required as of now.

  root@raspberrypi:~# fdisk -l   
  Disk /dev/mmcblk0: 16.1 GB, 16130244608 bytes   
  4 heads, 16 sectors/track, 492256 cylinders, total 31504384 sectors   
  Units = sectors of 1 * 512 = 512 bytes   
  Sector size (logical/physical): 512 bytes / 512 bytes   
  I/O size (minimum/optimal): 512 bytes / 512 bytes   
  Disk identifier: 0x00014d34   
    Device Boot  Start   End  Blocks Id System   
  /dev/mmcblk0p1   8192  122879  57344 c W95 FAT32 (LBA)   
  /dev/mmcblk0p2   122880  7454718  3665919+ 83 Linux   
  /dev/mmcblk0p3   7454719 31504383 12024832+ 8e Linux LVM   
  Disk /dev/sda: 8166 MB, 8166703104 bytes   
  224 heads, 63 sectors/track, 1130 cylinders, total 15950592 sectors   
  Units = sectors of 1 * 512 = 512 bytes   
  Sector size (logical/physical): 512 bytes / 512 bytes   
  I/O size (minimum/optimal): 512 bytes / 512 bytes   
  Disk identifier: 0x000ae796   
   Device Boot  Start   End  Blocks Id System   
  /dev/sda1   2048 15950591  7974272 8e Linux LVM   
  Disk /dev/sdb: 16.0 GB, 16008609792 bytes   
  64 heads, 32 sectors/track, 15267 cylinders, total 31266816 sectors   
  Units = sectors of 1 * 512 = 512 bytes   
  Sector size (logical/physical): 512 bytes / 512 bytes   
  I/O size (minimum/optimal): 512 bytes / 512 bytes   
  Disk identifier: 0x5ea0a18f   
   Device Boot  Start   End  Blocks Id System   
  /dev/sdb1   2048 31266815 15632384 8e Linux LVM   

OK. So there's three devices.
First memory card that RasPi boots from, Second the 8 GB USB and third 16 GB USB drives. /dev/mmcblk0, /dev/sda and /dev/sdb respectively.

There's two partitions on /dev/mmcblk0p1 and /dev/mmcblk0p2 used for RasPi itself. The third one was created by me. Note that the type of partition is Linux LVM. Similar partitions created on USB drive but only one on each that lie on full drive.

To know how to create a partition on a disk go here:

http://www.tldp.org/HOWTO/Partition/fdisk_partitioning.html

To know about LVM go here:


http://tldp.org/HOWTO/LVM-HOWTO/anatomy.html

Now, we need a volume group.


# vgcreate /dev/mmcblk0p3 /dev/sda1 /dev/sda2  
 volume group datavg created.  
# lvcreate -l 100%FREE datavg  
 logical volume lvol0 created.  
# mkfs.ext4 /dev/datavg/lvol0

vgcreate will combine space from /dev/mmcblk0p3 /dev/sda1 /dev/sda2 to create a single Volume group.

lvcreate will create a logical drive out of that volume group.

mkfs.ext4 will create an ext4 filesystem on the logical volume.

We need to mount this new logical volume.


#  mkdir /data  
# mount /dev/datavg/lvol0 /data  
# chmod 777 /data  

So our new filesystem which comprises space from three devices, will be accessible on /data partition.


Now, we need this logical volume to be mounted across each reboot. To make it happen, ran following command.



# cp /etc/fstab /etc/fstab.bak  
# echo /dev/datavg/lvol0 /data ext4 defaults 0 2 >> /etc/fstab  

We're done!

I will write another article to describe how I installed software and its configuration.

Labels: ,

April 11, 2013

Making you SD card work with your Ubuntu / Linux Laptop or Desktop

You insert you SD card in your Ubuntu PC and it simply does not work. Most probably your kernel has not loaded module required for recognizing your SD card.

You must run all commands in this post as root.
[Optional] : To run commands as root run command "sudo su root" and to switch user as root.

First check if your PC detects the SD Card controller.
For that run command
lspci | grep -i sd


  root@ubuntu:~# lspci | grep -i sd   
  23:00.1 System peripheral: JMicron Technology Corp. SD/MMC Host Controller (rev 30)   
  23:00.2 SD Host controller: JMicron Technology Corp. Standard SD Host Controller (rev 30)   

As you can see above, my PC recognised JMicron SD Card controller.

To make your OS load module for SD Card controller, simply run these commands.



  root@ubuntu:~# echo tifm_sd >> /etc/modules   
 root@ubuntu:~# echo mmc_block >> /etc/modules   


And then reboot. Your OS should recognise your SD card.

Labels: , , ,

September 14, 2012

Publish SSH Server through TMG

Yet another casual but useful post.

Here's how I did it.

If you have a look at all the protocols available in Forefront Threat Management Gateway Toolbox, SSH is there, but it is outbound.

TMG forwards only inbound protocols. So, You will have to create a new protocol definition with nay name you like, port 22 and "inbound". And then create a non-web server protocol publishing rule.

It seems dumb but ate my 10 minutes.

That's it.

Labels: , , , ,

August 12, 2012

RTNETLINK answers: File exists

If you've come across error "RTNETLINK answers: File exists" when using dhclient to renew IP address, here's how I did it:

root@SERVER02 :dhclient eth0 -r  
root@SERVER02 :dhclient eth0  

The -r option releases current configuration for the interface, allowing dhclient to create new config file.

Labels: , , ,

August 8, 2012

6 things you probably want to do after Solaris 10 installation

1. Set BASH as default shell for root:
This is first thing I really do! Because bash has multiple advantages for day to day use and scripting too, over other shells.
For this you can simply edit /etc/passwd file and change the shell from very first line.
By default it is /sbin/sh, you can change it to /bin/bash

2. Change the hostname from "unknown"
To change the hostname temporarily:
 hostname SERVER01  
To change the hostname so that it is persistent across reboots:
 echo SERVER01 > /etc/nodename  
However, the changed hostname is re-set when you run sys-unconfig command to reset the configuration of the system.

3. Disable GUI Login:
 /usr/dt/bin/dtconfig -d  
For more, see here about disabling and enabling GUI login in Solaris

4. Configure loghost:
You might get messages such as "loghost could not be resolved.". To be able to resolve loghost you must configure DNS Server or you can add entry in /etc/hosts such as "127.0.0.1  loghost".

5. Disable sendmail:
You can disable sendmail by issuing a simple command,
 svcadm disable sendmail  
Hmm... not everybody uses sendmail... 

6. Set PS1 variable (This is only for people using BASH):
It is solely user's choice to set this variable. Solaris has it as PS1='\s-\v\$ ' by default.
However, I set it as PS1="$LOGNAME@$HOSTNAME# " so that it will be displayed as:
 root@SERVER01# _  
For more information on PS1 environment variable check here and to make it look like Angelina Jolie :D check here.

Labels: , , ,

August 4, 2012

Solving basics hell out of vsftpd

Configuring vsftpd isn't a very hard thing. If you haven't read the docs, then its crucial to go.

I had a fresh installation of vsftpd on CentOS 6.2
I tweaked hardly one or two params in /etc/vsftpd/vsftpd.conf such as "anonymous_enable=NO"
Then created a new user using:

 #useradd -m -d /home/user1 -s /bin/bash user1  

Then I tried to connect to the server using our brand new user1.
Here's what I got:
500 OOPS: cannot change directory :/home/user1

After a bit digging on Google and thanks to this link, I was able to do it when I ran following command:

 /usr/sbin/setsebool -P ftp_home_dir 1  

This command takes a while to run, but it worked for me after that.
The setsebool sets boolean variables in SELinux.

Labels: , , , , , , ,

July 18, 2012

Find pid in Solaris 10


If you do not know the pid of a process, you can use "pidof" command in Linux. In case of Solaris, its not available.

Here's how you can find it:

 #ps -ef | grep nscd | grep -v grep | cut -c12-19
123

Here, it will find the pid of nscd. the cut command will cut characters from 12 to 19 from output of 'ps -ef' command.
or
 #ps -ef | grep nscd | grep -v grep | awk '{print $2}'
Here, we use awk to print second column of ps.

Labels: , , ,

Stopping OpenLDAP

This is most dumb but useful post. How to turn off slapd.

You know how to start the slapd:

 #/usr/local/libexec/slapd  [-option..]

however, pkill slapd is not the correct way to turn off slapd.

Here's how you turn it off:

 #kill -INT `cat /usr/local/var/slapd.pid`  

This will send appropriate signal to slapd process, and will store any cached data and close gracefully.

Labels: , , , , ,

July 17, 2012

OpenLDAP 2.4 on CentOS 6.2 Part 2

Continuing from Part 1.

Once you install OpenLDAP, it is yours.
Now you need to configure /usr/local/etc/openldap/slapd.conf
Note that, I have only changed

suffix          "dc=kaustubhghanekar,dc=com"  
rootdn         "cn=Manager,dc=kaustubhghanekar,dc=com"
Here's my slapd.conf:

 #  
 # See slapd.conf(5) for details on configuration options.  
 # This file should NOT be world readable.  
 #  
 include          /usr/local/etc/openldap/schema/core.schema  
 # Define global ACLs to disable default read access.  
 # Do not enable referrals until AFTER you have a working directory  
 # service AND an understanding of referrals.  
 #referral     ldap://root.openldap.org  
 pidfile          /usr/local/var/run/slapd.pid  
 argsfile     /usr/local/var/run/slapd.args  
 # Load dynamic backend modules:  
 # modulepath     /usr/local/libexec/openldap  
 # moduleload     back_bdb.la  
 # moduleload     back_hdb.la  
 # moduleload     back_ldap.la  
 # Sample security restrictions  
 #     Require integrity protection (prevent hijacking)  
 #     Require 112-bit (3DES or better) encryption for updates  
 #     Require 63-bit encryption for simple bind  
 # security ssf=1 update_ssf=112 simple_bind=64  
 # Sample access control policy:  
 #     Root DSE: allow anyone to read it  
 #     Subschema (sub)entry DSE: allow anyone to read it  
 #     Other DSEs:  
 #          Allow self write access  
 #          Allow authenticated users read access  
 #          Allow anonymous users to authenticate  
 #     Directives needed to implement policy:  
 # access to dn.base="" by * read  
 # access to dn.base="cn=Subschema" by * read  
 # access to *  
 #     by self write  
 #     by users read  
 #     by anonymous auth  
 #  
 # if no access controls are present, the default policy  
 # allows anyone and everyone to read anything but restricts  
 # updates to rootdn. (e.g., "access to * by * read")  
 #  
 # rootdn can always read and write EVERYTHING!  
 #######################################################################  
 # BDB database definitions  
 #######################################################################  
 database     bdb  
 suffix          "dc=kaustubhghanekar,dc=com"  
 rootdn          "cn=Manager,dc=kaustubhghanekar,dc=com"  
 # Cleartext passwords, especially for the rootdn, should  
 # be avoid. See slappasswd(8) and slapd.conf(5) for details.  
 # Use of strong authentication encouraged.  
 rootpw          secret  
 # The database directory MUST exist prior to running slapd AND   
 # should only be accessible by the slapd and slap tools.  
 # Mode 700 recommended.  
 directory     /usr/local/var/openldap-data  
 # Indices to maintain  
 index     objectClass     eq  

Then start slapd.
Before starting it, make sure that environment variables work perfect.
To check this, run following:


 # ldd /usr/local/libexec/slapd  
     linux-vdso.so.1 => (0x00007fffe01ff000)  
     libdb-5.3.so => /usr/local/BerkeleyDB.5.3/lib/libdb-5.3.so (0x00007fe2f743e000)  
     libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003fd1400000)  
     libresolv.so.2 => /lib64/libresolv.so.2 (0x0000003fd2c00000)  
     libc.so.6 => /lib64/libc.so.6 (0x0000003fd0c00000)  
     /lib64/ld-linux-x86-64.so.2 (0x0000003fd0800000)  


So now all the .so files are in place, we can start slapd.


 # /usr/local/libexec/slapd  

Verify all good status by running 'echo $?'


Sometimes when starting slapd after rebooting your server, may give error like this:


/usr/local/libexec/slapd: error while loading shared libraries: libdb-5.3.so: cannot open shared object file: No such file or directory


This is again problem with the environment variables. Make sure you have the variables CPPFLAGS, LDFLAGS, LD_LIBRARY_PATH are configured correctly as described in part1.


Now you can start populating server by adding objects.
For more on creating .ldif files and adding them using ldapadd, ldapmodify etc., look here.

Labels:

OpenLDAP 2.4 on CentOS 6.2 Part 1

It is painful when you have errors and somehow you aren't getting way around it.

Here's how I did my Installation:

Downloaded Latest release of OpenLDAP (2.4.31) from here.

Transferred the file to the CentOS 6.2 Server using Secure Copy (SCP). The directory on server can be any with sufficient space in it. I used /home.

The downloaded package was openldap-2.4.31.tgz.
Extract it.


 # tar -xvf openldap-2.4.31.tgz  

This will create a directory /home/openldap-2.4.31
cd to that Directory.

Here you will have some files including the "configure" script.
To check what options the script provides, perform following command


 #./configure --help  

It is always better to let the script decide what options are best for you. We will choose options later as required.


 #./configure

It will start to configure the build.

Here's first error I encountered:

configure: error: Unable to locate cc(1) or suitable replacement.  Check PATH or set CC.

Then I did


 yum install gcc

Which installed development tools, C compiler etc.

The next error, most common:

configure: error: MozNSS not found - please specify the location to the NSPR and NSS header files in CPPFLAGS and the location to the NSPR and NSS libraries in LDFLAGS (if not in the system location)

Location for NSPR and NSS Libraries and Headers varies with Operating System. However, I was unable to find that. I will update soon as soon as I find it.

I tried following option


 #./configure --with-tls=no  

This option bypassed the tls check.

WARNING: Your LDAP Server will then be unable to have TLS Data Protection.

The next error:
configure: error: BDB/HDB: BerkeleyDB not available

This made me download and install BerkeleyDB from here.
To install Berkeley DB see the documentation. I copied it to /home and installed it as follows:


 #tar -xvf db-5.3.21.gz  
 #cd db-5.3.21  
 #make  
 #make install  

Even after installing Berkely DB, it didn't let me proceed with same error. What was missing?
Well I set a few Variables, and I was off.


 CPPFLAGS="-I/usr/local/BerkeleyDB.5.3/include"  
 export CPPFLAGS  
 LDFLAGS="-L/usr/local/lib -L/usr/local/BerkeleyDB.5.3/lib -R/usr/local/BerkeleyDB.5.3/lib"  
 export LDFLAGS  
 LD_LIBRARY_PATH="/usr/local/BerkeleyDB.5.3/lib"  
 export LD_LIBRARY_PATH  

Make sure you put a capital "I" instead of "i" in CPPFLAGS or it may throw following error:


configure:5251: error: C compiler cannot create executables
See `config.log' for more details.

Then the harsh configure was done.
Next command, Run "make depend", then "make", then "make test" and last "make install"!

Continuing in Part 2, the configuration after installing OpenLDAP.

Labels: , , ,

June 30, 2012

Swapping your droid device with your Friend's!


Ever wondered why Android devices are better than any apple devices running iOS? There are many reasons, I have got one more for you. You can easily swap your devices by just performing following procedure.

Checklist before swapping your phone/tablet with your friend's:
1. Make sure you backup all your SD Card data by connecting it to PC before performing any of the steps below.
2. Make sure you have at least 1 GB of free space on your SD Card.
3. Make sure you have >30% of battery remaining. Its better to keep on AC charging.

What is recommended?
1. To have your contacts synced up with your Google Account.
2. Root.
3. Clockworkmod Recovery.
4. Not all Phone apps work with Tabs and vice versa. Its better to swap a phone with a phone and tablet with a tablet.

What this article does not cover?
1. Understanding what is android.
2. What is root and how to do it?
3. What is Clockworkmod, how do I install it and who is Koush? (BTW he's the  developer of CWM)
4. Backing up your system settings like "Saved WiFi networks","Ringtone and Volume settings" etc. It is neither recommended and does not always work.

Here is a simple swap process:
1. Backup Device1, Device2.... Devicen using backup flowchart below.
2. Connect devices to computer. Copy all files from SD Card of each device to a folder on your PC.
3. WARNING! MAKE SURE YOU HAVE ALL YOUR DATA BACKED UP! Now Format your device. To do this, go to Settings => Privacy => Factory Data Reset. Make sure you also format the USB Storage.
4. Restore is simply inverted backup process. Just copy the data you have backed up to SD Card and then restore it using respective apps. That's it!
5. Make your iPhone friends jealous after buying me a chocolate.


Backup:


A:
Download and Install "Titanium Backup" from Google Play. Grant it root access  when it asks for. Then backup your apps using screens below.





Titanium Backup Creates a folder "/mnt/sdcard/Titanium Backup" and stores its backups in it. You can use Cloud Services to store your data too if you purchase the app.

B:
Contacts are backed up with Google Account automatically. If this is not happening with you, you must check sync options.
When you add any new contacts to the phone, they should be chosen to store on your "Google Account" and not "Phone" or "SIM". Also, the Contacts sync option must be checked in Settings=>Accounts and Sync to make sure they sync with Google Servers.
However, if you do not wish to sync contacts with Google, there are plenty other options available.
I recommend using "Super Backup" search for "com.idea.backup.smscontact" in Google Play.

C:
You can use "Super Backup" mentioned above to backup Call Logs too.
As other option, I've been using "Call Logs Backup and Restore" "com.riteshsahu.CallLogBackupRestore" since a Year and its good.

D:
You can use "Super Backup" mentioned above to backup SMS too. As other option, I've been using "SMS Backup and Restore" "com.riteshsahu.SMSBackupRestore" since a Year and its good.

E:
I am not pretty sure about backing up apps with data in non rooted phones. Use "MyBackup" "com.rerware.android.MyBackup" to backup apps. However I haven't tested it.

N:
Root process varies with devices. You can search Google simply like "root HTC One X". Still, If you are unable to find it, just drop me a comment below with device model, I would love to search it for you.

Restore:
Restoring is as simple as Backup. This is pretty straightforward, usually, every app that you used for backup, creates a folder with its name and its files and directories in it. You just have to copy them to respective device and restore it.

Labels: , , ,

June 5, 2012

Disabling default GUI Startup Solaris 10

Many of us may not want to use the Solaris 10 Default JAVA or KDE default GUI. To startup Solaris 10 default in command Line mode you can make use of one of following:

1. You can use dtconfig command:
To disable GUI:
#/usr/dt/bin/dtconfig -d
To enable GUI:
#/usr/dt/bin/dtconfig -e
2. Disable/enable Service that handles cde-login:
To disable GUI:
#svcadm disable svc:/application/graphical-login/cde-login:default
To enable GUI:
#svcadm disable svc:/application/graphical-login/cde-login:default

It is that simple. No defense.

Labels: , , ,

May 28, 2012

Solaris 10 Static IP Network configuration guide

This is pretty simple task. Although some find it difficult because it is different from other Linux distributions.

To configure Solaris 10 network interface in Local files mode, you must first remove the file /etc/dhcp.interface (for ex. /etc/dhcp.e1000g0), then you have to configure six files.

/etc/nodename
/etc/hostname.interface
/etc/inet/hosts
/etc/inet/ipnodes
/etc/defaultdomain
/etc/defaultrouter

In /etc/nodename, you must specify your name of the server/host.
Ex.

#cat /etc/nodename
solarisbox1

The interface names in solaris include ce, hme, bge, e1000g etc. So, if you have an interface called e1000g0 there should be a file named /etc/hostname.e1000g0 In this file, you must specify network configuration information such as IP address, netmask etc.
Ex.

#cat /etc/hostname.e1000g0
10.91.10.5 netmask 255.255.255.0
#cat /etc/hostname.qfe0
192.168.0.88 netmask 255.255.255.0

The /etc/inet/hosts file serves as local file name resolver. It resolves hostnames, log hosts etc. You can specify any number of hosts associted with IP addresses in it. You must specify hostname of you system in it.
Ex.

#cat /etc/inet/hosts
#
# Internet host table
#
::1          localhost
127.0.0.1    localhost loghost solarisbox1
10.91.10.5   solarisbox1
192.168.0.88 solarisbox1
10.91.10.6   solarisbox2

For Solaris 10 11/06 and earlier releases, you must keep /etc/inet/ipnodes updated.
Ex.

# vi /etc/inet/ipnodes
10.0.0.14 myhost

The /etc/defaultdomain file specifies nothing other than FQDN (Fully Qualified Domain Name) of the System.
Ex.

#cat /etc/defaultdomain
solarisbox1.solarisstudy.com

The /etc/defaultrouter file specifies your default router (or gateway) details.
Ex.

#touch /etc/defaultrouter
#echo 10.91.10.1 >> /etc/defaultrouter

This will help you progress towards basic interface configuration in Solaris 10.
This article refers Oracle Documentation and is made in simple format to help newbies to configure network interface quickly.
For more information see:
http://docs.oracle.com/cd/E19253-01/816-4554/ipconfig-1/index.html
Solaris 10 System Administration Guide: IP Services

Labels:

May 13, 2012

Enabling Remote root login Solaris 10.

It is neither recommended nor suggested to allow remote root logins for security reasons.
For Test servers, Non-production servers or other servers, you may want to allow remote root login via SSH.

Usually you get "Access denied" errors when accessing a Solaris server as root when logging on remotely.

You just have to edit two entries in two files.

First:
/etc/default/login

Comment the following line in /etc/default/login by putting a # sign before the line.

 CONSOLE=/dev/console  

This will enable remote root logins to the system.

Second:
/etc/ssh/sshd_config

Comment the following line in /etc/ssh/sshd_config by putting a # sign before the line.

 PermitRootLogin no  

Then add the following line just below the above line.

 PermitRootLogin yes  

This will enable remote SSH and SCP Logins to the system.

Labels: , , , , ,

April 18, 2012

Print first column of passwd

The delimiter used to differentiate different fields in the /etc/passwd files is colon ' : ' . Therefore we need to look only after the semicolon.
To deal with column based files or formatted text the most commonly used command is awk.
Command below will print out the first column of /etc/passwd file:

 awk < /etc/passwd -F: '{ print $1 }'

Here

awk             is the text processor

< /etc/passwd    will serve as input file for awk

-F:             is a parameter for awk that specifies the delimiter. In our      
                           case is colon.

{ print $1 }    This will print the first line. You can put $2, $3 etc. to
                           print respective column.

My command produced following output:

 root  
 daemon  
 bin  
 sys  
 adm  
 lp  
 uucp  
 nuucp  
 smmsp  
 listen  
 gdm  
 webservd  
 postgres  
 svctag  
 nobody  
 noaccess  
 nobody4  

Labels: , , , , , ,

April 8, 2012

Quick Configure Subversion on Ubuntu 11.10 oneiric

Subversion is quiet good version control system, used by many developers across the world and is awesome!
I searched throughout Google to find a simple guide to deploy a least working subversion just to see it and was unable to.

(Note: use sudo whenever required.)
To install and get a simple up and running subversion on Ubuntu:
First install subversion packages

sudo apt-get install subversion libapache2-svn

After packages got installed, you need to create repositories.
To create a repository, I used my home directory.

mkdir /home/kaustubh/project1

Then create a repository

sudo svnadmin create /home/kaustubh/project1

Then open repository/conf/svnserve.conf (/home/kaustubh/project1/conf/svnserve.conf in my case) in your favorite text editor.
uncomment following parameters in the file. (Note: There should be no spaces before or after any parameter line. The svnserve will then be unable to read the config.) Most commonly made mistake.

auth-access = write
password-db = passwd

Then open repository/conf/passwd (/home/kaustubh/project1/conf/passwd in my case) in your favorite text editor.
Add lines below everything in following format

username = password

Its time to fire up the server
Enter following to start the server and after its started, use ctrl+c to kill the server.

svnserve -d --foreground -r /home/kaustubh

Here, -d means demon mode, --foreground means it will run in foreground, -r specifies path to repository.

Now you can easily connect to your repository using

svn://servername/project1

You will have to enter username and password mentiond in your repo/conf/passwd file.

Labels: , ,