5.1 - Linux Commands
5.1 - Linux Commands
The cp command copies files and directories from one location to another.
Copying a File:
cp file1.txt /path/to/destination
Copying a Directory:
cp -r directory_name /path/to/destination
The -r option allows recursive copying, which is necessary for directories.
Moving a File:
mv file1.txt /path/to/destination
Renaming a File:
mv oldname.txt newname.txt
mv file1 file2 : Rename file1 to file2.
mv file1 /destination/directory/ : Move file to another directory.
mv -i file1 file2 : Prompt before overwriting.
mv dir1 /destination/directory/ : Move a directory.
Exercises
Exercises:
Create a file and change its owner to another user (if you have permissions).
Change the group ownership of a file.
chown user file1: Change ownership to a user.
chown user:group file1: Change user and group ownership.
chown -R user:group dir1: Change ownership recursively for a directory.
df - Report file system disk space usage
• -g, –giga Displays memory usage in gigabytes. • –help Displays a help message and exits.