Wednesday, March 17, 2021

 

Delete Files using Find Command on Linux

Note - > Before  Deleting files by using find command -exec option you must ensure that files are correct. How to find files in a specific range.

 Delete Files OLDER than X days on Linux

Command Syntax

find /path/to/files -mtimes +<number of days> -exec rm {} \;

Note that there are spaces between rm, {}, and \;

Explanation 

1. path/to/files -  This argument takes the path where your files are located.

2. mtimes - This argument specify how older file you want to find. i.e. -mtimes +4 means - find the files which are older than 4 or more days.

3. -exec  - This command execute the argument passed to it. Here the argument is rm which remove the files. you can use -f option to forcefully remove the files. {} \; are mandatory this is the end of the command.

Delete Files created in Last X days

Command Syntax

find /path/to/files -mtimes -<number of days> -exec rm {} \;

To Delete files created in the last x days only change -mtimes argument it takes -<number of days> rather +<number of days>

Delete Files Older than x minutes

Command Syntax

find /path/to/files -mmin +<minutes> -exec rm {} \;

Delete files created in x minutes

Command Syntax

find /path/to/files -mmin -<minutes> -exec rm {} \;

Friday, March 5, 2021

 How to create RESTRICTED Session in Oracle DB

Apart from Startup nomount , Startup mount, or Startup [open] there is one more mode to start the Oracle DB Instance is 

Startup Restrict 

or 

Alter system enable restricted session;


How can user create session

When database is OPEN  i.e. startup open , users must be grant CREATE SESSION to Connect 

grant create session to yogesh;

When database is restricted mode, users must be grant create session as well as create restrict session.

grant create restricted session to yogesh;

Note - > if user already logged in and dba issue alter system enable restricted session; command then those user remain logged in.


Disable restricted mode

alter system disable restricted session.

Friday, February 12, 2021

 This Blog give the answer of following question which i faced after installing Oracle 12c , Oracle 19c 

Question 1. How to open enterprise manger  like oracle 11g

Question 2. Why emctl not found in $ORACLE_HOME/bin directory

Question 3. How to setup web console / enterprise manager express in Oracle 12c 

Question 4. How to install enterprise manager separately in Oracle 12c


Step by Step i give the answer of these above questions. After installing oracle 12c i faced these issue.

I hope most of you have either already noticed or going to be notice that enterprise manager controller emctl command has been removed from Oracle 12c / Oracle 19c.  This is because from Oracle 12c (cloud) Enterprise Manager come in separate bundle. 

So After completing setup of  Oracle 12c / Oracle 19c , when i tried to run emctl command it show the following error

[oracle@lap ~]$ emctl
bash: emctl: command not found...
[oracle@lap ~]$ find /u01 -type f -name emctl
[oracle@lap ~]$ 
So after little bit research i found the reason that emctl is not shipped with Database package. But we can run express edition of enterprise manager. which have limited functionality basically you can view the report.

So enable enterprise manager express in Oracle 12c or Oracle 19c you need to follow following steps...

Step 1. First check http and https port using gethttpport or gethttpsport funtion of DBMS_XDB_CONFIG package

For http port 

SQL> select dbms_xdb_config.gethttpport from dual;

GETHTTPPORT
-----------
          0

For https port 

SQL> select dbms_xdb_config.gethttpsport from dual;

GETHTTPSPORT
------------
           0

if output of above query are 0 then we need to configure the port and if output are any number than 0 than we don't need to configure these port again.

Step 2. Configure http or https port or both if it not set already i.e. output of above sql query are 0.  For setting http port we use dbms_xdb_config.sethttpport and https port we use  dbms_xdb_config.sethttpsport 


SQL> exec dbms_xdb_config.setHTTPsPort (5500);


PL/SQL procedure successfully completed.


SQL> exec dbms_xdb_config.setHTTPPort(5511);


PL/SQL procedure successfully completed.

Run the first 2 queries again and check for the required output.
SQL> select dbms_xdb_config.gethttpport from dual;


GETHTTPPORT
-----------
       5511


SQL> select dbms_xdb_config.gethttpsport from dual;


GETHTTPSPORT
------------
 5500
This show my enterprise manager express has been configured at my system. To open web console we need to use 

http://localhost:5500/em 
 
or 

 https://localhost:5511/em 

Oracle 12c web console required flash support to open login page for that we need to install flash-plugin.

 Note : Since Adobe no longer supports Flash Player after 31 December 2020 and blocked Flash content from running in Flash Player beginning 12 January 2021, Adobe strongly recommends all users immediately uninstall Flash Player to help protect their systems. 

Sunday, July 19, 2020

Ques What is difference among Privilege , Roles, and Profiles?

Privileges, Roles and Profiles


Privileges
A user privilege is a right to execute a particular type of SQL statement, or a right to access another user's object, execute a PL/SQL package, and so on. The types of privileges are defined by Oracle.
Roles
Roles are created by users (usually administrators) to group together privileges or other roles. They are a means of facilitating the granting of multiple privileges or roles to users.
Profiles
Profiles define resource limits imposed upon a user account. The "default" profile sets all resource limits to unlimited.

