file: command not found

A file name is a string of characters that identify a file. By using the right combination of characters in file names, you can ensure that the files are unique and easy to recognize.

On an ext4 file system, a file name may be up to 255 bytes long and contain any byte except NULL (\0) and the forward slash (/). File names of user files may not be . and .. as these are special reserved file names. Various file systems may enforce different requirements for file names.

The file command is used to determine the type of file. The syntax of the command is:

file [options] {file names}

If you encounter the below error while running the file command:

file: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install file
Ubuntu apt-get install file
Alpine apk add file
Arch Linux pacman -S file
Kali Linux apt-get install file
CentOS yum install file
Fedora dnf install file
Raspbian apt-get install file

file Command Examples

1. Give a description of the type of the specified file. Works fine for files with no file extension:

# file filename

2. Look inside a zipped file and determine the file type(s) inside:

# file -z foo.zip

3. Allow file to work with special or device files:

# file -s filename

4. Don’t stop at first file type match; keep going until the end of the file:

# file -k filename

5. Determine the mime encoding type of a file:

# file -i filename
Related Post