How to use the command 'clifm' (with examples)
CliFM is a powerful command-line file manager designed for users who prefer navigating their file system via the terminal. It offers a range of functionalities to manage files and directories efficiently, providing both simplicity and a rich set of features. Similar tools include vifm
, ranger
, mc
, and graphical counterparts like nautilus
.
Use case 1: Start CliFM
Code:
clifm
Motivation:
Starting CliFM is your first step towards managing your files through the command line. This command launches CliFM, enabling you to perform various file management tasks without leaving the terminal environment.
Explanation:
clifm
: This is the primary command to launch the CliFM interface. Once executed, you’ll enter the interactive mode where you can navigate directories, view files, and execute other commands.
Example Output:
Welcome to CliFM [version]
Type '?' for help or 'q' to quit. Navigate with arrows.
Use case 2: Open the file or directory whose ELN (entry list number) is 12
Code:
12
Motivation:
When managing files, you might come across directories or files you want to access quickly. Each file or directory in CliFM is assigned an entry list number (ELN), which provides a fast and efficient way to open it without typing lengthy directory paths or file names.
Explanation:
12
: The number represents the ELN of the desired file or directory. By typing the number, CliFM selects and opens the corresponding entry, streamlining navigation.
Example Output:
Opening [filename or directory name]...
Use case 3: Create a new file and a new directory
Code:
n file dir/
Motivation:
Creating new files and directories is a basic yet crucial task in file management. This command allows you to streamline project setup or organize your files directly from the command line.
Explanation:
n
: This command starts the creation process within CliFM.file
: This part specifies the new file’s name you wish to create.dir/
: This indicates the name of the new directory. The trailing slash signals to CliFM that a directory is intended.
Example Output:
File 'file' created.
Directory 'dir/' created.
Use case 4: Search for PDF files in the current directory
Code:
/*.pdf
Motivation:
For rapid file retrieval, searching capabilities are crucial. This command filters and displays all PDF files in the current directory, which is particularly useful when dealing with multiple file types or large datasets.
Explanation:
/*.pdf
: The asterisk*
is a wildcard symbol representing any string. Combined with.pdf
, it tells CliFM to search for all files ending with the.pdf
extension in the current directory.
Example Output:
Found files:
1. document1.pdf
2. report.pdf
3. presentation.pdf
Use case 5: Select all PNG files in the current directory
Code:
s *.png
Motivation:
Selecting files based on their type can enhance efficiency when performing batch operations, such as moving or deleting them. This command allows you to select all PNG files quickly in the current directory.
Explanation:
s
: Initiates the selection process.*.png
: Similar to the PDF search, this indicates that all files with a.png
extension should be selected.
Example Output:
Selected files:
1. image1.png
2. graphic.png
3. banner.png
Use case 6: Remove the previously selected files
Code:
r sel
Motivation:
Efficiently managing disk space often requires removing unnecessary files. This command helps you clean up your directory by removing the files you’ve previously selected, such as those selected in the previous example.
Explanation:
r
: Begins the removal process.sel
: Refers to the “selected” files, indicating that CliFM should remove the files you have selected in the session.
Example Output:
Selected files removed.
Use case 7: Display help
Code:
?
Motivation:
Knowing all available commands and their functionalities is crucial for effective file management. Displaying the help screen guides you in understanding CliFM’s capabilities, especially for new users or when you’re unsure about a specific command.
Explanation:
?
: The question mark triggers the display of the help menu, listing all available commands and their brief descriptions.
Example Output:
Help Menu:
n: Create file/directory
s: Select files
r: Remove files
?: Show help
q: Quit
...
Use case 8: Exit CliFM
Code:
q
Motivation:
Exiting CliFM appropriately ensures that session changes and selections are managed correctly. This command safely closes the file manager, returning you to your default shell prompt.
Explanation:
q
: A simple command that instructs CliFM to terminate the session and exit back to the terminal.
Example Output:
Goodbye.
Conclusion:
The command-line file manager CliFM is a robust and versatile tool for managing files directly from the terminal. Its uses, from navigating directories to batch managing files, allow users to efficiently handle their file system with ease. Whether you are organizing documents, searching for specific file types, or cleaning up directories, CliFM offers a comprehensive set of commands that streamline these processes, making it indispensable for those who prefer a command-line interface to graphical user interfaces.