3 ===================================================
4 cephfs-shell -- Shell-like tool talking with CephFS
5 ===================================================
7 .. program:: cephfs-shell
12 | **cephfs-shell** [options] [command]
13 | **cephfs-shell** [options] -- [command, command,...]
18 CephFS Shell provides shell-like commands that directly interact with the
21 This tool can be used in interactive mode as well as in non-interactive mode.
22 In former mode, cephfs-shell opens a shell session and after the given command
23 is finished, it prints the prompt string and waits indefinitely. When the
24 shell session is finished, cephfs-shell quits with the return value of last
25 executed command. In non-interactive mode, cephfs-shell issues a command and
26 exits right after the command's execution is complete with the command's
29 Behaviour of CephFS Shell can be tweaked using ``cephfs-shell.conf``. Refer to
30 `CephFS Shell Configuration File`_ for details.
35 .. option:: -b, --batch FILE
39 .. option:: -c, --config FILE
41 Path to cephfs-shell.conf
43 .. option:: -f, --fs FS
45 Name of filesystem to mount.
47 .. option:: -t, --test FILE
49 Path to transcript(s) in FILE for testing
53 Latest version of the cmd2 module is required for running cephfs-shell.
54 If CephFS is installed through source, execute cephfs-shell in the build
55 directory. It can also be executed as following using virtualenv:
59 [build]$ python3 -m venv venv && source venv/bin/activate && pip3 install cmd2
60 [build]$ source vstart_environment.sh && source venv/bin/activate && python3 ../src/tools/cephfs/cephfs-shell
68 Create the directory(ies), if they do not already exist.
72 mkdir [-option] <directory>...
74 * directory - name of the directory to be created.
77 -m MODE Sets the access mode for the new directory.
78 -p, --parent Create parent directories as necessary. When this option is specified, no error is reported if a directory already exists.
83 Copy a file/directory to Ceph File System from Local File System.
87 put [options] <source_path> <target_path>
89 * source_path - local file/directory path to be copied to cephfs.
90 * if `.` copies all the file/directories in the local working directory.
91 * if `-` Reads the input from stdin.
93 * target_path - remote directory path where the files/directories are to be copied to.
94 * if `.` files/directories are copied to the remote working directory.
97 -f, --force Overwrites the destination if it already exists.
103 Copy a file from Ceph File System to Local File System.
107 get [options] <source_path> <target_path>
109 * source_path - remote file/directory path which is to be copied to local file system.
110 * if `.` copies all the file/directories in the remote working directory.
112 * target_path - local directory path where the files/directories are to be copied to.
113 * if `.` files/directories are copied to the local working directory.
114 * if `-` Writes output to stdout.
117 -f, --force Overwrites the destination if it already exists.
122 List all the files and directories in the current working directory.
126 ls [option] [directory]...
128 * directory - name of directory whose files/directories are to be listed.
129 * By default current working directory's files/directories are listed.
132 -l, --long list with long format - show permissions
133 -r, --reverse reverse sort
135 -a, -all ignore entries starting with .
142 Concatenate files and print on the standard output
148 * file - name of the file
153 Change current working directory.
159 * directory - path/directory name. If no directory is mentioned it is changed to the root directory.
160 * If '.' moves to the parent directory of the current directory.
165 Get current working directory.
180 Change the permissions of file/directory.
184 chmod <mode> <file/directory>
189 Moves files/Directory from source to destination.
193 mv <source_path> <destination_path>
198 Delete a directory(ies).
202 rmdir <directory_name>.....
211 rm <file_name/pattern>...
217 Create and Write a file.
228 Lists all files and directories in the specified directory.Current local directory files and directories are listed if no path is mentioned
237 Moves into the given local directory.
246 Prints the absolute path of the current local directory.
256 Set and get the file mode creation mask
265 Define or display aliases
269 alias [name] | [<name> <value>]
271 * name - name of the alias being looked up, added, or replaced
272 * value - what the alias will be resolved to (if adding or replacing) this can contain spaces and does not need to be quoted
277 Runs a python script file inside the console
281 run_pyscript <script_path> [script_arguments]
283 * Console commands can be executed inside this script with cmd ("your command")
284 However, you cannot run nested "py" or "pyscript" commands from within this
285 script. Paths or arguments that contain spaces must be enclosed in quotes
287 .. note:: This command is available as ``pyscript`` for cmd2 versions 0.9.13
293 Invoke python command, shell, or script
297 py <command>: Executes a Python command.
298 py: Enters interactive Python mode.
303 Lists shortcuts (aliases) available
312 View, run, edit, and save previously entered commands.
316 history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT] [arg]
319 -h show this help message and exit
320 -r run selected history items
321 -e edit and then run selected history items
322 -s script format; no separation lines
323 -o FILE output commands to a script file
324 -t TRANSCRIPT output commands and results to a transcript file
333 unalias [-a] name [name ...]
335 * name - name of the alias being unset
338 -a remove all alias definitions
343 Sets a settable parameter or shows current settings of parameters.
347 set [-h] [-a] [-l] [settable [settable ...]]
349 * Call without arguments for a list of settable parameters with their values.
352 -h show this help message and exit
353 -a display read-only settings as well
354 -l describe function of parameter
359 Edit a file in a text editor.
365 * file_path - path to a file to open in editor
370 Runs commands in script file that is encoded as either ASCII or UTF-8 text.
371 Each command in the script should be separated by a newline.
375 run_script <file_path>
378 * file_path - a file path pointing to a script
380 .. note:: This command is available as ``load`` for cmd2 versions 0.9.13
386 Execute a command as if at the OS prompt.
390 shell <command> [arguments]
395 Find an item in File System
399 locate [options] <name>
402 -c Count number of items found
412 stat [-h] <file_name> [file_name ...]
415 -h Shows the help message
420 Create or Delete Snapshot
424 snap {create|delete} <snap_name> <dir_name>
426 * snap_name - Snapshot name to be created or deleted
428 * dir_name - directory under which snapshot should be created or deleted
433 Set extended attribute for a file
437 setxattr [-h] <path> <name> <value>
439 * path - Path to the file
441 * name - Extended attribute name to get or set
443 * value - Extended attribute value to be set
446 -h, --help Shows the help message
451 Get extended attribute value for the name associated with the path
455 getxattr [-h] <path> <name>
457 * path - Path to the file
459 * name - Extended attribute name to get or set
462 -h, --help Shows the help message
467 List extended attribute names associated with the path
471 listxattr [-h] <path>
473 * path - Path to the file
476 -h, --help Shows the help message
481 Display amount of available disk space
485 df [-h] [file [file ...]]
487 * file - name of the file
490 -h, --help Shows the help message
495 Show disk usage of a directory
499 du [-h] [-r] [paths [paths ...]]
501 * paths - name of the directory
504 -h, --help Shows the help message
506 -r Recursive Disk usage of all directories
512 Quota management for a Directory
516 quota [-h] [--max_bytes [MAX_BYTES]] [--max_files [MAX_FILES]] {get,set} path
518 * {get,set} - quota operation type.
520 * path - name of the directory.
523 -h, --help Shows the help message
525 --max_bytes MAX_BYTES Set max cumulative size of the data under this directory
527 --max_files MAX_FILES Set total number of files under this directory tree
529 CephFS Shell Configuration File
530 ===============================
531 By default, CephFS Shell looks for ``cephfs-shell.conf`` in the path provided
532 by the environment variable ``CEPHFS_SHELL_CONF`` and then in user's home
533 directory (``~/.cephfs-shell.conf``).
535 Right now, CephFS Shell inherits all its options from its dependency ``cmd2``.
536 Therefore, these options might vary with the version of ``cmd2`` installed on
537 your system. Refer to ``cmd2`` docs for a description of these options.
539 Following is a sample ``cephfs-shell.conf``
544 prompt = CephFS:~/>>>
545 continuation_prompt = >
553 autorun_on_edit = False
556 feedback_to_output = False
562 Following exit codes are returned by cephfs shell
564 +-----------------------------------------------+-----------+
565 | Error Type | Exit Code |
566 +===============================================+===========+
567 | Miscellaneous | 1 |
568 +-----------------------------------------------+-----------+
569 | Keyboard Interrupt | 2 |
570 +-----------------------------------------------+-----------+
571 | Operation not permitted | 3 |
572 +-----------------------------------------------+-----------+
573 | Permission denied | 4 |
574 +-----------------------------------------------+-----------+
575 | No such file or directory | 5 |
576 +-----------------------------------------------+-----------+
578 +-----------------------------------------------+-----------+
579 | No space left on device | 7 |
580 +-----------------------------------------------+-----------+
582 +-----------------------------------------------+-----------+
583 | No data available | 9 |
584 +-----------------------------------------------+-----------+
585 | Invalid argument | 10 |
586 +-----------------------------------------------+-----------+
587 | Operation not supported on transport endpoint | 11 |
588 +-----------------------------------------------+-----------+
590 +-----------------------------------------------+-----------+
591 | Operation would block | 13 |
592 +-----------------------------------------------+-----------+
593 | Directory not empty | 14 |
594 +-----------------------------------------------+-----------+
595 | Not a directory | 15 |
596 +-----------------------------------------------+-----------+
597 | Disk quota exceeded | 16 |
598 +-----------------------------------------------+-----------+
600 +-----------------------------------------------+-----------+
601 | Cannot send after transport endpoint shutdown | 18 |
602 +-----------------------------------------------+-----------+
603 | Connection aborted | 19 |
604 +-----------------------------------------------+-----------+
605 | Connection refused | 20 |
606 +-----------------------------------------------+-----------+
607 | Connection reset | 21 |
608 +-----------------------------------------------+-----------+
609 | Interrupted function call | 22 |
610 +-----------------------------------------------+-----------+
615 ``~/.cephfs-shell.conf``