If you can see this check that

next section prev section up prev page next page

Renaming, Copying and Removing Files

Using the mv command, you can rename the file 'myfile' to 'tempfile' as follows:

% mv myfile tempfile

To verify that mv renamed the file, use the ls command:

% ls
tempfile

To rename 'tempfile'' back to 'myfile' type:

% mv tempfile myfile
% ls
myfile

Warning: When renaming files, take care not to rename a file to the name of a file which already exists in that directory. If you do this, the file that already has that name will be lost.

Copy a file when you want to make a new version of it while still keeping the old version around. For example, to make a new copy of 'myfile' named 'myfile2', type:

% cp myfile myfile2

Now when you use the ls command, you will see the following:

% ls
myfile myfile2

Warning: When you copy a file to an existing file name, the existing file will be lost.

If you have files which are no longer needed, you can remove them as follows:

% rm myfile2

Centos 7 intro: Paths | BasicShell | Search
Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 log Mail
Caine 10.0: Essentials | Basic | Search | Acquisition | SysIntro | grep | MBR | GPT | FAT | NTFS | FRMeta | FRTools | Browser | Mock Exam |
CPD: Cygwin | Paths | Files and head/tail | Find and regex | Sort | Log Analysis
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Kali 2020-4: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7 | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2023 Edinburgh Napier University