Skip to main content

netcat

File transfer

Most of the time we are trying to transfer file over network and stumble upon the problem which tool to use. There are again numerous methods available like FTP, SCP, SMB etc. But is it really worth the effort to install and configure such complicated software and create a sever at your machine when you only need to transfer one file and only once.

Suppose you want to transfer a file “file.txt” from A to B

Anyone can be server or client, lets make A as server and B as client.

Server

$ nc -l 1567 < file.txt

Client

$ nc -n 172.31.100.7 1567 > file.txt

Here we have created a server at A at redirected the netcat input from file file.txt, So when any connection is successfull the netcat send the content of the file.

Again at the client we have redirect the output of netcat to file.txt. When B connects to A , A sends the file content and B save that content to file file.txt.

It is not necessary do create the source of file as server we can work in the eopposeit order also. Like in the below case we are sending file from B to A but server is created at A. This time we only need to redirect ouput of netcat at to file and input at B from file.

B as server (Server)

$ nc -l 1567 > file.txt

Client

$ nc 172.31.100.23 1567 < file.txt

Reference: http://mylinuxbook.com/linux-netcat-command/

Presentation on collectd / Graphite for PLUG

Below is my presentation from April for the Portland Linux/Unix Group (PLUG) Computer Group Advanced Topics Meeting. I wish I could thank the second person who jumped in and help answer some of the questions that I didn't have answers to.

There is a Version 1.0 (my draft), as well as a Version 1.1 (what I presented from) LibreOffice Presentation attached. Please contact me if you have any questions. I'm hoping to add some more Articles on this website when time allows (when does it ever?).

[http://www.tbruce.com/PLUG%20-%20Monitoring%20Presentation%20v1.0.odp] [http://www.tbruce.com/PLUG%20-%20Monitoring%20Presentation%20v1.1.odp]

I need to fix these URLs...They are not correct going forward.

MySQL Security Concern

Soemtimes when I encounter bugs, I have to sit and determine if they are a bug or just an issue. Or maybe, sometimes, it's how I think about something. In this case, maybe it's my process. In any case, I'm writing this up so I don't forget about it, and to share it with the larger community. This "bug" is with both MySQL v3.21 and v4.01 (I found it on 3.21 and verified it against v4.01 in my test environment).

For a little background. Several months ago I built a database for a friend on my web / database server. I added his user account so he could log in directly and created a database for him. I guess the name I chose for the database I built wasn't the best, as I deleted the database and removed his account from my system as the software (I named the database after the software I installed) didn't meet his needs (I used the MySQL commands "DROP USER 'xxx'@'localhost' and DROP USER 'xxx'@'%'". Everything looked good and I didn't see his name under the list of logins anymore (SELECT * FROM users WHERE user_login = 'xxx').

Having completely forgotten about this, I installed a newer version of the software for myself to look at a couple of weeks ago. And then last week, I re-added my friend back onto the server and granted him access to a different database. Imagine my surprise when he Instant Messaged me and asked why "his" database was still there, and what was all my data doing in it. It turned out that just dropping the user didn't remove the account access to the database, and I should also have executed a "REVOKE ALL PRIVILIGES FROM 'xxx'@'localhost' and REVOKE ALL PRIVILIGES FROM 'xxx'@'%'" on his account.

I'm not sure if this is a bug or just a detail in implementation. (And lucky for me I didn't have anything critical in there and that I trust him completely on my systems!)

lowspace.sh

This script is called from a cron job (scheduled task) and emails me on a daily basis this data so I can track disk space usage. I install it on all my systems (though I should probably do something different, like store the values in a database or something).

click to read the rest of the article

Creating A Drupal Database

The following SQL will create a PostgreSQL database for Drupal. I'm calling it drupal in this case, but you can call it whatever you want.

CREATE DATABASE drupal
 WITH OWNER = drupalweb
      ENCODING = 'UTF8'
      TABLESPACE = pg_default
      LC_COLLATE = 'en_US.UTF-8'
      LC_CTYPE = 'en_US.UTF-8'
      CONNECTION LIMIT = -1;
GRANT CONNECT, TEMPORARY ON DATABASE drupal TO public;
GRANT ALL ON DATABASE drupal TO drupalweb;

Uptime vs Availability

Do we need to sacrifice system uptime against system availability. And I use the term system availability to identify both uptime and unscheduled outages. So here system availability includes time from both unscheduled and scheduled outages. Why would I ask such a thing? Systems crash for all kinds of reasons: failure in the garbage collector to collect objects or collecting the wrong objects. So why do we need to do regular scheduled reboots of the system?

click to read the rest of the article

Finding the UUID for Linux Drives

UPDATE: I use the term "Drives" here for two reasons. One, people coming from Windows understand a harddisk drive (generally C: or another "device" letter). Two, this is specific to harddrives and not other devices in Linux (like the terminal, printer or scanner).

The Universally Unique Identifier (UUID) is a good way to mount drives under Linux with SATA drives (or any drives, PATA or IDE). This ensures that when you have more than one harddrive, it always gets mounted to the same location specified in /etc/fstab. The reason is that SATA drives are mounted when they're found and on one reboot can come up as /dev/sda and the next time as /dev/sdb.

So in order to set up your file system table correctly, you should specify the UUID instead of the physcial device. So your /etc/fstab will look like this:

Ok, so if you want to use the UUID, how can you find it? We're assuming the drive is already mounted, of course!

One way is to use

$ ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 11. Okt 18:02 485554c3-e681-4254-9344-6f038c826fb8 -> ../../sda2

This will list all the devices by UUID and tell you where they're currently mounted. Another would be to use the blkid command.

# blkid /dev/sda1
/dev/sda1: LABEL="/" UUID="485554c3-e681-4254-9344-6f038c826fb8" SEC_TYPE="ext2" TYPE="ext3"

One problem with this is that the blkid command can only list one device at a time. A secondary problem is that the command blkid has to be run as the root user.

Additional information can be found by googling Linux and UUID.