Monday, April 27, 2020

How to copy a project inside itellij idea.

Like Eclipse you can't copy project in intellij idea . Here Step By Step approach to make new copy of existing project.

Step 1 : Create copy of project - use terminal or explorer and copy the project and rename it.

Step 2 : Switch back to idea and open new Project

             File -> Open -(navigate the location where project exist)->open

Step 3 : Rename .iml File suppose your old project name was test and new  name is test-java. but when you expand project test-java in IDE then you find test.iml file rename it to project name i.e. test-java.iml

Step 4 : Open pom.xml and rename artifactId to project name, to avoid any conflict.

Step 5 : Navigate main method and right click and run  - this will open a window



Step 6 : Check Two input


  • Use classpath of module : if it <no-module> change it to project name
  • JRE : check it correctly set
Now project Copy


Thursday, April 23, 2020

CentOS 8 or RedHat 8 : docker run give error - docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.

After successful installation when i Try to test docker installation with sample container it give following error
[yogesh@devBase ~]$ systemctl start docker
[yogesh@devBase ~]$ docker run test
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Solution
Step 1 : Check docker group
[yogesh@devBase ~]$ cat /etc/group

docker:x:970:


if docker group does not exist create it

Step 2 : Add user to docker group
[yogesh@devBase ~]$ sudo usermod -aG docker ${USER}

Step 3 : Above two step not solved the problem now check /lib/systemd/system/docker.socket file.

[yogesh@devBase ~]$ ls -l /lib/systemd/system/docker.socket 
-rw-r--r--. 1 root root 197 Mar 11 06:56 /lib/systemd/system/docker.socket
if user and group of this file is root then change group to docker.
[yogesh@devBase ~]$ sudo chgrp docker /lib/systemd/system/docker.socket 
[sudo] password for yogesh: 
[yogesh@devBase ~]$ 
Step 4 : Give permission to group
[yogesh@devBase ~]$ sudo chmod g+w /lib/systemd/system/docker.socket
Step 5 : open new terminal and restart docker. now run docker run hello-world its working perfectly.
[yogesh@devBase ~]$ ls -l /lib/systemd/system/docker.socket 
-rw-rw-r--. 1 root docker 197 Mar 11 06:56 /lib/systemd/system/docker.socket

Wednesday, April 22, 2020

RedHat 8 or CentOS 8 : Docker Installation fails with Error : package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed

I have decided to use docker for ease of development of my application. when i installed according to docker documentation it fails and give following error.

[yogesh@devBase ~]$ sudo dnf install docker-ce docker-ce-cli containerd.io
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:26 ago on Wed 22 Apr 2020 09:21:50 PM IST.
Error: 
 Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
  - cannot install the best candidate for the job
  - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
  - package containerd.io-1.2.13-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
  - package containerd.io-1.2.2-3.el7.x86_64 is excluded
  - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

Solution
To resolve above error first install containerd.io.

[yogesh@devBase ~]$ sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.1.el7.x86_64.rpm
[sudo] password for yogesh: 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:07:11 ago on Wed 22 Apr 2020 09:21:50 PM IST.
containerd.io-1.2.13-3.1.el7.x86_64.rpm                                                                                22 kB/s |  23 MB     17:46    
Dependencies resolved.
======================================================================================================================================================
 Package                              Architecture                  Version                                 Repository                           Size
======================================================================================================================================================
Installing:
 containerd.io                        x86_64                        1.2.13-3.1.el7                          @commandline                         23 M
     replacing  runc.x86_64 1.0.0-64.rc9.module_el8.1.0+298+41f9343a

Transaction Summary
======================================================================================================================================================
Install  1 Package

Total size: 23 M
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                              1/1 
  Installing       : containerd.io-1.2.13-3.1.el7.x86_64                                                                                          1/2 
  Running scriptlet: containerd.io-1.2.13-3.1.el7.x86_64                                                                                          1/2 
  Obsoleting       : runc-1.0.0-64.rc9.module_el8.1.0+298+41f9343a.x86_64                                                                         2/2 
  Running scriptlet: runc-1.0.0-64.rc9.module_el8.1.0+298+41f9343a.x86_64                                                                         2/2 
  Verifying        : containerd.io-1.2.13-3.1.el7.x86_64                                                                                          1/2 
  Verifying        : runc-1.0.0-64.rc9.module_el8.1.0+298+41f9343a.x86_64                                                                         2/2 
Installed products updated.

Installed:
  containerd.io-1.2.13-3.1.el7.x86_64                                                                                                                 

Complete!

