Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cwd]

current working directory of a process

19
votes
4answers
2k views

Is there a POSIX (or at least a popular) utility to set the current working directory when invoking a program?

We have env(1) to modify the environment of the command we want to run (for example env MANPAGER=more man dtrace). Is there something similar but for modifying the directory that the command is going ...
5
votes
2answers
312 views

Meaning of statement that 'getcwd functions work correctly' in FreeBSD man page for mount_nullfs?

In FreeBSD, man mount_nullfs states that: The primary differences between a virtual copy of the file system and a symbolic link are that the getcwd(3) functions work correctly in the virtual ...
0
votes
2answers
451 views

chroot with working directory specified

Say I want to write wrapper for chroot command with the possibility to set working directory otherwise preserving chroot semantics. Thus semantics should be: chroot.sh <chroot-dir> <working-...
-4
votes
1answer
91 views

Change directory to execute a script

In my script I create a directory and need to execute subsequent commands within the directory. The below script creates a directory, but the next script it invokes (repo init) does not get executed ...
0
votes
1answer
779 views

handling $1 in shell script directory path

I have this part of the script(bash) that worked absolutely fine until recently but it throws me an error with file not found when using $1 to give directory path. Only difference I know is it stopped ...
4
votes
1answer
209 views

Making 'pushd' directory stack persistent

Ok this is a short question. I just happened to know that with pushd command, we can add more working directories into our list, which is handy. But is there a way to make this list permanent, so it ...
1
vote
2answers
101 views

Showing list of files in current directory while navigating? (Screen, Linux)

I'm looking for a way to have list of all files/folders of the current directory in my terminal that updates automatically and runs while I'm actively navigating and editing files. I imagine it to ...
2
votes
2answers
84 views

What is the benefit of a logical working directory?

I understand what a logical working directory is. When you create a symbolic link to a directory, and then cd to that directory using the symbolic link, your logical working directory becomes the path ...
1
vote
1answer
116 views

Setting a shortcut's cwd

I have a program that works correctly if: I run it from the command line in its own directory. I run it from the command line from wherever, using cd /path/to/prog && ./prog. I double-click ...
2
votes
1answer
90 views

Why does the pwd doesn't update after directory removal?

I tried a little experiment where I created 2 folders Dir1 and Dir2 inside my Desktop directory, such that Dir1 is parent of Dir2. /home/username/Desktop/Dir1/Dir2 Then, I use cd to set my pwd as /...
2
votes
1answer
82 views

How can I make pwd resolve a soft link?

On one of our servers, we have a directory with the following path: "/daten/i/scripts" When you go to /daten/i, one can see that scripts is a soft link to "/batch". When I type cd /daten/i/scripts ...
1
vote
0answers
589 views

new tab in bash on Arch Linux starts at home directory

On my Arch box, when I hit Ctrl+Alt+T bash opens a new tab in the Terminal's window. The pwd of this new tab is the current user's home directory. On my Ubuntu box at work however, the pwd of the new ...
1
vote
0answers
229 views

Opening a file from Nemo does not set current working directory

Suppose I have a file ~/work/report.txt. If I open a terminal and change directory to ~/work/, then issue gvim report.txt I get a gvim window where report.txt is opened and :pwd gives back ~/work/...
5
votes
2answers
2k views

“ls $PWD” and “ls .” get different files, strange caching perhaps?

I have a strange problem on my Linux Mint machine (with solid-state drive if that matters). Somehow the machine (on multiple occasions) gets different files, and different content for the same file, ...
3
votes
1answer
2k views

Changing the current working directory of a certain process

Can I change the current working directory of a certain process? For example, I am running a process that has the pid 1000. Right now, its current working directory is ~. I want to change its current ...
1
vote
2answers
81 views

How to work with symbolic links to directories

I am experimenting with symbolic links and I'm encountering a couple issues. The first is how after following a symbolic link to a directory to display the actual working directory instead of the ...
2
votes
3answers
10k views

Run a shell script via a symbolic link from the directory containing the script itself

My desire is not to change directory then execute. I use a jar file and need to execute that. So I made a very basic shell script to do that. #!/bin/sh java -jar TreeForm.jar Then, I saved it as ...
1
vote
2answers
73 views

Terminal has changed its default folder to start at

By default, every Linux distributions' Terminal I have used so far starts at /home/[username]. For some reason, without noticing, the default folder is now at root in Sabayon. How do I change the ...
1
vote
1answer
385 views

Kernel current working directory and inode information placement

I'm reading some doc about UNIX but I don't understand two things: Why is important for the kernel to know the current working directory of the running process? Why not keeping the inode information ...
2
votes
1answer
970 views

Can I start a background process with a specific working directory?

Say I have this structure /masterscript /a/script1 /a/b/script2 In masterscript I spawn the other scripts as background processes: "/a/script1" & "/a/b/script2" & The problem is that ...
9
votes
2answers
9k views

Create an absolute symbolic link to the current directory

I am now under a directory with very long path. For future visiting it quicker, I would like to create a link to it. I tried ln -s . ~/mylink ~/mylink actually links to ~. So can I expand ~ into ...
2
votes
1answer
996 views

The current path of a process

Suppose I write a program, which outputs a file under a relative path (as opposed to a full/absolute path) - let's say, the current path. Then I compile it and store the executable under some dir ...
7
votes
3answers
1k views

`/proc/$PID/cwd` : is there a POSIX equivalent?

Linux has a /proc directory and file‑system, which as far as I can tell, is not part of POSIX. In each /proc/$PID subdirectories, is a symbolic link, cwd, pointing to the actual working directory of ...
2
votes
1answer
2k views

Tmux config not retaining PWD on new-window or window split

So I'm trying to update my .tmux.conf file to reflect the change for -c in new-window. I've added this to my conf and it's not working unfortunately. My new windows and panes always start in ~/: # ...
133
votes
3answers
104k views

Find out current working directory of a running process?

What command(s) can one use to find out the current working directory (CWD) of a running process? These would be commands you could use externally from the process.
1
vote
8answers
255 views

remove content of directory in elegant way

I would like to remove all content of the current working directory. How to do it in efficient and elegant way? I have several files, directories and some of them starts with dot, like: touch .abc; ...
23
votes
2answers
10k views

Resolving symbolic links (pwd)

Say I do the following: cd /some/path ln -s /target/path symbolic_name If then do: cd /some/path cd symbolic_name pwd I get: /some/path/symblic_name and not: /target/path Is there a way to ...