Open Source For You — December 2017

(Steven Felgate) #1

TIPS


TRICKS


&


The command takes you to the last working directory.
This helps in directly moving to the last working directory
from the current one, instead of remembering and typing the
whole last working directory path.

—Abhinay Badam, [email protected]

Execute parallel ssh on multiple hosts
Here are the steps to do a parallel ssh on multiple
hosts. We are going to use pssh, which is a program for
executing ssh in parallel on a number of hosts. It provides
features such as sending inputs to all the processes, passing
a password to ssh, saving the output to files, and timing out.
You can access the complete manual of pssh at https://linux.
die.net/man/1/pssh.
First off, let us look at how to install it on a CentOS 7
system:

# yum install epel-release

Now install pssh, as follows:

# yum install pssh

Create pssh_hosts.txt file and enter the hosts you need
to target:

# cat pssh_hosts.txt
# write hosts per line like follows
#user@target_ip
[email protected]

We should create a key-pair between the master host and
targets -- this is the only way to get things done. Simply log
in the target from the master node for host key verification:

# ssh [email protected]

Tips you can use daily on a Linux
computer


  1. Shortcut for opening a terminal in Ubuntu
    To open a terminal in Ubuntu, press the Ctrl+Alt+t keys.
    This creates a new terminal.

  2. Running the previous command with ‘sudo’ in the terminal
    In case you have forgotten to run a command with ‘sudo’,
    you need not re-write the whole command. Just type
    ‘sudo!!’ and the last command will run with sudo.

  3. How to change a file permission
    An admin can change the file permissions by executing
    chmod u+ filename on the terminal where...


<permission> can be r(read), w(write), x(execute)

The admin can change permissions on the file that are
given by other users, by executing the above command,
and replacing ‘u’ with ‘g’ for group access and ‘u’ with ‘o’
for others.

—Anirudh Kalwa, [email protected]

Moving between the current and last
working directories easily
Everyone knows that typing ‘cd’ in the terminal in Ubuntu
takes the user to the home directory. However, if you want
to go to the last working directory, instead of entering the
following:

$cd <directory path>

...directly type the command shown below in the
terminal:

$cd -

104 | DECEMBER 2017 | OPEN SOURCE FOR YOU | http://www.OpenSourceForU.com

Free download pdf