Sunday, December 9, 2018

Useful linux commands



1. SSH to remote server


ssh -i <PEM FILE> <REMOTE_USERNAME>@<REMOTE_IP>


ex: ssh -i ~/.ssh/admin-user.pem admin-user@10.10.15.20

2. Copy a Remote File to a Local System using the scp Command


scp -<REMOTE_USERNAME>@<REMOTE_IP>:<FULL_PATH_TO_REMOTE_FILE> <PATH_OF_LOCAL_SYSTEM>

ex: scp remote_username@10.10.0.2:/remote/file.txt /local/directory

3. Copy a File Between Two Remote Systems using the scp Command


scp  <REMOTE1_USERNAME>@<REMOTE1_IP>:<FULL_PATH_TO_REMOTE1_FILE> <REMOTE2_USERNAME>@<REMOTE2_IP>:<FULL_PATH_TO_REMOTE2_FILE>

ex: scp user1@host1.com:/files/file.txt user2@host2.com:/files
In here, file.txt in host1 will be copied to host2 files directory.

4. Compress a folder

zip -r <ZIP_FILE_NAME> <FOLDER_NAME>

ex: zip -r abc.zip abc
In here, “abc” folder will be compressed to “abc.zip”


5. Extract a zip file


unzip -r <ZIP_FILE_NAME> <FOLDER_NAME>
ex: unzip file.zip -d destination_folder


Note: If unzip command is not installed in your system, you can use below command to install unzip.


sudo apt-get install unzip


6. Create a symlink

ln -s <PATH_TO_FILE> <PATH_TO_SYMLINK>

ex: ln -s /path/to/file /path/to/symlink


7 .Find all files containing specific text

grep -rnw '<PATH_TO_FOLDER>' -e '<PATTERN>'

ex: grep -rnw '/path/to/somewhere/' -e 'pattern'
Note:
  • -r or -R is recursive
  • -n is line number,
  • -w stands for match the whole word.


8. Replace a string in multiple files

sed -i 's/<OLD_WORD>/<NEW_WORD>/g' *

ex : sed -i 's/foo/bar/g' *
In here, occurrences of "foo" will be replaced with "bar".

Note: Before replace, go to the specific folder using "cd" command.
  • cd /path/to/your/folder


Thursday, August 30, 2018

Validate XML against XSD with Notepad++


  1. Add Plugin Manager to Notepad++ if it is not listed under "Plugins".
    1. Download the latest Notepad++ plugin manager from here.
    2. Extract the downloaded zip file.
    3. Import "PluginManager.dll" to Notepad++ ( Settings > Import > Import  plugin(s) ) inside the plugin folder of the extracted folder.
    4. If it is not working, copy PluginManager.dll to plugins folder inside Notepad++ installed folder.
       

    5. Copy gpup.exe inside the plugin folder of the extracted folder to updater directory where Notepad++ installed.

  2.  Now you will see "Plugin Manager" in Notepad++ (Plugins -> Plugin Manager)


  3. Then go to Plugins > Plugin Manager > Show Plugin Manager. Then select XML Tools plugin and click Install.


  4. Open XML document you want to validate and go to Plugins > XML Tools > Validate Now. Then, the following dialog will be open.


  5. Then select the relevant xsd file and click OK.

  6. If the validations are fine, you will receive following message.



  7. Else you will receive the following message with error reasons.