This content originally appeared on DEV Community and was authored by Alexander Njoku
This week I focused on Filesystem Navigation
What is filesystem navigation? Filesystem Navigation in Linux refers to the process of moving between different directories and files within the hierarchical file system using commands in the terminal. Is how users local and access the data stored on the system. Key to the process is understanding the single, root-based structure of the Linux filesystem, where everything branches from the / (root) directory.
Key takeaways:
Hierarchical structure
Current working directory
Paths- Specify the sequence of directories to traverse to reach a specific file or directory, they can be absolute (starting from the root) or relative (starting from the current directory).
Absolute paths- Start with / and specify the full path from the root
Relative paths- Specify the path relative to your current location
Before I dive in to the command is important to establish this fact; anytime you come to a system and see this sign (#) instead of ($) just know that you are in the root directory and you must be very careful here.
Flags, also known as options or switches, are used to modify the behavior of commands. They are typically preceded by a hyphen (-) or a double hyphen ( — ), and are used to specify options or provide additional instructions when executing a command.
ls: List directory contents, display a list of files and directories within your current working directory
ls -l: This will show a long information about a directory, date they were created, time, permission attached to it, group, owner and other details.
ls -a This will list hidden files
Note: Whenever you want to hide a file in linux start it with (.) dot.
ls -R Recursively list subdirectories, that means including the contents of all subdirectories and their subdirectories and so on.
ls — color=auto: To display colours and change colours
Note: (alias:) When you have a command that is too long you can create an alias for it instead of typing the long phrase, alias can be in one word, it is used to shorten commands.
cd: You use cd to change directory and also go straight to a file path direct when you copy the path.
cd../.. This will display your two steps backwards
You can use arrows in your keyboard to do this
Upper arrow key — Precious command
cd — This will tell you where you are
cd ..: Move up one directory.
cd ~: Return to the home directory.
cd -: Return to the previous directory
cd ../..: Return to two directories backward
Note:- If you want to see all the commands you have run in a system Type: History this will display all the commands you have run.
pwd: Print the current working directory
whoami: command in Linux is used to display the effective username of the currently logged-in user
mkdir: Make a directory
mkdir dir_name: Create a single directory
mkdir -p dir1/dir2: Create nested directories. (Note) Nested directories, also known as subdirectories or hierarchical directories, are a fundamental way to organize files and directories in Linux.
rmdir: Remove an empty directory. This will remove an empty directory
rmdir dir_name: Delete a directory (only if is empty).
rm -r: Remove a directory and its contents.
rm -r dir_name: Recursively delete a directory and all files/subdirectories.
mv: We use it in linux to move a file or directory
mv: We can also use it to rename a file or directory
Is also important to note that (Home directory) houses all the users in that server if what to see the users you are working with go to home.
Also keep in mind that you Linux can help you in many ways to explain things in details all you just need to do is type (man) in front of anything that you are confused about lets say i want to know more about (ls) i will just type :man ls
Thanks for sticking with me in this beautiful journey from Linux to DevOps Engineer, next I will go into File Operations, If there’s anything you want to share, ask, plan, or work through next — just let me know. Alex
This content originally appeared on DEV Community and was authored by Alexander Njoku