Thursday, May 18, 2023

Adding Users to Sudoers in Linux

 

Adding Users to Sudoers in Linux



Login as root user : visudo and check wheel (group) details should be there 

## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.


## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL



Login as root user to add user (atharv) in wheel group (sudoers)

[root@0.0.0.0~]# usermod -aG wheel atharv

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]# id atharv

uid=1002(atharv) gid=1002(dba) groups=1002(dba),10(wheel)

[root@0.0.0.0~]#


Login as atharv user 


[atharv@0.0.0.0 ~]$ su - atharv

Password:

Last login: Thu May 18 11:50:13 UTC 2023 on pts/1

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$ sudo fdisk -l

Disk /dev/xvda: 60 GiB, 64424509440 bytes, 125829120 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: gpt

Disk identifier: 2E431796-24CD-41A3-A4CB-7987FFF67072


Device     Start       End   Sectors Size Type

/dev/xvda1  2048      4095      2048   1M BIOS boot

/dev/xvda2  4096 125829086 125824991  60G Linux filesystem

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$ sudo ls -la /root

total 260816

dr-xr-x---.  9 root root      4096 May 18 11:12  .

dr-xr-xr-x. 21 root root      4096 Jan 13 14:03  ..

-rw-------.  1 root root      6953 May  4  2021  anaconda-ks.cfg

drwx------   4 root root        27 Apr 14 10:20  .ansible

drwxr-xr-x   3 root root        22 Apr 14 10:14  ansible

-rw-r--r--   1 root root  77218345 Jan  9 18:30 'AutoDL?BundleId=247937_0ae14417abb444ebb02b9815e2103550'

-rw-r--r--   1 root root    137320 Feb 18 13:07  aws_replication_agent_installer.log

-rw-r--r--   1 root root     25289 Feb  6 10:25  aws-replication-installer-init.py

-rw-------.  1 root root     17257 May 18 11:12  .bash_history

-rw-r--r--.  1 root root        18 Aug 12  2018  .bash_logout

-rw-r--r--.  1 root root       176 Aug 12  2018  .bash_profile

-rw-r--r--.  1 root root       176 Aug 12  2018  .bashrc

drwx------   3 root root        20 Sep 21  2022  .config

drwxr-xr-x   6 root root        95 Sep 21  2022  .cpan

drwxr-xr-x   3 root root        55 Sep 21  2022  .cpanm

-rw-r--r--.  1 root root       100 Aug 12  2018  .cshrc

-rw-r--r--   1 root root 189609546 Dec  7 23:14  jdk-19_linux-x64_bin.rpm

drwxr-xr-x   3 root root       105 Feb 18 13:01  mgn18022023

-rw-------.  1 root root         0 May 16 17:02  original-ks.cfg

-rw-------   1 root root      3167 Nov  8  2022  .psql_history

drwx------.  2 root root        48 Apr 14 10:25  .ssh

-rw-r--r--.  1 root root       129 Aug 12  2018  .tcshrc

-rw-r--r--   1 root root       111 May 18 10:44  test.txt

-rw-------   1 root root      1047 May 18 08:41  .viminfo

-rw-------   1 root root       518 May 18 05:50  .Xauthority

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

[atharv@0.0.0.0 ~]$

How to Add or Remove Linux User From Group : Linux OS

How to Add or Remove Linux User From Group ?


Add the User to a Group in Linux


[root@0.0.0.0~]# usermod -aG wheel atharv

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]# id atharv

uid=1002(atharv) gid=1002(dba) groups=1002(dba),10(wheel)

[root@0.0.0.0~]#



Remove the User from a Group in Linux



[root@0.0.0.0~]#

[root@0.0.0.0~]# gpasswd -d atharv wheel

Removing user atharv from group wheel

[root@0.0.0.0~]#

[root@0.0.0.0~]#

[root@0.0.0.0~]# id atharv

uid=1002(atharv) gid=1002(dba) groups=1002(dba)

[root@0.0.0.0~]#

[root@0.0.0.0~]#

Your account has expired; please contact your system administrator : Linux OS

Re-Enable user In Linux : Your account has expired; please contact your system administrator


[atharv@0.0.0.0~]$

[atharv@0.0.0.0~]$ su - atharv

Password:

Your account has expired; please contact your system administrator

su: User account has expired

[atharv@0.0.0.0~]$




Login as root user :


[root@0.0.0.0home]# chage -l atharv
Last password change                                    : May 18, 2023
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : May 18, 2023
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
[root@0.0.0.0home]#
[root@0.0.0.0home]#




[root@0.0.0.0home]#
[root@0.0.0.0home]#
[root@0.0.0.0home]# chage --expiredate 2023-05-19 atharv
[root@0.0.0.0home]#
[root@0.0.0.0home]#
[root@0.0.0.0home]# chage --list atharv
Last password change                                    : May 18, 2023
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : May 19, 2023
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
[root@0.0.0.0home]#

Monday, April 17, 2023

How to get public IP from AWS EC2 instance ?

 


Use Below command 


login as root 



curl http://checkip.amazonaws.com



[root@ip-173-11-11-11 ~]#

[root@ip-173-11-11-11~]# curl http://checkip.amazonaws.com

55.2232.1123.123341

[root@ip-173-11-11-11 ~]#

Saturday, April 15, 2023

How to check Ansible version ?

check version of Ansible on Linux  


[root@ip-0.0.0.0 project1]#

[root@ip-0.0.0.0 project1]# ansible --version

ansible 2.9.27

  config file = /etc/ansible/ansible.cfg

  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']

  ansible python module location = /usr/lib/python3.6/site-packages/ansible

  executable location = /usr/bin/ansible

  python version = 3.6.8 (default, Jan 11 2023, 08:43:50) [GCC 8.5.0 20210514 (Red Hat 8.5.0-16)]

