Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Delete contents of a directory command?

Discussion in 'General Discussion' started by 000, Jun 4, 2019.

  1. 000

    000 Well-Known Member

    Joined:
    Jun 3, 2008
    Messages:
    189
    Likes Received:
    1
    Trophy Points:
    68
    Hello, please see:
    Code:
    [Moderator Note: We removed your test commands from the ticket to ensure others seeing this thread do not use them by mistake.
    [email protected] [/]#
    why my command can't delete the folder?

    Thanks
     
    #1 000, Jun 4, 2019
    Last edited by a moderator: Jun 4, 2019
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,531
    Likes Received:
    2,181
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Can you execute the command below and share a snippet of the output?

    Code:
    ls -al /home/__LOGS/
    Specifically, look to determine if the filename prefix used for the files under this directory designate the files as hidden (e.g. .file_name).

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. 000

    000 Well-Known Member

    Joined:
    Jun 3, 2008
    Messages:
    189
    Likes Received:
    1
    Trophy Points:
    68
    thanks, the output is:
    Code:
    [email protected] [/]# ls -al /home/__LOGS/
    total 17484
    drwxrwxrwx   3 nobody nobody     4096 Jun  4 08:00 ./
    drwx--x--x. 51 root   root       4096 Jun  4 07:13 ../
    drwxr-xr-x   2 userABC userABC 17887232 Jun  4 15:08 .folderwithnameABC.com/
    [email protected] [/]#
    what I can do to delete the folder?

    thanks!
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,531
    Likes Received:
    2,181
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    You can add a period before the * symbol in the command syntax in order to identify hidden files (files starting with a period). Here's an example of how to list hidden files under a directory with the ls command:

    Code:
    ls -al /path/to/directory/.*
    If you are attempting to delete multiple files and directories with a single command, it's important to exercise caution. For instance, a simple typo in the path could lead to the unintended removal of multiple files and directories across the system.

    The "cp" command is helpful if you want to create a copy of files or directories before removing them. For example:

    Code:
    mkdir /root/copied-directories
    cp -a /home/__LOGS /root/copied-directories/
    
    Once you do this, you could proceed to remove files from the /home/__LOGS directory while keeping /root/copied-directories until you've confirmed the correct files were removed.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #4 cPanelMichael, Jun 4, 2019
    Last edited: Jun 4, 2019
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,531
    Likes Received:
    2,181
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    I modified my previous response and removed references to the rm command in your earlier posts to ensure inexperienced users do not accidentally use this command in a way that results in the unexpected removal of files or directories.

    Let me know if you have any additional questions.

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice