Manipulate files and directories using commands like cp, mv, rm, and chmod.

Context: GNU/Linux command examples.

Manipulate files and directories using commands like cp, mv, rm, and chmod.

Certainly! Here are examples of GNU/Linux commands for manipulating files and directories:

  1. Copy Files and Directories (cp):

    • Copy a file to another location:
      cp /path/to/source/file /path/to/destination/
    • Copy a directory and its contents to another location:
      cp -r /path/to/source/directory /path/to/destination/
  2. Move or Rename Files and Directories (mv):

    • Move a file to another location (also used for renaming files):
      mv /path/to/source/file /path/to/destination/
    • Move a directory and its contents to another location (also used for renaming directories):
      mv /path/to/source/directory /path/to/destination/
  3. Remove Files and Directories (rm):

    • Remove a file:
      rm /path/to/file
    • Remove a directory and its contents (recursively):
      rm -r /path/to/directory
    • Remove files or directories interactively with confirmation prompts:
      rm -i /path/to/file
  4. Change File Permissions (chmod):

    • Change file permissions using octal representation (e.g., chmod 644 file):
      chmod 644 /path/to/file
    • Change file permissions using symbolic representation (e.g., chmod u+r file):
      chmod u+r /path/to/file
    • Change permissions recursively for files and directories:
      chmod -R 755 /path/to/directory

These commands will allow you to manipulate files and directories in GNU/Linux. Remember to replace /path/to/source and /path/to/destination with the appropriate paths for your specific use case.

You should also read:

Docker commands

List all docker containers (running and stopped) docker ps --all docker run --name container_name image docker start|stop container_name docker pull image docker images…

Configuration files

Christiane is a RHEL Sysadmin at CNN: Christiane is going to take her RHEL exam in 1 week. Please list and explain the…