Linux Command learning Summary: rmdir, linuxrmdir

Source: Internet
Author: User

Linux Command learning Summary: rmdir, linuxrmdir

Command introduction:

This command is used to delete an empty directory. If the directory is not empty, an error occurs. You can use rm to delete files in the directory and then use rmdir to delete the directory. You can also use rm-rf to replace rmdir. This is a very simple command.

Command syntax:

Rmdir [OPTION]... DIRECTORY...

Command parameters:

Parameters

Long Parameter

Description

-- Ignore-fail-on-non-empty

Ignore errors caused by data files in any directory

-P

-- Parents

Recursively delete directories

-V

-- Verbose

Display command execution details

-- Help

Show command online help

-- Version

Display command version information

Example:

1: view the help information of the rmdir command

[root@DB-Server ~]# rmdir --help
Usage: rmdir [OPTION]... DIRECTORY...
Remove the DIRECTORY(ies), if they are empty.
 
      --ignore-fail-on-non-empty
                  ignore each failure that is solely because a directory
                  is non-empty
  -p, --parents   Remove DIRECTORY and its ancestors.  E.g., `rmdir -p a/b/c' is
                  similar to `rmdir a/b/c a/b a'.
  -v, --verbose   output a diagnostic for every directory processed
      --help     display this help and exit
      --version  output version information and exit
 
Report bugs to <bug-coreutils@gnu.org>.

You can also use the following command to view rmdir document information.

[Root @ DB-Server ~] # Man rmdir

2: Use rmdir to delete an empty directory

If the directory is not empty, an error message is displayed.

[root@DB-Server ~]# ls /root/kerry/
file1
[root@DB-Server ~]# rmdir kerry
rmdir: kerry: Directory not empty
[root@DB-Server ~]# rm -f /root/kerry/*
[root@DB-Server ~]# rmdir kerry

3: displays detailed information about command execution.

 

[root@DB-Server ~]# mkdir test1  test2 test3
[root@DB-Server ~]# ls
anaconda-ks.cfg  Desktop  install.log  install.log.syslog  test1  test2  test3
[root@DB-Server ~]# rmdir -v test1  test2 test3
rmdir: removing directory, test1
rmdir: removing directory, test2
rmdir: removing directory, test3

4: recursively delete directories, as shown below. First create the directory kerry, create the empty directory tmp under the kerry directory, and then empty the directory test

 

[root@DB-Server ~]# mkdir -p kerry/tmp/test
[root@DB-Server ~]# tree kerry
kerry
`-- tmp
    `-- test
 
2 directories, 0 files
[root@DB-Server ~]# rmdir -p kerry/tmp/test

5: ignore any errors caused by data files in the directory

[root@DB-Server ~]# mkdir kerry
 
[root@DB-Server ~]# cd kerry
 
[root@DB-Server kerry]# touch file1
 
[root@DB-Server kerry]# cd ..
 
[root@DB-Server ~]# rmdir --ignore-fail-on-non-empty kerry/

What is the format of the non-empty directory forcibly deleted by the rmdir command in Linux? (An example is recommended)

In Linux, The rmdir command is used to delete an empty directory.
Usage: rmdir [-p] dirName
Parameter:-p is used to delete a subdirectory that becomes an empty directory.

Example:
Rmdir folder1
Delete a subdirectory named folder1.

Rmdir-p folder1/folder2
Delete the sub-directory folder2 named in folder1. If folder1 becomes an empty directory after the sub-directory folder2 is deleted, folder1 is also deleted.

If you want to delete a non-empty directory, you cannot use rmdir.
You only need to use rm.
Usage: rm [options] name...

Parameter [options]:
-I ask for confirmation one by one before deletion.
-F the original file is deleted directly even if its attribute is set to "read-only". You do not need to confirm the attribute one by one.
-R also deletes directories and the following files one by one.

Example:
Delete all. java files. Confirm the deletion one by one:
Rm-I *. java

Delete all files in the project subdirectories and subdirectories:
Rm-r project

Wish you a smooth use!

How to Learn LINUX in Command Line Mode

Login and Shutdown
(1) Login
In login: Enter
User ID (this indicates the Enter key)
Enter password:
123456 (note that it is not displayed on the screen)
The $ prompt is displayed, indicating that the user is normal.
(2) Shutdown
Enter after $
Halt
Turn off the power when System halted is displayed on the screen.

Man command

The man command is used to view the usage instructions of various Linux commands. The usage is as follows:

Man command name
Refer to the background or use man commands to familiarize yourself with the usage of the following basic commands:
Ls; List objects by conditions
Cd; enter a directory
Cp; copy files
Mkdir; create a directory
Rmdir; Delete directory
Mv; move files/Directories
Rm; delete an object
Cat; display file content
More; show File Content in Distribution
Less; display file content by PAGE
File; file type judgment
Du; view the space occupied by the Directory
Df; view disk space
Mount; mount the File System
Umount; uninstall the File System
Chmod; Modify file attributes
Chown; modify all Permissions
Pwd; view the current path
Which; find the path of the program
3. Basic System Management commands
Linux is a real multi-user multi-task operating system. Anyone who uses Linux must first use an account
Login. The account name is the user name.
User management must be performed under the root user permission. Be careful !!!
Refer to the background or use man commands to familiarize yourself with the following methods:
Useradd; Add a new user
Userdel; delete a user
Passwd; Change Password
Finger; view user information
Groupadd; add Group
Groupdel; delete a group
Ps; Process Information
Nice; run the process with a specific priority
Renice;
Kill; kill specific processes
Top; view current system resources
Free; release memory usage
Cal; Calendar
Date; date
Uname; operating system name
Login; login
Logout; exit
Exit; exit
Halt; Shutdown
Shutdown

First, familiarize yourself with the basic commands. When you learn windows again!
Net.pku.edu.cn/...alicloud can download this ebook ~~~ First, take a look at the instructions in the instructions, and then familiarize yourself with them!

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.