≡ Menu

scp command

scp: Do not Overwrite Existing File On Linux or Unix System

I am a new Linux user. I use scp to upload files to net-storage provided CDN company. I do not want to overwrite the existing files. How can I prevent overwriting of files when using scp command under Linux, Mac OS X or Unix like operating systems?
[click to continue…]

Ubuntu / Debian Linux Server Install Keychain SSH Key Manager For OpenSSH

I do not want to start ssh-agent and ssh-add as described here to manage my ssh keys for password less login. How do I install keychain software to manage my keys running on a Debian or Ubuntu based cloud server?
[click to continue…]

Linux / Unix: scp Copy All Hidden Dot Files

I'm using scp command to copy files from one server to another server. The problem is that I'm unable to copy all hidden files (such as .bash_history). How do I copy hidden files using the scp command under Unix like operating systems?
[click to continue…]

Linux / UNIX: scp / rsync File Name With a Colon (:) In It

How do I copy a file with a colon punctuation (:) name in it. When I type the following command to copy "file:name.txt" to a remote host called server1:

scp file:name.txt user@server1:/path

I get the following error:

ssh: Could not resolve hostname s: Name or service not known

How do I copy file with scp or rsync with a colon in it?
[click to continue…]

UNIX / Linux: Rsnapshot Restore Backups

I've created the backup server using this tutorial under Redhat and Debian Linux systems. How do I restore files (such as /var/www/html) with rsnapshot backup tool? How do I restore MySQL database dumps with rsnapshot under UNIX or Linux operating systems?
[click to continue…]

Linux / UNIX scp Copy Hidden . (Dot) Files

How do I copy all hidden files from $HOME using scp command line tool?
[click to continue…]

Q. How do I copy all the file including subdirectories from DVD disk mounted at /mnt/dvd to /home/tom at a shell prompt under CentOS Linux?

A. You need to use cp command to copy SOURCE to DESTINATION or multiple SOURCE(s) to a DIRECTORY. Gnu cp command has -a option which copy directories recursively while preserving the file attributes such as mode,ownership,timestamps and security contexts, if possible additional attributes such as links et all.

cp command syntax

Use the following syntax:
cp -a {/path/to/source} {/path/to/destination}

For example copy all files including subdirectories from /mnt/dvd/data to /home/tom/data, enter:
$ cp -a /mnt/dvd/data/* /home/tom/data
$ cp -av /mnt/dvd/data/* /home/tom/data

Recursively copy entire directories

Many other command (including cp) support -r or -R option for copying file recursively. For example scp secure network copy command:
$ scp -r *.cpp remote_user@server.nixcraft.in:~
OR use cp command locally (instead of -a option):
$ cp -r *.cpp /path/to/dest

Howto install duplicity rpm under RedHat / CentOS / Fedora Core Linux

Q. I would like to use duplicity package to automatically encrypting and storing remote backups in a bandwidth efficient manner in our backup server. The server is already configured and I’d like to install the same under RedHat Enterprise Linux. How do I install duplicity w/o compiling from source code?

A. Duplicity is a piece of software which provides easy encrypted versioned remote backup of files requiring little of the remote server. It does this using GnuPG, tar, and rdiff. To transmit data it can use ssh/scp, local file access, rsync, ftp, and Amazon S3.

The best way to install it to use rpm files from DAG's repo. For example RHEL 4 64 bit version can be installed using RPM command:
# wget http://dag.wieers.com/rpm/packages/duplicity/duplicity-0.4.2-1.el4.rf.x86_64.rpm
# rpm -ivh duplicity-0.4.2-1.el4.rf.x86_64.rpm

In order to use duplicity you need to create a GPG key:
# gpg --gen-key
Next run duplicity as follows to make backups:
# duplicity --encrypt-key="YOUR-KEY" /home scp://user@backup.server.com/directory
You can verify backups with --verify option:
# duplicity --encrypt-key="YOUR-KEY" --verify scp://user@backup.server.com/directory /home

Finally, if you need to restore file use command as follows:
# mkdir -p /disk3/resored.file
# duplicity --encrypt-key="YOUR-KEY" scp://user@backup.server.com/directory /disk3/resored.file

Read the man page of duplicity and gpg for more information and command options.

Move or migrate user accounts from old Linux server to a new Linux server

Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation.

A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x.

Following files/dirs are required for traditional Linux user management:
* /etc/passwd - contains various pieces of information for each user account

* /etc/shadow - contains the encrypted password information for user's accounts and optional the password aging information.
[click to continue…]

Import MySQL Dumpfile, SQL Datafile Into My Database

How can I import a MySQL dumpfile into my database? I'm using CentOS Linux 5 server. My old hosting provider gave me a data.sql file and I do have access to my Unix / Linux server via ssh. So How do I restore my data using command line over the ssh session?
[click to continue…]