Home Download Ubuntu

"start: Unknown job: ssh" error while running Xubuntu Live CD

I tried running Xubuntu Live CD on an older laptop, but ssh server didn't wanted to start.
Running the start init.d script

sudo /etc/init.d/ssh start

showed me this error "start: Unknown job: ssh"
Searching for an answer lead me to this ubuntuforums.org post and this stackoverflow post. None of those solutions worked, however they helped me in a way to solve this problem.
Xubuntu Live CD doesn't have ssh server installed by default. I installed the ssh client and server:

sudo apt-get install ssh openssh-server -y

and I tried to start it when it gave me the error.
By running the ssh server manually
/usr/sbin/sshd -D

showed me this error "Missing priviledge separation directory: /var/run/sshd"
By creating this directory, the problem was solved:
sudo mkdir /var/run/sshd

Now, I can simply run
/usr/sbin/sshd -D

and the ssh server works

Bad "End Of Line" (EOL) for bash script under windows

The other day I was writing a script in Notepad++ under Windows. This file was saved on a linux machine but I had a surprise when I tried to run it. Ubuntu's bash complained about "bash: ./script.sh: /bin/sh^M: bad interpreter: No such file or directory". This  lead me to a stackoverflow post about this problem and how to solve it.

For an already opened document, goto Edit menu, EOL Conversion and select Unix/OSX Format. The file has been converted, you only need to save it and run it.


If you want all your new files to have the Linux EOL, goto Settings, Preferences, click the New Document/Default Directory tab, and under the New Document, Format legend choose Windows/Mac/Linux. All your future text document will have the Linux new line (EOL).

Dump all MySQL databases into separate files

Sometimes we need to to dump all databases form a MySQL server. This can be done using the mysqldump utility with the --all-databases switch enabled. In this case mysqldump will dump all databases to the standard output or to a file if explicitly specified. Let’s assume a situation where we want to backup all of the databases from the server, with the possibility to restore only one database at a time. To achieve this, you need to dump all the databases one by one or to use a pre-made script to do the heavylifting for you.  I’ve found a simple solution here: http://soniahamilton.wordpress.com/2005/11/16/backup-multiple-databases-into-separate-files/. I used this script as a starting point, and made some enhancements to it: 1. MySQL username can be specified from the command line (it’s not hardcoded in the file)
2. The script asks for the corresponding MySQL password for security reasons (the password is not echoed or saved anywhere – as you would expect on a Unix systems)
3. The output dir can also be specified from the command line
4. Support for gzipped output files (optional)

Usage

Download the dump-all-databases.sh. Make it executable using chmod +x dump-all-databases.sh.
Run it:
./dump-all-databases.sh -u user -o my_backup_dir -z

The command line options are the following:
  • -u – the MySQL user
  • -o – output dir (optional, if not specified the dump files will be placed in current directory)
  • -z – enables the gzipped output (optional)

Download

dump-all-databases.sh

System requirements

Unix/Linux system with mysql and mysqldump installed, for gzipped output gzip is also required.


Resources: http://carrotplant.com

A different approach to change MySQL root password in Ubuntu Server

The other day I was having a problem with the MySQL server on my Ubuntu machine. After connecting to mysql server in php, I could not select a database. The error was: Access denied for user ''@'localhost' to database foo. I did specify the user being root, but it keept saying I don't have permissions with the user '' (anonymous). Reinstalling mysql didn't do the job. So, let's delete the user ''.

1. Stop the MySQL Server:

sudo /etc/init.d/mysql stop

or
sudo service mysql stop

2. Start the mysqld:
sudo mysqld --skip-grant-tables &

Press CTRL+C (^C) to be able to enter the new command.
3. Login to mysql server:
sudo mysql -u root mysql

4. Delete the user '':
If you enter the following command:
SELECT USER(),CURRENT_USER();

you will see that the users are different, one being '' and the other root.
Delete the anonymous user:
DELETE FROM mysql.user WHERE user = '';

Update root password (optional, if you know it):
UPDATE user SET Password=PASSWORD('1234') WHERE User='root';

5. Stop mysql server instance:
ps aux | grep mysql

On the second column, you will find the PID (process id) of mysql server. Kill it:
kill 20233

6. Start the usual mysql server:
sudo service mysql start


Resources: ubuntu.flowconsult.at

Change PureFTpd passive ports

If you are behind a firewall and you want to narrow the range of ftp passive ports, run this:

echo "29799 29899" > /etc/pure-ftpd/conf/PassivePortRange

where 29799 29899 is your port range. this configuration is for 50 clients. and yes, you need to have 2 ports for each client.

You might also consider creating a config for max clients:

echo "50" > /etc/pure-ftpd/conf/MaxClientsNumber

Restart pure-ftp-mysql:

/etc/init.d/pure-ftpd-mysql restart

Resources: www.howtoforge.com