gbash

File and Path Commands

Commands for creating, copying, moving, inspecting, and removing files and directories within the sandbox filesystem.

basename

Strip directory and suffix from a filename.

basename /home/agent/project/main.go        # main.go
basename /home/agent/project/main.go .go    # main

cat

Concatenate and print files.

cat file.txt
cat header.txt body.txt footer.txt > combined.txt
cat -n file.txt                             # number all lines

chmod

Change file mode bits.

chmod 755 script.sh
chmod u+x script.sh
chmod -R 644 src/

chown

Change file owner and group.

chown agent file.txt
chown agent:staff file.txt

cp

Copy files and directories.

cp source.txt dest.txt
cp -r src/ backup/
cp -p original.txt copy.txt                 # preserve attributes

dirname

Strip the last component from a path.

dirname /home/agent/project/main.go         # /home/agent/project

du

Estimate file space usage.

du -sh /home/agent/project
du -a src/

file

Determine file type.

file image.png
file script.sh

find

Search for files in a directory hierarchy.

find . -name "*.go"
find /home/agent -type f -name "*.txt"
find . -name "*.log" -size +1k

ln

Create symbolic links.

ln -s /home/agent/project/config.yaml config
ln -sf target.txt link.txt                  # force overwrite

Create a hard link.

link original.txt hardcopy.txt

ls

List directory contents.

ls
ls -la /home/agent
ls -lh --sort=size src/

dir

List directory contents. Behaves like ls.

dir /home/agent/project

mkdir

Create directories.

mkdir newdir
mkdir -p path/to/nested/dir

mv

Move or rename files and directories.

mv old.txt new.txt
mv file.txt /home/agent/archive/

Print the target of a symbolic link.

readlink symlink.txt
readlink -f relative/symlink                # canonicalize

rm

Remove files or directories.

rm file.txt
rm -r directory/
rm -rf build/

rmdir

Remove empty directories.

rmdir emptydir
rmdir -p a/b/c                              # remove parents too

stat

Display file status.

stat file.txt

touch

Change file timestamps or create empty files.

touch newfile.txt
touch -m existing.txt                       # update modification time

tree

List directory contents in a tree format.

tree
tree -L 2 src/
tree -d                                     # directories only

Additional File and Path Utilities

These commands are also part of the default registry:

CommandDescription
chgrpChange file group ownership without changing the owning user
ddCopy raw data streams with block-size, skip, and count controls
dfReport filesystem space usage for the current sandbox backend
installCopy files into place while setting permissions and ownership-like metadata
mktempCreate uniquely named temporary files or directories
pathchkValidate path names against portability and length rules
realpathResolve a path to its canonical absolute location
truncateSet a file to an exact byte length
unlinkRemove a single file path without recursive behavior
vdirVerbose directory listing equivalent to ls -l

For flags and shell-facing help text, run help <command> inside gbash.