Add one or more folders to .zip archive

To add single directory (with all files and sub-directories) simply execute:

zip -r name_of_your_directory

To add all contents of current directory (again, recursively) call instead:

zip -r *

While to add two or more directories (but not all) in current directory — list them:

zip -r directory_a directory_b directory_c

Call just zip to see all switches, options etc.

chown: Recursively change owner of all files and folders

Sometimes QNAP changes file owner to admin:administ (actually to admin:administratorsadmin user in administrators group) which may cause some troubles on certain FTP operations when you’re logged in to QNAP’s FTP server with user different than admin (using this user to operate on FTP is a quite great mistake and you should always use other, less privileged user for this).

Using chown command you can easily fix this.

Read More “chown: Recursively change owner of all files and folders”

Change prompt and enable command auto-completion [updated]

I really like some simple extensions and changes to command line in Linux. An ability to enable command auto-complete, commands history navigation and changing prompts look in particular.

However, not every console is suited with these changes, so I wrote this simple article to keep all my how-tos around Linux command line in one place.

Read More “Change prompt and enable command auto-completion [updated]”

Get WebSVN to QNAP

This guide assumes, that you have svn already installed on your QNAP, fully configured and working like a charm, and you just want to enhance it with web client (WebSVN). You can use this guide also on any other server, than QNAP, but keep in mind, that it contains some QNAP-specific problems.

Keep in mind: WebSVN (as good as all other alternatives mentioned in the end of this text) are read-only web SVN clients! You can do a lot of useful stuff on your repos, but forget about committing or anything similar that requires write access or changing repository structure.

Read More “Get WebSVN to QNAP”

Installing and configuring FTP server on on Ubuntu 12.04 and adding users

As for good FTP server for Ubuntu I’ve choosen vsftp server, though it has some glitches (more here), after fairly good response in the Internet. Many guides shows how to configure and use vsftp on local users, though giving them, by default, access only to their home folder. And allowing them to access server via SSH.

Which is not, what we want in most cases.

I’ve found a good guide, which shows you how to add ftp users with access to folder inside WWW root only.

Read More “Installing and configuring FTP server on on Ubuntu 12.04 and adding users”

Fixing 500 OOPS: vsftpd: refusing to run with writable root inside chroot()

Unfortunately, Ubuntu 12.04 LTS has vsftpd (very famous FTP server) in version 2.3.5 as latest one, which is affected by well know problem of disallowing users to login and throwing

500 OOPS: vsftpd: refusing to run with writable root inside chroot()

error, when using default vsftpd configuration (including a must-have chroot_local_user=YES setting).

There are few ways of working around this problem and most of them are discussed in this post.

Read More “Fixing 500 OOPS: vsftpd: refusing to run with writable root inside chroot()”

Finding Apache installation path and configuration file

There are several ways to determine, where Apache has been installed on your Linux/Unix system and what are other imporant paths for it (WWW root, configuration etc.). You can use this nice blog entry, which in general means executing ps -ef | grep apache to determine path and then running /usr/sbin/apache2 -V with proper path (replace /usr/sbin/ part) to determine Apache configuration details.

You can also use DistrosDefaultLayout page in Httpd Wiki to find default path layout for your particular operating system.

If everything else fails, try to help yourself with Installation and setup of the Apache Web Server (Linux) document.

Copy large folders using command-line with progress indication

By many sources cp is mentioned as the fastest way to copy large filesets. And the only fault of it, is that it does not provide an easy way to see progress of copy process. This post discusses various ways of fixing this problem. Keep in mind, that this post is (again) QNAP-optimized, meaning that it mostly focuses on solutions available on my old, lame QNAP TS-210 NAS system. It only points out other methods, that are not available on this very limited edition of Linux.

Read More “Copy large folders using command-line with progress indication”

Scanning all incoming traffic. Proper use of tcpdump

I had to do some strange listening stuff with even more strange Chineese GPS locator, that was weird enough to use UDP protocol only. Since there was absolutely no technical guide for these devices (at least, when I was looking for them), I had to listen for everything on every port of my local server to see, what this damn box is actually sending.

