Wednesday, September 22, 2010

Simple File Sharing with Python SimpleHTTPServer

Have you ever come across a situation where you quickly need to share a file and you lack that quick expertise to setup FTP/Apache or Websphere. Python has this in built SimpleHTTPServer which can solve this and help you share any file in seconds.

For ex. you want to share some files in /appsData.

[root@DebaTestBox debu]# cd /appsData
[root@DebaTestBox appsData]# python -m SimpleHTTPServer 18000 &

Now you can see that your SimpleHTTPServer is running on port 18000

[root@DebaTestBox appsData]# netstat -lntp | grep 18000
Active Internet connections (only servers)
tcp 0 0 0.0.0.0:18000 0.0.0.0:* LISTEN 16889/python

[root@DebaTestBox appsData]# ps -ef | grep HTTP
root 16889 16861 0 05:48 pts/0 00:00:00 python -m SimpleHTTPServer 18000


Now go to any web browser and try to see the files as below:

http://YourServeripAddress:18000

Yay!! That's it !!!! You are now sharing your files without setting up a dedicated weblogic or apache or any FTP Server and it did not really ask for any prior hardcore knowledge of system administration.

Network ACL check whether a port is open or not:

This can even be used to test whether a port is open between two servers when the respective services on them has NOT yet been started. Run this server on the port which you want to check on the first server and do a telnet from the other box. This is one of way how you can test a Network ACL port open or not, probably in less than 10 sec ! Yeah? Enjoy!

Cheers!
DK

Tuesday, September 21, 2010

Best Free Online Scanner

You can keep a bookmark of the below free online scanners -

McAfee’s Freescan,
Trendmicro’s HouseCall, and
Symantec’s Security Check.

I have also come across Eset's scanners as well. Eset is a trusted name; their antivirus solutions have been a gold standard in security for many years now.


Enjoy!
DK

Sunday, September 19, 2010

See last modified File in UNIX

I strongly suggest installing a File Integrity checker like Tripwire on your server. Even if you don't have that we can always use 'stat' command of UNIX to see these stats on suspected file or file in question.

But there is less popular version of find command which can quickly check and list the set of files ordered by last modified time , that too in a matter of seconds. Not "what Got Changed" though! Just try it out :-)

find /etc -type f -printf "%T+ %p \n" | sort -n

-Cheers!
DK

Check a bash script without executing

This is really essential sometime, we want to check the syntax and validate our script rather then running it upfront.

Available Options:

Debugging Options set -o Option Command-line Option Action
noexec -n Don't run commands; check for syntax errors only
verbose -v Echo commands before running them
xtrace -x Echo commands after command-line processing


Example:

$bash -n myscript.sh
$/bin/sh -nv myscript.sh

Enjoy!!!
DEBU

Skip Linux History

Have you ever felt... you want to quit your bash session without saving your history? I am not sure for what good reason, but yes there are ways -

$ kill -9 $$

Here, $$ is the pid of the current bash instance.
Or,

$unset SAVEFILE;unset HISTFILE;

This way you can skipfast from being you session recorded in Bash History!!

PS. But I have usually seen this behavior specially amongst Freshers, trying to hide their mistakes out of panic, which is wrong. You should NOT hide it, rather report them actively. Error is inevitable in every sphere of human activity. Just we need to be sure about what we do and a bit careful while doing the same, that's it !!

Enjoy!
DK

Wednesday, September 15, 2010

My Favorite netcat(nc) combinations

Netcat(nc) has always been referred to as the legendary Swiss Army Knife of Networking. It is a single binary, which takes up about some KB of space of space on your disk, but yet so handy!! Below are some of my netcat favorite I use time to time.

See which ports are open on a particular server.

#nc -v -w 2 -z 172.16.80.70 1-65535

Checking disk status of a set of server mentioned in a text file wslist.txt


#for i in `cat wslist.txt`; do echo $i; ssh -q $i df -h|grep /data$|awk '{ if($5>=90) {print $5 "->Disk Danger"} else { print "Disk OK"}}' ; done

Check if port 22 is open a list of server mentioned in wslist.txt

#for i in `cat wslist.txt`; do nc -v -w 1 -z $i 22 ; done

Transfer a file from Server A to Server B on a specified port.

Server B
nc -l 1337 > dk.txt

Server A
nc 172.16.80.70 1337 <>

[rick@TestBox ~]# nc -l 1337
Hey Debu,did you know we can chat on the console like this?
@Rick, yeah! It's so cool man..


[debu@c00000005221 ~]$ nc 172.16.80.70 1337

Hey Debu,did you know we can chat on the console like this?
@Rick, yeah! It's so cool man..


Ctrl+d


Network Scan:


range="172.16.80."; port=80; for host in $(seq 1 255); do multi_task=$(result=$(nc -zv $range$host $port 2>&1 | grep succeeded); if [ -n "$result" ]; then echo $range$host":"$port >> "/tmp/pscan"; fi;) & done



Cheers!

DK

Sunday, September 12, 2010

How To Copy Windows CMD Output!!



Pipe the command to windows clipboard with the command ( | clip) and then paste(ctrl+v) it anywhere you want. yes! This example is something that your network admin asks the most. They need prove...always!!

Anyway - who says, tricks in *nix only makes the geeks rock!! After all Bill is still my trusted Gateway to reach Torvald !!! :-)

  🔭 First Impression: Exploring Grafana Mimir              ... After Years with Thanos! Not an observability( OE ) purist, but I do appreci...