Execute commands and access any directory, without leaving the current directory ‘./’ the terminal
For console users,
.The term "console" might sound familiar. It’s among the wonderful features of Linux which makes it easy to access from the terminal.
If you are unsure what
.or is, we’ve provided you with the information you need. This article will clarify the in depth what
."/" in Linux is and what it do within Linux. Linux system.
Table of Contents
The meaning of
.The meaning of. up to
The simplest definition of
.The simplest meaning of. can be described as ‘ Current Directory‘. It’s as easy as that. But wait, there are additional useful and intriguing aspects to it.
For console users everywhere The small details of this
.The / symbol are extremely crucial and are specific to the hierarchy of users that could be overlooked by a new Linux user.
Any time you’re using Linux via your command prompt, you’re situated somewhere in the hierarchy of the file system. If you’re working as an unroot user, you are likely to be in your home directory.
Whatever your current directory looks like, it is possible that you will need to manage files outside of the current directory. Therefore, changing your directory on a regular basis could be a time-consuming task. To make this simpler it is recommended to use
.The / could prove to be an efficient method to manage and alter multiple files in the directory you are currently in. It is not necessary to change directories more than once, and will result in efficient and time-saving method.
Understanding .In pieces
Let’s look at the meaning behind
.or in distinct segments that are
. (dot) and
. (dot):- With reference to the issue we will be talking about in the article The
. (dot) simply refers to that it is the current directory of the user‘.
[email protected]:~$ ls -al total 179572 drwxr-xr-x 86 gauravv gauravv 266240 Sep 12 09:10 . drwxr-xr-x 4 root root 4096 Sep 4 18:29 .. drwxr-xr-x 2 gauravv gauravv 65536 Jul 15 2018 100CANON
In the code above In the highlighted line, you will notice an asterisk (. ) in the middle. This indicates that it is my current directory.
(slash): (slash):If we add an
(slash) or (slash) in front of the
.(dot) it is a simple way to ensure that you aren’t working within a file. The same applies to appending
the letter / or any other name for a directory.
.or by using an example
Let’s take an example to understand
.or With more explanations.
Let’s say you want to make use of nano text editor.
nano text editor (a text editor that works with on consoles) in place of Graphical Text Editor. You’ll be working with the console entirely. Once you begin working in the editor, you will be put within the Home Directory by default.
However, suppose that the document you’d like to modify is located in a different directory. There’s a directory called Space and there’s the file cool.txt. So the location path of this cool.txt file becomes ‘/home/gaurav/space/cool.txt‘.
To open this file in
nano, you certainly could type
[Directory_name_where_file_located] and then
To make it easier and simple, we could enter
the nano ./space/cool.txt.
Take a look at the following outputs to better comprehend the scenario.
[email protected]:~$ pwd /home/gaurav [email protected]:~$
Here the Home Directory is ‘ /home/gaurav‘. And the file to be edited (cool.txt) is located at ‘/home/gaurav/space‘.
Let’s say I don’t want to alter the directory I am currently in ( /home/gaurav) and instead work directly in my current home directory. It’s as simple as that.
[email protected]:Nano $ ./space/cool.txt GNU nano 2.9.3 ./space/cool.txt Modified Hello my name is Tony stark and I am an superhero.
[email protected]:$ cat ./space/cool.txt Hello my name is Tony stark and I am an superhero. [email protected]:~$
Here , I modified the file in my home directory without altering the directory path.
The primary benefit that comes with using
.The main benefit of using. is that even if you don’t want to move away from the folder you’re currently in it is still possible to manipulate the files that surround you.
If you typed
the nano cool.txt, you would be directing
the nano to access a folder in your home directory ( /home/gaurav) it would give an error because the file isn’t within home directories. This is why you’re using
the nano ./space/cool.txt
Programming with .or
./ is a way to run executable files of a software. This will be explained by using an example.
If I’m looking to run an C program within the directory of my
echo $PATH command to find your path) I’ll simply build this C program. After compilation the executable file
a.out will be created in the directory currently. To run this program, I will execute an executable program called
a.out. To execute the C program, I will simply enter
./a.out to execute the C program.
[email protected]:~/space$ sudo gcc demo.c [sudo] password for gaurav: [email protected]:~/space$ ./a.out [email protected]:~/space$
In this case the prefixing of the command with
."/" effectively means “forget about the PATH, I want you to look only in the current directory”.
You can also tell the system to look at only one specific area using a prefix using an absolute or relative path , such as:
.."/" is Parent Directory or
./work/demo.c which means to search for the demo.c file demo.c in the directory called Work.
./” is used in a pathname to denote that the directory is currently active. It is also possible to execute a script using the current working directory. It’s an efficient practice to include .or in your $PATH since it allows you to edit files that aren’t in the current directory, and all without leaving the current directory.