Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
18
rated 0 times [  18] [ 0]  / answers: 1 / hits: 25753  / 2 Years ago, wed, march 2, 2022, 6:06:37

I know what dot files or folders are, but there is a specific dot named folder (the name is just a dot) in every directories. What are they used for?



For example here is a part of my "bin" folder. Look at the first tow lines.



drwxr-xr-x  2 root root 4.0K Jul 29 12:39 .
drwxr-xr-x 23 root root 4.0K Jul 29 12:37 ..
-rwxr-xr-x 1 root root 904K Mar 30 20:02 bash
-rwxr-xr-x 1 root root 30K Aug 3 2012 bunzip2
...

More From » directory

 Answers
1

Every directory contains a . and a .. entry.


. means the directory itself. It is called the current directory.


.. means the directory's parent directory, that is, the directory that contains it.


There is one directory that is not contained by any other directory: /. So / is special--like all other directories, it contains a .. entry, but its .. entry is itself. So for /, and only for /, .. and . are equivalent.


These directory entries are handy for a variety of purposes. For example, you can change directory to the parent of the directory you're currently in with the command cd ...


You may have seen . in the context of running programs or scripts. In a Unix-style shell, when you run a command by name, the shell doesn't automatically try to run a program by the name in the current directory. (This is surprising to some users coming from Windows, where traditionally that would happen.) The main reason for this is security--if someone creates a program in their directory that has the same name as some system administration tool, and you run that tool while in their directory, they could have just tricked you into running their program.


So, to run a program that is not in your PATH, you must call it by some name that has a / in it. To run a program in the current directory, you can use ./program. (You cannot use /program, because that is an absolute path and means "the file called program in the root directory, /.")


[#30130] Friday, March 4, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
confiorc

Total Points: 42
Total Questions: 121
Total Answers: 123

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
confiorc questions
Fri, Jul 23, 21, 18:21, 3 Years ago
Tue, Mar 22, 22, 14:25, 2 Years ago
Thu, Feb 17, 22, 22:43, 2 Years ago
;