Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, March 16, 2015

Installing OpenLDAP in Ubuntu

LDAP stands for Lightweight Directory access protocol. LDAP protocol is used to access Directory servers. Think of LDAP similar to SQL. In this post we will see how to install openLDAP which is a directory server and can be accessed using LDAP protocol. The steps are for Ubuntu boxes are as follows. This is tried on Ubuntu 1404.

Installation Steps

Update your server with latest

Sunday, October 19, 2014

vmstat in Linux - Monitoring resource usage in Linux

vmstat stands for Virtual Memory statistics. It's a utility which collects and displays parameters about processes, memory, paging, block IO, traps, disks and cpu activity. 

vmstat can be run by giving the time interval in which vmstat will collect and display the information. vmstat can be run with following command

vmstat <interval to summarize the data> <Total run>

Thursday, October 9, 2014

Handling Symbolic Links in Tomcat in Linux

Tomcat by default does not allows files to be accessed via symbolic links or symlinks. For example 
you have an application context foo. The chance is you will have a foo directory sitting in webapps 
which contains all the things about the application. However you want to have access to a report.pdf 
file generated in other part of system, let's say at /etc/reports/report.pdf. The file is generated with some frequency so you would like to put a symblolic link to the generated file. The symbolic link can be given by

ln -s report.pdf /etc/reports/report.pdf

By default, Tomcat does not allows linking to the symbolic links. To achieve that you neeed to change the context.xml file at <Tomcat Installation Directory>/conf/context.xml

Friday, October 3, 2014

Top in Linux

Top is a Linux utility to see the running state of the system. Let's see what each fields in the top 
output means. To see top, go to a Linux shell and on prompt type

top

It will show a set of parameters which refreshes automatically.

Friday, September 26, 2014

Shellshock : How to tell if System is Compromised and How to Fix it

Shellshock is the new bug doing rounds and security experts are considering it to be of the same proportion as Heartbleed. Is that the case?

Shellshock in simple terms is a shock that can be passed through Shell. A shell is a utility that helps to interact with the Systems. The particular shell that this bug targets is bash shell. 

If you are a windows user, you are not at all at risk, for a change. As more and more applications are moving to web and they are mostly hosted on Linux environment, we might see this as more and more of a rule and not as an exception. But if you are a Linux or Apple user than you are at risk. A

Friday, September 19, 2014

Handling logs with logrotate

For system administration and diagnostics in Linux, log files are important. However left unattended, they can quickly chock the system. logrotate is a nice utility to handle this.

The configuration file for logrotate is at /etc/logrotate.conf. A sample configuration file may look like (from my ubuntu 14.04 machine)

# see "man logrotate" for details
# rotate log files weekly
weekly

# use the syslog group by default, since this is the owning group

Handling Tomcat Catalina logs with logrotate

Tomcat by default logs on catalina.out file. Tomcat does not have log4j files where we can specify the various parameters to rotate the logs. If left unattended, this can lead to catalina files becoming huge. The big size catalina log files results in
  • Disk space getting chocked
  • Application become slower as when they have to log they have to deal with a large file to work with,
To handle proper rotation of catalina log file, in Linux we can use the logrotate capability. If you

Monday, August 18, 2014

Linux Commands

Linux commands help in doing a myriad of tasks. To get help on a command, open a terminal window and do one of the following:
  • Type <command> --help. For example to know more about ls command type ls --help
  • To know more details about a command, type man <command>. For example to know more about ls type man ls
  • To know about the binaries and manual paged of a command, type whereis <command>. For examplt to know about ls, type whereis ls.
