Thursday, November 4, 2010

Complex Linux Commands

Rsync:

rsync -ave "ssh -p 46647" /usr/local/apache/bin/* root@100.100.100.100 :/usr/local/apache/bin

rsync -ave "ssh -p1122" /home/arjun/public_html/i.tar arjun@dest.server.com:/home/arjun/public_html/

Execute the above command in source server. "dest.server.com" is the destination server here.


SCP:

root@sw1 [~]# scp filename root@IP:destination_folder

Execute the below command in the source server:

scp /usr/local/apache/bin/* root@100.100.100.100 :/usr/local/apache/bin


Examples:

If you want to transfer folders,

root@sw1 [~]# scp -r folder_name root@IP:destination_folder

--

If you wish to transfer a file from other server to your server, please use the below command in your server:

scp -r -P1122 username@remotehost_ip_address:directory/filename foldername

Here,

remotehost_ip_address = IP address of the server from where you wish to copy files to our server using scp.

foldername = the folder name where you wish to copy to


Command to create a test 1MB file:

dd if=/dev/zero of=1-mb-file bs=1024 count=1000


Removing semaphores:

for i in `ipcs -s | grep nobody | awk '{print $2}'`; do ipcrm -s $i; done

Another Method:

ipcs  | awk {'print$2'} | xargs --replace ipcrm -s {}


Allow an IP in the IPTables:

iptables -I INPUT -s 100.100.100.100 -j ACCEPT


Command only chmod’s files to 644:

$find -type f | xargs -i chmod 644 {}
or
$find ./ -type f -exec chmod 644 {} \;


Command only chmod’s directories to 755:

$find -type d | xargs -i chmod 755 {}


Command to find and list the files that are modified 3 days back:

find . -mtime -3

No comments:

Post a Comment

Google Custom Search