Questions tagged [cwd]

current working directory of a process

Filter by
Sorted by
Tagged with
0 votes
0 answers
126 views

TCP Congestion Window in Linux

I'm making some test between two peer (CentOS7) in a 10Gbit network with iperf. The configuration in /proc/sys/net/ipv4 and /proc/sys/net/core are exactly the same, so every socket buffer default size ...
Andrea Montanari's user avatar
2 votes
2 answers
1k views

Set alias to run python venv setup based on current directory name

Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...). What I want to achieve is to create an alias that creates a python virtual environment, ...
calexandru's user avatar
0 votes
0 answers
113 views

How to get the final current working directory of a child process?

If I spawn off a child process, I can access its working directory (in a not-very-cross-platform way) any time while it's alive by examining /proc/<PID>/cwd. But what are my options if I want to ...
Different55's user avatar
5 votes
1 answer
8k views

What is the difference between cwd and pwd?

What is the difference between cwd and pwd? I've tried googling it, and one of the answers mentioned that depending on some factor (which I sadly do not remember), the implementation (the code I'm ...
account's user avatar
  • 53
1 vote
1 answer
164 views

Get the unresolved pwd of a shell from another process

I'm hitting an issue where I need to get the unresolved symlink of a shell process. For example given a symlink ~/link -> ~/actual, if bash is launched with a $PWD of ~/link, I need to fetch that ...
Daniel Imms's user avatar
13 votes
2 answers
3k views

Why do all users start in /root instead of their home directories after su as root?

I feel like this should be straightforward but I've never seen anyone ask this that I can tell. The situation is pretty straight forward. Whenever I become a user, ie su user it always starts in /root ...
Chris Jones's user avatar
0 votes
1 answer
140 views

Why cwd in /proc/nautilus_pid/cwd always points to /home/username?

I wanted to check the current directory opened in nautilus window. I check the pid of nautilus, and symbolic link proc/pid/cwd, always points to home directory. Is this expected behaviour? If so ...
Prvt_Yadav's user avatar
  • 5,852
8 votes
1 answer
1k views

Can I create a one way symlink?

I want to create a one way symlink i.e. I can use it to go to the destination directory but I cannot go back. Let's say there is a directory called D with two subdirectories S1 and S2. I want to ...
WYSIWYG's user avatar
  • 363
3 votes
0 answers
51 views

Shell: Mounting to CWD does not update in shell session [duplicate]

When mounting a partition into my CWD (mount /path/do/devxy $(pwd)), the current shell session does not recognize it, e.g. find does not show any contents of the partition and umount $(pwd) succeeds ...
FelixJN's user avatar
  • 13.5k
1 vote
1 answer
1k views

Customize zsh prompt to separately show tail of current working dir

So my current prompt looks like this: ~/path/to/dir % If possible, I'd like it to show the topmost dir separately, like this: ~/path/to (dir) % I've gotten close! In my .zshrc, I currently have: ...
user11319's user avatar
22 votes
4 answers
3k 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 ...
Mateusz Piotrowski's user avatar
5 votes
2 answers
525 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 ...
Stilez's user avatar
  • 1,231
1 vote
3 answers
3k 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-...
reddot's user avatar
  • 276
-4 votes
1 answer
273 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 ...
user1050619's user avatar
1 vote
1 answer
4k 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 ...
MO12's user avatar
  • 391
6 votes
1 answer
1k 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 ...
Sollosa's user avatar
  • 1,919
1 vote
2 answers
255 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 ...
Forivin's user avatar
  • 827
2 votes
2 answers
457 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 ...
Steve's user avatar
  • 827
1 vote
1 answer
303 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 ...
Kev's user avatar
  • 1,739
2 votes
1 answer
295 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 /...
Ashish's user avatar
  • 31
3 votes
1 answer
294 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 ...
Wolfgang Adamec's user avatar
1 vote
1 answer
2k 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 ...
Dohn Joe's user avatar
  • 215
1 vote
0 answers
494 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/...
evencoil's user avatar
  • 233
5 votes
3 answers
5k 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, ...
Adam N. Rosenberg's user avatar
8 votes
1 answer
6k 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 ...
v7d8dpo4's user avatar
  • 678
1 vote
2 answers
173 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 ...
dsaxton's user avatar
  • 113
3 votes
3 answers
30k 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 ...
Eray Erdin's user avatar
1 vote
2 answers
698 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 ...
user avatar
1 vote
1 answer
711 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 ...
Develobeer's user avatar
2 votes
1 answer
2k 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 ...
Pithikos's user avatar
  • 3,274
17 votes
2 answers
26k 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 ...
Tim's user avatar
  • 101k
2 votes
1 answer
2k 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 ...
Tim's user avatar
  • 101k
9 votes
3 answers
3k 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 ...
Hibou57's user avatar
  • 905
2 votes
1 answer
3k 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 ~/: # ...
user66402's user avatar
285 votes
7 answers
236k 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.
slm's user avatar
  • 369k
1 vote
8 answers
310 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; ...
Michał Šrajer's user avatar
56 votes
2 answers
28k 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 ...
Amelio Vazquez-Reina's user avatar