Most of the commands are now available as part of GUI desktop environment. GNome and KDE are two most popular Desktop GUI environment. You can handle most of the task mentioned down by easy GUI facilities. For example to move a file, you can select the file and drag to the folder where you want to move it. Look into the documentation of your Linux flavour. For Windows user, the analogy is between the MS-DOS commands and the similar feature available as part of GUI.
Some of the following commands only work with root privilege. Linux will warn you accordingly.
File Content Commands
cat
Show the file content on standard output.
cat abc - Show the content of file abc.
less
Shows the content of a file on Standard output. Page up and Page down can be done.
less abc - Show the content of file abc. 
more
Shows the content of a file on Standard output with one page at a time.
more abc - Show the content of file abc.
File Manipulation Commands
cd
Change the current directory.
cd - Change to home directory of the user. Also can use cd ~.
cd /home - Change to /home directory
cd Data - Change to Data directory existing in the current directory
cp
Copy one file to another
cp a b - Make a copy of file a with name b. If b is there, it is overwritten. The file name can be given with full directory path also.
cp -i a b - If b is there a prompt for comfirmation is shown. Preferable to use. Better make an alias for cp and cp -i
cp -dpr dir1 dir2 - Copy all the contents of dir1 to dir2. 
dd
Copy a file, converting and formatting according to the operands. 
ln
Make a symbolic link to a file.
ln -s abc abcLink - Make a symbolic link abcLink for file abc. 
ls
List the files.
ls - List all files and directories in the current directory.
ls /home - List all files and directories in the /home directory.
ls -al - Show detail information including permissions
mv
Move the file.
mv a b - Move the file from a to b. If b is there, it is overwritten. The file name can be given with full directory path also.
mv -i a b - If b is there a prompt for comfirmation is shown. Preferable to use. Better make an alias for mv and mv -i
pwd
Show the name of current working directory.
File Searching Commands
locate
Locate the file based on the indexing of files in a database. Before this command is used, slocate -u needs to run to build the database. Many systems run slocate as a periodic cron job.
locate abc - List all the files which contain abc in its name.
System Commands
df -h
Shows information about partition
lalit@lalit:~/Desktop> df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 20641788 5229552 14363596 27% /
udev 1523044 136 1522908 1% /dev
/dev/sda7 116176524 27748572 82526476 26% /home
gvfs-fuse-daemon 20641788 5229552 14363596 27% /home/lalit/.gvfs
shutdown
Shuts the system down.
shutdown - Shuts the system down.
shutdown -h now - Shuts the system and halts it.
shutdown - r now - reboot.
User Administration Commands
adduser
Add a new user.
adduser lalit - Add a new user with name lalit. Give the password when prompted.
chage__
Change the time when a users password will expire.
chage lalit - Change the password age for user lalit.
chf
Change a user's finger information.
chsh
Change a user's shell.
chsh - Change the current user's shell.
chsh lalit - Change the shell of user with name lalit.
chgrp
Changes the group ownership of files.
chown
Change the owner of files.
finger
Shows the current system users including remote users.
gpasswd
Change the group password.
groupadd
Add a new group.
grpconv
Convert to shadow group.
grpunconv
Convert from shadow group.
groupdel
Delete a group.
groupmod
Modify a group.
groups
Print the list of groups to which a user belong.
groups - Print the list of groups for current user.
groups lalit - Print the list of groups to which used with name lalit belongs.
grpck
Check the integrity of group files.
id
Print group and user ID numbers for the specified user.
id - Prints the group and user Id for current user.
id lalit - Prints the group and user Id for user with name lalit.
logout
Logout the current user.
newgrp
Allows a user to log in to a new group.
newusers
Creat and update new users in batch form.
nologin
Stops non-root users from logging onto the system.
passwd
Update the password.
passwd - Update the password of current user.
passwd lalit - Update the password of user with name lalit.
pwconv
Convert to shadow account.
pwunconv
Convert from shadow account.
su
Change the effective user.
su - Change the effective user to root.
su lalit - Change the effective user to user name with lalit.
sudo
Allow a user to act as root user based on the permission in /etc/sudoers file.
useradd
Create a new.
userdel
Delete a user.
userdel lalit - Delete the user with user name lalit.
usermod
Modify a user account.

Installing Microsoft Fonts in Ubuntu

For Microsoft fonts, install the msttcorefonts package. It can be installed either using Synaptic Package Manager or apt-get.

For Synaptic Package Manage, open it from System-> Adminstration. Search for msttcorefonts and install it.

For apt-get, issue the following command

sudo apt-get install msttcorefonts
The new fonts should be available to use. If you face a problem, do log in again.

Installing rpm in Ubuntu

For installing rpm package in Ubuntu, it has to be converted into .deb. For conversion alien tool can be used. The steps to convert the rpm into deb and than installing it as follows.
Install alien
$sudo apt-get update
$sudo apt-get install alien
Convert .rpm into .deb
Go to the location where .rpm package is there and run the alien command
$sudo alien -k <rpm file with extension>
-k keeps the version number
This will create a .deb file
Install the .deb package
$sudo dpkg -i <name-of deb-f file with extension>

Wednesday, August 17, 2011

Adding Ubuntu to Windows ADS

ADS stands for Active Directory server. This article explains how to add an Ubuntu machine to a Active Directory server based domain controller. To add that first install the following packages using Synaptic Package Manager.
Samba (version 3):
  • samba
  • samba-common (installed by default)
  • smbclient (installed by default)
  • winbind
Kerberos:
  • krb5-config
  • krb5-user
