In Kali Linux, most of the operations are performed on files. And to handle these files Kali Linux has directories also known as folders which are maintained in a tree-like structure. Though, these directories are also a type of file themselves. Kali Linux has 3 basic types of files:
- Regular Files: It is the common file type in Linux. it includes files like – text files, images, binary files, etc. Such files can be created using the touch command. They consist of the majority of files in the Linux/UNIX system. The regular file contains ASCII or Human Readable text, executable program binaries, program data, and much more.
- Directories: Windows call these directories as folders. These are the files that store the list of file names and the related information. The root directory(/) is the base of the system, /home/ is the default location for user’s home directories, /bin for Essential User Binaries, /boot – Static Boot Files, etc. We could create new directories with mkdir command.
- Special Files: Represents a real physical device such as a printer which is used for IO operations. Device or special files are used for device Input/Output(I/O) on UNIX and Linux systems. You can see them in a file system as an ordinary directory or file.
In Unix systems, there are two types of special files for each device, i.e. character special files and block special files. For more details, read the article Unix file system.
You can read more about the Linux File Management.
Kali Linux – File Hierarchy Structure
Kali Linux follows a specific File hierarchy structure which is just a way of organizing files, filesystems, directories, installed packages, and external devices connected to the system. It basically sets a standard or a base for defining the directory structure.
In Kali Linux File Hierarchy Structure the base or the main directory which contains all the directories is the root directory depicted by a “/”.
Managing and Working with Files in Kali Linux
1. To List the Files. In Kali Linux, we use ls command to list files and directories. To use this enter the following command in the terminal.
This command will print all the file and directories in the current directory.
2. To create a new file. In Kali Linux, we use touch command to create a new file. To use this enter the following command in the terminal.
This command will create a new file named filename.extension.
3. To display the content of a file. In Kali Linux, we use cat command to display the contents of a file. To use this enter the following command in the terminal.
This command will print the content of the filename.extension file.
4. To copy files. In Kali Linux, we use cp command to copy files and directories. To use this enter the following command in the terminal.
cp old/location/of/file /new/location/of/file
This command will copy file form old location to new location.
5. To move files. In Kali Linux, we use mv command to move files and directories. To use this enter the following command in the terminal.
mv old/location/of/file /new/location/of/file
This command will move the file form old location to new location.
6. To rename a file. In Kali Linux, we use mv command to rename files and directories. To use this enter the following command in the terminal.
mv filename.extension new_name.extension
This command will rename the file from filename.extension to new_name.extension.
7. To delete a file. In Kali Linux, we use rm command to delete files and directories. To use this enter the following command in the terminal.
This command will remove/delete the filename.extension from the current directory.
8. To edit a file. In Kali Linux, we use nano command to edit files. To use this enter the following command in the terminal.
This command will open an editor to write to file and after completing the same press ctrl+o to save the file.