Mastering Basic Linux Commands (Part 1)
Greetings everyone! we're going to delve into some fundamental Linux commands that will empower you to navigate and manipulate your system like a pro. Let's dive right in!
1. Checking Your Present Working Directory
Understanding where you're currently situated in your system is essential to avoid confusion and mistakes. The command for this is 'pwd' which stands for 'Print Working Directory'. When you type this into your terminal and press enter, it will print the full system path of the current directory. Here's an example:
$ pwd
/home/username/Documents
In this case, the user is in the 'Documents' directory.
2. Listing All Files or Directories Including Hidden Files
To view all the files and directories in your present working directory, including hidden ones, use the 'ls' command with the '-a' option. 'ls' stands for 'list', and '-a' instructs it to show 'all' files, including those that are hidden. Hidden files usually start with a dot (.). Here's how you use it:
$ ls -a
. .. .hiddenfile file1 file2 directory1 directory2
The '.' represents the current directory, and '..' represents the parent directory.
Recommended by LinkedIn
3. Creating a Nested Directory A/B/C/D/E
Creating directories, or folders, in Linux is achieved using the 'mkdir' command, which stands for 'make directory'. To create a nested directory structure like A/B/C/D/E, you'd use the '-p' option which allows the creation of parent directories as needed. Here's how to do it:
$ mkdir -p A/B/C/D/E
To verify that your nested directories were created successfully, navigate to the 'E' directory and print the working directory:
$ cd A/B/C/D/E
$ pwd
/home/username/A/B/C/D/E
In this case, you've successfully created and navigated to the 'E' directory.
That wraps up our Linux command series (part 1)! Practice these commands and get comfortable with them. They will be your bread and butter in Linux.
Stay tuned for part 2 where we'll dive deeper into the Linux command line interface!