]> git.proxmox.com Git - ceph.git/blame - ceph/doc/man/8/cephfs-shell.rst
import ceph quincy 17.2.1
[ceph.git] / ceph / doc / man / 8 / cephfs-shell.rst
CommitLineData
20effc67 1:orphan:
11fdf7f2 2
20effc67
TL
3===================================================
4cephfs-shell -- Shell-like tool talking with CephFS
5===================================================
6
7.. program:: cephfs-shell
8
9Synopsis
10========
11
12| **cephfs-shell** [options] [command]
13| **cephfs-shell** [options] -- [command, command,...]
14
15Description
16===========
11fdf7f2 17
f67539c2 18CephFS Shell provides shell-like commands that directly interact with the
20effc67 19Ceph File System.
f67539c2
TL
20
21This tool can be used in interactive mode as well as in non-interactive mode.
22In former mode, cephfs-shell opens a shell session and after the given command
23is finished, it prints the prompt string and waits indefinitely. When the
24shell session is finished, cephfs-shell quits with the return value of last
25executed command. In non-interactive mode, cephfs-shell issues a command and
26exits right after the command's execution is complete with the command's
27return value.
28
29Behaviour of CephFS Shell can be tweaked using ``cephfs-shell.conf``. Refer to
30`CephFS Shell Configuration File`_ for details.
11fdf7f2 31
20effc67
TL
32Options
33=======
11fdf7f2 34
20effc67 35.. option:: -b, --batch FILE
11fdf7f2 36
20effc67
TL
37 Path to batch file.
38
39.. option:: -c, --config FILE
11fdf7f2 40
20effc67
TL
41 Path to cephfs-shell.conf
42
43.. option:: -f, --fs FS
44
45 Name of filesystem to mount.
46
47.. option:: -t, --test FILE
48
49 Path to transcript(s) in FILE for testing
9f95a23c
TL
50
51.. note::
52
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:
56
57.. code:: bash
58
a4b75251 59 [build]$ python3 -m venv venv && source venv/bin/activate && pip3 install cmd2
9f95a23c
TL
60 [build]$ source vstart_environment.sh && source venv/bin/activate && python3 ../src/tools/cephfs/cephfs-shell
61
11fdf7f2
TL
62Commands
63========
64
65mkdir
66-----
67
68Create the directory(ies), if they do not already exist.
69
70Usage :
71
72 mkdir [-option] <directory>...
73
74* directory - name of the directory to be created.
75
76Options :
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.
79
80put
81---
82
9f95a23c 83Copy a file/directory to Ceph File System from Local File System.
11fdf7f2
TL
84
85Usage :
86
33c7a0ef 87 put [options] <source_path> <target_path>
11fdf7f2
TL
88
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.
92
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.
95
96Options :
97 -f, --force Overwrites the destination if it already exists.
98
99
100get
101---
102
9f95a23c 103Copy a file from Ceph File System to Local File System.
11fdf7f2
TL
104
105Usage :
106
33c7a0ef 107 get [options] <source_path> <target_path>
11fdf7f2 108
9f95a23c 109* source_path - remote file/directory path which is to be copied to local file system.
11fdf7f2
TL
110 * if `.` copies all the file/directories in the remote working directory.
111
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.
115
116Options:
117 -f, --force Overwrites the destination if it already exists.
118
119ls
120--
121
122List all the files and directories in the current working directory.
123
124Usage :
125
126 ls [option] [directory]...
127
128* directory - name of directory whose files/directories are to be listed.
129 * By default current working directory's files/directories are listed.
130
131Options:
132 -l, --long list with long format - show permissions
133 -r, --reverse reverse sort
134 -H human readable
135 -a, -all ignore entries starting with .
136 -S Sort by file_size
137
138
139cat
140---
141
142Concatenate files and print on the standard output
143
144Usage :
145
146 cat <file>....
147
148* file - name of the file
149
150cd
151--
152
153Change current working directory.
154
155Usage :
156
157 cd [directory]
158
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.
161
162cwd
163---
164
165Get current working directory.
166
167Usage :
168
169 cwd
170
171
172quit/Ctrl + D
173-------------
174
175Close the shell.
176
177chmod
178-----
179
180Change the permissions of file/directory.
181
182Usage :
183
184 chmod <mode> <file/directory>
185
186mv
187--
188
189Moves files/Directory from source to destination.
190
191Usage :
192
193 mv <source_path> <destination_path>
194
195rmdir
196-----
197
198Delete a directory(ies).
199
200Usage :
201
202 rmdir <directory_name>.....
203
204rm
205--
206
207Remove a file(es).
208
209Usage :
210
211 rm <file_name/pattern>...
212
213
214write
215-----
216
217Create and Write a file.
218
219Usage :
220
221 write <file_name>
222 <Enter Data>
223 Ctrl+D Exit.
224
225lls
226---
227
228Lists all files and directories in the specified directory.Current local directory files and directories are listed if no path is mentioned
229
230Usage:
231
232 lls <path>.....
233
234lcd
235---
236
237Moves into the given local directory.
238
239Usage :
240
241 lcd <path>
242
243lpwd
244----
245
246Prints the absolute path of the current local directory.
247
248Usage :
249
250 lpwd
251
252
253umask
254-----
255
256Set and get the file mode creation mask
257
258Usage :
259
260 umask [mode]
261
262alias
263-----
264
265Define or display aliases
266
267Usage:
268
269 alias [name] | [<name> <value>]
270
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
273
9f95a23c
TL
274run_pyscript
275------------
11fdf7f2
TL
276
277Runs a python script file inside the console
278
279Usage:
280
9f95a23c 281 run_pyscript <script_path> [script_arguments]
11fdf7f2
TL
282
283* Console commands can be executed inside this script with cmd ("your command")
9f95a23c
TL
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
286
287.. note:: This command is available as ``pyscript`` for cmd2 versions 0.9.13
288 or less.
11fdf7f2
TL
289
290py
291--
292
293Invoke python command, shell, or script
294
295Usage :
296
297 py <command>: Executes a Python command.
298 py: Enters interactive Python mode.
299
300shortcuts
301---------
302
303Lists shortcuts (aliases) available
304
9f95a23c
TL
305Usage :
306
307 shortcuts
308
11fdf7f2
TL
309history
310-------
311
312View, run, edit, and save previously entered commands.
313
314Usage :
315
316 history [-h] [-r | -e | -s | -o FILE | -t TRANSCRIPT] [arg]
317
318Options:
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
325
326unalias
327-------
328
329Unsets aliases
330
331Usage :
332
333 unalias [-a] name [name ...]
334
335* name - name of the alias being unset
336
337Options:
338 -a remove all alias definitions
339
340set
341---
342
343Sets a settable parameter or shows current settings of parameters.
344
345Usage :
346
347 set [-h] [-a] [-l] [settable [settable ...]]
348
349* Call without arguments for a list of settable parameters with their values.
350
9f95a23c
TL
351Options :
352 -h show this help message and exit
353 -a display read-only settings as well
354 -l describe function of parameter
11fdf7f2
TL
355
356edit
357----
358
359Edit a file in a text editor.
360
361Usage:
362
363 edit [file_path]
364
365* file_path - path to a file to open in editor
366
9f95a23c
TL
367run_script
368----------
11fdf7f2
TL
369
370Runs commands in script file that is encoded as either ASCII or UTF-8 text.
9f95a23c 371Each command in the script should be separated by a newline.
11fdf7f2
TL
372
373Usage:
374
9f95a23c
TL
375 run_script <file_path>
376
11fdf7f2
TL
377
378* file_path - a file path pointing to a script
379
9f95a23c
TL
380.. note:: This command is available as ``load`` for cmd2 versions 0.9.13
381 or less.
11fdf7f2
TL
382
383shell
384-----
385
386Execute a command as if at the OS prompt.
387
388Usage:
389
390 shell <command> [arguments]
391
392locate
393------
394
9f95a23c 395Find an item in File System
11fdf7f2
TL
396
397Usage:
9f95a23c 398
11fdf7f2
TL
399 locate [options] <name>
400
401Options :
402 -c Count number of items found
403 -i Ignore case
404
9f95a23c
TL
405stat
406------
407
408Display file status.
409
410Usage :
411
412 stat [-h] <file_name> [file_name ...]
413
414Options :
415 -h Shows the help message
416
417snap
418----
419
420Create or Delete Snapshot
421
422Usage:
423
424 snap {create|delete} <snap_name> <dir_name>
425
426* snap_name - Snapshot name to be created or deleted
427
428* dir_name - directory under which snapshot should be created or deleted
429
430setxattr
431--------
432
433Set extended attribute for a file
434
435Usage :
436
437 setxattr [-h] <path> <name> <value>
438
439* path - Path to the file
440
441* name - Extended attribute name to get or set
442
443* value - Extended attribute value to be set
444
445Options:
446 -h, --help Shows the help message
447
448getxattr
449--------
450
451Get extended attribute value for the name associated with the path
452
453Usage :
454
455 getxattr [-h] <path> <name>
456
457* path - Path to the file
458
459* name - Extended attribute name to get or set
460
461Options:
462 -h, --help Shows the help message
463
464listxattr
465---------
466
467List extended attribute names associated with the path
468
469Usage :
470
471 listxattr [-h] <path>
472
473* path - Path to the file
474
475Options:
476 -h, --help Shows the help message
f67539c2
TL
477
478df
479--
480
481Display amount of available disk space
482
483Usage :
484
485 df [-h] [file [file ...]]
486
487* file - name of the file
488
489Options:
490 -h, --help Shows the help message
491
492du
493--
494
495Show disk usage of a directory
496
497Usage :
498
499 du [-h] [-r] [paths [paths ...]]
500
501* paths - name of the directory
502
503Options:
504 -h, --help Shows the help message
505
506 -r Recursive Disk usage of all directories
507
508
509quota
510-----
511
512Quota management for a Directory
513
514Usage :
515
516 quota [-h] [--max_bytes [MAX_BYTES]] [--max_files [MAX_FILES]] {get,set} path
517
518* {get,set} - quota operation type.
519
520* path - name of the directory.
521
522Options :
523 -h, --help Shows the help message
524
525 --max_bytes MAX_BYTES Set max cumulative size of the data under this directory
526
527 --max_files MAX_FILES Set total number of files under this directory tree
528
529CephFS Shell Configuration File
530===============================
531By default, CephFS Shell looks for ``cephfs-shell.conf`` in the path provided
532by the environment variable ``CEPHFS_SHELL_CONF`` and then in user's home
533directory (``~/.cephfs-shell.conf``).
534
535Right now, CephFS Shell inherits all its options from its dependency ``cmd2``.
536Therefore, these options might vary with the version of ``cmd2`` installed on
537your system. Refer to ``cmd2`` docs for a description of these options.
538
20effc67
TL
539Following is a sample ``cephfs-shell.conf``
540
541.. code-block:: ini
f67539c2
TL
542
543 [cephfs-shell]
544 prompt = CephFS:~/>>>
545 continuation_prompt = >
546
547 quiet = False
548 timing = False
549 colors = True
550 debug = False
551
552 abbrev = False
553 autorun_on_edit = False
554 echo = False
555 editor = vim
556 feedback_to_output = False
557 locals_in_py = True
558
559Exit Code
560=========
561
562Following exit codes are returned by cephfs shell
563
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+-----------------------------------------------+-----------+
577| I/O error | 6 |
578+-----------------------------------------------+-----------+
579| No space left on device | 7 |
580+-----------------------------------------------+-----------+
581| File exists | 8 |
582+-----------------------------------------------+-----------+
583| No data available | 9 |
584+-----------------------------------------------+-----------+
585| Invalid argument | 10 |
586+-----------------------------------------------+-----------+
587| Operation not supported on transport endpoint | 11 |
588+-----------------------------------------------+-----------+
589| Range error | 12 |
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+-----------------------------------------------+-----------+
599| Broken pipe | 17 |
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+-----------------------------------------------+-----------+
20effc67
TL
611
612Files
613=====
614
615``~/.cephfs-shell.conf``