We will use Likewise open to add the machine to domain. Likewise provides a simple gui to handle the tast, which otherwise would result in hand editing configurations files. Add Like-Wise open using Add/remove Application facility.
For the exercise we will assume the following details
  • Domain Name: LALITBHATT.COM
  • IP: 192.168.1.111
  • Host name: linuxBox
As per the above we need to do the following chages in smb.conf with sudo permission.
sudo gedit /etc/samba/nsswitch.conf
Make the following changes
In Global Section

workgroup = LALITBHATT.COM
realm=192.168.1.111
netbios name=linuxBox
In authentication section
security = ads
Kerberos are used for login purposed. The changes are done in krb5.conf
 sudo gedit /etc/krb5.conf

changes are:
realms
LALITBHATT.COM = {
kdc = 192.168.1.111
admin_server = 192.168.1.111
}
domain_realm
.LALITBHATT.COM = 192.168.1.111
LALITBHATT.COM = 192.168.1.111
login
krb4_convert = true
krb4_get_tickets = true
Changes In nsswich.conf
sudo gedit /etc/nsswitch.conf
Changes
passwd: compat winbind lsass
group: compat winbind lsass
shadow: compat
After the above changes are done, we need to restart the samba and winbind service
sudo /etc/init.d/samba restart
sudo /etc/init.d/winbind restart
Now we will add the machine using Likewise. Start the likewise application and add the domain name as "LALITBHATT.COM". Provide the administrative username and password of machine on which the Primary domain controller (ADS) is hosted. The machine should become a part of the domain. To login into the machine use the format <domain_name>/<user_name> .

Wednesday, August 18, 2010

Installing Oracle on Ubuntu

Download Oracle

Download oracle from the Oracle site. It's usually a zip file for linux version and unzip it in a directory.

Install the Package

We need to install some packages which are needed by oracle. Run the following apt-get for that

sudo apt-get install gcc make binutils libmotif3 lesstif2 rpm libaio1 zip 
sudo apt-get install libstdc

Make some soft links

sudo ln -s /usr/bin/awk /bin/awk
sudo ln -s /usr/bin/rpm /bin/rpm
sudo ln -s /usr/bin/basename /bin/basename 
sudo ln -s /etc /etc/rc.d

Oracle supports only some of the linux version officially, so we tell oracle that we are one of those. Change the following file as follows

sudo gedit /etc/redhat-release

Copy/Paste the following text:

Red Hat Linux release 3.0 (drupal)

Make the oracle user and groups dba,oinstall

sudo userdel nobody
sudo groupadd oinstall
sudo groupadd dba
sudo groupadd nobody
sudo useradd -g oinstall -G dba -p passwd -d /home/oracle oracle -s /bin/bash
sudo useradd -g nobody nobody

Now, we create the directory where Oracle will be installed

sudo mkdir -p /u01/app/oracle
sudo mkdir -p /u02/oradata
sudo chown -R oracle:oinstall /u01 /u02
sudo chmod -R 775 /u01 /u02

At the end of /etc/security/limits.conf add the following:

*               soft    nproc   2047
*               hard    nproc   16384
*               soft    nofile  1024
*               hard    nofile  65536^

In the following file

sudo vi /etc/pam.d/login 

uncomment

session    required   pam_limits.so

In the file

sudo vi /etc/pam.d/su

uncomment

^session    required   pam_limits.so

Add this line to /etc/profile as root

if [ $USER = "oracle" ]; then
           ulimit -u 16384 -n 65536
fi

Add the following lines to the end of /home/oracle/.bashrc (open it in root or oracle user):

umask 022
PATH=${PATH}:/u01/app/oracle/oracle/product/10.2.0/db_1/bin/
ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/db_1/
ORACLE_SID=orcl
ORATAB=/etc/oratab
ORACLE_HOME_LISTNER=$ORACLE_BASE
ORACLE_BASE=$ORACLE_HOME
export ORACLE_BASE ORACLE_SID ORATAB ORACLE_HOME ORACLE_HOME_LISTNER

Now login as oracle user and go the the directory where oracle installer is unzipped

./runInstaller

Follow the instruction. At the end do not forget to run root.sh.

If you find following problems that do as following

Error in invoking target all_no_orcl ihsodbc of makefile - Download libstd using apt-get

sudo apt-get install libstdc++5

Accessing Oracle

Different admin applications can be accessed on following url's. Replace <hostname> with your machine name

iSQL*Plus URL: http://:5560/isqlplus

iSQL*Plus DBA URL: http://:5560/isqlplus/dba

Enterprise Manager 10g Database Control URL: http://:5500/em