Broadcast your shell thru port 5000

2010-11-20 1 min read Bash Fedora Linux

Broadcast your shell thru port 5000

  <td>
    <div class="text codecolorer">
      mkfifo /tmp/fifo;(nc -q0 -l 5000 < /tmp/fifo &);script -f /tmp/fifo
    </div>
  </td>
</tr>
1

run

  <td>
    <div class="text codecolorer">
      nc yourip 5000
    </div>
  </td>
</tr>
1

elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.

Continue reading

Screen enable/disable logging in all windows

2010-11-19 1 min read Bash Learning Linux

If you use screen command a lot then this is something that you will like 🙂

Screen enable/disable loggin in all windows

  <td>
    <div class="text codecolorer">
      bindkey ^l at "#" log on<br /> <br /> bindkey ^o at "#" log off
    </div>
  </td>
</tr>
1
2
3

The command when added in screenrc enables logging all open windows by using the C-l (control-l key combination) and disable by C-o . The lines need to be added in separate lines .

Continue reading

function for copy files with progress bar (using pv – pipe viewer)

2010-11-11 1 min read Bash Linux

function for copy files with progress bar (using pv – pipe viewer)

  <td>
    <div class="text codecolorer">
      &nbsp;cp_p() { if [ `echo "$2" | grep ".*/$"` ]; then pv "$1" > "$2""$1"; else pv "$1" > "$2"/"$1"; fi; }
    </div>
  </td>
</tr>
1

dont have to type new file name (it copy file under same name) and dont have to use ‘/’ in the end of destination folder (but you can if u want, its idiot proof)

Continue reading

Print all environment variables, including hidden ones

2010-11-09 2 min read Bash Fedora Linux

Print all environment variables, including hidden ones

  <td>
    <div class="text codecolorer">
      for _a in {A..Z} {a..z};do _z=${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -Tsv
    </div>
  </td>
</tr>
1

This uses some tricks I found while reading the bash man page to enumerate and display all the current environment variables, including those not listed by the ‘env‘ command which according to the bash docs are more for internal use by BASH. The main trick is the way bash will list all environment variable names when performing expansion on ${!A*}. Then the eval builtin makes it work in a loop.

Continue reading

List all the rpms by size – quick way to find out what is eating your disk space in root partition

2010-10-13 1 min read Bash Fedora

Here is a quick command to check the list of installed packages by their size in reverse order. Very useful if you want to remove unwanted rpms just to clean up some space on your disk:

  <td>
    <div class="text codecolorer">
      rpm -q -a --qf "%10{SIZE}\t%{NAME}\n" | sort -k1,1nr |more
    </div>
  </td>
</tr>
1

Sample output:

78070452    kernel
78060477    kernel
50708634    jre
50316408    libgcj
48581593    wireshark
47778643    gimp
47674675    jre
47303084    qt-x11
45838912    otrs
45657248    chromium-libs
42070128    wxPython

Continue reading

Quick tip on zipping logs in real time.

2010-10-13 1 min read Bash Learning Linux

Sometimes, some small things that we don’t actually think can be useful are such useful. I faced this couple of days back when I was working on something and the amount of logs getting generated and the files getting rotated was too fast. If I had to use this for sometime, I needed some script, application or something to make sure that the logs are zipped every few seconds. Finding an application for this would take time and what good is bash if we need to find applications for this. So, a simple bash command did the trick. Most of us would know this but applying it and using it at the right time, was what saved my life. Thanks to bash. Here is the command:

Continue reading

Resize all the images in directory.

2010-10-04 2 min read Bash Linux Photo
Geotagger "Solmeta N2 Kompass" for N...
  <dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">
    Image via <a href="http://commons.wikipedia.org/wiki/File:Solmeta_N2_auf_Nikon_D5000_Rueckansicht.JPG">Wikipedia</a>
  </dd>
</dl>

When I take a photo with my DSLR Nikon D5000, the size of the image comes to around 5MB and I know that with my point and shoot camera also it does not come to any lesser than 3MB. Definitely this is quite good to keep the images in the same size for use but when it comes to on-line sharing I don’t think this is the size that is required. I guess mosr of the time 1024×768 is sufficient. Even if you are sending the images in email, you cannot afford to send a lot of images of this size even with a gmail account.

Continue reading
Older posts Newer posts