Wednesday, August 14, 2013

SCP & Mount

SCP (Secured Copy)
scp relies on ssh to operate. scp is used to securely copy files/directories from/to remote location. The syntax of scpis identical to cp.
Syntax:  scp     -arg     source     destination

# scp  192.168.10.1:/root/f1  /home/sarmed

Copies the file ‘f1’ from remote host 192.168.10.1 to local directory /home/sarmed
# scp  f2  192.168.10.2:/home/sarmed


Copies the local file ‘f2’ to remote host 192.168.10.2 in the location /home/sarmed
# scp  –r  localdir  192.168.10.2:/home/sarmed
Copies local ‘localdir’ to remote host 192.168.10.2 in the location /home/sarmed

# scp  -P 87 192.168.10.1:/root/f3 /home/sarmed
Same as the first example. However, this timescp connects to port 87 instead of default sshport 22.

# scp –P 87 sarmed@192.168.10.1:/home/sarmed/f4 /root
Same as the 4th example. Communicates with the remote host 192.168.10.1 at port 87 and as user sarmed. Copies the file f4 from the remote machine to /root in local host.

Mount
To access any physical device, it must be mounted to some logical location. By accessing the logical location, we actually access the physical device.
Syntax: command       -arg          source          destination
# mount  /dev/sdb1  /mnt
Mounts the physical partition /dev/sdb1 to logical location /mnt

# mount  /dev/sdc2  /media
Mounts the physical partition /dev/sdc2 to logical location /media

# mount  -t  nfs  192.168.10.1:/share  /newshare
Mounts the directory /share located in remote host 192.168.10.1 using NFS (network file system) to local /newshare. (NFS must be preconfigured in 192.168.10.1 for this command to work)

# mount –o  remount rw  /
Often used in recovery mode. –o = option. This command remounts / directory in rw mode

0 comments: