WebSphere Issues

06/06/2017

Linux disk partitions using file and loop device

Filed under: Linux — Tags: — Ishtiaque @ 1:03 pm

1. Create a 1 GB file:

  • dd if=/dev/zero of=imgfile bs=1M count=1024

2. Mount the file onto a loop device

  • losetup -f  imgfile
  • losetupa (OR -l)

3. Create Partitions:

  • fdisk /dev/loop0 (OR /dev/sda)
  • Press ‘n’ for new
  • Press ‘p’ for primary and ‘e’ for extended partition
  • Enter partition size for example as +256M
  • Press ‘p’ to print the partition table
  • Press ‘w’ to save and exit

4. Reload and list partitions:

  • partprobe /dev/loop0
  • cat /proc/partitions
  • ls -l /dev/loop0*
  • fdisk -l /dev/loop0
  • partprobe -s /dev/loop0

5. Format partitions:

  • mkfs -t ext4 /dev/loop0

6. Mount partition:

  • mkdir mntp1
  • mount -o loop /dev/loop0p1 mntp1
  • df -hT
  • umount mntp1 (Unmount a partition)

29/05/2017

sed and awk commands

Filed under: Other — Ishtiaque @ 2:10 pm

1. sed:

  • sed -i s/string1/string2/g file.txt (Replace all occurrences of string1 with string2 and save the file)
  • sed s/pattern/replace_string/ file.txt (Replace first occurrence of string1 with string2)
  • sed 1,3s/pattern/replace_string/g file.txt (Replace all occurrences of string1 with string2 from lines 1 to 3)
  • sed -e ‘s/01/JAN/’ -e ‘s/02/FEB/’ -e ‘s/03/MAR/’ file.txt

2. awk:

  • awk ‘{ print $0 }’ /etc/passwd      (Prints entire file)
  • awk -F: ‘{ print $1 }’ /etc/passwd  (Prints first field of every line)
  • awk -F: ‘{ print $1 $6 }’ /etc/passwd (Prints first and sixth field of every line)

08/05/2017

Apache mod_rewrite

Filed under: Other — Ishtiaque @ 10:27 am
  • Apache mod_rewrite Introduction:

https://httpd.apache.org/docs/current/rewrite/intro.html

  • URL Rewriting Guide:

https://httpd.apache.org/docs/2.2/en/rewrite/

  • Apache Rewrite cheatsheet:

http://borkweb.com/story/apache-rewrite-cheatsheet

23/04/2017

chmod, chown, chgrp commands in Linux

Filed under: Other — Ishtiaque @ 12:35 pm
  • Octal -> Read(4), Wite (2), Execute (1)
  • Symobolic -> o+rwx, g+rwx, u+rwx = o=owner, g=group, u=user/other

chmod:

  • chmod ou+x,g-w file   (‘owner’ and ‘user’ -> execute and group -> remove write)
  • chmod 755 file             (Owner -> rwx (7); Group-> rx; Others-> rw)

chown:

  • chown user afile (Changes user owner)
  • chown user:grp file (Changes user and group ownership togather)
  • chown -r user:grp dir (Changes user and group on subdirectores)

chgrp:

  • chown grp file (Changes group owner)

getfacl:

  • getfacl file (View permission assigned on a file)
  • getfacl dir (View permission assigned on a directory)

setfacl:

  • setfacl -m u:user:rx /tmp/file

20/04/2017

User and group management in Linux

Filed under: Other — Ishtiaque @ 11:37 am

User commands:

  • useradd user1 (-d /var/user1 changes home directory)
  • userdel -r user1 (removes user and its home/mail folders)
  • usermod -a -G grp1, grp2 user1 (Adds users to grp1 and grp2)
  • chage -l user1 (List user details)
  • Files: /etc/passwd and /etc/shadow
  • cut -f 1,6 -d “:” /etc/passwd (List all users and their home directory)

Group commands:

  • groupadd grp1
  • groupdel grp1
  • groupmod
  • groups user1 OR id -Gn (List groups of a user)
  • /etc/group and /etc/gshadow

19/04/2017

Ubuntu Advanced Packaging Tool commands

Filed under: Linux, Other — Tags: — Ishtiaque @ 12:46 pm

1. apt-cache:

-> Search the repository for a package

  • apt-cache search apache2
  • apt-cache -n kernel
  • apt-cache pkgnames kernel

-> Display info of a package

  • apt-cache show apache2
  • apt-cache showpkg apache2

-> List dependent packages

  • apt-cache depends apache2

-> Search package based on file

  • apt-file search apache2.conf
  • apt-file list apache2

2. apt-get
-> Update: Synchronize the package index files with the repository source:

  • apt-get update

-> Apply all available updates to packages already installed:

  • apt-get upgrade (-u switch will show upgraded packages)
  • apt-get dist-upgrade (Remove obsolete packages)

-> Install

  • apt-get install apache2

-> Uninstall or Remove

  • apt-get remove apache2
  • apt-get –purge remove apache2 (Removes config files also)
  • apt-get autoremove (Remove package not needed anymore)

-> Clean cache

  • apt-get clean

RPM commands

Filed under: Linux — Tags: , — Ishtiaque @ 11:58 am

– Install a package

  • rpm -ivh httpd-2.4.6-45.el7.centos.4.x86_64

– Uninstall or Remove a package

  • rpm -e httpd

– Upgrade a package

  • rpm -Uvh httpd-2.4.6-45.el7.centos.4.x86_64

– Query package

  • rpm -qa | grep httpd*
  • rpm -q httpd

– Search based on config file

  • rpm -qf /etc/httpd/conf.d/welcome.conf

– List files installed by the package

  • rpm -ql httpd
  • rpm -qil httpd

– Show info a the package

  • rpm -qi rpm

– Verify packages

  • rpm -Va
  • rpm -V httpd

– The standard naming format:

  • <name>-<version>-<release>.<distro>.<architecture>.rpm
  • sed-4.2.1-10.e16.x86_64.rpm

Yum commands

Filed under: Linux — Tags: , — Ishtiaque @ 10:38 am

1. Install or update a particular package

  • yum install httpd
  • yum update httpd

2. Check and install updates

  • yum check-update
  • yum list update
  • yum update

3. List available or installed packages

  • yum list installed
  • yum list available
  • yum list installed “kernel*”
  • yum list “kernel*”

3. Search a package

  • yum search httpd

4. Get details of a package

  • yum info httpd

5. List dependencies of a package

  • yum deplist httpd

6. Group of packages

  • yum grouplist
  • yum groupinfo “GNOME Desktop”
  • yum groupinstall “GNOME Desktop”
  • yum groupremove “”GNOME Desktop”

7. Repository list

  • yum repolist

7. Config files

  • /etc/yum.conf
  • /etc/yum.repos.d/

18/04/2017

Script to check connectivity between single or multiple hosts – telnet

Filed under: Other — Ishtiaque @ 11:07 am

Alternate to telnet commands to check single host:

  • echo > /dev/tcp/{host}/{port} && echo “SUCCESS” || echo “FAILED”
  • timeout 1 bash -c ‘(If output 0 then Sucess else Failed)

Script to check connectivity between multiple hosts:

#!/bin/bash
SRC_HOSTS=(‘src1’ ‘src2’ ‘src3’ ‘src3’ ‘src4’)

DEST_HOSTS=(‘dest1’ ‘dest2’)
PORT=1521
TIMEOUT=1

for src in ${SRC_HOSTS[@]}; do
echo “—Testing connection from $src—”

for dest in ${DEST_HOSTS[@]}; do
ssh root@$src “timeout $TIMEOUT bash -c ‘ /dev/null 2>&1

if [[ $? -eq 0 ]]; then
echo “SUCCESS: $dest”
else
echo “FAILED: $dest”
fi
done
done
exit 0

Note: You could use IP address instead of hostnames in SRC_HOST and DEST_HOST variables.

05/04/2017

No supported authentication methods available (Server sent: publickey)

Filed under: Other — Ishtiaque @ 2:24 pm

First of all make sure you have setup ssh keys correctly by following the post:

https://websphereissues.wordpress.com/2014/11/25/add-ssh-keys-for-a-user-in-linux/

In /var/log/secure, if you noticed the error “Authentication refused bad ownership or modes for directory“, then you need to set “StrictModes no” in /etc/ssh/sshd_config file and run “service sshd” restart command to resolve this issue.

Older Posts »

Create a free website or blog at WordPress.com.