Exploring and Managing Files and Directories
Once you have a basic understanding of the Linux file system structure and how to navigate it using the cd
command, the next step is to learn how to explore and manage files and directories.
The ls
(list) command is one of the most commonly used commands for viewing the contents of a directory. You can use it to list the files and subdirectories within the current working directory or a specified directory.
ls
file1.txt file2.txt directory1/
To create a new directory, you can use the mkdir
(make directory) command followed by the name of the new directory.
mkdir new_directory
To create a new file, you can use the touch
command followed by the name of the file you want to create.
touch new_file.txt
To remove a file, you can use the rm
(remove) command followed by the name of the file.
rm file1.txt
To copy a file, you can use the cp
(copy) command followed by the source file and the destination file.
cp file1.txt file_copy.txt
To move or rename a file, you can use the mv
(move) command followed by the source file and the destination file or new name.
mv file1.txt renamed_file.txt
By mastering these basic file and directory management commands, you can effectively navigate, explore, and manipulate the contents of the Linux file system to suit your needs.