vsftp
Sometimes it is nice to have an ftp server, you might have Samba and ownCloud, but sometimes you really need ftp to do something. It is the right tool at the right time and I can’t imagine running a server without FTP installed.
sudo apt-get install vsftpd
Edit the configuration file
Back it up first then do an edit
sudo cp /etc/vsftpd.conf /etc/vsftpd.orig
sudo nano /etc/vsftpd.conf
uncomment local_enable = YES
uncomment write_enable = YES
In this manner you will be able to read and write to your home directory. With SSH and FTP you can do just about anything remotely to your server. You can ( put ) FTP a file up to your home and move it anywhere and in the opposite direction also ( get ).
For example I downloaded the zip file for the OwnCloud Music App on a Windows computer, then FTP’d it the Linux server into my home directory and moved and unzipped it in the proper directory using SSH. Zip/unzip is not loaded by default with the Ubuntu Server disc, to get it see below.
This is powerful and with that power comes danger. You don’t want anyone to be able to SSH and FTP in, so be careful when opening these ports. I get “hits” on port 22 for SSH a lot, I don’t even open port 21 for FTP outside of my LAN. When I mean hits, I mean I can see IP addresses come in on my routers log that are from outside the US, by looking them up, or browsing to them. Sometimes using a ping command to the IP a return will come from another IP. These cyber-criminals try to get in on open ports.
vsftp website…
https://security.appspot.com/vsftpd.html
Zip/unzip is not loaded by default with the Ubuntu Server disc
Zipping and unzipping files from the CLI is an important thing to be able to do.To get it…
sudo apt-get install zip unzip
More info on how to use it….
http://askubuntu.com/questions/86849/how-to-unzip-a-zip-file-from-the-terminal
dos2unix
Editing shell or config files on a Windows machine, presents you with the CR-LF and LF issue, for Win and UNIX respectively. Scripts won’t run, problems happen with config files when they are not in the right format. Frequently I encounter this when I coy and paste some code from the Web into eMacs or Notepad, then save it on the Linux server. Then I need to execute dos2unix on it to make it run right.
UNIX and DOS endlines
I had a brain dead moment where I forgot about the entire UNIX and DOS endline thing when I was working on getting the server to auto shutdown.
So when I grabbed the autosuspend script with copy and paste and I brought it into eMacs in Windows, saved it to my /files/public folder on the server and tried to execute it. Lots of $’\r’: command not found.
The solution is to use dos2unix to convert the endlines, if you don’t have it, just do…
sudo apt-get install dos2unix
Then do dos2unix filename and it will modify it in place. Which is good but beware of this default behavior. It does have other options, which can be explored using dos2unix –help.
It’s one and only job is to remove CR-LF (Carriage Return-Line Feed )and just leaving LF ( Line Feed ) as UNIX/Linux wants it to be. If a file acts screwy when brought in from Windows it is most likely this issue. I even had to do it on the autosuspend.conf file!
You can always check a file with the command
cat -e filename
BAD example…
#!/bin/bash^M$ ^M$ # Source the configuration file^M$ . /etc/autosuspend.conf^M$ ^M$
GOOD example….
#!/bin/bash$ # Source the configuration file$ . /etc/autosuspend.conf$ $
The caret M$ is DOS, $ is UNIX.
Emails using ssmtp
It is great that CRON and other applications send an email to the root on a Linux server, which can be read simply by using mailx from the CLI. But, what if you are not logging into the machine very often at all. Using ssmtp might work well for those situations. Even my Netgear N150 router has something similar as far as sending email. On the router, you input email account settings on it and will email you the log file and other information you would like at regular intervals. Ssmtp may be of interest to me with regards to the server at some point and I have noted it for reference.
It would be interesting and a great idea to have the server be able to send emails of certain things, issues it may be encountering.
This looks interesting, I might do this at some point….
2 thoughts on “Additional utilities for a Linux Server”