File and Directory Management
Managing files and directories is essential when working with HPC systems. This section covers commands that allow you to manipulate files, move them between directories, create new directories, copy files, change file ownership and permissions, and delete them as needed.
Â
Useful Commands
Move or Rename Files and Directories
mv source_file_or_directory target_directory_or_filename
Moves a file or directory from one location to another. It can also be used to rename files and directories.
Remove Files or Directories
rm filename
Removes (deletes) a file. Use with caution, as deleted files are not recoverable.
rm -r directory
Recursively removes a directory and its contents. This command is used for deleting directories.
Â
Remove Empty Directories
Removes an empty directory. This command only works if the directory is empty.
Create Directories
Creates a new directory with the specified name.
Copy Files or Directories
Copies a file to a new location.
Recursively copies a directory and its contents to a new location.
Create Empty File
Creates an empty file with the specified name. If the file already exists, update its timestamp.
Change File Ownership
Changes the owner (and group) of a file to the specified user (group).
Recursively changes the owner of a directory and its contents to the specified user (group).
Change File Permissions
Changes the permissions of a file. Permissions can be specified using octal numbers (e.g.,
chmod 644 file
) or symbolic notation (e.g.,chmod u+x file
). See Linux file permissions explained | Enable Sysadmin (redhat.com) for more information on file permissions.Recursively changes the permissions of a directory and its contents.
Â
These commands are fundamental for manipulating files and directories on HPC systems. Each command may have additional options (flags) to modify its behavior. For more detailed information about each command and its available flags, consult the manual pages by executing man command
(e.g., man mv
) on the login nodes.
Center for Computational Sciences