[root@ip-0.0.0.0 project1]#

[root@ip-0.0.0.0 project1]#

How to install Ansible on Linux ?

Install Ansible on Linux OS


=> Login as root user 


[root@ip-0.0.0.0 ~]#

[root@ip-0.0.0.0 ~]# yum install ansible

Updating Subscription Management repositories.

Unable to read consumer identity


This system is not registered with an entitlement server. You can use subscription-manager to register.


Last metadata expiration check: 2:49:39 ago on Fri 14 Apr 2023 07:03:14 AM UTC.

Dependencies resolved.

==========================================================================================================================

 Package                     Architecture      Version                    Repository                                 Size

==========================================================================================================================

Installing:

 ansible                     noarch            2.9.27-1.el8ae             ansible-2-for-rhel-8-rhui-rpms             17 M

Installing dependencies:

 sshpass                     x86_64            1.09-4.el8                 rhel-8-appstream-rhui-rpms                 30 k

Installing weak dependencies:

 python3-jmespath            noarch            0.9.0-11.el8               rhel-8-appstream-rhui-rpms                 45 k


Transaction Summary

==========================================================================================================================

Install  3 Packages


Total download size: 17 M

Installed size: 96 M

Is this ok [y/N]: y

Downloading Packages:

(1/3): python3-jmespath-0.9.0-11.el8.noarch.rpm                                           825 kB/s |  45 kB     00:00

(2/3): sshpass-1.09-4.el8.x86_64.rpm                                                      526 kB/s |  30 kB     00:00

(3/3): ansible-2.9.27-1.el8ae.noarch.rpm                                                   52 MB/s |  17 MB     00:00

--------------------------------------------------------------------------------------------------------------------------

Total                                                                                      44 MB/s |  17 MB     00:00

Running transaction check

Transaction check succeeded.

Running transaction test

Transaction test succeeded.

Running transaction

  Preparing        :                                                                                                  1/1

  Installing       : sshpass-1.09-4.el8.x86_64                                                                        1/3

  Installing       : python3-jmespath-0.9.0-11.el8.noarch                                                             2/3

  Installing       : ansible-2.9.27-1.el8ae.noarch                                                                    3/3

  Running scriptlet: ansible-2.9.27-1.el8ae.noarch                                                                    3/3

  Verifying        : python3-jmespath-0.9.0-11.el8.noarch                                                             1/3

  Verifying        : sshpass-1.09-4.el8.x86_64                                                                        2/3

  Verifying        : ansible-2.9.27-1.el8ae.noarch                                                                    3/3

Installed products updated.


Installed:

  ansible-2.9.27-1.el8ae.noarch          python3-jmespath-0.9.0-11.el8.noarch          sshpass-1.09-4.el8.x86_64


Complete!

[root@ip-0.0.0.0 ~]#


Monday, March 6, 2023

java.lang.UnsupportedClassVersionError: com/dom/benchmarking/swingbench/SwingBench

 java.lang.UnsupportedClassVersionError:



[oracle@10.1.0.2 bin]$

[oracle@10.1.0.2 bin]$ ./swingbench

java.lang.UnsupportedClassVersionError: com/dom/benchmarking/swingbench/SwingBench has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)

        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

        at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)

        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)

        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)

        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:264)

        at org.apache.commons.launcher.ChildMain.run(ChildMain.java:183)

[oracle@10.1.0.2 bin]$

[oracle@10.1.0.2 bin]$

[oracle@10.1.0.2 bin]$




[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]# wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpm

--2023-03-06 14:49:06--  https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpm

Resolving download.oracle.com (download.oracle.com)... 23.56.12.90

Connecting to download.oracle.com (download.oracle.com)|23.56.12.90|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 189609546 (181M) [application/x-redhat-package-manager]

Saving to: ‘jdk-19_linux-x64_bin.rpm’


jdk-19_linux-x64_bin.rpm       100%[==================================================>] 180.83M  99.6MB/s    in 1.8s


2023-03-06 14:49:08 (99.6 MB/s) - ‘jdk-19_linux-x64_bin.rpm’ saved [189609546/189609546]


[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]# ls -lrt

total 260760

-rw-------. 1 root root      6699 May  4  2021  original-ks.cfg

-rw-------. 1 root root      6953 May  4  2021  anaconda-ks.cfg

-rw-r--r--  1 root root 189609546 Dec  7 23:14  jdk-19_linux-x64_bin.rpm

-rw-r--r--  1 root root  77218345 Jan  9 18:30 'AutoDL?BundleId=247937_0ae14417abb444ebb02b9815e2103550'

-rw-r--r--  1 root root     25289 Feb  6 10:25  aws-replication-installer-init.py

drwxr-xr-x  3 root root       105 Feb 18 13:01  mgn18022023

-rw-r--r--  1 root root    137320 Feb 18 13:07  aws_replication_agent_installer.log

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]# rpm -Uvh jdk-19_linux-x64_bin.rpm

warning: jdk-19_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY

Verifying...                          ################################# [100%]

Preparing...                          ################################# [100%]

Updating / installing...

   1:jdk-19-2000:19.0.2-7             ################################# [100%]

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]# which java

/usr/bin/java

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]# java -version

java version "19.0.2" 2023-01-17

Java(TM) SE Runtime Environment (build 19.0.2+7-44)

Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)

[root@10.1.0.2 ~]#

[root@10.1.0.2 ~]#



workaround :

 We have to install compatible java version so that application software (swingbench)  run

How to create Nano Banana 3D figurine step-by-step?

1. Launch Google Gemini or open Google AI Studio. 2. Select and upload the photo you want to convert. 3. Enter the following nanao banana 3...