# UnixFileSystem

Import: `import com.install4j.api.unix.UnixFileSystem;`

```java
public class UnixFileSystem
```

Collection of static methods to access Unix-specific file operations and information.

| Type | Kind | Description |
|---|---|---|
## Nested types

| [UnixFileSystem.FileInformation](UnixFileSystem.FileInformation.md) | interface | Holds Unix-specific information about a file. |

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`setMode(int, File)`](#setmode-int-file) | `boolean` | Set the Unix file mode for a file. |
| [`setMode(String, File)`](#setmode-string-file) | `boolean` | Set the Unix file mode for a file. |
| [`createLink(String, File)`](#createlink-string-file) | `boolean` | Create a symbolic link on Unix. |
| [`setOwner(String, File)`](#setowner-string-file) | `boolean` | Set the owner of a file. |
| [`getFileInformation(File)`](#getfileinformation-file) | `FileInformation` | Get Unix-specific information about a file. |
| [`findExecutableInPath(String)`](#findexecutableinpath-string) | `File` | Returns the absolute path of an executable if it is located on the path. |
| [`getShell()`](#getshell) | `String` | Returns the shell executable of the current user. |

### setMode(int, File)

```java
public static boolean setMode(int intMode, File destFile)
```

Set the Unix file mode for a file. For specifying integer file modes, you can use octal numbers by prefixing
a "0".


**Parameters:**

- `intMode` — the Unix file mode
- `destFile` — the file for which the mode should be set

**Returns:** whether the operation was successful or not

### setMode(String, File)

```java
public static boolean setMode(String mode, File destFile)
```

Set the Unix file mode for a file.


**Parameters:**

- `mode` — the Unix file mode as an octal string, e.g. "755".
- `destFile` — the file for which the mode should be set

**Returns:** whether the operation was successful or not

### createLink(String, File)

```java
public static boolean createLink(String destFileName, File linkFile)
```

Create a symbolic link on Unix. If the link exists, it will be overwritten.


**Parameters:**

- `destFileName` — the file where the link should point to
- `linkFile` — the link that should be created

**Returns:** whether the operation was successful or not

### setOwner(String, File)

```java
public static boolean setOwner(String owner, File file)
```

Set the owner of a file.


**Parameters:**

- `owner` — the owner spec. Either a user name like "user" or a user name followed by a colon and a group name, like "user:group".
In the latter case, "user" can be the empty string and only the group ownership will be changed.
- `file` — the file for which the owner should be set.

**Returns:** whether the operation was successful or not

### getFileInformation(File)

```java
public static FileInformation getFileInformation(File file)
```

Get Unix-specific information about a file.


**Parameters:**

- `file` — the file for which the information is requested.

**Returns:** the `FileInformation` object with the Unix-specific information

### findExecutableInPath(String)

```java
public static File findExecutableInPath(String executable)
```

Returns the absolute path of an executable if it is located on the path.


**Parameters:**

- `executable` — the executable name without path information or quotes

**Returns:** the path of the executable or `null` if the executable was not found.

### getShell()

```java
public static String getShell()
```

Returns the shell executable of the current user.
If the `SHELL` environment variable is set, its value is returned, otherwise the return value is
`/bin/sh`

## Constructors

| Signature | Description |
|---|---|
| [`UnixFileSystem()`](#unixfilesystem) |  |

### UnixFileSystem()

```java
public UnixFileSystem()
```