Once containerd.io install now install docker-ce and docker-ce-cli.
[yogesh@devBase ~]$ sudo dnf install docker-ce docker-ce-cli
[sudo] password for yogesh: 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
CentOS-8 - AppStream                                                                                                  4.7 kB/s | 4.3 kB     00:00    
CentOS-8 - Base                                                                                                       1.1 kB/s | 3.8 kB     00:03    
CentOS-8 - cr                                                                                                         2.4 kB/s | 3.0 kB     00:01    
CentOS-8 - Extras                                                                                                     1.7 kB/s | 1.5 kB     00:00    
CentOS-8 - PowerTools                                                                                                 2.2 kB/s | 4.3 kB     00:01    
CentOS-8 - Plus                                                                                                       2.7 kB/s | 3.0 kB     00:01    
CentOS-8 - fasttrack                                                                                                  2.7 kB/s | 3.0 kB     00:01    
Amazon Corretto                                                                                                       1.5 kB/s | 2.9 kB     00:01    
Docker CE Stable - x86_64                                                                                             3.1 kB/s | 3.5 kB     00:01    
ELRepo.org Community Enterprise Linux Repository - el8                                                                1.0 kB/s | 2.9 kB     00:02    
ELRepo.org Community Enterprise Linux Repository - el8                                                                 23 kB/s | 147 kB     00:06    
ELRepo.org Community Enterprise Linux Kernel Repository - el8                                                         2.0 kB/s | 2.9 kB     00:01    
ELRepo.org Community Enterprise Linux Kernel Repository - el8                                                          30 kB/s | 939 kB     00:31    
ELRepo.org Community Enterprise Linux Extras Repository - el8                                                         1.8 kB/s | 2.9 kB     00:01    
ELRepo.org Community Enterprise Linux Extras Repository - el8                                                          12 kB/s |  31 kB     00:02    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                3.1 kB/s | 9.8 kB     00:03    
Extra Packages for Enterprise Linux 8 - x86_64                                                                        5.8 kB/s | 3.1 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                                                                        9.9 kB/s | 6.4 MB     11:01    
google-chrome                                                                                                         3.5 kB/s | 1.3 kB     00:00    
google-chrome                                                                                                         4.9 kB/s | 3.5 kB     00:00    
RPM Fusion for EL 8 - Free - Updates                                                                                  1.9 kB/s | 3.7 kB     00:01    
RPM Fusion for EL 8 - Nonfree - Updates                                                                               3.8 kB/s | 3.7 kB     00:00    
Dependencies resolved.
======================================================================================================================================================
 Package                             Architecture                 Version                                Repository                              Size
======================================================================================================================================================
Installing:
 docker-ce                           x86_64                       3:19.03.8-3.el7                        docker-ce-stable                        25 M
 docker-ce-cli                       x86_64                       1:19.03.8-3.el7                        docker-ce-stable                        40 M
Installing dependencies:
 libcgroup                           x86_64                       0.41-19.el8                            BaseOS                                  70 k

Transaction Summary
======================================================================================================================================================
Install  3 Packages

Total size: 64 M
Total download size: 64 M
Installed size: 273 M
Is this ok [y/N]: y
Downloading Packages:
[SKIPPED] libcgroup-0.41-19.el8.x86_64.rpm: Already downloaded                                                                                       
[MIRROR] docker-ce-19.03.8-3.el7.x86_64.rpm: Curl error (28): Timeout was reached for https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.8-3.el7.x86_64.rpm [Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds]
(2/3): docker-ce-cli-19.03.8-3.el7.x86_64.rpm                                                                          37 kB/s |  40 MB     18:14    
(3/3): docker-ce-19.03.8-3.el7.x86_64.rpm                                                                              16 kB/s |  25 MB     25:21    
------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                  43 kB/s |  64 MB     25:21     
warning: /var/cache/dnf/docker-ce-stable-091d8a9c23201250/packages/docker-ce-19.03.8-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Docker CE Stable - x86_64                                                                                             3.5 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                              1/1 
  Installing       : docker-ce-cli-1:19.03.8-3.el7.x86_64                                                                                         1/3 
  Running scriptlet: docker-ce-cli-1:19.03.8-3.el7.x86_64                                                                                         1/3 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                 2/3 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                                 2/3 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                                 2/3 
  Installing       : docker-ce-3:19.03.8-3.el7.x86_64                                                                                             3/3 
  Running scriptlet: docker-ce-3:19.03.8-3.el7.x86_64                                                                                             3/3 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                                 1/3 
  Verifying        : docker-ce-3:19.03.8-3.el7.x86_64                                                                                             2/3 
  Verifying        : docker-ce-cli-1:19.03.8-3.el7.x86_64                                                                                         3/3 
Installed products updated.

Installed:
  docker-ce-3:19.03.8-3.el7.x86_64                 docker-ce-cli-1:19.03.8-3.el7.x86_64                 libcgroup-0.41-19.el8.x86_64                

Complete!
[yogesh@devBase ~]$ docker --help

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/home/yogesh/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with
                           "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/home/yogesh/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/home/yogesh/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/home/yogesh/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  engine      Manage the docker engine
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  deploy      Deploy a new stack or update an existing stack
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
[yogesh@devBase ~]$ docker --version
Docker version 19.03.8, build afacb8b
[yogesh@devBase ~]$ 

Docker install successfully.