Tuesday, 13 June 2023

Enable 'HTML Manager'- Apache Tomcat

 Enable 'HTML Manager'- Apache Tomcat


Go to Apache-tomcat's home directory and edit the tomcat-users.xml


${apache_home}/conf/tomcat-users.xml


Add/uncomment the below lines in tomcat-users.xml and save it.


<role rolename="admin"/>

<role rolename="admin-gui"/>

 <role rolename="manager"/>

 <role rolename="manager-gui"/>

<user username="uname" password="password" roles="admin,admin-gui,manager,manager-gui"/>


Note: Replace the username and password as per your choice.

Give a try to access the html manager using the below url.

http://<IP:port>/manager/html

Feed the username and password if prompted.


If you are getting the error - 403 Access Denied , then try below to fix it.


Goto the manager project directory and edit the context.xml


${apache_home}/webapps/manager/META-INF/


comment the tag- Valve , OR seed your ip in the allow variable.


Wednesday, 31 May 2023

Create user Ubuntu with the command and directory restriction

 Create User:

    sudo useradd -m user_name -s /bin/rbash

    sudo passwd user_name

    Enter password


Make Directory and grant permission  

    sudo mkdir /home/user_name/bin

    sudo chown root. /home/user_name/.profile

    sudo chmod 755 /home/user_name/.profile


Restrict Directory and access


sudo vim /home/user_name/.profile


################ADD BELOW IN FILE#######

# if running bash

if [ -n "$BASH_VERSION" ]; then

    # include .bashrc if it exists

    if [ -f "$HOME/.bashrc" ]; then

. "$HOME/.bashrc"

    fi

fi


# set PATH so it includes user's private bin if it exists

PATH=$HOME/bin


export PATH

#########################################


Assign Commands

sudo ln -s /bin/grep /home/user_name/bin/tail

sudo ln -s /bin/cat /home/user_name/bin/cat

sudo ln -s /bin/echo /home/user_name/bin/more

Create SFTP user with home directory restriction

 



Restrict on the home directory and sftp only Ubuntu

create a group -
 
sudo addgroup group_name

create a user

useradd -m -d /home/username username

Assign group to user

usermod -g group_name username


restrict the directory and ftp

add below to the end of /etc/ssh/sshd_config file

   Match Group group_name
   ChrootDirectory /home/username
   ForceCommand internal-sftp
   X11Forwarding no
   AllowTcpForwarding no


Still unable to log in to sftp try to change the ownership to root for the user's home directory. 

Also check the mod of the home directory, it should be 755

Saturday, 15 December 2018

Upgrade GLIBC Rhel/CentoOs

To upgrade glibc below package are reuqired.


  • glibc
  • glibc-common
  • glibc-devel
  • glibc-headers
  • glibc-static
  • glibc-utils
Download the above packages from below link, and copy in /tmp directoyr.

Download Package From here 

Make sure all above package should be in same version.


go to the /tmp directory and execute below command to update the packages.

rpm -Uvh glibc-2.17-55.el6.x86_64.rpm \
glibc-common-2.17-55.el6.x86_64.rpm \
glibc-devel-2.17-55.el6.x86_64.rpm \
glibc-headers-2.17-55.el6.x86_64.rpm \
glibc-static-2.17-55.el6.x86_64.rpm \
glibc-utils-2.17-55.el6.x86_64.rpm



Check the lattest install version.

rpm -qa |grep glibc

Saturday, 19 May 2018

Mount FTP share locally in Linux using ftpfs

Mount FTP share locally in Linux using ftpfs

 To mount a remote FTP account to locally on Linux system- 

1)Install required Packages
2)Mounting system with remote details
3)Testing

1) - Install fuse-curlftpfs package on you Linux system.

2)- After package installation need to create a mount point(directory) and mount ftp server data using curlftpfs command, to do this you must have ftp details. 

Consider below details.
 
 ftp User: altmish
 ftp Password: tech2smooth
 ftp Host:- ftp.tech2smooth.in
 Mount Directory:-  /usr/ftp_data

Create the mount point and mount ftp account data.
[root@localhost /]#mkdir /usr/ftp_data
[root@localhost /]#curlftpfs -o altmish:tech2smooth@ftp.tech2smooth.in /usr/ftp_data

Note: Above mounted data will be accessible only for the user who mounted the system. To make it public-ally accessible use below.


[root@localhost /]#curlftpfs -o allow_other altmish:tech2smooth@ftp.tech2smooth.in /usr/ftp_data

 3)- Go to ftp data directory

[root@localhost /]#cd /usr/ftp_data

[root@localhost /]#ls -ltrh

Saturday, 5 May 2018

Memory Leak in tomcat

To prevent this particular memory leak you should edit your tomcat/conf/server.xml and change

<Listener  lassName="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
to

<Listener 
className="org.apache.catalina.core.JreMemoryLeakPreventionListener"
classesToInitialize="com.mysql.jdbc.NonRegisteringDriver" />

Error parsing HTTP request header- Invalid character found in the request target.



Http11Processor.service Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986


Solution

Edit catalina.properties add below line in end of the file.

tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

 
 

Monday, 30 April 2018

Unable to Start MySQL Linux - Please read "Security" section of the manual....

ISSUE- [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root


Solution- Start mysql using below command.

/usr/sbin/mysqld --user=root --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Thursday, 31 August 2017

Grep Temp Password from MySQL

As of now for latest MySQL version there is a default password. To get this password tail mysql.log file and restart MySQL instance, and you will found MySQL temporary password.

              grep 'temporary password' /var/log/mysqld.log

Restart MySQL instance

# /etc/init.d/mysqld restart

OR

# /etc/init.d/mysql restart

Your Boot Partition is on a Disk Using GTP

1. At the partitioning screen, press Ctrl + Alt + F2 to get to a shell prompt.

2. Overwrite the GPT partition label with an MSDOS label.

[root@host ~]# parted /dev/sda -s mklabel msdos

3. Press Ctrl + Alt + F6 to return to the partitioning screen, and continue installation, it may be needed to back one step up in order for the installer to see the new changes.

Root Cause
  • The GRand Unifed Bootloader (GRUB) is not compiled with the ability to utilize GPT partitions in RHEL5.
  • The MSDOS partition label will allow GRUB to boot correctly, but has a physical limitation of 2 TB.
  • This above error was a check added in RHEL 5.2.
  • In 5.0 and 5.1, the installation would continue but the ending install will not boot.
#Source- RHEL

Install RPM From Linux CD

1- Create a directory for you local repository, e.g.
/home/user/repo
.
2- Move the RPMs into that directory.
3-Fix some ownership and file system permissions:
# chown -R root.root /home/user/repo
4- Install the createrepo package if not installed yet, and run
# createrepo /home/user/repo
# chmod -R o-w+r /home/user/repo
5- Create a repository configuration file, e.g. /etc/yum.repos.d/myrepo.repo containing
[local]
name=My Awesome Repo
baseurl=file:///home/user/repo
enabled=1
gpgcheck=0
6- Install your package using
# yum install packagename

Thursday, 29 October 2015

Install Adobe Flash Player CentOS


FOR 32-bit x86

Install adobe noarch and import it.
rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

FOR 64-bit x86_64

Install adobe noarch and import it.
rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

Now check for update.
yum check-update

Now install flash plugin and supported libraries using yum.
yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl


Friday, 14 November 2014

Want to Copy Single file to Mulitple Location in Linux?


If you are looking for shorter way to copy a file from one location to another location, follow below:

To perform above operation you have to user xargs command in Linux.

Suppose you want to copy a file demo.txtt to three different directory.


echo directory1 directory2 directory3 | xargs -n 1 cp -i demo.txt

The -i option of cp command means that you will be asked whether to overwrite a file in the current directory with the demo.txt.


The -n Use at most max-args arguments per command line.

Saturday, 20 September 2014

ERROR 2002 (HY000): Can't connect to local MySQL server.

Are you are getting following error while running MySQL server?


ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)


Simply follow these steps:-

-Go to MySQL directory
   root@localhost:[/]cd /var/lib/mysql
   root@localhost:[/var/lib/mysql]

-Rename mysql.sock file to mysql.sock_old
   root@localhost:[/var/lib/mysql]mv mysql.sock mysql.sock_old

-Restart MySQL server.
   root@localhost:[/var/lib/mysql]service mysqld restart
      OR
    root@localhost:[/var/lib/mysql]/etc/init.d/mysqld restart

