taT4Nix | Setting up Git repository in Fedora 12

I have been using Git for quite sometime now, although at work place. I could explore as much as I could, by setting up local repositories only. One day, I thought of cloning one of the repositories hosted at GitHub. However, I could not, possibly due to restrictions in place by System Administrator (I guess).

Setup GitHub Account and Installing Git

Now, to get more out of GitHub and explore further, I need a GitHub account and Linux OS. So I got started by setting up my account at GitHub and created repository, PrayogShala.

Recently, I had installed Fedora 12 (64 Bit) as Guest OS (via Virtual Box). So, I started the Virtual Machine and logged in with user account [nvarun] (created while installing the Guest OS) and executed steps as follows.

To begin contributing to repository at GitHub, one should install Git first and to do that, open up Terminal Desktop Application and refer yum steps in the reference guide.

Once dependencies are installed/updated, execute following command;

$> sudo yum install git

Once completed, find out the installed version of Git;

$> git --version
git version

Clone Repository

After installing Git, I cloned the repository earlier created on GitHub as follows;

$> git clone https://github.com/nvarun/PrayogShala.git PrayogShala

Then, based on my experiences at work place, I added useful git aliases in $HOME/.profile and started added/updating files in the repository. The interesting thing to notice, that all the changes I make, affects repository locally. To push the changes to remote location, i.e. the repository hosted at GitHub, execute following command;

$> git push origin master

Once you do that, the Terminal prompts for username and password of GitHub account. If validated with success, the changes are pushed successfully onto GitHub.


taT4Nix | Setting up Korn Shell in Linux OS

Having spent over a year at work place, working on AIX Server, I end up doing overtime writing tools using shell scripting in Korn Shell environment. I was wondering if there is some way possible, so that I could setup similar environment at home using Linux Desktop, like Ubuntu, Fedora, etc and avoid doing overtime 🙂

AIX Server uses ksh as the default shell for every user account, whereas most of the Linux OS (I guess) have bash as the default shell. As AIX is proprietary server made by IBM, so I opted for Virtual Box instead, where I could do all my exploration.

Why Fedora 12?

Just download the ISO Image for suitable flavor of Linux OS available in the Open Source community. Thankfully, I had Fedora 12 ISO Image, which I downloaded back in 2010. To save time, I used the same to setup VM using Virtual Box. 

While installing the Fedora 12 VM (on Windows 7 Host OS), I created user account [nvarun], which by default has bash shell environment loaded whenever I open the Terminal desktop application to do command line operations.

Setting up Korn Shell

I have spent past few weeks, trying to figure out how to change default shell for user account and loading ksh environment, whenever I open Terminal desktop application and user account [nvarun] logs in by default.

  1. Open Terminal desktop application
  2. By default, the user account [nvarun] is logged in.
  3. Execute following command;
    $> grep nvarun /etc/passwd
    nvarun:x:500:500:Varun Nischal:/home/nvarun:/bin/bash
  4. As you would notice, the entry is colon-delimited and the last delimited field tells you the default shell for user account.
  5. Now to change the default shell to /bin/ksh, execute following command;
    $> sudo chsh -s /bin/ksh nvarun
    Changing shell for nvarun.
    Shell changed.
    $> exit
  6. As you exit from Terminal and re-open it again, you won’t see the change yet.

Before we proceed further, it is important to understand what AIX Server does with user accounts.

The shell uses two types of profile files when you log in to the operating system.

The shell evaluates the commands contained in the files and then runs the commands to set up your system environment.

The files have similar functions except that the /etc/profile file controls profile variables for all users on a system whereas the .profile file allows you to customize your own environment.

As we need to customize the our environment, in that case, use vi editor to edit the $HOME/.profile file and add following line;

export ENV=/etc/kshrc

The /etc/kshrc file is a shell script that customizes the Korn Shell environment and often contains list of environment variables, aliases and function definitions, etc.

Each time you start a new instance of the Korn shell, the ksh command examines the value of the ENV environment variable set in the $HOME/.profile file.

If the ENV environment variable contains the name of an existing, readable file, the ksh command runs this file as a script.

By convention, this file is named $HOME/.kshrc. You can use another name, but you must set the ENV environment variable to point to it.

Now, you may exit from Terminal and re-open it again, the changes would be reflected and this lets nvarun create aliases, functions, etc. to customize the environment further.

I am already excited to explore further, hope this helps 🙂

taT4Nix | Using visudo To Run Commands With Root Privileges

Recently, I wrote a script to automate the task of mounting the shared folders in Guest OS (Ubuntu 9.10) from Host OS (Windows 7), courtesy of VirtualBox. Now, I couldn’t run that script because I needed root privileges 😐 Although, I have installed the Guest OS, so I know the root password.

