Linux bash provides the alias
keyword in order to as command shortcuts and easily run them without typing complex commands. The rm -rf
command is used to remove or delete all files and directories. As you expect the alias ls='sudo rm -rf~/*'
command creates a shortcut with the ls
name which deletes all current user’s home directory contents. Normally the ls command is used to list files and directories for the current working directory. The “alias ls=’sudo rm -rf ~/*'” is a very dangerous command which is not used for regular operations it is just an attacking command to delete a victim’s files and directories. But in very rare cases this can be a valid command to delete a user’s data after deleting the user account.
Why Use “alias ls=’sudo rm -rf ~/*'”
As stated in the previous part this command can be used to delete all user data the account is already deleted. Take the following scenario. We add “alias ls=’sudo rm -rf ~/*'” command to the .bashrc
file for the current user to call it easily.
$ echo "alias ls='sudo rm -rf ~/*'" >> ~./bashrc
How To Define “alias ls=’sudo rm -rf ~/*'” Globally
Sometimes we may want to define the “alias ls=’sudo rm -rf ~/*'” command in order to make it callable by all users.
$ echo "alias ls='sudo rm -rf ~/*'" >> /etc/bashrc
“alias ls=’sudo rm -rf / –no-preserve-root'” Thsirt
The “alias ls=’sudo rm -rf ~/*'” command is a very popular joke among Linux system administrators and there are different versions of this command. The “alias ls=’sudo rm -rf / –no-preserve-root” is the more dangerous version that simply deletes all root directories with all data. This command is created as a funny Tshirt and sold in different stores like Amazon.