This is the development version of Kanrisuru. Since this is still a pre-1.0 release, we don't recommend using this in system-critical production environments.



List contents of a directory in ruby
linux manual

Basic Usage

require 'kanrisuru'
host = '', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result = '/home')



Field Type Description
all boolean
Do not ignore entries starting with "."
path string
List information about FILES at path location
id boolean
Use UID and GID instead of user and group names


Returns an array of FileInfo structs.

FileInfo Fields

Field Type Description
inode integer Unique inode value assigned to file
mode Kanrisuru::Mode An instance of the mode class for querying the mode of a file
hard_links integer The number of hard links pointing to the inode
owner string The owner of file or directory. Can either be a string or integer depending on id param passed
group string The group the file or directory belongs to. Can either be a string or integer depending on id param passed
fsize integer Size of the file in bytes
date DateTime An instance of the DateTime class. Indicates last update time
path string Location of the file

Return Example '/home')[0]
  fsize = 4096,
  date = <DateTime: 2021-07-21T19:55:00+00:00 ((2459417j,71700s,0n),+0s,2299161j)>,
  group = "ubuntu",
  inode = 322561,
  memory_blocks = 3,
  mode = <Kanrisuru::Mode:0x920 @numeric=775 @symbolic=drwxrwxr-x>,
  owner = "ubuntu",
  path = "build",
  type = "directory"

Exit Status

Code Description
0 Success
1 Minor problems (e.g., cannot access subdirectory)
2 Serious trouble (e.g., cannot access command-line argument)

Additional Examples

result = '/etc/', id: true)

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES