If you need help in managing files, directories, and other stuff right from your Raspberry Pi terminal, follow this article to learn about navigating file structure on the Raspberry Pi system.
So, let’s start this guide!
Navigating File Structure – Raspberry Pi Linux
Here you will learn different methods to work with files and directories on your Raspberry Pi system.
Navigate Present Writing Directory
At some stage you may need to find the location of the present directory you are in and for this purpose, you can execute the following command in your terminal to see the location of the present writing directory.
As a result of the above command, the present directory will display on the terminal.
List of Files/Directories
If you want to see the list of directories inside the present directory, you can type the following command:
As a result of the above command, all the directories listed will be displayed on the terminal.
List the File Size
To display the list of files along with the size of each file, the below-mentioned command can be copied into the terminal.
File Information
To display the list of files along with the readable size and time/date of each file creation, you can use the following command:
Change Directory
The “cd” command is used for changing the directory as it takes you directly toward the other directory through a single command. However, you must need to provide the directory name or path using the following syntax:
Note: Remember to use your required directory name at a place of <directory-path> in the above command.
For example, to navigate to the Downloads folder use:
To move back to previous directory below mentioned command can be used:
Move a File
In case you want to move a file from one directory to another, you can easily do it from the following command:
Note: Remember in the above command replace <file-name> and <destination-path> according to your required file name and directory.
For example, the following command is moving the linux-raspi.txt file to the Downloads directory.
Make sure that the file is there in the current directory you are working in.
Copy a File
If you want to just copy the file and send it to another location, you can follow the below-mentioned command:
Note: Remember to change the <file-path> and <destination-path> according to your requirement. <file-path> is the directory where your file is placed and <destination-path> is where you want to copy the file.
For example
The ls command in the above image is used to check the copied file on the desktop.
Remove a File
You may need to remove a file from your Raspberry Pi system at some stage. For this purpose, you can use the following command to remove a file from your Raspberry Pi system:
Note: Remember to replace <file name > with the name of the file you want to remove then press “Enter”.
To remove linux-raspi.txt file use:
That’s it for this guide!
Conclusion
Navigating files structure in the Linux-based operating system of Raspberry Pi can be a little different than other operating systems. To navigate file structure in Raspberry Pi, different commands are used like pwd, ls, ls -lh, cd and others. To move and copy the file mv and cp commands are used. Lastly, an rm command can be used to remove the required file.