As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [pwd]

For questions about the working directory of processes, as well as the `pwd` command

Filter by
Sorted by
Tagged with
32 votes
1 answer
3k views

How to get the cd shell-builtin to stop guessing?

For example: $ ls -aF ./ ../ bin/ $ cd tin # with a tee, not bee bin $ pwd /home/user/bin In other words, cd guesses that what I really meant was cd bin, and successfully (huh?) changes the current ...
Ana Nimbus's user avatar
0 votes
1 answer
78 views

pwd add '\' in folder spaces

i know that on Linux when you try to cd with folder that have spaces you must add \ in there. for example, i have folder named folder one. when i try pwd the output is : /home/user/folder one what i ...
Tzy's user avatar
  • 1
1 vote
1 answer
26 views

Enter directory without knowing its name?

Suppose we have a user pepe who has a directory ~/pepe_cant_see in his home directory in which he possesses -wx permissions, and inside of this directory, another directory ~/pepe_cant_see/...
Franklin Pezzuti Dyer's user avatar
15 votes
1 answer
3k views

Why did 'scp 10.0.0.11:/home/someuser/.*' start copying from /home as well?

I'm doing my first ever moving of user files from an old system to a new system. My goal is to use SCP for it's simple syntax of scp -r source destination. I tried the following command to copy the ...
Brian's user avatar
  • 292
3 votes
1 answer
3k 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
  • 33
0 votes
3 answers
558 views

How Can I Use the sed Command to Replace /home/user With ~

Suppose this is the output of pwd: /home/amarakon/.local/src/amarakon/scripts/src How can I change it to this: ~/.local/src/amarakon/scripts/src I tried this command: pwd | sed 's|/home/.*|~|' But ...
Amarakon's user avatar
  • 279
1 vote
1 answer
228 views

Display recursively all parent directories relative to the current one

Display recursively all parent directories relative to the current one. #!/bin/bash IFS=/ for var in $(pwd) do echo "$var" done
Fluffy's user avatar
  • 7
1 vote
2 answers
393 views

Get the Absolute Path from feh

The feh command allows you to view images within a folder recursively: feh --recursive --auto-zoom While viewing images, it also allows you to associate custom commands with keys 0-9 on your keyboard....
Lonnie Best's user avatar
  • 4,795
0 votes
1 answer
41 views

How to list contents my present directory but only show the absolute file path and name?

I have an alias: alias lp=find $(pwd) I would like this to be similar to ls and ll (list path) but this command searches through every directory instead of my present working directory. I would ...
echo_LOGNAME's user avatar
1 vote
1 answer
119 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
4 votes
2 answers
3k views

How to change the tmux working directory with a shell command

I want to create a shell command that, when run, sets the working directory of the current tmux session to the current working directory. There are numerous answered questions on how to set the ...
Lucretiel's user avatar
  • 212
0 votes
1 answer
899 views

Alias to copy current directory path to clipboard through ssh linux

I am working on macos and on the terminal app I am connecting to a server which run on linux, through ssh -X (and I actually I should not be allowed to install any software on it). In order to save ...
computational's user avatar
0 votes
0 answers
145 views

return escape spaces with pwd

printf "%q\n" "$(pwd)" zSH Catalina OSX returns /Volumes/Public/Photos/Paris\ 2016/Musee\ Rodin\ 2016 I would like the result in a variable so that it can be used in a script. ...
gatorback's user avatar
  • 1,196
0 votes
1 answer
141 views

Current/working directory issue from wrapper

