March 2007


I found myself wanting to create an extra FTP user for one of my Plesk machines that would only have access to a subdirectory of one of the machine’s domains.

It turns out this isn’t as tricky as I made it!

If you create a new OS user giving them the same user ID number as the primary FTP user and the Plesk group ‘psacln’, they have the same privileges. Giving them a home directory of the subdirectory instead of the primary user’s home directory chroots them inside it.. perfect.

1. Determine the uid number of the primary user (bob)


# cat /etc/passwd | grep bob
bob:x:10021:10001::/home/httpd/vhosts/bob.org:/bin/false

2. Create the new user with the same uid number, group, and shell (if you wish) but with a new home directory.

# useradd -u 10021 -o -d /home/httpd/vhosts/bob.org/httpdocs/bobs_subdir -g psacln -s /bin/false bob
# passwd bob

Give them a password and you’re done!

Thanks to this post on the SWSoft forums
http://forum.swsoft.com/showthread.php?postid=118777

Counting files in a folder
ls -1 | wc -l

Deleting a lot of files when plain ol rm won’t work
find . -name 'prefix*' -print0 | xargs -0 rm

Find files containing a text string
grep -lir "some text" *

Find files recursively containing a text string
find . -type f -exec grep -l "some text" {} \; -print

The -l switch outputs only the names of files in which the text occurs (instead of each line containing the text), the -i switch ignores the case, and the -r descends into subdirectories.