Click on each book below to review & buy on Amazon.
As an Amazon Associate, I earn from qualifying purchases.
LPI Linux Essentials Exam 010-160 - Topic 2.4 - Create, Copy, Move & Delete Files
Managing files is a fundamental skill when working with Linux systems. In this guide we will focus on the key commands touch
, cp
, mv
, and rm
.
Whereas Windows operating systems are case insensitive, Linux operating system are case sensitive. Files myfile.txt
and MyFile.TXT
are two different files.
Creating Files
The touch
command can be used to create empty files..
To create a single empty file:
touch filename
With the touch
command, if the file already exists, then the access and modification time of the file is updated to the current time.
Copying Files
The cp
command is used to copy files to another location or you can create a backup copy of a file in the same location.
To copy a file to another location:
cp source_file destination_directory/
To create a backup copy of the file in the same location:
cp source_file source_file.bak
Moving & Renaming Files
The mv
command is used to move files to a different location and can also be used for renaming files.
To rename a file:
mv old_filename new_filename
To move a file to a different location:
mv filename /new/location/
Deleting Files
The rm
command is used to delete files. This command is critical for managing unwanted or unnecessary files.
To delete a single file:
rm filename
Exercise
In the following exercise, you will practice creating, copying, moving, and deleting files:
Exercise: Create, copy, move & delete files:
The -v
option is used for many commands to provide verbose output, which confirms the successful execution of commands.
Create a directory to practice in:
mkdir -pv ~/lpi_24_files
Switch to the lpi_24_files
directory:
cd ~/lpi_24_files
Create a new empty file named my_file.txt
:
touch my_file.txt
Copy my_file.txt
to your home directory:
cp -v my_file.txt ~/
Move my_file.txt
to the /tmp
directory:
mv -v my_file.txt /tmp/
Delete both versions of the my_file.txt
file:
rm -v /tmp/my_file.txt
rm -v ~/my_file.txt
Support DTV Linux
Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.
NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.