Table of Contents

Create Delete Copy And Move Files And Directories

General Information

Basic file/directory manipulation.


Creating

Create new file “file1”

touch file1


Create three files

touch {file1,file2,file3}


Create new directory

mkdir dir1


Create new directory tree

mkdir -p newdir/dir1/dir2/dir3


View directory structure in tree outline

~$ tree
.
├── anaconda-ks.cfg
├── file1
├── newdir
│   └── dir1
│       └── dir2
│           └── dir3
├── newfile
├── otherdir

Renaming

Rename file or directory

mv dir1 newdir

Removing

Remove empty directory

rmdir dir1


Remove directory recursively

rm -rf dir1

Copying

Copy file2 into dir2

cp file2 dir2/


Copy directory dir2 and its contents into newdir

cp -r dir2 /home/newdir/

Moving

Move file1 into dir1

mv file1 dir1/