Changing Directory Ownership via Command Line

Trying to replace, delete or change files via FTP, you may notice you get insufficient permissions errors. If you haven’t seen this a lot, your first instinct is to try to change the permissions on the directories in question, in which case you will continue to get mooned. This issue is less about permissions per se than about directory ownership. If you’re running on a server that has some directories owned by nobody/99, that means the server itself is considered “owner” and individual users won’t be able to change or delete these. ((If your server requires 777 permissions for certain functions, then you most likely will have some directories “owned” by the server/nobody.))

chown -Rv username:groupname *

The username/groupname should be replaced with your info–but you don’t know this already, best to get out of there and get tech support to help you–and these two will normally be the same. The R makes it recursive, changing the files inside the directory as well as the directory you run the command on, and the v gives you verbose output so you can see what got changed.

Share Button

Restarting dbus via Command Line

As a companion to our “Restarting Haldaemon from the Command Line” piece (coming in handy after software update where you get those annoying ConfigServer firewall warnings “Suspicious process running under user dbus”), here’s what you need to do to restart dbus from the command line:

/etc/init.d/messagebus restart

Note: Your server configuration may vary.

Share Button

Transferring Databases via SSH Command Line

Command Line Fu has a solution for those who have SSH access and need to move a database:

To create a new database with a different name:

ssh -C user@newhost "mysql -uUSER -pPASS -e 'create database NEW_DB_NAME;'" && mysqldump --force --log-error=mysql_error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@remotehost "mysql -uUSER -pPASS NEW_DB_NAME"

To use the same database name for target as the source:

mysqldump --databases --force --log-error=/root/mysql_error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS"

If you’re using SSH on a non-standard port (recommended), you’ll need to add a parameter for it in your code after the ssh command, such as -p XXX, where “XXX” is replaced by your port number.

Share Button

Restarting Haldaemon from the Command Line

Have a need to restart Haldaemon? I did, p0inted out from the ConfigServer Firewall (CSF) error report:

The file system shows this process is running an executable file that has been deleted. This typically happens when the original file has been replaced by a new file when the application is updated. To prevent this being reported again, restart the process that runs this excecutable file. See csf.conf and the PT_DELETED text for more information about the security implications of processes running deleted executable files.

From command line prompt: /etc/init.d/haldaemon restart

At least, that’s where it was on my system.

Share Button

Enabling Secure FTP for User via SSH

Enabling Secure FTP for user via Command Line (from Hostgator forums):

chsh -s /usr/libexec/openssh/sftp-server <username>

Share Button

Putty: Setting up SSH Keys to New Server

When setting up a new server, you’ll want to set up your SSH Keys so you can remotely access without having to type in root password. Info for using putty, the simple, lightweight, open source SSH client.

Download Putty and the keygen tool here | Instructions for generating keys here

  1. Use Putty Keygen to create a public/private key pair and save locally. Make sure you use RSA keys, SSH2, and DO save a passphrase.
  2. Log into WHM -> Security -> Manage SSH Keys -> Import Key
  3. Paste Public and Private Key Pair into boxes provided. Add your pass-phrase and import.
  4. Make sure putty is set to use your private key, and connect to your server. (See image below)
  5. Log in as Root and use passphrase, which will be required to log in.
putty add keys
Browse to your private key & save this connection
Share Button