Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I'm still a Linux newbie and I'm wondering: What is the Linux directory // ?
I can change dir (cd) to the root dir using cd /
~> cd /
/>
Using pwd (print name of working directory) tells me I'm in root (/)
/> pwd
/
Using ls (list directory contents) I see the following (using Raspbian Jessie)
/> ls
bin boot dev etc home include lib lost+found media mnt opt proc root run sbin share srv sys tmp usr var
By mistake I changed dir to // and found that it was valid:
~> cd //
//>
Also using pwd tells me I'm in a directory called // :
//> pwd
//
But using ls I see the that I'm probably still in 'something' looking like root.
//> ls
bin boot dev etc home include lib lost+found media mnt opt proc root run sbin share srv sys tmp usr var
... but telling me it's called // (rootroot ;-)
So what is directory // ?
In Linux (and most other platforms), multiple slashes in a path are interpreted the same as a single slash. However, the POSIX specification states that:
A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash.
// may be reserved for a special purpose (e.g: accessing a network drive in Cygwin). However, if you check ls in / and // on Linux you should see the same content.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Created a directory as root and changed its permissions to 0766:
drwxrw-rw- 2 root root 4096 Aug 2 13:33 test/
When running touch test/test.txt as a user, I get error: touch: cannot touch 'test/test.txt': Permission denied.
$getfacl /test
getfacl: Removing leading '/' from absolute path names
# file: test
# owner: root
# group: root
user::rwx
group::rw-
other::rw-
The directory is set with write permission to all users, what am I missing?
For directories the bits of the access rights have a different meaning than for files:
x means that files inside the directory may be accessed.
r means that you can list the names of the files inside directory. If r is set but x is not set, ls can list the names of the files and sub-directories inside the directory; however, ls cannot show you more information if x is not set; not even if some file it is a regular file or a sub-directory.
w is required to rename or to delete files or to create files or sub-directories inside the directory. However, w has no effect if x is not set!
0766 directory
Because x is not set for group and others, this is the same as a 0744 directory:
Other users may list the names of files and sub-directories inside the directory, but they cannot do more: They cannot even see if some file inside the directory is a regular file or a sub-directory.
You might have an Access Control List (ACL), which permits the access to your folder.
I don't know very much about those lists, but this link should explain them https://www.redhat.com/sysadmin/linux-access-control-lists
You can view the ACL using the getfacl command
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
As the title says what does -LA do in a ls command?
I tried reading the manual for ls and this what it said:
-A List all entries except for . and ... Always set for the super-user.
-L Follow all symbolic links to final target and list the file or directory the link references rather than the link itself. This option cancels the -P
option.
But I'm not quite sure what those mean.
the ls command prints a list of files and folders in the current directory.
When using ls -A, the command prints out ALL files and folders in the current directory. This includes hidden files and folders (like files/folders starting witch a dot). However, . (current directory) and .. (parent directory) will be ignored.
When using ls -L the command will follow symbolic links and print out the location of the reference too.
When combining this 2 options you get ls -LA which prints out a list of ALL files and folders, and also prints out the references to symbolic links in the folder.
Just try it out in the terminal. You'll see the difference.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
ls ..
means ‘list upper directorie’s files and directories.’
When I changed directory following a symbolic link, ls .. does not follow the symblic link. It just shows the real upper directory.
For example, when the directory structure is as follows,
r ┬ a - b - sub#
└ sub
(sub# is a symbolic link to sub directory)
ls ..command after cd a/b/sub gives files at r directory as I’m in r/sub. not b directory’s. But cd .. command takes me to b directory.
How can I use ls command to show files in directory b?
A directory doesn't know what symbolic link you used to get to it; .. is an actual directory entry that points to the real parent directory. But when you use the shell command cd .., bash cheats. It knows what path you used to get there (it's in $PWD), so it just removes the last component of that and changes to the resulting directory.
You can use the same trick yourself for the benefit of other commands by using "${PWD%/*}" instead of ..:
ls "${PWD%/*}"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
when i copy files, execute the file in linux, I am Not quite understand the difference and how to use them.
please help. thanks.
. means current directory
./ means current directory, too
./* means all files in current directory
. means the current directory, and ./ is the same but more explicit, saying "Hey, I'm a directory!" It's like any other folder: TheFolder and TheFolder/ refer to the same object. One case where the meaning is different is when looking at a symlink pointing at a directory: TheLink can refer either to the link object or the directory that you pointed at, depending on the situation, while TheLink/ will always refer to the directory. Also, when you run the rsync command, it will treat TheFolder and TheFolder/ differently.
./* just means all the files in the current directory, same as *. Bash expands that asterisk before the command is run, so the program doesn't see the asterisk, instead seeing all the files as arguments. The difference between these two is that for the former, the command will see "./" prepended to each filename.
To see how these differ, echo is a safe command to run. It will just print the value of what you send it:
echo *
echo ./*
. and ./ both mean current working directory
../ means parent directory of the current working directory
./* means all files and directories in current working directory plus all files and directories in all directories in the current working directory.
./* is all files in current directory
./ is current directory
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I am trying to create a directory in my home directory on Linux using the mkdir command, but am getting a 'permission denied' error. I have recently installed Lubuntu on my laptop, and have the only user profile on the computer.
Here's what happened on my command line:
jdub#Snowball:~$ cd /home
jdub#Snowball:/home$ mkdir bin
mkdir: cannot create directory ‘bin’: Permission denied
jdub#Snowball:/home$
How do I gain access to this folder? I am trying to write a script and following a tutorial here: http://linuxcommand.org/wss0010.php
Thanks for your help!
As #kirbyfan64sos notes in a comment, /home is NOT your home directory (a.k.a. home folder):
The fact that /home is an absolute, literal path that has no user-specific component provides a clue.
While /home happens to be the parent directory of all user-specific home directories on Linux-based systems, you shouldn't even rely on that, given that this differs across platforms: for instance, the equivalent directory on macOS is /Users.
What all Unix platforms DO have in common are the following ways to navigate to / refer to your home directory:
Using cd with NO argument changes to your home dir., i.e., makes your home dir. the working directory.
e.g.: cd # changes to home dir; e.g., '/home/jdoe'
Unquoted ~ by itself / unquoted ~/ at the start of a path string represents your home dir. / a path starting at your home dir.; this is referred to as tilde expansion (see man bash)
e.g.: echo ~ # outputs, e.g., '/home/jdoe'
$HOME - as part of either unquoted or preferably a double-quoted string - refers to your home dir. HOME is a predefined, user-specific environment variable:
e.g.: cd "$HOME/tmp" # changes to your personal folder for temp. files
Thus, to create the desired folder, you could use:
mkdir "$HOME/bin" # same as: mkdir ~/bin
Note that most locations outside your home dir. require superuser (root user) privileges in order to create files or directories - that's why you ran into the Permission denied error.
you can try writing the command using 'sudo':
sudo mkdir DirName
Try running fuser command
[root#guest2 ~]# fuser -mv /home
USER PID ACCESS COMMAND
/home: root 2919 f.... automount
[root#guest2 ~]# kill -9 2919
autofs service is known to cause this issue.
You can use command
#service autofs stop
And try again.