Tag Info

Hot answers tagged

9

You need write permission in the parent direct ory to delete anything from it. In your case this is /home, and as only root has write permissions here only root can delete items from it.


8

Not a neat answer but an alternative if you're using bash as your shell: you could createt some alias in your .bashrc. For instance: alias a='cd /tmp/A ; history -w ; history -c ; export HISTFILE=/home/user/.a_history ; history -r $HISTFILE' alias b='cd /tmp/B ; history -w ; history -c ; export HISTFILE=/home/user/.b_history ; history -r $HISTFILE' Then, ...


8

Any file on a conventionally designed UNIX filesystem whose reference count (e.g. the sum of the hardlink count and the number of open file handles*) reaches 0 is removed. However, on modern UNIX systems, the rmdir system call removes an empty directory in a single operation rather than removing . and .. one-by-one. In historical UNIX systems, however, this ...


6

Firstly not all filesystems use . and .. as hard links. this is documented in the gnu find manual. I am going to ignore those filesystems for the rest of my answer because they were not designed for unix and only complicate things without adding clarity. I am also going to ignore the root directory and mount points for the same reason. the number of links ...


6

Solution Using Parallel You could use GNU Parallel for a compact, faster solution. find . -type d -print0 | parallel -0 cd {}'&&' <command-name> This will work absolutely fine, even for directory names containing spaces and newlines. What parallel does here is that it takes the output from find, which is every directory and then feeds it to ...


6

* is expanded by the shell before tar gets executed. So, making tar change the directory invalidates the arguments that * expanded into. You can simply tell tar to compress the directory instead: tar -czf /backupmnt/abc.tar.gz -C /backupmnt/statusService/ . The . represents the current directory, which will change when tar changes directories. This will ...


5

With zsh: printf '%s\n' **/*(D^om/:t) Those are glob qualifiers, a feature unique to zsh at this time. D: include dot-files ^: reverse the following qualifiers om: order on modification time (reversed with ^) /: exclude (with ^) files of type directory. :t: a modifier that gets the tail of the file (the basename). (if you want the full path as opposed ...


5

The find command is powerful, but that makes it a little challenging to use. I'm pretty sure it can do what you need - this command below is "almost" what you ask for: find . -type d -execdir pwd \; But - this does not run the command in the deepest directory level - it runs in the directories in which other directories are found. So it wil run in ...


4

.. and then cd .system. The presence of a dot at the start of really doesn't mean much of anything except to make it "hidden" - i.e. it won't appear in a default ls listing unless you specify -a.


3

With zsh, you could do: mkdir -p ~/.zsh/dirhist And add to your ~/.zshrc: HISTSIZE=1000 SAVEHIST=10000 setopt HIST_SAVE_NO_DUPS INC_APPEND_HISTORY HISTFILE=~/.zsh/dirhist/${PWD//\//@} chpwd() { [[ $PWD = $OLDPWD ]] || fc -Pp ~/.zsh/dirhist/${PWD//\//@} } chpwd() is called whenever the current directory changes. There, we reset the history file to ...


3

Think of a directory as a text file that looks something like: 123:foo.txt 234:bar.txt 123:other-name-for-foo.txt That's all there is (at least in traditional Unix file systems). foo.txt is not a child of that directory in that it's not an exclusive relationship. It's just that the file of inode number 123 is referenced in two entries of that directory: ...


3

Whatever you're saying about ~$, home$, and /home$ doesn't make much sense.  I guess you're talking about your command line prompt; if so, it would have been useful to show what you typed and what happened (and then explained what you expected). But I can read minds, so I believe that I understand the issue: ~ and ~user239887 (assuming user239887 is your ...


2

A crude way to do it: for f in /path/to/PDFs/*.pdf; do base=$( basename "$f" .pdf ) if [ ! -f /path/to/PNGs/"$base".png ]; then mv "$f" /path/to/garbage/ fi done


2

Why do not use explicit directory change? cd /backupmnt/statusService && tar -czf /backupmnt/abc.tar.gz * Or you can use relative paths: cd / tar -czf /backupmnt/abc.tar.gz backupmnt/statusService1/* backupmnt/statusService2/* backupmnt/statusService3/* Which can be even better solution as you will keep files separated in folders and avoid ...


2

This can be easily done by using NFS. You'll have to install a NSF server on your host (very easy) and then mount the directory on the guest. https://wiki.archlinux.org/index.php/NFS


2

I don't know what shell you're using, but zsh has built-in support for this. It's called named directories. To set this up, add code like the following to .zshrc: mywork=/home/work/software #set variable : ~mywork #Reference variable with a tilde in a no-op statement Then you can use it at the command line like this: $ cd ~mywork Or this: $ cd ...


2

You should better define what is the "other process" and what method it uses to launch a program. In any case, the current working directory is a property of each and every process running so it might be used to locate a program to run. Whether it is safe to implement it that way is questionable.


2

/bin is probably a symlink to /usr/bin on your system. If that were true then: /bin/../sfw/bin/zsh would actually be the same as /usr/bin/../sfw/bin/zsh which reduces to /usr/sfw/bin/zsh which is where zsh actually lives. Note that what you tried, which was /bin/sfw/bin does not correspond to any path that you actually could see on the system. ...


2

Yes, it is possible by setting up the search path appropriately (either containing your working directory explicitly or by containing "./"), but it is good practice to have the "./" in front of the program name. The reason is security: A malware could write an executable file with the name of a commonly used program (say, ls) and the next call to ls will ...


2

You can try following: tar -czf ./zips/someFile.tar.gz -C ./tmp/ someFolder


1

The tar command does not zip. Not even with the -z flag. However, it does collect a series of files/folders and optionally compress the result. To contrast, zip compresses each file and adds it to an archive. zip and tar use different compression algorithms. The man page for tar shows the -C flag (--directory) to change directory, so you could do this tar ...


1

You can use the parameter -C or --directory tar -czf ./zips/someFile.tar.gz -C ./tmp someFolder From man tar -C, --directory DIR change to directory DIR Example % ls -og total 4 -rw-rw-r-- 1 0 Mai 21 18:39 bar drwxrwxr-x 2 4096 Mai 21 18:39 foo tar -cvf ../sample.tar -C /home/user/tmp . tar -tvf ../sample.tar drwxrwxr-x user/user 0 ...


1

The Unix/Linux/*BSD kernel has always kept track of working directory. The chdir() and fchdir() system calls have been around for as long as the C language has been around. If you write a C language program and use execve(), it's up to your program to specify the filename argument of execve(). The kernel will find executables in the current working ...


1

Well a quick workaround would be creating an alias. This creation can be added to the .bashrc to have it added during startup.


1

One of the other answers came close to this: find . -type d -exec sh -c 'cd "$0" && cmd' {} \; (running the command only if the cd succeeds).  Some people recommend inserting a dummy argument, so the found directory ({}) slides over to $1: find . -type d -exec sh -c 'cd "$1" && cmd' foo {} ";" Of course, you can use any string here in place of foo.  ...


1

It sounds like setting CDPATH could get you close to what you are asking: cd cd [-L|[-P [-e]] [-@] [directory] Change the current working directory to directory. [...] If the shell variable CDPATH exists, it is used as a search path: each directory name in CDPATH is searched for directory, with alternative directory names in ...


1

On Unix and Unix-like systems, . means the current directory. For example, ls . is the same as ls, it will list the contents of the current directory. So, when you run ./Desktop it finds a directory called Desktop that is under your current directory. You then get an error telling you that this is a directory and, therefore, cannot be executed as it is not a ...


1

Sample explanation: / (slash) means root, from the root of the filesystem. So, /home/yogesh/Desktop/Books starts from the root, then checks for home, under home check for yogesh and so on. This is called an absolute path. . (dot) means starting from current directory. So, if your current directory is /home/yogesh and you check for ./Desktop, it is there. ...


1

On unix (like on Windows), /foo is the location of a file or directory (absolute location, from the root directory: /). Whereas ./foo is a relative location (relative to the current directory)... You can omit the leading dot + slash and just write foo. By typing the command /Desktop or ./Desktop, you tell the shell to execute Desktop... Which can't be ...


1

The GVFS documentation has a file about Controlling What is Shown in the User Interface. In short, you have two ways to do this: If it's in /etc/fstab, add x-gvfs-hide as one of the options (or, for older versions of udisks2, comment=gvfs-hide). Configure udev to set the $ENV{UDISKS_IGNORE}="1" for the relevant device. For example, here is how I hide ...



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