Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Creating file and Directory

Creating file and Directory:

  1. Creating file:

The ‘cat’ command is used to create a file

Syntax:

# cat > filename

example:

# cat > abc.txt

(Ctrl +D) is used to save the file.

  1. View the content of file

Syntax:

# cat filename

Example:

#cat abc.txt

#cat –b abc.txt

  1. Creating Directory

The ‘mkdir’ command is used to create directory

Syntax:

Mkdir [directory_name]

Example:

# mkdir rohan

Option used:

cd : To change directory

cd .. : To come out from directory

cd : to jump to root directory

cd - : to jump to previous directory

Deleting Files and directory:

Syntax:

For file:

rm

example:

rm abc.txt

for directory

syntax:

rmdir

Note: Only empty directory will be deleted)

If we want to delete the tree structure of directory then we need to use the following command

Syntax:

rm –rf

where

r = recursively

f= force

in order to remove non empty directory

Syntax:

rm –r

example;

rm –r rohan

this will remove directory step by step ,first remove sub directory and then finally main directory.

Another method of creating file :

Touch : this command is used to create a blank file with size zero.

# touch

Example:

#touch abc



This post first appeared on RED HAT ENTERPRISE LINUX, please read the originial post: here

Share the post

Creating file and Directory

×

Subscribe to Red Hat Enterprise Linux

Get updates delivered right to your inbox!

Thank you for your subscription

×