Launching custom scripts from command (shortcuts)

Well, too lazy to execute the commands to launch my vpn, rsync commands etc I created a bash script which does it for me.

Well, that did not make me happy either, because I have to cd into the directory where my scripts are and then run them. Errr…. my time is too precious to do that (I am too lazy to do that).

Thinking why not execute my scripts from using anywhere just like I launch any other standard linux commands???

Google again, and I stumbled upon this thread on asubuntu.com

Life saver 🙂 Joe Oppegaard.

Steps:

Create a bin folder in home directory:

Copy scripts into the folder:

Edit ~/.bashrc adding below to the end of the file:

PATH=$PATH:~/bin

Open new terminal and enter the script name to executing the script from anywhere in terminal.

Linux nohup to launch multiple scripts using bash

I came across this useful command when I wanted to automate some of my scripts to launch openvpn, rsync etc using one command.

The problem I had when trying this is with HUP (hangup) signal that would prevent the execution of commands further to execute other scripts.

For example, I have commands like this in my bash script:

cd /media/root/WORKING;
terminator --working-directory=/media/root/WORKING;
openvpn /media/root/WORKING/OS*;
/root/Desktop/c-programs/util/sync-cprograms.sh;
/root/Desktop/c-programs/util/sync-scripts.sh;

The first to commands gets executed and terminator launches with working directory mentioned.

OpenVPN works too, but remains in verbose mode (am I correct???). The process does not end until I exit the same. So my next commands to run scripts (that sync my folders on desktop using rsync).

Was looking for a solution and I can get any from Google. I found this command nohup. With nohup, my bash looks as below:

cd /media/root/WORKING;
openvpn /media/root/WORKING/OS* </dev/null &>/dev/null &
nohup bash /root/Desktop/c-programs/util/sync-cprograms.sh </dev/null >/dev/null 2>&1 &
nohup bash /root/Desktop/c-programs/util/sync-scripts.sh </dev/null >/dev/null 2>&1 &
terminator --working-directory=/media/root/WORKING &

Reference: nohup, null device

Linux command cheats

Remote desktop (rdesktop):

To open a remote desktop over rdp with required window dimension (1280×960 in this example):

root@kali:/media/root/PWK# rdesktop -u offsec -p CEmbxkhMQ1Z 10.11.14.78 -g 1280x960

Change file owner/group (chown):

SYNOPSIS                                                                        
     chown [-fhvx] [-R [-H | -L | -P]] owner[:group] file ...                   
     chown [-fhvx] [-R [-H | -L | -P]] :group file ...

chown localshare:localshare demo

We can see that the new owner of demo folder is localshare. But does this change apply to sub folders??? No… child folders/files are still owned by previous owner/s as below:

To change the owner for all content in folder:

chown -R localshare:localshare demo