Essential Linux File Management Commands
Linux provides a variety of commands for managing files and directories. These commands allow users to create, copy, move, delete, and perform other operations on files and directories.
Creating Files and Directories
The touch
command is used to create new files:
touch file.txt
The mkdir
command is used to create new directories:
mkdir documents
Copying and Moving Files
The cp
command is used to copy files:
cp file.txt file_copy.txt
The mv
command is used to move or rename files:
mv file.txt documents/file.txt
Deleting Files and Directories
The rm
command is used to delete files:
rm file.txt
The rmdir
command is used to delete empty directories:
rmdir documents
To delete a non-empty directory, you can use the -r
(recursive) option with rm
:
rm -r documents
Listing File and Directory Contents
The ls
command is used to list the contents of a directory:
ls
ls -l ## Long listing format
ls -a ## Include hidden files
Managing File Permissions
Linux file permissions are controlled using the chmod
command:
chmod 644 file.txt ## Set read-write permissions for owner, read-only for group and others
Understanding and utilizing these essential file management commands is crucial for navigating and maintaining the Linux file system effectively.