The creation and deletion of directory in Linux the instructions for using the command

Source: Internet
Author: User
Tags create directory file size mkdir parent directory sort root directory

mkdir command

MkDir is used to create one or more directories

Grammar:

Grammar is

mkdir [command switch] Directory

Command switch:

-M Text directory set operation permissions
-P If the parent directory does not exist, create them at the same time.
-V Output information for each directory created by

Example:

Create directory:

mkdir test

The above command creates the directory ' test '.

To create a directory and set access permissions:

Mkdir-m 666 Test

The above command creates the directory ' test ' and sets read and write permissions.

rmdir command

The rmdir command is used to delete/remove directories and their subdirectories.

Grammar:

Grammar is

rmdir [command switch ...] directory name

Command switch:

-P Allows the user to delete the dirname directory and delete it if the directory's upper-level directory has become an empty directory.

Example:

Deletes/removes a directory.

RMDIR tmp

If the TMP directory is an empty directory, the rmdir command removes/deletes the TMP directory.

To delete a directory tree:

Rm-ir tmp

This command recursively deletes the contents of all subdirectories under the TMP directory, prompting you for deletion of each file, and then deleting the TMP directory itself.

CD command

The CD command is used to change the directory.

Grammar:

Grammar is

cd [Directory name | ~ |./| / | - ]

Command switch:

-L Use a tree-type directory structure.
-P The mandatory signature connection.

Example:

CD linux-Command This command (linux-command) changes from its parent directory to the subdirectory.

Cd.. This will change from the current working directory/subdirectory to the parent directory.

CD ~ This command will change to the user's home directory "/home/username"

PWD command

pwd– displays the working directory. The PWD command displays the absolute path name of the current working directory.

Grammar:

Grammar is

PWD [command switch]

Command switch:

-P Displays a pathname that does not contain a symbolic connection.
-L Displays the path name that contains the symbolic connection.

Example:

Displays the current working directory.

PWD If you work in the home directory, then the PWD command displays the current working directory as/home.

ls command

ls command files and directories in the current working directory.

Grammar:

Grammar is

LS [command switch] ... File

Command switch:

-l
-t
-a
-d
-p
-u
-i
-ltr
-LSR

Example:

Displays the contents of the root directory:

LS/lists the contents of the root directory.

Show hidden files and directories:

LS-A lists all items, including hidden files and directories.

Display node Information:

ls-i7373073 Book.gif

7373074 Clock.gif

7373082 Globe.gif

7373078 Pencil.gif

7373080 Child.gif

7373081 Email.gif

7373076 Indigo.gif

The above command displays the file name and file size.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.