Unix Blog !

July 29, 2008

Mounting a cdrom under Solaris

Filed under: Uncategorized — Tags: , — sriram003 @ 12:53 pm

1) Log in as a user with root authority.

2) Insert the CD-ROM into the drive.

3) If the Volume Manager (vold) is running on your system, the CD-ROM is automatically mounted as /cdrom/cd_label if the CD has a label or /cdrom/unnamed_cdrom if it is unlabeled. (more…)

July 7, 2008

Solaris quick reference !

Filed under: Uncategorized — Tags: — sriram003 @ 5:21 am

Display Physical RAM:
prtconf

Kernel modules are stored in three directories
1)  /platform/sparc/kernel or /platform/i86pc/kernel
2)  /kernel
3) /usr/kernel

List devices:
sysdef

Configure a Device:
drvconfig

Remove a Device:
rem_config

Where are the templates stored that are copied into the user’s home
directories for their personal customizations?

/etc/skel

# Display the parent/child tree of a process ?
– ptree Example: ptree 1267

# Show the working directory of a process ?
– pwdx Example: pwdx 1267

# Display the processes current open files ? –
pfiles Example: pfiles 1267

Alternative for top command ? –
prstat -a

July 4, 2008

diff 2 files; output diff’s to 3rd file

Filed under: Uncategorized — Tags: , — sriram003 @ 5:20 am

bash# diff file1 file2 | grep “[<>]” | sed “s/>/\t/g;s/<//g” > file3

The above command will the difference of file1 file2 in file 3

The output of file3 looks like below:

host1
host2
                 host3
                 host4

which means file1 has host1 and host2 which is not found in file2,  and in file2 there are words like host3, host4 which is not found in file1.

June 22, 2008

While running df command it says read only filesystem

Filed under: Uncategorized — sriram003 @ 3:11 pm

Taking further from my previous post,

I was not able to run df -k command :

It says , no filesystems processed:

Solution:

To remount root filesystem with read-write :
$mount -o remount,rw /

This will make a entry in /etc/mtab for read,write access to root filesystem

Using Linux Rescue

Filed under: Uncategorized — Tags: — sriram003 @ 3:09 pm

While trying to install Fedora core 8 on my Virtualbox(VM)
It got hanged after installation was done …

Here’s what I did:

1) Boot through Fedora core 8 CD

2) Select rescue installed system.

3) You will be asked to select the language, which defaults to English. Select the appropriate language and press OK to continue.

4)You will be asked to select the keyboard type, which defaults to us (USA). Select the appropriate keyboard type and press OK to continue.

5) do you want to start network interface – NO

6) Now it says, the rescue environment will find linux install and mount it under /mnt/sysimage – Select Continue

7) now it will say: your sytem is mounted under /mnt/sysimage and will reboot
if you exit – OK

8) now you you get a shell prompt

Once at shell prompt, Type :

i) chroot /mnt/sysimage
ii) fsck /dev/sda1 or fsck -p /dev/sda1

remove disk.
Reboot and check … your system should be up !

September 23, 2006

How Linux Boots

Filed under: Uncategorized — sriram003 @ 11:04 am

  1. The BIOS loads and execute the first 512 bytes off the disk

    (/dev/hda), a.k.a. the Master Boot Record (MBR)

  2. The boot loader executes the first 512 bytes of the partition that

    you selected (if more than one is available).

    Advanced boot loaders like Grub or System Commander offer more features

    than the DOS boot loader. Some boot loaders save their configuration in

    the MBR (hence the need to remember to run the lilo command after

    editing it to save your changes to the master boot record on disk), while others

    save their data in a partition

  3. The partition loader now decompresses the kernel in RAM, and runs it

  4. The kernel initialises devices, loads the root partition,

    loads the /sbin/init process (PID=1) that reads its configuration

    information from /etc/inittab to know which boot scripts to run

    and at which run-level to start, and which processes to spawn.

    The actual scripts are in /etc/rc.d/init.d, and /etc/rc.d/rc#.d

    only contains links

  5. Init launches Getty to open consoles, and launches Login

    to present the user with a logon prompt

Note that once the Linux kernel has been loaded by lilo,

it looks in “all the usual places” for init and runs the first copy it finds.

More information: Inside the Linux boot process by Tim Jones

