Monday, July 9, 2018

Install IPython on CentOS_7

iPython is a great python shell. It comes handy to test quick the python code and ideas immediately and It has an interactive python shell into a python application. And can even be used as a system shell. To install this on CentOS_7 you will need to enable and install epel-release (extra packages) repository and then try to run following commands at your own discretion:

# yum install epel-release
# yum update -y
# yum install ipython
[root@CentOS_7 ~]# ipython
Python 2.7.5 (default, Apr 11 2018, 07:36:10) 
Type "copyright", "credits" or "license" for more information.

IPython 3.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]:

[root@CentOS_7 ~]# uname -a
Linux dhcp-172-20-196-165 3.10.0-862.el7.x86_64

centos_7 on MAC_Pro_No_IP_Address on Oracle VirtualBox

On Oracle Virtual Box after installing CentOS 7 from an ISO and logged in but the IP address was missing. After checking /etc/sysconfig/network-scripts/ifcfg-enp0s3 file, found that the ONBOOT=no
was set. But do not edit the file directly as this is deprecated in CentOS 7. So use nuclei instead.

1. Login as root and run the following command
# nmcli con mod enp0s3 connection.autoconnect yes
2. Bring down the NIC
# nmcli con down enps03
3. Bring up the NIC
# nmcli con up enp0s3
4. Now run ip a s

Note: After changing the Network Setting for the NIC - I used "Bridged adapter" this made sure that the local desktop/Laptop and the CentOS VM is in the same LAN so that you can ssh from ssh client.

Friday, January 26, 2018

Difference between $* and $#

- Set couple of sentences in the command line with set command.
[root@rhel74 shellscripts]# set You have the capacity to learn from the mistakes. You will learn a lot in your life
-try to echo eleven words from the sentences but from the shell you can access only nine positional parameters. When we tried to refer $10 it was interpreted as if you wanted the value of $1 and a 0. So we got You0 as output.

[root@rhel74 shellscripts]# echo $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11
You have the capacity to learn from the mistakes. You0 You1

-if you echo $# you get how many total numbers of the positional parameters were passed.

[root@rhel74 shellscripts]# echo "Total number of the positional parameters passed: $#"
Total number of the positional parameters passed: 17
- if you do $* you get everything passed as positional parameters to the command line.

[root@rhel74 shellscripts]# echo $*
You have the capacity to learn from the mistakes. You will learn a lot in your life

Wednesday, September 27, 2017

Another app is currently holding the yum lock; waiting for it to exit...

How to resolve - Another app is currently holding the yum lock; waiting for it to exit...

[Centos7-01 ~]# yum repolist
Loaded plugins: enabled_repos_upload, langpacks, package_upload, product-id, search-
              : disabled-repos, subscription-manager
Existing lock /var/run/yum.pid: another copy is running as pid 3272.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  77 M RSS (515 MB VSZ)
    Started: Wed Sep 27 08:57:19 2017 - 00:02 ago
    State  : Sleeping, pid: 3272
Another app is currently holding the yum lock; waiting for it to exit...

Step1:

# kill 3272
if does not work, hard kill
# kill -9 3272


But this also did not help... Next:

Step 2:

Found that there was old local repository active from the ISO monted to /mnt.
Please disable the old repository - yum repolist will show the details

[centOS7-01 ~]# yum-config-manager --disable "Centos 7.4"
Loaded plugins: langpacks, product-id
============================================================================ repo: InstallMedia ============================================================================
[InstallMedia]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7Server
baseurl = file:///mnt/
cache = 0

Output truncated......

[Centos7-01 ~]# yum repolist

Now please run below commands and install the packages of your choice.

[Centos7-01 ~]# yum clean all
[Centos7-01 ~]# yum update all
[Centos7-01 ~]# yum install ksh

That's it!

Thursday, August 17, 2017

CentOS 7 - Runlevel change

CentOS 7 - Runlevel change

Method one:

# systemctl get-default
multi-user.target


# systemctl set-default multi-user.target

# reboot

Second method:

# ls /lib/systemd/system/runlevel*target -l
lrwxrwxrwx. 1 root root 15 Aug  3 13:44 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Aug  3 13:44 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Aug  3 13:44 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Aug  3 13:44 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Aug  3 13:44 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Aug  3 13:44 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Aug  3 13:44 /lib/systemd/system/runlevel6.target -> reboot.target


# ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

# systemctl get-default
runlevel5.target

# reboot

Thursday, August 3, 2017

find: paths must precede expression

[root@dns1 bashscripts]# find . -type f  -name *.core  -print
find: paths must precede expression: various1.core
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

[root@dns1 bashscripts]# find . -type f  -name '*.core'  -print
./various4.core
./various9.core
./various7.core
./various1.core
./various5.core
./various8.core
./various2.core
./various10.core
./various6.core
./various3.core

[root@dns1 bashscripts]# ls -l *.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various10.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various1.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various2.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various3.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various4.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various5.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various6.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various7.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various8.core
-rw-r--r--. 1 root root 0 Apr 18 22:40 various9.core

Note: Single quotes will stop wild cards from expanding the search.