Thursday, 18 September 2014

Get MySQL Table Creation Time.

How to check table create,update,check time in MySQL?


You can check table creation,update,check time for any table. Find below.

If you want to check the last update time or create time or last check time of table use following query for the above.

Syntax:- SELECT CREATE_TIME,UPDATE_TIME,CHECK_TIME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'database_name' AND TABLE_NAME='table_name' ;

Also you can check following for any table.

TABLE_CATALOG
TABLE_SCHEMA
TABLE_NAME
TABLE_TYPE
ENGINE
VERSION
ROW_FORMAT
TABLE_ROWS
AVG_ROW_LENGTH
DATA_LENGTH
MAX_DATA_LENGTH
INDEX_LENGTH
DATA_FREE
AUTO_INCREMENT
CREATE_TIME
UPDATE_TIME
CHECK_TIME
TABLE_COLLATION
CHECKSUM
CREATE_OPTIONS
TABLE_COMMENT
TABLESPACE_NAME






Wednesday, 17 September 2014

Create MySQL User and Grant Permission

Create MySQL user and grant permission


Here we learn, how to create MySQL user?

Suppose we want to create user Danish and want to full access on MySQL Databases/tables from any IP.

Syntax to create user:- CREATE USER '< user name >'@'< password >' IDENTIFIED BY
Syntax to grant permission:- GRANT < permission > ON < database >.< table > WITH GRANT OPTION

Following is an example of above.

 CREATE USER 'danish'@'*' IDENTIFIED BY 'danish';

 GRANT ALL PRIVILEGES ON student.login TO 'danish'@'*' WITH GRANT OPTION;

In above example we have created a user with name danish, this user can only access login table in student database and can perform all operations on login table.

You can assing a specific domain/ip for MySQL user danish to access MySQL. Find below.

 CREATE USER 'danish'@'255.255.255.255' IDENTIFIED BY 'danish';

 GRANT ALL PRIVILEGES ON student.login TO 'danish'@'255.255.255.255' WITH GRANT OPTION;


You can grant all database access with all tables. Find Below.


 CREATE USER 'danish'@'255.255.255.255' IDENTIFIED BY 'danish';

 GRANT ALL PRIVILEGES ON *.*TO 'danish'@'255.255.255.255' WITH GRANT OPTION;


Following are the privileges and their meaning in MySQL.


Tuesday, 16 September 2014

How to set auto-logout time for SSH sessions RHEL

Set auto logout for SSH session.


If you want to set timeout for user sessions on your Linux machine, you can use the variable TMOUT. You can set a value for TMOUT in bash_profile or bashrc file.

# auto-logout if the shell session is idle for 1 hour
TMOUT=3600

Saturday, 13 September 2014

Easy Way: Java

Easy Way: Java: Write a program to addd two integer without using + or any arithmetic operator public static int get_sum(int a, int b){  if(b==0) retur...

Want to copy files/directories from one server to another using SSH?

Want to copy files/directories from one server to another using SSH?


Following are two way to copy files/directories from one server to another server over SSH.

Copy content from a directory:

scp -P < SSH port number of remote server> < files path on local server> < ip/host of remote server>:< path to copy files/directories>

e.g. scp -P 22 /home/xyz.zip www.example.com:/home/cfile/

Copy content from directory and the contents of any directory inside that directory

scp -P < SSH port number of remote server> -r < files path on local server> < ip/host of remote server>:< path to copy files/directories>

e.g. scp -P 22 -r /home/cpfiles/ www.example.com:/home/cfile/


Linux : could not start the session due to some internal error

What is next if your Linux OS is unable to boot with following error?


Error: could not start the session due to some internal error

To remove above error message follow following steps:-

Try turning off selinux at boottime

  -When the grub splash screen is displayed press any key
  -Select the Linux boot choice and press the 'e' key
  -Select the kernel line and press the 'e' key again
  -At the end of the line add a space followed by selinux=0
  -When done press the 'Enter' key followed by the 'b' key

Enable 'HTML Manager'- Apache Tomcat

 Enable 'HTML Manager'- Apache Tomcat Go to Apache-tomcat's home directory and edit the tomcat-users.xml ${apache_home}/conf/tom...