User Tools

Site Tools


files-and-directories

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
files-and-directories [2019/09/12 13:44]
Miroslav Bernát
files-and-directories [2019/09/20 21:41] (current)
Miroslav Bernát
Line 19: Line 19:
 | **rm** <​file/​directory>​ | removes a file, **-R** directory with its contents, **-i** asks for confirmation,​ **-f** without confirmation,​ **-v** detailed output | | **rm** <​file/​directory>​ | removes a file, **-R** directory with its contents, **-i** asks for confirmation,​ **-f** without confirmation,​ **-v** detailed output |
 | **rmdir** <​directory>​ | removes an empty directory, **-p** more child directories at the same time | | **rmdir** <​directory>​ | removes an empty directory, **-p** more child directories at the same time |
-| **cp** <​source>​ <​target>​ | copies a source file into an existing target directory; if two files are considered and the target one does not exist, it will be created, if it exists, its contents will be automatically overwritten,​ **-i** asks for confirmation,​ **-f** without confirmation,​ **-b** creates a backup of the target files that might be possibly overwritten,​ **-R** copies a directory with its contents, **-p** preserves the source attributes, **-u** copies only when the source is newer than the target or the target is missing, **-v** detailed output\\ ''#​ cp -pR /home /​mnt/​extdisk''​\\ ''#​ cp -pR /​home/​tom/​{*,​.[^.]*} /​mnt/​extdisk/​home/​tom''​\\ (copies the contents of user „tom” home directory to an external disk, including the hidden files) ​ |+| **cp** <​source>​ <​target>​ | copies a source file into an existing target directory; if two files are considered and the target one does not exist, it will be created, if it exists, its contents will be automatically overwritten,​ **-i** asks for confirmation,​ **-f** without confirmation,​ **-b** creates a backup of the target files that might be possibly overwritten,​ **-R** copies a directory with its contents, **-p** preserves the source attributes, **-u** copies only when the source is newer than the target or the target is missing, **-v** detailed output\\ ''​$ cp file1 ./​file2''​\\ (copies a file under a different name to the same directory)\\ ''#​ cp -pR /home /​mnt/​extdisk''​\\ ''#​ cp -pR /​home/​tom/​{*,​.[^.]*} /​mnt/​extdisk/​home/​tom''​\\ (copies the contents of user „tom” home directory to an external disk, including the hidden files) ​ |
 | **rsync** <​source>​ <​target>​ | copies a source file into an existing target directory; if two files are considered and the target one does not exist, it will be created, if it exists, its contents will be automatically overwritten;​ if the target already contains some identical data as the source, only the difference is being copied; it is also possible to transfer data between remote computers, **-r** copies a directory with its contents, **-l** preserves symbolic links, **-p** preserves permissions of the file, **-o** preserves the owner of the file, **-g** preserves the group of the file, **-t** preserves modification times, **-D** preserves special files, **-a** includes options "​-rlptgoD",​ **-z** compresses the data during the transfer, **--delete** removes redundant data in the target directory which do not exist in the source any more, **--ignore-errors** removes redundant data even in case of I/O errors, **--exclude** <​pattern>​ excludes files matching the specified pattern, **--progress** prints the progress of synchronization,​ **--rsh** <​command>​ specifies a remote command during the transfer, **-v** detailed output\\ ''#​ rsync -a --delete --exclude "​.gvfs"​ /home /​mnt/​extdisk''​\\ ''#​ rsync -avz /var/log/ 192.168.0.20:/​logs''​\\ ''​$ rsync --rsh="​ssh -l root -p 22022" file1 file2 192.168.152.47:/​tmp''​ | | **rsync** <​source>​ <​target>​ | copies a source file into an existing target directory; if two files are considered and the target one does not exist, it will be created, if it exists, its contents will be automatically overwritten;​ if the target already contains some identical data as the source, only the difference is being copied; it is also possible to transfer data between remote computers, **-r** copies a directory with its contents, **-l** preserves symbolic links, **-p** preserves permissions of the file, **-o** preserves the owner of the file, **-g** preserves the group of the file, **-t** preserves modification times, **-D** preserves special files, **-a** includes options "​-rlptgoD",​ **-z** compresses the data during the transfer, **--delete** removes redundant data in the target directory which do not exist in the source any more, **--ignore-errors** removes redundant data even in case of I/O errors, **--exclude** <​pattern>​ excludes files matching the specified pattern, **--progress** prints the progress of synchronization,​ **--rsh** <​command>​ specifies a remote command during the transfer, **-v** detailed output\\ ''#​ rsync -a --delete --exclude "​.gvfs"​ /home /​mnt/​extdisk''​\\ ''#​ rsync -avz /var/log/ 192.168.0.20:/​logs''​\\ ''​$ rsync --rsh="​ssh -l root -p 22022" file1 file2 192.168.152.47:/​tmp''​ |
 | **dd** <​parameter>​**=**<​value>​ | copies data between devices, **if**=<​source>,​ **of**=<​target>,​ **bs**=<​block_size_in_bytes>​ (512 B by default), **count**=<​number_of_blocks>​\\ ''​$ dd if=/​dev/​cdrom bs=1500 of=/​tmp/​image.iso''​\\ ''​$ dd if=/​dev/​zero of=test bs=5M count=10''​\\ (easily creates an empty bigger file)\\ ''#​ dd if=/​dev/​urandom of=/​dev/​sdb1 bs=1G''​\\ (overwrites a disk/​partition with random data) | | **dd** <​parameter>​**=**<​value>​ | copies data between devices, **if**=<​source>,​ **of**=<​target>,​ **bs**=<​block_size_in_bytes>​ (512 B by default), **count**=<​number_of_blocks>​\\ ''​$ dd if=/​dev/​cdrom bs=1500 of=/​tmp/​image.iso''​\\ ''​$ dd if=/​dev/​zero of=test bs=5M count=10''​\\ (easily creates an empty bigger file)\\ ''#​ dd if=/​dev/​urandom of=/​dev/​sdb1 bs=1G''​\\ (overwrites a disk/​partition with random data) |
Last modified: 2019/09/20 21:41 by Miroslav Bernát

visits: