Basic Linux Commands

Deepesh GuptaDeepesh Gupta
2 min read

Command to check present working directory?

pwd

The command mentioned is used to find out which directory you are currently working in on Linux. It has a few options:

  • -L, --logical: This uses the directory as it appears in your system, even if it's linked to another location.

  • -P, --physical: This ignores any symbolic links and shows the actual directory.

  • --help: It shows information on how to use the command.

  • --version: It shows which version of the command you are using.

If you don't use any option, it behaves as if you used -P.

Keep in mind that depending on your specific command shell, there might be variations in how the pwd command works. Always check your shell's documentation for more details on what options are supported.

Command to display all files and directories, including hidden ones?

ls 
ls -l 
ls -a 
ls -la

The ls command is utilized to list all files, while the -la flag expands this to include directories, along with hidden files.

  • -l, --long: Provides a detailed listing.

  • -a, --shows hidden files and folders: Reveals files and directories whose names begin with a dot, denoting them as hidden.

Command for finding the content within a file?

The "cat" command displays the content contained within a file.

For instance, if we have a file named "demo.txt" with the text "Hello DevOps" inside, the command to view its content would be:

cat demo.txt

Command to change the access permission of a file?

The preceding command grants full permissions, including read, write, and execute permissions, to all users, groups, and others.

In the above screenshot, file1.txt has all the permissions ( Read, Write, Execute )

Command to check which commands you have run till now

history

0
Subscribe to my newsletter

Read articles from Deepesh Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Deepesh Gupta
Deepesh Gupta

DevOps & Cloud Enthusiast | Open Source Contributor | Driving Technological Excellence in DevOps and Cloud Solutions