August 9, 2006

Installing Jira and Perforce Plugin

Filed under: Uncategorized — sriram003 @ 2:29 pm

This is my first assignment after a very long time.

Jira is a Bug Tracking tool similar to bugzilla.

Since we are using Perforce which is similar to CVS .

We are planning to Integrate Jira with Perforce Plugin to be able to track versions.

Heres what I have done to get this running :

Jira Installation and Perforce Plugin Installation:
===================================

Jira Installation
1) Check if Java is Installed – ps -ef grep java

2) Export JAVA_Home to where you are Installing Jira
$cd /opt/Jira
$export JAVA_HOME=/usr/java/jdk1.5.0_06/

3) Download atlassian-jira-standard-3.6.3-standalone.tar.gz

4) Untar it in /opt/Jira
$tar -zxvf atlassian-jira-standard-3.6.3-standalone.tar.gz

5) By Default Jira runs on 8080 port you can change it to whatver port you want.
For eg. In our case we have changed it to 8090

Change the below two settings in
/opt/Jira/atlassian-jira-standard-3.6.3-standalone/conf/server.xml
1) Server Port “8005”
2) Connector Port “8090” <—- Port Jira Connects

6) Now Start Jira
/opt/Jira/atlassian-jira-standard-3.6.3-standalone/bin/startup.sh

To Stop Jira
/opt/Jira/atlassian-jira-standard-3.6.3-standalone/bin/shutdown.sh

7) Now Point your Browser to
http://Jira_host:8090

8) This will ask you some some questions to complete Jira Installation and a next will add a Jira Administrator.

To Obtain a Evaluation License Key (Below Link)
http://www.atlassian.com/software/jira/Licenses.jspa

Perforce Plugin Installation :
=====================

Note – Please make sure you have Installed Perforce command line tool before you Install Perforce Plugin for Jira.
You can find the P4 command Line tool from the below link
http://www.perforce.com/perforce/downloads/linux26x86.html

1) Download atlassian-jira-perforce-plugin-1.1.5.zip

2) Unzip it in /opt/Jira

3) Copy the below files from /opt/Jira/atlassian-jira-perforce-plugin-1.1.5
– atlassian-jira-perforce-plugin-1.1.5.jar
– p4package-rev13.jar

To – /opt/Jira/atlassian-jira-standard-3.6.3-standalone/atlassian-jira/WEB-INF/lib

4) Edit perforce-jira-plugin.properties from /opt/Jira/atlassian-jira-perforce-plugin-1.1.5
p4.executable=/opt/Jira/p4

Most of the Information regarding p4port , User, Pass were all Hashed in my case as I did not have the Info.

I had also hashed the Logging Entries.

5) Now copy perforce-jira-plugin.properties
To – /opt/Jira/atlassian-jira-standard-3.6.3-standalone/atlassian-jira/WEB-INF/classes

6) I have not copied any Licence for Plugins as per there Docs.

7) Restart Jira
TO see if plugin is Installed Login to Jira Web based Under Administration section > System > Plugins

It Should have Installed 7 Modules.

rm command – Argument List too long

Filed under: Uncategorized — sriram003 @ 2:20 pm

Some days back I had problems deleting n no of files in folder.

while using rm command it would say

