How To Delete File/Directory in CentOS VPS?

Jovani

Active member
Joined
Jul 10, 2012
Messages
335
Points
28
I have thousand of files now storing on my vps hosting and I want to remove some files and any directories unused at this time. Anyone give me any tips or commands how to delete file/directory in my CentOS VPS?
 

Alex Thompson

Moderator
Joined
Jun 6, 2013
Messages
652
Points
43
@jovani
You can use these commands as following
Code:
rm -rf "dir name" 
or
rm -r -f dir_path
Paramaters: -r = recursive and -f = force(!), which may be required, depending on the file ownerships/perms at this time.
 

Jovani

Active member
Joined
Jul 10, 2012
Messages
335
Points
28
@Alex
If I want to delete specific files and all files in the current directory, which commands I should use?
 

Alex Thompson

Moderator
Joined
Jun 6, 2013
Messages
652
Points
43
Alex Thompson
Ok, here we go
Code:
rm file1.txt file2.txt
To delete a all folder and its content recursively, you can this:
Code:
rm -rf foldername/
To delete all files/folders in the current directory, without deleting the directory itself, you use this code:
Code:
rm -rf *
Hope it helps!
 

geo_whr

New member
Joined
Nov 26, 2014
Messages
2
Points
0
You can use:

rm -rf /path/to/folder/* > to delete all files in that particular folder
rm -rf /path/to/folder/*.txt > to remove all files having .txt extension
rm -rf filename > to remove specific file
 
Older threads
Newer threads
Latest threads
Replies
4
Views
27
Replies
2
Views
40
Replies
5
Views
37
Recommended threads
Replies
7
Views
1,346
Replies
14
Views
6,196
Replies
25
Views
5,022
Replies
1
Views
2,866

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top