Common file management commands in Linux include:
-
ls: Lists files and directories in the current directory.ls -l # Detailed listing ls -a # Includes hidden files -
cd: Changes the current directory.cd /path/to/directory # Navigate to a specific directory cd .. # Move up one level cd ~ # Go to the home directory -
cp: Copies files or directories.cp source.txt destination.txt # Copy a file cp -r source_directory/ destination_directory/ # Copy a directory recursively -
mv: Moves or renames files or directories.mv oldname.txt newname.txt # Rename a file mv file.txt /path/to/directory/ # Move a file to another directory -
rm: Removes files or directories.rm file.txt # Remove a file rm -r directory/ # Remove a directory and its contents recursively -
mkdir: Creates a new directory.mkdir new_directory # Create a new directory -
rmdir: Removes an empty directory.rmdir empty_directory # Remove an empty directory -
touch: Creates an empty file or updates the timestamp of an existing file.touch newfile.txt # Create a new empty file -
find: Searches for files and directories based on criteria.find /path/to/search -name "filename.txt" # Find a file by name -
chmod: Changes the permissions of a file or directory.chmod 755 script.sh # Set permissions for a script
These commands form the foundation of file management in Linux, allowing you to create, modify, and organize files and directories efficiently.