Since I’m kind of Linux newbie, I asked this Unix & Linux question and got answer enough worth for me, that I decided to put some summary of them to my own blog.

Read More “Scanning all incoming traffic. Proper use of tcpdump”

screen: Force program to continue after logging-off from the console

So, there I was… needing to have any solution, that will allows me to write my very own port listener. Since the only language, in which I am handy is PHP, I was forced to be able to run PHP script without interruption, 24 hours a day, 7 days a week. That was a bit of challenge for me, given my quite very limited Linux knowledge, but — as they say — the only thing not possible in IT is to open an umbrella in your ass! :>

Read More “screen: Force program to continue after logging-off from the console”

Installing SVN on QNAP using IPKG (Optware)

This article is based on information provided by QPKG package created for SVN by noski and on QNAP Wiki article about SVN and of course a piece of my experience. But since SVN is relatively easily to install by-hand (so you don’t actually need QPKG package) and since Wiki article about SVN is outdated / contains some garbage (directory /share does note belong to /dev/ram!), I decided to write my own guide.

Read More “Installing SVN on QNAP using IPKG (Optware)”

Fix for problem with mixing USB shares on QNAP

Most QNAPs randomly mounts USB disk shares. I.e. you can have disk attached to left USB port as USBDisk1, second as USBDisk2 and after reset — changed together. This causes many problems, where being unable to write some script accessing particular disks could be named at first. There isn’t an easy way to work around it. The only solution I found out was to write an script that resides in flash memory (therefore is called upon each restart of QNAP) and that mounts disks under shares similar to their disk labels.

Read More “Fix for problem with mixing USB shares on QNAP”

Remove non-empty directory on QNAP or Linux

You may try to use rm -rf [directory] to delete given directory along with all its content (including all subdirectiories and all files). Use this with caution, to not end up deleting all files on your root! :>

Note, that on QNAP (but not on regular Linux) you have to start your session as admin user, as you cannot use su command to become root. If you try this, you’ll end up with error su: user root does not exist.

No Samba access after password change

Let us understand it. Windows is stupid and idiotic system. Suppose, you store (remember) your NAS’s Samba username and password, so you don’t have to provide it, each time you access your local network share. If you thenchange your user password, Windows either won’t detect the fact that password has changed or, even if it detect it, it won’t show you login/password dialog box to provide new one. Instead, it continue to provide NAS with wrong (outdated) password.

Read More “No Samba access after password change”

Introduction to bash scripts

While playing with some extra features on my newly purchased QNAP TS-210 at some point I was forced to finally write some bash script to be able to control things, that are uncontrollable via administration panel. For this reason I had to learn myself at least basics of bash, that is installed on my QNAP. I used floppix page and Wiki as a base for my learning process (and source for this article), however I had to write down my own memo-list to be able to quickly find, what I’m looking for.

Read More “Introduction to bash scripts”

Incorrectly formatted external disk on QNAP TS-210

After using QNAP’s web-panel to format external disk, it suddenly turned out that formatting to any partition type ends with extremely small free disk size. For example, completely empty (as should be after format) 1,5 TB disk, formatted to any Windows type (FAT32 / NTFS) has only 1,9 GB free space. Formatting it to any Linux type (Ext3, Ext4) ends with 1,84 GB free space and formatting to HPS+ with 1,89 GB. In all attempts disk has less then 0,2% free space right after format. Here is the solution, that I came up with after a lot of digging.

Read More “Incorrectly formatted external disk on QNAP TS-210”

Patching some security problems in Samba

QNAP is built upon Debian, created and designed by a bunch of wise guys, constantly being improved and used around the world, sometimes in very important solutions. Thus, it is generally a safe and secured solution. On the other hand, there isn’t (there never was and there never will be) any thing, done by a human, that another human wouldn’t be able to breke, change, alter or destroy. So, there is always a good idea to improve security, whenever you’re possible to do so. This article discusses some smaller or bigger security holes in Samba on board QNAP with a possible solution or workaround.

Read More “Patching some security problems in Samba”