[Linux command] rm command option list [Must-see for beginners]

[Linux command] rm command option list [Must-see for beginners]

Summary Linux command list

What is the rm command?

Linux command to delete files and directories. "rm" is an abbreviation for "remove".

How to use commands

/home/hoge


#Check the contents of the directory
$ ls -l
-rw-r--r-- 1 hoge hoge   11 Feb 24 17:11 hoge.txt
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

# hoge.Delete txt
$ rm hoge.txt

#Confirm that it has been deleted
$ ls -l
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

Man command option list

option Description
-f Execute without displaying an error message(Danger)
-i Check before deleting
-I Check before deleting only when there are 4 or more deletion targets
-r Include directories to be deleted
-v View deletion details

-i option

/home/hoge


#Check the contents of the directory
$ ls -l
-rw-r--r-- 1 hoge hoge   11 Feb 24 17:11 hoge.txt
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

# hoge.Delete txt
$ rm -i hoge.txt
remove hoge.txt? (y or n) y

#Confirm that it has been deleted
$ ls -l
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

-r option

/home/hoge


#Check the contents of the directory
$ ls -l
-rw-r--r-- 1 hoge hoge   11 Feb 24 17:11 hoge.txt
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

# hoge.Delete txt
$ rm -r test

#Confirm that it has been deleted
$ ls -l
-rw-r--r-- 1 hoge hoge   11 Feb 24 17:11 hoge.txt
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

-v option

/home/hoge


#Check the contents of the directory
$ ls -v
-rw-r--r-- 1 hoge hoge   11 Feb 24 17:11 hoge.txt
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

# hoge.Delete txt
$ rm -v hoge.txt
mooooo.tx

#Confirm that it has been deleted
$ ls -l
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:14 test
drwxr-xr-x 2 hoge hoge 4096 Feb 24 17:15 test2

-rf option (magic of ruin)

/


#Try to ruin
$ cd /
$ sudo rm -rf /

List of options for other Linux commands

pwd, mkdir, cd , cat, cp, ls, touch, less, mv, rm, ssh, man, ** Adding at any time **

Advertising space

We undertake various development and construction contracts and mentor work for beginners. If you are interested, please go to ** here **

Recommended Posts

[Linux command] rm command option list [Must-see for beginners]
[Linux command] cp command option list [Must-see for beginners]
[Linux command] ls command option list [Must-see for beginners]
[Linux command] touch command option list [Must-see for beginners]
[Linux command] less command option list [Must-see for beginners]
[Linux command] cat command option list [Must-see for beginners]
[Linux command] pwd command option list [Must-see for beginners]
[Linux command] cd command option list [Must-see for beginners]
[Linux command] mv command option list [Must-see for beginners]
[Linux command] man command option list [Must-see for beginners]
[Linux command] ssh command option list [Must-see for beginners]
[Linux command] mkdir command option list [Must-see for beginners]
Linux command memorandum [for beginners]
[Must-see for beginners] Basics of Linux
Linux command list
Linux operation for beginners Basic command summary
Linux command for self-collection
What is Linux? [Command list]
Linux distribution recommended for beginners
Linux Command Dictionary (for myself)
Python #list for super beginners
Convenient Linux shortcuts (for beginners)
Frequently used Linux commands (for beginners)
Linux command # 4
Linux command # 3
Linux command # 5
How to create a shortcut command for LINUX
[Linux] Search command
Roadmap for beginners
Linux command <Basic 2>
Linux [directory command]
Linux server command
Linux # Command Memo 1
Linux command [read]
Linux Command Summary
[Basic] linux command
Linux [shell command]
[Linux] Command / Knowledge
pyenv for linux
My linux command
Linux command <Basic 1>
Linux command collection
Linux mkdir command
Linux command basics
[Linux] Git command
Linux (command memory)
[Linux] A list of Linux commands that beginners should know
[For beginners] How to use say command in python!
[Linux] Basics of authority setting by chmod for beginners