$rm -f /home/sriram/tmp/*.txt
-bash: /bin/rm: Argument list too long

This is not a limitation of the rm command, but a kernel limitation on the size of the parameters of the command. Since I was performing shell globbing (selecting all the files with extension .txt), this meant that the size of the command line arguments became bigger with the number of the files.

One solution is to to either run rm command inside a loop and delete each individual result, or to use find with the xargs parameter to pass the delete command. I prefer the find solution so I had changed the rm line inside the script to:

find /home/$u/tmp/ -name ‘*.txt’ -print0 xargs -0 rm

this does the trick and solves the problem. One final touch was to not receive warnings if there were no actual files to delete, like:

rm: too few arguments

Try `rm –help’ for more information.

For this I have added the -f parameter to rm (-f, –force = ignore nonexistent files, never prompt). Since this was running in a shell script from cron the prompt was not needed also so no problem here. The final line I used to replace the rm one was:

find /home/$u/tmp/ -name ‘*.txt’ -print0 xargs -0 rm -f

You can also do this in the directory:
ls xargs rm

Alternatively you could have used a one line find:

find /home/$u/tmp/ -name ‘*.txt’ -exec rm {} \; -print

Thanks to him

June 12, 2006

10 Most Valuable tips Vi Editor

Filed under: Uncategorized — sriram003 @ 5:48 pm

1. undo & redo
don’t be surprise that vi also have undo & redo capabilities. but for vi is only one level undo. not really sure how many level for vim, for sure more than vi. just press u to find out.
Esc + u or :u to undo
Ctrl + r to redo

2. search pattern
a few ways to search a pattern in vi:
/pattern search down for pattern
?pattern search up for pattern
pressing n or N to go to the next or previous matching pattern

press * or # search for a pattern under the cursor
pressing * or # to go to the next or previous matching pattern

3. search & replace
search & replace is quite important in my job where sometime i need to do a bulk replacement
:s/pattern/new_patten/ replace a pattern with new pattern
:1,$ s/pattern/new_patten/g g for replace all occurrences of pattern
:1,$ s/pattern/new_patten/c c for confirm replace

1 start from line 1
$ end at last line
Read more…

4. go to specific line
do you hate when you run a scripts, an error occurred in specific line!
this is how you go directly to the line to find out what went wrong
:n will go to line n (eg: :69 will bring your cursor to line 69)
:se nu or :set number will display line number
:.= shows current line number
:= shows number of line in file
Ctrl + g shows file name, current line number, total lines in file & % of the file location

5. vi few files
i’m sure sometime you need to edit several files at once. especially those log files.
while you are in vi, you can open up other file using:
:split other_file to open other file & will split into 2 screens
Ctrl + w + w to switch between the files

while in command prompt, simply:
$ vi file1 file2 file3
:n edit next file (file2)
:n edit next file (file3)
:rew rewind to the first file (file1)

6. shell access or run a command
while editing a file in vi, you can also access shell to run specific commands without quiting from vi
:shell will gives you a command prompt, type exit when you done with the shell, will return back to vi
or simply use :!command to execute the command

7. command output into vi
don’t waste time to copy & paste the command output, instead redirect it into the file
:r!cat /etc/passwd will inserts content of /etc/passwd into the current file

8. recovering your file
life is not perfect, sometime something goes wrong while you are editing your file, eg: power failure or lost connection. indeed you can recover it back by using:
$ vi -r your_filename

9. word completion
for me this feature is quite useful for developers since they most likely repeating the same words/patterns:
type a few characters of the word and then keep on pressing Ctrl + p or Ctrl + n until you find the match, but make sure the words/patterns are already there in the file.

10. get help, don’t panic!
if you get lost or no idea how to do things in vi, don’t panic! get help
use :h or :help to access the main help file
to go directly to specific help, give an argument to the :help command
or to search for help use :help any_word eg: :help me will bring you to the line which contains word me, pressing Ctrl + d to see matching help entries for me.

Thanks to this article

June 10, 2006

Who Visits your Website – Apache logs

Filed under: Uncategorized — sriram003 @ 11:27 am

There are couple of Programs like Awstats, PhpMyVisites etc …
which can calculate the statistics of Visitors from your Apache Logs.

But what if you are lazy like me to configure those stuff,
Create logins etc… and check the graph.

Heres a easy way out :

[root@localhost unixbox]# cat /var/log/httpd/access_log
| sort | uniq -w15 -c | cut -f 1 -d- | sort -r -g

10 210.214.45.231
6 210.214.243.38
4 210.214.190.85
2 210.214.190.250
2 202.171.143.53
2 201.2.65.26
2 200.124.175.159
2 200.124.167.220

The Left hand side will list the total number of hits from the IP addresses.

For example 210.214.45.231 has visited us 10 times,
Now if you want to check the date and time of the visit grep
that particular IP address in access_log.

Now suppose you want the total number of hits for a Particular Directory,
then you may try this, Say For eg. /ram/ directory and print a count
(from greatest to least).

add this ” grep -e /ram ” , like the below command will list IP addresses
accessing /ram folder.

[root@localhost unixbox]# cat /var/log/httpd/access_log
|grep -e /ram/ | sort | uniq -w15 -c | cut -f 1 -d- | sort -r -g

Thanks to this article

Older Posts »

Create a free website or blog at WordPress.com.