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 despite me being in the directory (keeping it busy).  Only after explicitly entering into the directory via cd . I can browse the files and unmounting fails.  So obviously the information on the changes in my CWD is not passed on. This behaviour is very different from e.g. entering a directory in one session and creating a file into that directory from another one. In this case find's results are up to date.  So how does the shell determine where it is and why is the mounting not visible immediately?  Using GNU bash, version 5.0.3(1) on debian 10.    Considered solved: please check comments.
122234
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 working directory here is very simple intuitively to understand: the parent node has a list of child nodes that it can access, and presumably it uses an (optimised) variant of a search to locate the existence of a child node with the name the user entered, and the working directory is then "altered" to match this — correct me if I'm wrong there. It may even be simpler that the shell simply "naively" tries to attempt to access the directory exactly as per the user's wishes and when the file system returns some type of error, the shell displays a response accordingly.   What I am interested in however, is how the same process works when I navigate up a directory, i.e. to a parent, or a parent's parent.   Given my unknown, presumably "blind" location of Documents, one of possibly many directories in the entire file system tree with that name, how does Unix determine where I should be placed next? Does it make a reference to pwd and examine that? If yes, how does pwd track the current navigational state?
122854
I wrote a script for the purpose of changing directory and then scan a file.  #!/bin/bash model_dir=/mypath  function chdir () {   cd $1 } chdir ${model_dir}/config if [[ ! -s *.cfg ]] then   echo `date` "configure file does not exist"   exit 1 fi   I don't why my current directory is not changed after I execute this script with source myscript.sh.
46166
How do I mount an ext4 partition as my user account so I wouldn't require root access to r/w on it? I used -o uid=flint,gid=flint on the mount command but I keep getting   mount: wrong fs type, bad option, bad superblock on /dev/sda7,        missing codepage or helper program, or other error        In some cases useful info is found in syslog - try        dmesg | tail  or so   Another thing, I want avoid using udisks for now as it doesn't let me mount to my specified mount point name.
35970
I am using the terminal app to ssh and when I do, it conveniently tells me (at the very top) what and where I am logged into for example:  user@computer:/home/user/directory/  and so forth. However, when I exit the ssh session and am sitting nicely at my local directory, it still tells me the directory path of the place I was previously logged in to.  Is there any way to have it tell me that information only when I am actually logged in to a remote machine? I have already gone to Terminal -> preferences -> profiles -> window and I only have "Dimensions" checked.
36483
Is there some order of operations to rm? I performed rm on a large directory and am curious where I should look to see what might have been deleted. Does rm work on files first, then directories? Or is it based on some information in the inode table?  Specs: rm from GNU coreutils 8.22 system: Arch Linux running on a beagleboneblack filesystem operating on was an external Seagate HDD (ext4) using USB 2.0.  Backstory:  I was performing some directory cleanup and performed  cp -r A/ B/ C/ Dest/   Unwittingly, I followed that up with   rm -r A/ B/ C/ Dest/   when I meant to simply perform   rm -r A/ B/ C/   I caught this and hit Ctrl+C before too long had passed. Specifically, it was &lt; 3 seconds as I was using the time command in conjunction with rm &amp; cp.  I went in and examined Dest/ expecting it to be non-existent, but lo and behold it was whole and appeared to not be affected. This is a bit surprising as A/ B/ C/ were quite small. Maybe 100–200 MB total. Dest/ however, is just shy of 1TB. Performing an ls on Dest/ showed that there were both files and directories at both ends of the alphabet (e.g. AFile.txt .... .... Zoo.txt).   Did I get lucky and cancelled the rm before it wrought havoc on my Dest/ directory? Is rm really that slow (thankfully!)?   If not, how does rm go about recursively removing things such that I can guess what might have been lost?  I'm not really expecting to recover what I might have lost, just curious what potentially was blown away.
87006
I have a setup where my users log on using ldap and it works just fine.  I want to run a script after my users login (its a script that will detect which groups they are in and map network shares accordingly), and after they logout (umounting their shares).  Both scripts are done and they work.  I want that when the user logs in the box a script runs downloading the mounting script from my server (wget i guess?) and runs it, same thing for logout.  Can it be done? I've been searching the net and had no luck so far. I've managed to make that work on shell login/logout, but my users dont even know what shell is and have no use for it :)
78112
I have several closely related questions about what happens when I insert a CD. The files on the CD /media/Ubuntu\ 11.04\ i386/, but from what I've seen /dev/cdrom is also involved.   What is the difference between /dev, /media and /mnt? Following is what I have found from internet but I still have little idea:        /dev — this folder contains device   files    /media — this is a mount point for   removable devices   /mnt — this is a temporary mount point     What is the purpose of mount? In other words, if a device has been represented by the OS as a device file under /dev, why can it not be accessed via the device file directly without mounting?   Is mount only used for storage device, not for non-storage device, such as graphical card, network card, camera, ...? Where is a device file under /dev mounted to, under /media or under /mnt? I remember I have seen both, but am curious when to mount to which? I found my CD was automatically mounted to /media/Ubuntu 11.04 i386. I guess the device file of the CD is /dev/cdrom, but I cannot confirm it by looking into /dev/cdrom and /media/Ubuntu 11.04 i386:  $ ls -l /media/Ubuntu\ 11.04\ i386/ total 3522 -r--r--r-- 1 Tim Tim     143 2011-04-27 13:04 autorun.inf ... $ ls -l /dev/cdrw lrwxrwxrwx 1 root root 3 2011-05-28 15:12 /dev/cdrw -&gt; sr0 $ ls -l /dev/cdrom lrwxrwxrwx 1 root root 3 2011-05-28 15:12 /dev/cdrom -&gt; sr0   How can I find out which device file is for my CD?
106831
I'm trying to locate where some files are stored and I can easily browse to them via ssh by going to "cd ~/foldername", however, I have no idea what directory "~/" actually is.  When I browse around folders via WinSCP (yes, I'm a Windows admin), I can't seem to locate this folder at all.   Note: I'm using Amazon Linux on EC2.
78253
Windows allows the  of certain files or folders. I currently have a Windows folder that is set to "encrypt contents to secure data". (The Windows partition is NTFS.)  If I mount this drive under Linux, is there anyway to decrypt the contents of the directory so that I can read the files without having to reboot into Windows?
38872
I have two shells open. The first is in directory A. In the second, I remove directory A, and then recreate it. When I go back to the first shell, and type ls, the output is:  ls: cannot open directory .: Stale file handle   Why? I thought the first shell (the one that remained open inside a non-existent directory) would "freeze" while waiting for the next command, and wouldn't have "realized" that the directory was deleted and recreated. Does the shell hold a "deeper" reference to its current working directory other than the string $PWD?
119055
i have a directory name with ISO&amp;Emulator having some Important Files. and this directory is in different partition, and partition not showing in my FileManager(Nautilus). so i mount my partition and access it from terminal, but i can't get into directory because of its name.  when i tried to change directory:  cd ISO&amp;Emulator   result:  [1] 1635 bash: Emulator: command not found bash: cd: ISO: No such file or directory [1]+  Exit 1   its taking directory name as a command. any ways for access this directory from terminal?  how to fix this?
105872
On login to EC2 (Ubuntu) instance, I see   *** /dev/xvda1 should be checked for errors ***   I can't fsck /dev/xvda1 because it is mounted, and sudo umount /dev/xvda1 fails because it is in use.  lsof shows   jbd2/xvda  172               root  cwd       DIR              202,1     4096          2 / jbd2/xvda  172               root  rtd       DIR              202,1     4096          2 / jbd2/xvda  172               root  txt   unknown                                        /proc/172/exe   and kill -SIGKILL 172 is ineffective.  What to do?
95297
An encrypted /home directory gets mounted automatically for me when I log in. I have a second internal hard drive that I've formatted and encrypted with Disk Utility. I want it to be automatically mounted when I login, just like my encrypted /home directory is. How do I do this?  There are several very similar questions here, but the answers don't apply to my situation. It might be best to close/merge my question here and edit the second one below, but I think it may have been abandoned (and therefore never to be marked as accepted).   isn't a secure method, it circumvents the encryption.  requires editing fstab, which necessitates entering an additional password at boot. It's not automatic like mounting /home.  is very similar, but does not apply to an encrypted drive. The solution won't work for my needs.  but it's for NTFS drives, mine is ext4.    I can re-format and re-encrypt the second drive if a solution requires this. I've got all the data backed up elsewhere.
9620
I want to run a script to simply change the current working directory:  #!/bin/bash cd web/www/project   But, after I run it, the current pwd remains unchanged! How can I do that?
13284
I tried which cd and it didn't give a path but instead returned the exit code 1 (checked with echo $?). The coreutil cd itself is working, so the executable should be there, right? I also ran a find for cd, but there was no executable file shown. How is it implemented then?  Update:  I don't know if I should ask this in another post but since I think it is good here, I'm expanding (?) the post... So the answer was actually quite simple, there's no executable for that — because it's a builtin — But I've found some builtins (bash shell in Fedora) have the executable files! So builtin -> no executable isn't right I suppose? Maybe an answer explaining what builtins actually are (builtin commands?), which actually is the matter here, rather than focusing more on cd... Some good links posted previously indicate that builtins are not programs... so what are they? How do they work? Are they just functions or threads of the shell?
40712
Edit: This is a duplicate of .  I don't have the reputation to close this question as duplicate.  I'm not referring to ~ as in the home directory but rather this:  $ ls ~foo/bar /some/mount/point/foo/bar   However if I attempt it with a different mount point, e.g.:  $ mount | ag "/dev " devfs on /dev (devfs, local, nobrowse) $ ls /dev/stdin /dev/stdin $ ls ~stdin zsh: no such user or named directory: stdin .  # bash has a similar error message:  ls: ~stdin: No such file or directory   What is the ~ called in this context?  How does it work?  Edit: More information based on some of the comments below:   I can attest that foo is not a username on my system. When attempting to autocomplete ls -lah ~ not all options are shown.  i.e. I'm able to cd ~qux, when qux doesn't show up in the autocomplete.  Again qux is not a user in my system. If it matters /some/mount/point is a network share. All of the details suggest some named path muckery, a Z shell feature of pathname expansion, but this works in bash as well, which apparently doesn't support things like the Z shell's named paths.
103482
I am creating an RPM and in the pre stage, I want to determine apache's document root so I can copy the web application files there.   First, I check if apache is installed. If apache is installed, the script will look for the location of httpd.conf file since it contains the document root param. But I do not know how to handle the return of the command find / -name httpd.conf. I'm just new to shell scripts and RPM. Would like also to know if this is possible. The goal to have the RPM so it can be deployed at any system, without much manual intervention. Bellow is the code I was planning. It is not yet working  if [ "$(expr substr $(httpd -v) 17 6)" == "Apache"]; then     echo "Apache is installed";     find / -name httpd.conf     //need to handle the return of find and store to a location var to be used on the next line     grep -i 'DocumentRoot' $location/httpd.conf     //need to store the return document root to a var el     echo "Apache is not installed"; fi