File Manipulation Commands

This guide covers essential commands used for creating, copying, moving, and deleting files in UNIX/Linux systems.

File Creation and Editing

touch: Create a new file or update the timestamps of an existing file. Usage: touch filename

nano/vi: Edit files using a text editor. Usage: nano filename or vi filename

File Copying, Moving, and Deleting

cp: Copy files or directories. Usage: cp source_file destination_file or cp -r source_directory destination_directory

mv: Move or rename files or directories. Usage: mv current_filename new_filename or mv file /path/to/directory/

rm: Remove files or directories. Usage: rm filename or rm -r directory_name to remove a directory and its contents.

File Permissions and Ownership

chmod: Change file permissions. Usage: chmod 755 filename or chmod +x filename to make a file executable.

chown: Change file owner and group. Usage: chown user:group filename

chgrp: Change the group ownership of a file. Usage: chgrp groupname filename