File System Navigation Commands in Linux
Linux offers an alternative to the usual windows and icons. The terminal might seem different at first, relying on text commands instead of a mouse. It might seem different at first, relying on text commands instead of a mouse. But this simplicity holds immense power.
In this article, youâll be going through a demonstration of Navigation Commands in Linux which will help in quickly navigating in the Linux file system. Letâs go through them, but before that have a short idea of the difference between Linux and Windows file systems.
File System Navigation Commands in Linux
- Difference between Windows and Linux File System
- Commonly Used File System Navigation Commands
- 1. pwd (print working directory)
- 2. ls (list files and directories)
- 3. cd (change directory)
- 4. mkdir (make directory)
- 5. rmdir (remove empty directory)
- 6. cp (copy)
- 7. mv (move)
- Additional Shortcut Tips
Difference between Windows and Linux File System
Feature |
Windows |
Linux |
---|---|---|
Structure |
Drives (C:, D:, etc.) and folders |
Single, unified tree structure starting from root (/) |
Case Sensitivity |
Not case-sensitive |
Case-sensitive |
File Permissions |
Simpler (user accounts) |
More granular control (user, group, others) |
File System |
Primarily NTFS |
Ext4 (most common) FAT32, NTFS (sometimes) |
Overall Remarks |
User-friendly, familiar interface |
Flexible, powerful for advanced users |
Commonly Used File System Navigation Commands
Linux Commands |
Functions |
---|---|
pwd |
Shows the current location. |
ls |
List files and folders. |
cd |
Change working directory. |
mkdir |
Used to create new folder. |
rmdir |
Remove an empty folder. |
cp |
Creating a copy of a file in a new location. |
mv |
Relocate files from one folder to another. |
1. pwd (print working directory)
The pwd command shows the current location in the system. It tells you which folder youâre currently in.
pwd
Observation
The current directory is /home/kali/Templates
2. ls (list files and directories)
The ls command is used to list the files and directories in the current directory. It provides an overview of what is inside a folder.
ls
Observation
All the files and folders present inside the current folder is listed.
3. cd (change directory)
The cd command is used to move between folders. You can tell it exactly which folder you want to go to (like giving it an address), or you can use shortcuts to get around. Letâs look into both the methods.
Moving around nearby folder
If you want to move into a folder thatâs within the one youâre already in, you can just use its name. For instance, if youâre in your home directory and want to reach downloads.
cd [directory name]
cd Downloads
Observation
A. checking the current directory
B. using cd command to change the directory
C. observe the updated directory
Going to a Specific Folder
Imagine telling someone the full address to find your house. Similarly, you can do the same by giving the complete path to the folder. For example, you want to access the documents folder inside the username folder.
cd [directory path]
cd /home/username/documents
Observation
Considering the above directory structure, the active directory was changed from Downloads to Documents by traversing from the home directory.
4. mkdir (make directory)
The mkdir command, an abbreviation for âmake directory,â allows you to create new folders within your existing file system. This provides a structured way to categorize and store your files.
mkdir [directory name]
mkdir w3wiki
Observation
A. User tried to create a new folder named w3wiki
B. changed the directory to newly created directory
C. The active directory is updated
5. rmdir (remove empty directory)
The rmdir command, short for âremove directory,â enables you to delete empty directories. This is useful for cleaning up unused folders and maintaining a streamlined file system.
The syntax for rmdir is:
rmdir [directory_name]
Note: rmdir can only delete empty directories.
Observation
Observe that the empty directory was removed.
6. cp (copy)
The cp command acts like a duplicator, creating a copy of a file in a new location.
cp [source_file] [location]
For instance, to copy âimage.jpgâ from Downloads to Pictures while keeping the original, youâd use
cp ~/Downloads/image.jpg ~/Pictures
Obervation
A. Executing the copying command.
B. Changing the current active directory for checking.
C. Using the list command, we can observe that the image.jpg was copied.
7. mv (move)
The mv command is like a handy mover, allowing you to relocate files from one folder to another.
mv [source_file] [location]
For instance, to move a file named âimage.jpgâ from your Downloads folder to Documents, youâd use
mv ~/Downloads/image.jpg ~/Pictures
Observation
A. Executing the mv (move) command.
B. Changing the current active directory.
C. After executing ls (list) command, we can observe that the file has been transferred.
Additional Shortcut Tips
Serial No |
Symbol |
Symbol Name |
Function |
---|---|---|---|
1 |
~ |
tilde |
shortcut to your home base |
2 |
. |
dot |
the folder youâre in right now |
3 |
.. |
double dot |
the folder one level above |
1. ~ (tilde) â shortcut in Linux
This symbol is like a shortcut to your home base. No matter where you are, typing tilde will always bring you back to your home folder.
cd ~
The active directory was updated to home.
2. . (dot) â shortcut in Linux
This simply means the folder youâre in right now. If youâre already inside a folder and want to work with something there, you can use the dot symbol.
3. .. (double dot) â shortcut in Linux
This means the folder one level above the one youâre in, like going up a floor in a building. If youâre deep inside folders and want to go back a step, this will take you to the bigger folder that contains the one youâre in.
cd ..
Observation
A. The current directory is visible, and we execute the command.
B. The active directory is updated.
4. tree â seeing the bigger picture in Linux
This command isnât exactly for moving around, but it helps you see all the folders at once. It shows how all the folders are connected, like a family tree, so you can understand the bigger picture.
tree
Observation
All the files and folders of the active directory is listed.
Conclusion
The Linux terminal might seem daunting at first, but with a handful of basic commands, youâve unlocked the ability to navigate the file system with ease. By using pwd to check your location, cd to move around, and ~, ., and .. for shortcuts, you can efficiently access files and folders. Remember, the tree command provides a helpful visual map of the directory structure.
As you gain confidence, thereâs a whole world of commands waiting to be explored. You can learn to copy, move, and delete files, create new directories, and even edit text files directly from the terminal. The possibilities are vast!
Do check out w3wiki Linux/Unix Tutorial
File System Navigation in Linux â FAQs
What if I forget the exact command name?
No worries! You can often get help by typing a few letters of the command and then pressing the Tab key. This will try to complete the command name for you and show you any options if there are similar commands. You can also use the man command followed by the command name (e.g. man pwd) to see the manual page for that specific command, which will explain what it does and how to use it.
How do I go back and forth between recently used folders?
The history command can show you a list of commands youâve typed recently, including cd commands for folders youâve visited. You can then use the up and down arrow keys to navigate through the history and press Enter to run a specific command again.
Can I see whatâs inside a folder without going into it?
Yes! The ls (list) command will show you the contents of the current folder. You can also use ls with a folder path as an argument to see whatâs inside that specific folder without going there first (e.g. ls /home/username/documents).
What if I accidentally type the wrong command?
Most of the time, you can simply press the Up arrow key to recall the previous command and edit it. Otherwise, you can press Ctrl+C to cancel the current command.
Contact Us