How To Delete File/Directory in CentOS VPS?

Jovani

Active member
Joined
Jul 10, 2012
Messages
338
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
651
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
338
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
651
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
0
Views
29
Replies
0
Views
32
Replies
1
Views
41
Replies
3
Views
106
Recommended threads
Replies
1
Views
4,028
jyy
Replies
18
Views
12,559
Replies
7
Views
3,842
Top