Monday, July 23, 2018

Put existing running process in background on Linux

In case you need to put existing running process on the current shell in the background for some reason. Please apply following steps:

example:

# echo "Hello World" ; sleep 100
# run ctrl z keyboard keys together
# bg
# disown -h
# exit

Explanation: Ctrl z will pause the program and will bring you back to the shell, bg command will put the process in background and disown -h will make sure that the process is not killed when you exit the terminal. exit is pretty much self explanatory.

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.