rubyisforfun/manuscript/014.txt
Roman Pushkin 845b6a57eb Save
2018-12-23 01:08:11 -08:00

52 lines
No EOL
4.1 KiB
Text

## File System Navigation
File system navigation is just switching between directories to see what's inside, to get the list of files, their names and other attributes. In Far Manager you can use Up, Down keys and Enter to switch into directory (we often say "to change directory"). Use Tab to switch from left to right panel and vice versa.
In bash (zsh or other type of shell) there are commands you need to type from your keyboard in terminal to change directories and get the list of files. It's much easier to do in file managers, but you will definitely remember these shell commands over the time:
```
$ cd my_dir # switch to directory my_dir (or "change directory")
$ cd .. # go one level up
$ ls # list of files
```
Note: pound sign `#` (or hash) indicates the comment. Everything after this sign will be ignored by your shell.
`cd` command is pretty straightforward and easy to remember (**C**hange **D**irectory). But `ls` (list) is a bit tricky. It turns out that there's something else in the file system: hidden files! On Linux and MacOS file names of hidden files start with `.` (dot), so they are often referred as dot-files. To show all the files, including hidden you need to type `ls -a` (`-a` here is parameter to `ls` command and means "all"). But the most useful command is `ls -lah`:
* `l` stands for "long format" or "long listing". This long listing has file attributes, file owner information, size in bytes and modification date.
* `a` tells that we want to show _all_ files.
* `h` is the flag to show meta information in human-readable format. For example, instead of "1000000000 bytes" we'll see "1GB".
Note that Far Manager also has the setting to show/hide hidden files, you can reach it by going to Options (F9), Panel Settings, Show Hidden and System Files.
By the way, `h` flag is quite useful and in addition to `ls`, is often used in other commands. For example, `df -h` stands for "disk filesystem in human readable format" and will display statistics about free space on your hard drives and mounted volumes (like USB stick):
![System information in terminal](images/014-sysinfo-terminal.png)
Hit Ctrl+L in Far Manager to get the same useful system information about free and used disk space, memory, and so on. To hide this panel click Ctrl+L again:
![Right panel with system information in Far Manager](images/014-sysinfo.png)
Quite often you can switch on and off (toggle) different pieces of functionality by pressing the same key. For example, hit F3 to view a file in Far Manager and open built-in file viewer. To exit "view file" mode press F3 again. The same trick works in Midnight Commander.
We've gotten familiar with few shell commands (you don't need to remember all of them, but may want to write down in your notepad or add a bookmark), but in file manager it's all achievable with hotkeys. As you can see, hotkeys are much easier to remember, and result is more clear. Beginners not only able to see the contents of a file system without a need to remember `ls` command and its parameters, but also can navigate file system easily with arrow keys.
Despite all the experience with shell commands, author of this book often jumps back to the file manager when necessary. This tool is also quite useful on new projects with directory structure you're not familiar with.
X> ## Exercise
X> Walk around file system on your computer with file manager and look at directories and files you have. Use F3 key to toggle the file view. Use Tab to switch between left and right panel.
Some useful file manager hotkeys (also see the bottom bar on screenshot above):
* `F3` - toggle view file mode
* `F4` - edit file
* `F5` - copy file or directory from current panel to another
* `F6` - move file or directory from current panel to another
* `F7` - create directory
* `F8` - remove file or directory
* `F9` - options
* `Tab` - switch from one panel to another
* `Ctrl+L` - toggle system information panel
As you can see, basic file operations are achievable with F-keys. If you're planning to buy new laptop, make sure your new laptop has physical F1, F3, F4... keys (for example, some newer Macs have touchbars instead of F-keys).