A common packaging issue I encounter is when a tool is looking for relative resources in its root directory (install directory). Eg. pkg-name (/usr/share/pkg-name/pkg-name) is looking for resourceA (/...
noraj's user avatar
  • 290
4 votes
1 answer
666 views

What does the '.' dot mean as a working directory?

I'm not referring to the . you see in shell commands or in the output of ls -a. I just ran an install script for a vpn application, and after the command exited, my terminal prompt was in the . ...
dukeluke's user avatar
  • 141
0 votes
1 answer
408 views

What use rm -rf "`pwd`/folder instead of rm -rf ./folder [closed]

Why would I want to use the command rm -rf "`pwd`/folder" instead of rm -rf ./folder What reasons are there to prefer one over the other?
Stanley Hughes's user avatar
0 votes
1 answer
819 views

GNOME ".desktop" shortcut: Specify Start-In path

I'm making some shortcuts to games I would normally run via terminal. For instance, UT2004: cd "$HOME/Unreal Tournament 2004/System/" ./ut2004-bin-linux-amd64 My work so far: [Desktop Entry] ...
Nick Bailuc's user avatar
0 votes
0 answers
37 views

How does my shell know when the current working directory has been moved?

If I am in a directory /foo, and I move (from a different session) /foo to /bar. If I then go back to the session in /foo and run ls, the files are still there, and I can see new files if they are ...
retnikt's user avatar
  • 319
0 votes
1 answer
969 views

Can't loop files using pwd if current directory has spaces in the path [duplicate]

I have the following bit of code in a bash script I've created. When I run it from a directory with no spaces in the path it works as expected, however if I run from a directory with spaces it fails. ...
Al_'s user avatar
  • 101
0 votes
0 answers
207 views

Subshell does not inherit PWD

Hi I am fairly new to Linux and I've been trying to SSH and CD in one line from Windows 10 into Ubuntu. One solution I thought to try was: ssh -t <ip address> "cd <directory>; bash" I've ...
Saxpy's user avatar
  • 11
1 vote
1 answer
29 views

unbundling a file of here docs when file's directory is different from pwd

All, I have a file (called, say, bundled_file.txt) of here docs stored in a directory, and the file looks like this: cat > a.txt << 'eof' ... ... ... 'eof' cat > b.txt << 'eof' ......
Justin's user avatar
  • 11
1 vote
2 answers
241 views

How to change user and keep current location?

I wonder how in one command I can switch to another user (in my case it is usually root) and still remain in the same location where I am before the change. I usually do it this way, unfortunately ...
simhumileco's user avatar
1 vote
2 answers
109 views

sh: is there a command to interactively edit the PWD?

I'm looking for a command that invokes readline or similar, primed with the current $PWD, to let the user edit the current directory, then cd to the edited value. E.g. > cd ~/a/b/c/d > pwd > ...
Robert Fleming's user avatar
4 votes
1 answer
268 views

Complete a command fully relative to a different directory

I have a function to run a single command in a different category. cd1 SOMEDIR MYCOMMAND ARG… is equivalent to (cd SOMEDIR && MYCOMMAND ARG…), with two advantages. It's slightly easier to type ...
Gilles 'SO- stop being evil''s user avatar
0 votes
1 answer
692 views

Difficulty in undersanding pwd command

I am writing pwd in terminal, and it is showing home/<my_username>. But I cannot physically find any directory with this path. To clear my confusion, I typed ls, but it shows the folders in my ...
Proteeti Prova's user avatar
0 votes
1 answer
112 views

Specifying path to a file within a program command line

I am using a program called Diamond and I have a script that goes like this: cd /srv/scratch/myname/hello diamond blastp -d /srv/scratch/myname/goodbye/inputFile1.dmnd -q inputFile2.faa -o /diamond/...
gwrathe's user avatar
1 vote
0 answers
47 views

Add file to PATH only when in specific directory [duplicate]

Is it possible to make executable appear in the global search path when I am entering to the some specific directory and get it removed once directory changed again?
l00p's user avatar
  • 253
1 vote
1 answer
774 views

tcl cd/pwd command with regard to real/symbolic path

When I work under tcl environment, once I cd to a directory, even if the path I specify is its symbolic link, then no matter whether I run pwd -L or pwd -P, they all return the absolute path. This is ...
John's user avatar
  • 113
1 vote
1 answer
6k views

When can a "cd" command fail in a shell script and what can I do to remedy it?

I have a shell script that failed to finish last week; it was a failed "cd" command and it exits if it fails. The script is a bash shell script for configuring new Debian installs. Here is the full ...
somethingSomething's user avatar
0 votes
2 answers
4k views

How to run a command with a different working directory?

I use this shell pipeline to get a SQL dump using the terminal: $ cd var/lib/mysql && mysqldump -uroot -p"craft" --add-drop-table craft > ~/../docker-entrypoint-initdb.d/base.sql &&...
Arefe's user avatar
  • 233
1 vote
1 answer
3k views

Use SCP from local machine to recursively copy current working directory to remote?

Trying to do something like (in pseudo-unix): scp -r <pwd> username@remote.com:~/<dirname of toplevel> In other words, I'm trying to copy the current directory I'm in locally (and the ...
Brandon J's user avatar
0 votes
2 answers
943 views

tmux change default working directory of a session without attaching

I'm looking for a way to do something like this without attaching to the session. tmux attach-session -c <directory> -t <session> ^^^^^^^^^^^^^^ Per tmux(1), there ...
iBug's user avatar
  • 3,369
12 votes
2 answers
3k views

Why pwd does not accept long options like --physical?

When I display the manual for pwd command, it says that long options like --physical are supported $ man pwd PWD(1) User Commands PWD(1) NAME ...
Michal Kordas's user avatar
1 vote
1 answer
83 views

Remove all lines that contain $PWD

I have a file that contains paths - looks like this: /Users/a/Desktop /Users/a/Documents /Users/a/Documents/Work What would be the easiest way to remove all lines that contain the current directory (...
Emanuil Rusev's user avatar
0 votes
1 answer
1k views

Trying to remove current directory using rmdir

I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory ...
LocalHost's user avatar
  • 449
-4 votes
1 answer
380 views

Linux: How to display the output of both command who and pwd using 1 command [closed]

I tried: who & pwd and it output the result of pwd output: /root. May I know if I am right?
gene's user avatar
  • 11
1 vote
2 answers
110 views

Get container directory more easily

I have a bash script here: $GOPATH/ src/ build.sh and in build.sh I have: export GOPATH="$(cd $(dirname "$BASH_SOURCE") && pwd)" is there a shorter way to get the containing dir ...
Alexander Mills's user avatar
-2 votes
1 answer
61 views

A directory showing up in itself [closed]

I do cd ~ and then pwd. It shows /root. Then I do ls. It again shows root. This is NOT another directory with the same name because when I do cd root, it says -bash: cd: root: Not a directory. ...
a_fan's user avatar
  • 115
0 votes
2 answers
436 views

content from pwd and which failed with sed to be replaced [duplicate]

I have a file which has the following content: BWA='/software/bwa/bwa-0.7.12/bwa' SAMTOOLS='/software/samtools/samtools-1.3.1/samtools' The above tools are on my computer: which bwa => /work/...
user977828's user avatar
2 votes
1 answer
2k views

How to change working directory of a child process by posix_spawn? [closed]

In Linux (CentOS 7.5, kernel 3.10, gcc 7.3), is it possible to change the working directory of a child process created by posix_spawn before it runs a given process image (an executable)? If yes, how? ...
user1507435's user avatar
3 votes
2 answers
7k views

how to run shell command inside awk

i am trying to change dir when from A path to B path like below pwd|awk '{if($1=="/") cd /tmp/}' awk: syntax error near line 1 awk: illegal statement near line 1 please suggest
Anavarathan's user avatar
5 votes
3 answers
6k views

why piping pwd and echo does not work? [duplicate]

I'm new to unix. I typed this command in ubuntu terminal: pwd | echo I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test) but the output was just a single empty line. ...
Fatemeh Karimi's user avatar
1 vote
1 answer
716 views

Change path directory bash.exe

I installed bash on my Windows machine, and now when I run the shell, the pwd is: /mnt/c/Windows/System32 How may I change this? I open this shell everyday to work, and the directory when I'm ...
user avatar
7 votes
2 answers
2k views

What happens when the current directory is deleted?

In the first terminal A, I create a directory, enter the directory, and create a file: $ mkdir test $ cd test $ touch file1.txt $ ls file1.txt Then in another terminal B, I delete the directory: $ ...
wenzeslaus's user avatar
-3 votes
2 answers
85 views

In what cases may some programs require you to run them on a specific directory? [closed]

https://unix.stackexchange.com/a/76641/674 Create a short shell script to run your wine program in this directory, i.e. ~/bin/textaloud: #!/bin/bash cd "~/.wine/drive_c" exec wine "~/.wine/...
Tim's user avatar
  • 96.9k
3 votes
2 answers
11k views

Concatenate pwd and basename [closed]

I want to assign the path and file name to a variable: /path/to/myfile/file.txt For example MYFILE=$(pwd)$(basename) How can i do it ?
Omar BISTAMI's user avatar
1 vote
1 answer
562 views

How to make my PS1 bash session show the whole pwd at all times?

Relevant .bashrc section: if [ "$color_prompt" = yes ]; then if [[ ${EUID} == 0 ]] ; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] ' ...
Vlastimil Burián's user avatar
31 votes
3 answers
4k views

How does Unix keep track of a user's working directory when navigating the file system?

Say I log into a shell on a unix system and begin tapping away commands. I initially begin in my user's home directory ~. I might from there cd down to the directory Documents. The command to change ...
marked-down's user avatar
3 votes
3 answers
6k views

How to get pid number and folder where it works

How I can get PID number and folder where it works? If I run 2 same programs in different folders: /var/www/public_html/first_folder/test.jar <i>(it runs all the time)</i> /var/www/...
K Deis's user avatar
  • 41
9 votes
1 answer
723 views

Etymology of $PWD

What is the etymology of $PWD? Is it an acronym? I know there is a command pwd which prints working directory, but to my mind, it would have made more sense to name the variable $CWD for Current ...
Tom Hale's user avatar
  • 28k