Showing posts with label basic command. Show all posts
Showing posts with label basic command. Show all posts

Monday, May 7, 2012

Reverse Copy

I nearly forget about reverse copy. Yasterday sis Salina have problem to copy file for Server Source to Server Destination.

Here is the way where we can pull the data ( reverse copy )
Normal copy ( copy command at source server ) source -> destination
Reverse copy ( copy command at destination server ) destination  <- source

For example you want to copy DATA from Server S (source) to Server D (destination):

Normally at Server S
# scp /path/to/DATA aminah@ipServerD:   -> file akan ada kat home/aminah/
# scp /path/to/copyDATA aminah@ipServerD:/path/to/save/  -file akan ada kat /path/to/save/

But for reverse copy, we copy DATA to our home at server S.
-> so at server S we have /home/aminah/DATA

At Server D 
# scp aminah@ServerS.contoso.com.my:DATA ./

Reverse SCP for amazon
#scp -i mykey.pem root@ec2-184-73-72-150.compute-1.amazonaws.com:/file/path/filename ./

./ -> mean current directory 

Normal SCP for amazon
#scp -i mykey.pem filename root@ec2-184-73-72-150.compute-1.amazonaws.com:/path/to/save/ 



hehehe... done..  

Tuesday, April 24, 2012

Move / Copy files with exception in UNIX.

The syntax :
mv [!filename]* target.
ie:
In directory "y" you have these files :
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 1
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 2 
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 3
-rw-r--r-- 1 sirap sirap 0 2010-03-25 11:40 4 

 You want to move all files except file "4" to directory "z".
The syntax should look like this :
# mv [!4]* ../z/ Done.

Wednesday, March 28, 2012

Basic freeBSD to copy, move files

Copy to same server

cp -rp {path file} {path }

Monday, January 30, 2012

Copy, Remove, Tar, Change Owner, Change mod, Clear History

How to check size folder
#du -h
#df -h

tar files
#tar -cjvf sha.tar.bz2 fold1 fold2 fold3 fold4
c- create j-tar.bz2 v-show process f-files
# tar cvzf archive_name.tar.gz dirname/


copy file tar to another server
#scp sha.tar.bz2 shariha@162.12.12.22:
ni dia akan pi ke home shariha di server 162.12.12.22

untar
#tar -xjvf sha.tar.bz2
#tar -zxvf sha.tgz
#tar -xvzf sha.tar.gz

katakan nak move file tuh ke /data/mms
#cd /data/mms
#mv /home/shariha/sha.tar.bz2 ./
./ means current path

Change ownership
#chown -R www-data:www-data fold1 fold2 fold3 fold4

Change mod
#chmod -R 755 fold1 fold2 fold3
| 7 | 5 | 5 |
|rwx|r-x|r-x|
|owner|group|world|

Copy
#cp -rp /home/shariha/sha.tar.bz2 /data/mms

copy name folder start from 3** (30, 300, 301, 321..etc)
#cp -rp /../data/3* ./
so dia akan copy apa2 yang foldername start 3... kepada current path

Clear History
#history -c
kalu laa tertype password.. leh argh nak clearkan.. 

Find / Whereis 
#find /path/want/to/search -name mysong.php (ubuntu)
or
#find /path/want/to/search -name *.php
or
#whereis