Tag Info

Hot answers tagged

20

To me the "cd ../code" is a noop. I'm very interested into hearing why it isn't. Because files and directories are fundamentally filesystem inodes, not names -- this is perhaps an implementation detail specific to the filesystem type, but it is true for all the ext systems, so I'll stick to it here. When a new directory code is created, it is ...


13

Your shell doesn't every time do a cd to the path that it was in during the last command, before executing the next command. You deleted the current directory and created a directory with the same name, which is not the same directory, just something with the same name/path. File browsers like Nautilus and Windows Explorer normally "go up" the directory ...


8

There are three types of paths: relative paths like foo, foo/bar, ../a, .. They don't start with / and are relative to the current directory of the process making a system call with that path. absolute paths like /, /foo/bar or ///x. They start with 1, or 3 or more /, they are not relative, are looked up starting from the / root directory. POSIX allows ...


6

First off, if you delete a folder that inotifywait is watching, then, yes, it will stop watching it. The obvious way around that is simply to monitor the directory one level up (you could even create a directory to monitor especially and put your work_folder in there. However this won't work if you have a folder underneath which is unmounted/remounted ...


6

As Josh Jolly said in his answer, you should never parse ls, use the approach in his answer instead. Still, here's an awk solution to remove paths from file names, just don't use it with ls: find . | awk -F'/' '{print $NF}' The -F'/' sets the field separator to / which means that the last field, $NF, will be the file name.


5

You can prevent non-root users from listing the content of a directory while allowing them to access files in that directory by giving them the x permission but not r. For a directory, r (“read”) means that you can list the content, whereas x means that you can access files in the directory or cd into it. However, this doesn't seem to be what the assignment ...


4

Using strace would seem to indicate that the file sizes are indeed calculated by querying the files within the directory. Example Say I fill a directory with 3 1MB files. $ mkdir adir $ fallocate -l 1M adir/afile1.txt $ fallocate -l 1M adir/afile2.txt $ fallocate -l 1M adir/afile3.txt Now when we trace the du -h command: $ strace -s 2000 -o du.log du ...


3

With GNU find, you could call: find /some/dir -mindepth 1 -maxdepth 1 -type f \ \( -executable -printf 'X%p\0' -o -printf 'F%p\0' \) -o \ -type d -printf 'D%p\0' The output will be a NUL-delimited (NUL is the only character that may not appear in a file path) list of records, the first letter of which identifies the type (X, F, D for executable ...


3

On most UNIX-like systems, the "current directory" for a process is stored in the kernel as a file descriptor pointing to that directory. The kernel doesn't actually store the path of the current directory: that information is tracked by your shell. A filesystem object (file or directory) is only destroyed for good when all filesystem links to it are gone, ...


3

For example, as best as I can tell, it seems that foo/bar and foo//bar both point to the same place. Yes. This is common because software sometimes concatenates a path assuming the first part was not terminated with a forward slash, so one is thrown in to make sure (meaning there may end up being two or more). foo///bar and foo/////bar also point to ...


2

The following function permits to change to sibling directories (bash function) function sib() { ## sib search sibling directories ## prompt for choice (when two or more directories are found, current dir is removed from choices) ## change to directory after selection local substr=$1 local curdir=$(pwd) local choices=$(find ...


1

Setting a user's home directory only determines the directory where they are by default. Users can see the rest of the filesystem. If you want an account to be restricted to file transfer and to only have access to a specific directory tree, you need to “jail” that user. This is supported natively by OpenSSH; for example, if you put those friends (and only ...


1

Unless you created the users specifically without a home directory, the standard directories are created under /home/username. The ~ directory is just a link to the appropriate /home/username location of the current shell or ssh user. For example the command cd ~ will send you to different places if executed as root or as a named user. You can specify ...


1

Both CentOS and Fedora make use of GNOME for their desktop environments. To open multiple tabs you can use Ctrl+T to add additional tabs.     If you're attempting to have Nautilus open these tabs pre-populated with specific directories this, to my knowledge, is not possible. You'll have to resort to a scripted method such as this one from ...


1

cd ~/ Is in fact an alias for your home directory and equal cd /home/YourUsername In the case of nginx the home folder is probably /var/www or something similar you can find out in looking into /etc/passwd and looking for the ngnix user You can for example when you're root authenticate as any user. sudo user_that_launch_your_daemon #or su ...



Only top voted, non community-wiki answers of a minimum length are eligible