≡ Menu

rm command

Delete All Files And Folders In Linux

How do I delete all files and folders stored in /home/jerry/movies directories under Linux operating systems?
[click to continue…]

Linux Delete Folder

How do I delete folders under Linux operating systems?
[click to continue…]

Linux Delete Folder Recursively

How do I delete folder recursively under Linux operating systems using a bash command line options?
[click to continue…]

Ubuntu / Debian Linux Regenerate OpenSSH Host Keys

How do I regenerate OpenSSH sshd server host keys stored in /etc/ssh/ssh_host_* files? Can I safely regenerate ssh host keys using remote ssh session as my existing ssh connections shouldn't be interrupted on Debian or Ubuntu Linux?
[click to continue…]

Linux Gnome: Networkmanger Connects To Wrong Default Wireless Access Point

Q. I'm using Ubuntu Linux and my Gnome network manger always connects to wrong default WAP / AP after login ( boot ). How do I fix this problem?
[click to continue…]

UNIX: Remove A File With A Name Starting With – (dash) Character

I am a new Unix shell user at my university shell server. Accidentally, I had created a file called -foo. Now, how do I remove a file with a name starting with '-' under UNIX-like or Linux operating system?
[click to continue…]

Linux Rm A Folder And Contents

How do I remove a folder and all its contents including files and other folders?
[click to continue…]

Ubuntu Linux: Delete Directory Command in Terminal

How do I delete a directory in terminal using Ubuntu Linux operating systems?
[click to continue…]

Linux Delete Directory With rmdir Command

I'm new to Linux and I'd like to know how to delete directory under any Linux distributions?
[click to continue…]

How to delete lots of directory at a one time in Linux or UNIX

Q. I’d like to delete lots of directory at a one time in Linux or UNIX. For example /data2/2005 is old archived data and it is no longer needed. How do I delete all directories and files from /data2/2005? Do I need to write a script?

A.. You need to use rm command to remove files or directories at a once time. You don't have to write a script. Modern rm command has -r option which remove directories and their contents recursively. You also need to pass -f (force) option. In short enter command as follows to wipe out everything inside /data2/2005 directory:
$ rm -rf /data2/2005

However if you have thousands and thousands of files and sub directories, rm may not work out of box due to shell limitation. Try the combination of find and rm command as follows:
$ find -t f /data2/2005 -exec rm -rf '{}' \;
$ find /data2/2005 -exec rm -rf '{}' \;

The first one will only wipe out files.