0

When typing in this command:

touch ./__init__.py

This is what the file looks like in nautilus > right click __init__.py:

enter image description here

as you can see, its a text file instead of a py file.

I am using ubuntu 18.04 bionic.

How can I enable file extensions in the terminal?

muru
  • 197,895
  • 55
  • 485
  • 740

1 Answers1

2

In Linux / Ubuntu, file extension really are only used for the user to easily identify what the file is.

Using the command file can show you what the file is actually supposed to be. It will read the contents of the file and tell you what it is. So, when a file is empty, it just shows a normal text icon. Once it has content then it will show correctly.

Examples:

terrance@terrance-ubuntu:~/tmp$ touch file.bsh
terrance@terrance-ubuntu:~/tmp$ file file.bsh 
file.bsh: empty

enter image description here

enter image description here

Added #!/bin/bash to the file.bsh file:

terrance@terrance-ubuntu:~/tmp$ cat file.bsh 
#!/bin/bash
terrance@terrance-ubuntu:~/tmp$ file file.bsh 
file.bsh: Bourne-Again shell script, ASCII text executable

enter image description here

enter image description here

Terrance
  • 41,612
  • 7
  • 124
  • 183