Capture, upload screenshots from cmdline

image_editor_compThere are numerous GUI screen capture tools (like HotShots) which can upload the images to file hosting services like imgur. What if you want the same action from the cmdline? It’s very much possible. This article explores some cmdline utilities (scripts) which can be used to grab and upload images. Continue reading Capture, upload screenshots from cmdline

More network tools from ntop devs

If you are not familiar with it, ntop is a tool that shows the network usage, similar to what the popular top command does. While ntop is a very useful utility, the developers didn’t stop at that. They offer many more free network utilities for network monitoring, capture, replay, analysis and VPN. In this article we will explore those. Continue reading More network tools from ntop devs

unp: single command to extract archives

We explored patool in one of our earlier articles. unp (abbreviation of unpack) is a similar utility which detects the compression type of a file and extracts it. Though it is less powerful than patool by flexibility, it compensates through ease of use, supports commonly used formats and does what it claims. unp is written in python. Continue reading unp: single command to extract archives

Share huge files from the terminal 2

transfer_compThis is the follow-up to the earlier article with the same name. Here are some more services to upload files directly from the console:

wsend.net

wsend is the opposite of wget. Once an upload is complete, it will give you a link to the file.

To install wsend:

wget https://raw.githubusercontent.com/abemassry/wsend/master/install.sh -O - | bash
alias wsend="~/.wsend/wsend"
OR
wget https://wsend.net/wsend
chmod +x wsend

To upload a file:

./wsend file.txt

chunk.io

No registration or installation needed. To upload:

$ curl -T path/to/file chunk.io

chunk.io will return the path to the file as payload it will show in the terminal.

fh.tl

Send any text file from anywhere to the service and it will send you back the link to the text. Particularly useful for debugging.

To send the text file:

$ cat test.txt |curl -F 'paste=<-' http://fh.tl
OR
$ df -h |curl -F 'paste=<-' http://fh.tl

cpulimit & taskset: control process CPU affinity & usage

cool_penguin_smallPlaying with processes on Linux is always fun. cpulimit and taskset are two cool and useful utilities to control the behaviour of your processes at a CPU-core level.

cpulimit

Lets you control or limit the CPU usage of a process. This will make a processor intensive process take longer to finish but will allow other processes to utilize the CPU. cpulimit works on both single or multi-core environments. Run the following command to install cpulimit on Ubuntu:

$ sudo apt-get install cpulimit

The easiest way to use cpulimit is to add cpulimit -l perecentage_of_cpu before your usual command. For example:

$ cpulimit -l 20 ghb

will run HandBrake (ghb) and force it to use around 20% of your processing capacity. cpulimit has options to attach to an already running process:

-p PID : attach to the process with PID process ID
$ cpulimit -l 20 -p 1234
 
-e prog_name : attach to the  executable with name prog_name
$ cpulimit -l 20 -e ghb

The -b option runs cpulimit in the background.

taskset

taskset is a wrapper to the sched_setaffinity system call. Use it to control which processor core(s) a process can run on.

To start HandBrake on cores 0, 2 and 3:

$ taskset -c 0,2,3 ghb

To make a process with PID 1234 run on cores 0 and 2 (the output will show the current and changed affinity):

$ taskset -c -p 0,2 1234 //note: 0,2 comes after -p followed by PID
pid 1234's current affinity list: 0-3
pid 1234's new affinity list: 0,2

As you can see, before changing the affinity, the process could have run on any core from 0 to 3 (I have a quad core device). That’s the general affinity of any process started without taskset.

To know the current affinity of any process:

$ taskset -c -p PID

You can also use ps:

$ ps -o pid,psr,comm -p PID

Share huge files from the terminal

transfer_compThere are many web services to share large files. We explored some of those is an earlier article. Here are some services those allow uploading files from the terminal. Both of them use curl to upload.

transfer.sh

  • Drag any file to the website and get the link in return.
  • Upload large files.
  • Create an alias in .bashrc to upload files
    transfer() { curl --upload-file ./$1 http://transfer.sh/$1; }
    alias transfer=transfer

    Upload a file using

    $ transfer hello.txt
  • Files can be download maximum 20 times to prevent abuse.
  • Link remains live for 2 weeks.

cURL.io

The major drawback of cURL.io is that you need to open the browser to get a link for file upload.

  • Share files either encrypted or non-encrypted.
  • Uses gpg for encryption.
  • You need to open the website to generate the command to upload. This is necessary because the unique key is generated beforehand and there is no dedicated client side software. Paste the file path in the text box and the console below will show the generated command. Works for both secure and insecure mode.
  • Maximum file size is 5 GB and is deleted in 4 hours.

Record, share terminal sessions

terminalThis article is the continuation of the earlier article to record a terminal session as an animated gif image. I found some more services which make it very easy to record your terminal activities and share with friends or for future reference.

Asciinema

Asciinema was inspired by script. Record terminal and share online with friends. You can copy and paste text from the recordings. On the downside, it lets you watch the video online only and if you need more control like embed or delete you need to create an account.

  • To install on Ubuntu
    $ sudo apt-add-repository ppa:zanchey/asciinema
    $ sudo apt-get update
    $ sudo apt-get install asciinema

    To install on other distros check the instructions.

  • Start the recording
    $ asciinema rec
  • Press ^D or type exit to finish recording
  • The app will ask whether to upload the video. Press y. If you don’t you will not have any local copy. Once the upload is complete it will show you the link to the video.
  • If you have an account (which you need to create from the webpage) you can then authenticate and have more control on the video:
    $ asciinema auth

Monitor

Monitor is the newest tool in this list. The recordings are uploaded to commands.com. You can also download the scripts (check the installation step).

  • The easiest way to install on Ubuntu is to install using a captured script
    $ curl commands.io/install-monitor-ubuntu
  • To use Monitor you need to have an account on commands.com.
  • Usage is simaple
    $ monitor {-d} {-h} {-u }
        -d : do not delete /tmp files
        -h : help
        -u : commands.com username

    For example:

    $ monitor -u myusername

Showterm

Showterm is a Ruby tool that follows a similar philosophy as the previous two. There are options to provide the playing speed (slow or fast) in the embeddable link URL.

  • Install on Ubuntu (in case you do not have Ruby). Check for other option here.
    $ curl showterm.io/showterm > ~/bin/showterm
    $ chmod +x ~/bin/showterm
  • Run showterm
    $ showterm
    //or if you haven't installed showterm
    $ bash <(curl record.showterm.io)
  • Type exit ot ^D to end recording. Showterm will upload the video and show you the link to the video.

TermRecord

TermRecord save your recording locally as a sel-contained html file and you can replay it in your browser. It doesn’t have any corresponding web service to upload the recordings. TermRecord comes with several templates for the generated html files. You an play around with them. TermRecord also depends on script, term.js, Ubuntu Mono font and Jinja2.

  • The easiest way to install it is
    $ sudo apt-get install python-pip
    $ sudo pip install TermRecord
    $ TermRecord -o /path_to_output/record.html

PLAYterm

Run ttyrec, record your session and upload the .tty file to PLAYterm. It will play the recording in a beautiful embedded player. Share the link with your friends or embed on your website.