Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Monday, July 11, 2016

Unzip multiple files from Linux console

Many of you might have came across the situation where you had to extract multiple zip files. This can be done very easily from the Linux console.

When we unzip a file from the Linux console we use a command similar to the following.

unzip wso2am-2.0.0-BETA2.zip
In the same way, if you try to unzip multiple files using the same command,  the following error would we given.

unzip *.zip
Archive:  wso2am-2.0.0-BETA2.zip
caution: filename not matched:  wso2analytics-apim-2.0.0-beta2.zip
To overcome this issue of "filename not matched", we can simply use the following command. This command will unzip all the zip files in the current folder.

unzip '*.zip'

Friday, July 8, 2016

Force shutdown/Kill WSO2 Servers running in a Linux environment

In Linux there are multiple ways to force shutdown/kill all the process of a certain type. If we want to force shutdown all the WSO2 Servers that are running on a particular node, we can easily execute the following command.
killall java
The problem with the above command is that it will force shutdown all the java process running on that node which are not WSO2 specific.

The following command can be used to force shutdown or kill all the WSO2 servers that are running on a particular node and leave the other Java process intact.

ps -ef | egrep 'wso2' | mawk '{print($2)}' | xargs kill -9

How to Base64 Encode/Decode in Ubuntu command line

There are many situations where we need to get a Base64 Encoded string or a decode an already encoded string.

We can use the Linux command line to achieve this easily.

Encode a String: 


To Encode the string "admin:admin" we can use the following command.
echo -n 'admin:admin' | base64
This would give a result similar to the following.
YWRtaW46YWRtaW4= 


Decode a String:


To Decode the string "YWRtaW46YWRtaW4=" we can use the following command.
echo "YWRtaW46YWRtaW4=" | base64 --decode
This would give a result similar to the following
admin:admin