thef*** is a Linux utility that comes as a python package can be installed via pip command to provide you automatic features to correct previous incorrect commands.
Although various tools provide such features for Linux shells, such as autosuggestion and refined manual page, thef*** tool also comes in the middle of all other tools.
Two tools, python3 and pip3, are required on your system before starting the installation process for thef*** command in Linux.
Type the below command into your terminal to check whether it is already installed on your system.
#To check python3 is installed on your system
$ python3 -V
#To check pip3 is installed on your system
$ pip3 -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
Install thef*** on Linux
After ensuring that both the required tool is installed on your system, use one of the below-mentioned methods depending upon your system to install thef*** command.
$ pip3 install thefuck --user
Now navigate to your home directory and edit either “.bashrc” for the bash shell or “.zshrc” for zsh shell, and add “
eval $(thefuck --alias FUCK)” this line at the end of the file and save exit.
Finally, start the new shell session, or to make changes reflected immediately, execute “source ./bashrc” for bash shell or “
source ./zshrc” for zsh shell in the terminal.
use the Homebrew command to install thef*** on your mac system, as shown below.
$ brew install thefuck
To autocorrect every previously incorrect command, type
f*** as the following command for python is incorrect.
puthon: command not found
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
First, I have entered
puthon which incorrect command for
python, so corrected it using
To update your repository for the Debian based operating system, the correct command is the
apt update. What if I write
aptupdate without providing space between apt and update?
[email protected]:~$ aptupdate
aptupdate: command not found
[email protected]:~$ fuck
At this time, instead of directly suggesting an
apt update thef*** command suggesting
It is finding relatable command to the previous wrong entered command. If the output command is incorrect for you, then navigate to some other sample related to your wrong executed command using the up or down arrow key.
After confirming the right suggestion, press enter to execute the command as shown below.
aptupdate: command not found
sudo apt update [enter/↑/↓/ctrl+c]
Reading package lists... Done
Below is the behaviour of the above command.
In thef*** command, two important optional flag/arguments need to be considered,
-y for direct execution of suggested commands and
-r to execute until the correct command.
For example, you accidentally executed any command such as puthon for python and want to run the first suggested command in thef*** use
-y flags as shown below.
If you try to perform the same method for the wrong aptupdate command as shown below.
It will execute the wrong command due to the incorrect suggestion that you need to specify the correct command using the up and down arrow key and press
-y flag as we did earlier.
As you can see above, the
apt update command unable execute due to sudo privileges. In such a situation, you can use the
-r flag executes until the command is error-free, as shown below.
Do you need thef*** tool?
If you are new to Linux, then thef*** tool can be pretty helpful to avoid unusual errors and practice the command line utility in Linux, while at the same time, you also get relative flags with that command which help you understand more about that particular command.
Innovative tech mind with 12 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.