Sobes.tech
Junior — Middle

What Linux commands are applicable for managing files and directories?

sobes.tech AI

Answer from AI

In Linux, the following basic commands are used for managing files and directories:

  • ls — displays a list of files and directories in the current or specified directory.
  • cd — changes the current directory.
  • pwd — shows the full path of the current directory.
  • mkdir — creates a new directory.
  • rmdir — removes an empty directory.
  • rm — deletes files and directories (with the -r option for recursive deletion).
  • cp — copies files and directories.
  • mv — moves or renames files and directories.
  • touch — creates an empty file or updates the modification time.
  • find — searches for files and directories based on criteria.

Example:

mkdir my_folder       # Create a directory
cd my_folder          # Change to the directory
touch file.txt        # Create a file
ls -l                 # Show detailed list
cp file.txt copy.txt  # Copy the file
mv copy.txt ../       # Move the file to the parent directory
rm file.txt           # Delete the file
cd ..                 # Go back
rmdir my_folder       # Remove the empty directory

These commands are fundamental for navigation and managing the file system in Linux.