File Move From Windows to Linux Server:
----------------------------------------------------
Copy from Linux to Windows OS Server "D:\Putty\" drive
D:\Putty>pscp linux_username@IPAddress:/tmp/filename.csv.gz .
Copy to Linux Server From Windows OS Server "D:\Putty\" drive
D:\Putty>pscp filename.csv.gz linux_username@IPAddress:/tmp/
SCP within the Linux Environment:
-------------------------------------------
Copy to Another Linux Server command:
[normaluser@source_hostname data]$scp ReplicationTest.bz2 destinationhostname:/glide/mysql/data
Note: Normaluser username must have access to the folder to scp. Otherwise we can use
[normaluser@fsource_hostname data]$sudo scp ReplicationTest.bz2 destinationhostname:/glide/mysql/data
it will ask for root@destinationhostname's password: -- you need to know the root password
[normaluser@fsource_hostname$cd /tmp
[normaluser@fsource_hostname tmp]$ls -ltr
[normaluser@fsource_hostname tmp]$sudo scp dbnamedumps.sql destinationhostname:/tmp
[normaluser@fsource_hostname tmp]$sudo -su mysql scp dbnamedumps.sql destinationhostname:/tmp
More useful command from below website:
https://www.garron.me/en/articles/scp.html
Emailing:
-----------
[username@hostname tmp]echo "Filename.CSV" | mailx -s "Filename.CSV" -a /tmp/Filename.CSV test@domain.com
Unzip Files:
--------------
Exclude files:
[normaluser@fsource_hostname data]$sudo tar zxf filename.tar.gz --exclude='java' --exclude='logs' --exclude='nodes' --exclude='temp' -C /glide
----------------------------------------------------
Copy from Linux to Windows OS Server "D:\Putty\" drive
D:\Putty>pscp linux_username@IPAddress:/tmp/filename.csv.gz .
Copy to Linux Server From Windows OS Server "D:\Putty\" drive
D:\Putty>pscp filename.csv.gz linux_username@IPAddress:/tmp/
SCP within the Linux Environment:
-------------------------------------------
Copy to Another Linux Server command:
[normaluser@source_hostname data]$scp ReplicationTest.bz2 destinationhostname:/glide/mysql/data
Note: Normaluser username must have access to the folder to scp. Otherwise we can use
[normaluser@fsource_hostname data]$sudo scp ReplicationTest.bz2 destinationhostname:/glide/mysql/data
it will ask for root@destinationhostname's password: -- you need to know the root password
[normaluser@fsource_hostname$cd /tmp
[normaluser@fsource_hostname tmp]$ls -ltr
[normaluser@fsource_hostname tmp]$sudo scp dbnamedumps.sql destinationhostname:/tmp
[normaluser@fsource_hostname tmp]$sudo -su mysql scp dbnamedumps.sql destinationhostname:/tmp
The below script will copy all files of a given extension to the remote server. For instance, you want to copy all your text files (txt extension) to a new folder.
scp /home/moh/*.txt username@IPaddress:/home/sid/
More useful command from below website:
https://www.garron.me/en/articles/scp.html
Emailing:
-----------
[username@hostname tmp]echo "Filename.CSV" | mailx -s "Filename.CSV" -a /tmp/Filename.CSV test@domain.com
Unzip Files:
--------------
Exclude files:
[normaluser@fsource_hostname data]$sudo tar zxf filename.tar.gz --exclude='java' --exclude='logs' --exclude='nodes' --exclude='temp' -C /glide
We have two choices:
cd /root/Desktop/folder
tar zxf /root/Documents/file.tar.gz
or
tar zxf file.tar.gz -C /root/Desktop/folder
How to Zip files using tar
Reference: http://www.cyberciti.biz/faq/how-do-i-compress-a-whole-linux-or-unix-directory/
For example, say you have a directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog
Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use the following command (it will extract all files in current directory):
$ tar -zxvf prog-1-jan-2005.tar.gz
Where,
- -x: Extract files
If you wish to extract files in particular directory, for example in /tmp then you need to use the following command:
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -