Sunday, March 4, 2018

Keep the process of a program running after closing the shell terminal

to keep the process running after the shell terminal close on ubuntu 16.04 use the following
command:

nohup my_command > my.log 2>&1 &

if you don't want to log the output of this command to a log file the replace my.log by
/dev/null, So it will be like the following:

nohup my_command > /dev/null 2>&1 &

if you want to find the process after a while and want to kill the process then, list all
the running processes:

ps -ef

you will find the command in the CMD column of the diplayed list. Now find the process Id from
the PID column and insert the kill command

sudo kill pid

How to Secure your ubuntu server - essential steps




create new user $ adduser username
$ usermod -aG sudo username
$ echo 'username ALL=NOPASSWD ALL' >> /etc/sudoers

$ nano /etc/ssh/sshd_config
change ssh port from 22 to 9022
#Port 22
Port 9122

Disable Root Account
change in /etc/ssh/sshd_config
PermitRootLogin yes
to
PermitRootLogin no


Add firewall rules :
sudo iptables -I INPUT 1 -i lo -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 9122 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo  iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -I INPUT -p udp  --dport 111 -j REJECT
sudo iptables -A INPUT -j REJECT

well be updated later .