In addition to the basic file management commands you've learned, here are some other important commands that can help you manage files and directories effectively in a Linux environment:
-
cp:
- Copies files or directories.
- Example:
cp source.txt destination.txtcopiessource.txttodestination.txt.
-
mv:
- Moves or renames files or directories.
- Example:
mv oldname.txt newname.txtrenamesoldname.txttonewname.txt.
-
rm:
- Removes files or directories.
- Example:
rm file.txtdeletesfile.txt. Use-rfor recursive deletion of directories (e.g.,rm -r directory_name).
-
rmdir:
- Removes empty directories.
- Example:
rmdir empty_directorydeletesempty_directoryonly if it is empty.
-
find:
- Searches for files and directories based on criteria.
- Example:
find . -name "*.txt"searches for all.txtfiles in the current directory and its subdirectories.
-
chmod:
- Changes the permissions of files or directories.
- Example:
chmod 755 script.shsets the permissions ofscript.shto read, write, and execute for the owner, and read and execute for others.
-
chown:
- Changes the ownership of files or directories.
- Example:
chown user:group file.txtchanges the owner and group offile.txt.
-
tar:
- Archives files into a single file (tarball).
- Example:
tar -cvf archive.tar directory_namecreates an archive ofdirectory_name.
-
gzip:
- Compresses files to save space.
- Example:
gzip file.txtcompressesfile.txttofile.txt.gz.
-
scp:
- Securely copies files between hosts over a network.
- Example:
scp file.txt user@remote_host:/path/to/destinationcopiesfile.txtto a remote server.
These commands provide a robust toolkit for managing files and directories, allowing you to copy, move, delete, search, and modify permissions as needed. Mastering these commands will enhance your efficiency in navigating and managing your Linux file system.
