所以,我正在通过 ssh 在远程服务器上工作,我每天登录和退出数十次,我想在cd登录后立即将 bash转到我选择的默认目录,但我不'实际上不想改变用户主页。有没有简单的方法可以做到这一点?
明确地说,我想要的是看到,比如说,~/foo/bar/当我登录时,而不是~/,并且可以选择随意更改默认值,而不必担心危险的usermod疯狂。
这并不重要,但肯定会很方便。
看完问题当你输入“ls -a”时,“.”的意义是什么?和 ”..”?,我有一个类似的。
为什么要显示.?我的意思是,是否有任何目录cd .不起作用?用户每次看到这条线有什么帮助?
比如我cd依次做了以下几件事——
cd /tmp
cd /home/admin
cd /root/
cd /some_other/directory
Run Code Online (Sandbox Code Playgroud)
现在我在/some_other/directory. 现在,无论如何要/tmp从命令行返回到我开始的目录吗?就像我们使用 GUI 中的后退按钮导航目录一样?
cd - 只带我回到一级。
在我编写脚本之前,任何人都知道执行以下操作的简单方法:
$ pwd
/foo/bar
$ ls -l
lrwxr-xr-x 1 username admin 48 Apr 17 2012 foo.sh -> /bar/foo.sh
$ cd /bar
$ ls
foo.sh
Run Code Online (Sandbox Code Playgroud)
即,在目录中/foo/bar,我想做一些类似cdl(cd link) 的操作,这会将我带到链接文件的目录(或者也可以转到链接目录,如果碰巧是这样的话——如果是我的话)可以输入cd -P /bar)。
操作系统 = MacOS 10.8.5/ Darwin Kernel Version 12.5.0。
在我的.bash_profile我有:
export DIR_PATH=~/concrete/path
Run Code Online (Sandbox Code Playgroud)
在终端
>echo ${DIR_PATH}
~/concrete/path
Run Code Online (Sandbox Code Playgroud)
也显式 cd 作品:
>cd ~/concrete/path
>pwd
/Users/myuserid/concrete/path
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时
>cd ${DIR_PATH}
-bash: cd: ~/concrete/path: No such file or directory
Run Code Online (Sandbox Code Playgroud)
问题是什么?
当我们通过软链接 cd 进入一个目录时,我观察到:
ls ..将显示链接目录的父目录的内容,而cd ..将在软链接的父目录下。他们为什么不同?
cd ..后跟 tab 不提供任何完成选项,无论是链接目录的父目录的内容,还是软链接的父目录的内容。为什么会这样?
在上述情况下,我们如何知道在所有目录命令中,哪些适用于链接目录或其软链接?
例如我在我的目录中:
/home/myname
Run Code Online (Sandbox Code Playgroud)
然后我想 CD 到一个不同的目录。
/home/pulsar/...
Run Code Online (Sandbox Code Playgroud)
由于我需要深入到另一个目录中,如何在不必键入整行的情况下执行此操作?我试过
cd */thedirectoryiwanttogointo
Run Code Online (Sandbox Code Playgroud)
但这不起作用。我必须输入整行。
在bash 4.4.12,help cd说:
Run Code Online (Sandbox Code Playgroud)Options: -L force symbolic links to be followed: resolve symbolic links in DIR after processing instances of `..' -P use the physical directory structure without following symbolic links: resolve symbolic links in DIR before processing instances of `..' -e if the -P option is supplied, and the current working directory cannot be determined successfully, exit with a non-zero status -@ on systems that support it, present a file with extended attributes as a …
Drectories包含.和..它们硬链接到当前和父目录。
那么 shell 如何知道例如在提示中当前目录在 中被称为“a” cd a/path/..?它有专门的外壳吗?
否则从它的角度来看,是不是进入了一个名为 的目录..,而不是知道这个目录也是上面的目录?它怎么知道名字的?
背景
我在 VirtualBox 中使用 tmux 2.0、Ubuntu 14.04.2 LTS。
为了让 tmux 使用与当前窗口相同的路径打开新窗口,我将此行添加到我的~/.tmux.conf文件中:
bind c new-window -c "#{pane_current_path}"
Run Code Online (Sandbox Code Playgroud)
请注意,在 tmux 中,如果我通过 symlinkcd从家到子目录,然后检查并得到:pwdpwd -P
~$ cd pythons
~/pythons$ # An awesome prompt
~/pythons$ pwd # According to "man pwd" this shows the "logical" path
/home/qiime/pythons
~/pythons$ pwd -P # and this shows the "physical" path
/media/sf_Google_Drive/Home/Programs/Pythons
Run Code Online (Sandbox Code Playgroud)
问题是
如果我在新的 bash 提示中打开一个新的tmux 窗口,则~/pythons该窗口将采用物理路径:
/media/sf_Google_Drive/Home/Programs/Pythons$ # Not an awesome prompt
Run Code Online (Sandbox Code Playgroud)
问:是的,它打开到了正确的 …