- Midnight Commander — консольный файловый менеджер в Linux.
- Что такое Midnight Commander.
- Установка Midnight Commander в Linux.
- How to Run Multiple Linux Commands at Once in Terminal
- Using ; to run multiple Linux commands in one line
- Using && to run multiple Linux commands
- Using || to run several Linux commands at once
- Bonus Tip: Combine && and || operators
- More such Linux terminal tips
- 8 Best Linux Console File Managers
- GNU Midnight Commander
- Ranger Console File Manager
- Cfiles Fast Terminal File Manager
- Vifm Console File Manager
- Nnn Terminal File Browser
- Lfm Last File Manager
- lf – List Files
- WCM Commander
Midnight Commander — консольный файловый менеджер в Linux.
Когда приходится работать с большим количеством файлов в консоли, например, если необходимо перемещение или копирование большого количества файлов, то такая работа может оказаться утомительной. В среде GUI имеется файловый менеджер, который значительно упрощает такую работу. С помощью файлового менеджера не нужно запоминать синтаксис/команду, связанную с копированием/перемещением файлов. Не надо придумывать регулярное выражение, которое точно опишет тот набор файлов, с которым необходимо произвести ту или иную операцию. Вы просто щелкаете мышью и перетаскиваете эти файлы, чтобы сделать свою работу.
В консольной среде щелкнуть и перетянуть файл или вызвать контекстное меню и воспользоваться буфером обмена, у вас уже не получится. Вы должны помнить синтаксис той команды, которую вы хотите произвести. А в различных командах, одни и те же параметры могут иметь одинаковые наименования, но быть разными по значению. Что еще больше усложняет задачу. К счастью, в Linux есть текстовый файловый менеджер, который работает в консольной среде. И имя такому менеджеру — Midnight Commander .
Что такое Midnight Commander.
GNU Midnight Commander — это визуальный файловый менеджер, работающий под лицензией GNU General Public License и поэтому квалифицируется, как свободное программное обеспечение. Это многофункциональное полноэкранное текстовое приложение, которое позволяет копировать, перемещать и удалять файлы и целые деревья каталогов, искать файлы и запускать команды в подоболочке. Так же включает в себя текстовый просмотрщик и редактор включены.
Установка Midnight Commander в Linux.
По умолчанию, Midnight Commander ( далее MC ) не установлен в Linux системах. Так что, перед тем как начать работать с ним, вам необходимо будет его установить. Для этого можно воспользоваться одной из следующих команд:
После завершения установки просто введите « mc » в консоли, чтобы запустить его.
How to Run Multiple Linux Commands at Once in Terminal
Running two or more commands in one line can save you a good deal of time and help you become more efficient and productive in Linux.
Running two or more commands in one line can save you a good deal of time and help you become more efficient and productive in Linux. There are three ways you can run multiple commands in one line in Linux:
Operator | Example | Explanation |
---|---|---|
; | Command 1 ; Command 2 | Run command 1 first and then command 2 |
&& | Command 1 && Command 2 | Run command 2 only if command 1 ends sucessfully |
|| | Command 1 || Command 2 | Run command 2 only if command 1 fails |
Let me show you in detail how you can chain commands in Linux.
Using ; to run multiple Linux commands in one line
The simplest of them all is the semicolon (;). You just combine several commands that you want to run using ; in the following fashion:
Here, cmd1 will run first. Irrespective of whether cmd1 runs successfully or with error, cmd2 will run after it. And when cmd2 command finishes, cmd3 will run. Let’s take an example you can practice easily (if you want to).
mkdir new_dir; cd new_dir; pwd
In the above command, you create a new directory named new_dir with mkdir command. Then you switch to this newly created directory using cd command. Lastly, you print your current location with pwd command.
Using && to run multiple Linux commands
Sometimes you want to ensure that the in the chain of Linux commands, the next command only runs when the previous command ends successfully. This is where the logical AND operator && comes into the picture:
If you use Ubuntu or Debian based distributions, you must have come across this command that utilizes && concept:
sudo apt update && sudo apt upgrade
Here, the first command (sudo apt update) refreshes the package database cache. If there is no error, it will then upgrade all the packages that have newer versions available. Let’s take the earlier example. If the new_dir already exists, mkdir command will return an error. The difference in the behavior of ; and && can be seen in the screenshot below: Did you see how commands separated by && stopped when the first command resulted in an error?
Using || to run several Linux commands at once
You can use the logical OR operator (||) to run a chain of commands but the next command only runs when the previous command ends in error. This is opposite to what you saw with &&.
If cmd1 fails, cmd2 runs. If cmd2 runs successfully, cmd3 won’t run. In the screenshot above, mkdir new_dir command fails because `new_dir already exists. Since this command fails, the next command cd new_dir is executed successfully. And now that this command has run successfully, the next command pwd won’t run.
Bonus Tip: Combine && and || operators
You may combine the operators to run two or more Linux commands. If you combine three commands with && and || , it will behave as the ternary operator in C/C++ ( condition ? expression_true ; expression_false).
[ -f file.txt ] && echo "File exists" || echo "File doesn't exist"
Run the above command before and after creating the file.txt file to see the difference: You can also use ; , && and || to run multiple commands in bash scripts as well.
More such Linux terminal tips
Like copy-paste in Linux terminal, running multiple commands at once is also one of the many Linux command line tips for saving time. Though elementary, it is an essential concept any Linux terminal user should know. Here are a few more. And if you are absolutely new to Linux commands, I have created a series of tutorials that will help you. I hope you liked this terminal trick. Stay tuned for more Linux command tips and tools.
8 Best Linux Console File Managers
Linux console file managers can be very helpful in a day to day tasks, when managing files on a local machine or when connected to a remote one. The visual console representation of the directory helps quickly perform file/folder operations and save us some time.
In this article, we are going to review some of the most frequently used Linux console file managers and their features and benefits.
GNU Midnight Commander
Midnight Command, often referred to simply as mc and is one of the top file managers discussed in this article. Mc comes with all kinds of useful features, aside from copy, move, delete, create files and directories you can change permissions and ownership, review archives, use it as FTP client and many more.
To install midnight commander you can use the following commands:
$ sudo apt install mc [Debian/Ubuntu] $ sudo yum install mc [CentOS/RHEL] $ sudo dnf install mc [Fedora]
Ranger Console File Manager
Ranger is another top choice when, looking for a console file manager. It has a vim like interface, preview of the selected file or directory, bookmarks mouse support and tabbed view.
To install ranger you can use the following commands:
$ sudo apt install ranger [Debian/Ubuntu] $ sudo yum install ranger [CentOS/RHEL] $ sudo dnf install ranger [Fedora]
Cfiles Fast Terminal File Manager
Cfiles is a fast terminal file manager written in C and uses ncurses, similar to ranger, it also uses vi keybindings. It has few dependencies such as cp, mv, fzf, xdg-open and others. While it is lightweight, its installation requires few more steps:
To install cfiles, first you need to install development tools using following commands:
$ sudo apt-get install build-essential [On Debian/Ubuntu] $ sudo yum groupinstall 'Development Tools' [on CentOS/RHEL 7/6]
Next, clone the cfiles repository and install it using following commands.
$ git clone https://github.com/mananapr/cfiles.git $ cd cfiles $ gcc cf.c -lncurses -o cf $ sudo cp cf /usr/bin/ #Or copy somewhere else in your $PATH
More detailed review of cfiles can be found here: Cfiles a terminal file manager for Linux.
Vifm Console File Manager
Vifm is another command line based file manager, which uses curses interface. This one however copies some features from mutter. If you are vim user, you won’t need to learn new set of commands to work with vifm. It uses same keybindings and also has the ability to edit several kind of files.
Similar to other console file managers, it has two panes, supports auto completion. It also supports various of different views for comparison of file trees. You can also execute remote commands with it.
To install Vifm you can use the following commands:
$ sudo apt install vifm [Debian/Ubuntu] $ sudo yum install vifm [CentOS/RHEL] $ sudo dnf install vifm [Fedora]
More detailed review of vifm can be seen at: Vifm command line based file manager for Linux.
Nnn Terminal File Browser
Nnn is the fastest console file manager in our list. While it has less features compared to other file managers, it is extremely lightweight and it is closest to a desktop file manager on what you can get on console. The interaction is simple and allows new users to easily get used to the terminal.
To install nnn, you can use the following command:
$ sudo apt install nnn [Debian/Ubuntu] $ sudo yum install nnn [CentOS/RHEL] $ sudo dnf install nnn [Fedora]
More detailed preview of nnn can be found at: Nnn – fast and friendly terminal file browser.
Lfm Last File Manager
Lfm shortened for Last File Manager is a curses based console file manager written in Python 3.4. It can be used with 1 or 2 panes. It has some useful features such as filters, bookmarks, history, VFS for compressed files, tree view and direct integration with find command, grep utility, df command and other tools. Customize themes are also available.
To install Lfm, you can use the following command:
$ sudo apt install lfm [Debian/Ubuntu] $ sudo yum install lfm [CentOS/RHEL] $ sudo dnf install lfm [Fedora] $ sudo pacman -S lfm [[Arch Linux]
You can also install lfm using pip command:
lf – List Files
Lf – “List files” is a command line file manager written in Go, inspired by Ranger. Originally it was meant to fill the gaps of missing features that ranger had.
Some of the main features of lf are:
- It’s cross platform – Linux, OSX, Windows (only partial).
- Single binary without any runtime dependencies.
- Low memory footprint.
- Configuration with shell commands.
- Customizable keybindings.
Future plans, include the activation of mouse control.
To install lf simply download the binary related build for your OS from the lf releases page.
WCM Commander
The last in our list is WCM command which is another cross platform console file manager.The authors of the WCM commander meant to create a cross platform file manager which mimics the features of Far Manager.
It has a built in terminal, built in text editor and viewer, syntax highlighting, virtual filesystem, and very fast user interface. Mouse support is also enabled. Package for each OS can be found on the WCM download page:
Conclusion
This was our short presentation on some of the top Linux console file managers. If you think we have missed one or like some of them more, please share your thoughts in the comment section.