However, when VM boots, I am logging in with user account created while installing Guest OS. So, to run certain commands that need root privileges, I have to explicitly use sudo and then enter password, when prompted.

Using visudo

Now, surfing the web led me to a solution, i.e. edit /etc/sudoers file that contains list of privileges given to root and other users. So, to edit this sudoers list, one must run the following;

sudo visudo

You’re prompted for password, enter it and then, you would see something like this;

# /etc/sudoers
## This file MUST be edited with the 'visudo' command as root.
## See the man page for details on how to write a sudoers file.#

Defaults    env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

As you can see, the last statement implies that if any user account belongs to admin group, then that user account will have privileges of a super user. So, if I run the following command again, for instance;

sudo visudo

I won’t get any prompt for password and /etc/sudoers without delay.

Trick 2 Gain Root Privileges..

So, go to “System > Administration > Users and Groups” and click on the account properties you want to assign root privileges. Then, switch to “Advanced Tab“, change the “Main Group” to admin. Now, if you have followed till here, it’s time to make following changes to /etc/sudoers file;

# Members of the admin group may gain root privileges

Now, you have root privileges, you may now run the commands that need root permissions without getting prompt for password. Try doing the same for the script I mentioned in the beginning.

taT4Nix | Mount Shared Folders from Host OS in Guest OS

Brief Overview

I have Ubuntu 9.10 as 64-bit Guest OS running on top of Windows 7 as 64-bit Host OS using VirtualBox 3.1.2. Now, I have also added 3 folders from Windows Filesystem for sharing with Guest OS. As you know, I have to mount the folders by running commands in Terminal for accessing data in shared folders. So, I have to do it manually every time I start the VM.

Latest Updates

Chances are you might not be able to run the following scripts without root privileges, as commands like mount need root privileges. So, refer this blog entry for more details to solve the problem.

Problem Description

I was looking forward to automate this and I came across “System > Preferences > Startup Applications” in my Guest OS. However, I need to run the mount command 3 times for 3 shared folders I have. So, I wrote the following scripts to automate the task and assigning just one script in “Startup Applications”.

Also, I need this because I have created playlists for videos (Movie Player/VLC) and music (Audacious 2), also set desktop background of my choice. These files are only available in shared folders. Now, using single startup script, I would be able to make a copy of music, pictures, videos, etc. every time I login with specific account after starting VM.

Getting Started

To do the needful, I came up with the following script, which would run two more scripts in background, when I login with specific user account. Let’s get started;



nohup $HOME/mnt_cp_hostos_data.sh A B C > /dev/null
nohup $HOME/unmnt_hostos_data.sh A B C > /dev/null

Now, that we have startup script ready that will first mount shared folders and then, unmount them. This seems to be stupid if you don’t go below for more details about those two scripts.

Mount Shared Folders and Copy Them Recursively

Now, the following script will accept N arguments where each argument will be the name assigned to shared folder path in Host OS. So, the script will not run with ZERO arguments and it will make the directory under /media/win7-share in Guest OS with the argument name and then, mount the folder before copying the data in the Public directory of specific account’s $HOME.



if [ $# -eq 0 ]; then
 echo "Exiting.." > /dev/null
 exit 0

for dname in $@


 if [ ! -d ${SHARE_DIR} ]; then
 mkdir ${SHARE_DIR}

 if [ $? -eq 0 ]; then
 echo "${SHARE_DIR} created successfully.."
 exit 1

 mount -t vboxsf $dname ${SHARE_DIR}

 if [ $? -eq 0 ]; then
 echo "Mounted $dname successfully.."
 exit 1

 cp -nr --target-directory=$HOME/Public/windows7/ ${SHARE_DIR}

 if [ $? -eq 0 ]; then
 echo "Copied data into $HOME/Public/windows7/$dname successfully.."
 exit 1


Unmount Shared Folders..

The following script also accepts N arguments where each argument will be the name assigned to shared folder path in Host OS. So, the script will not run with ZERO arguments and it is just going to unmount the directory made the directory under /media/win7-share in Guest OS with the argument name.



if [ $# -eq 0 ]; then
 echo "Exiting.." > /dev/null
 exit 0

for dname in $@


 if [ -d ${SHARE_DIR} ]; then
 umount -f ${SHARE_DIR}

 if [ $? -eq 0 ]; then
 echo "Unmounted ${SHARE_DIR} successfully.."
 exit 1


Work Ahead

As you might have understood by know the shared folders names are A, B, C (see share_hostos_data.sh). That’s something I had to hardcode inside the script for passing them as arguments to mnt_cp* and unmnt* scripts. I ran this command VBoxMange showvminfo “<VM-Name>” in my Host OS command prompt, to find out the names of shared folders.

If I could access the names somehow, then I can pick up these names and supply them as an argument to the necessary scripts created above. That’s all for today, have a great time..