在没有root用户访问权限的情况下安装zsh? [英] Install zsh without root access?

查看:74
本文介绍了在没有root用户访问权限的情况下安装zsh?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可能(以及如何)?我确实需要几个具有ssh访问权限(但没有root用户访问权限)的远程计算机.

Is it possible (and how)? I really need this for several remote computers where I've got ssh access (but no root access).

推荐答案

您可以尝试使用 chsh 命令.您确定远程计算机上未安装zsh吗?如果没有,则可以执行此操作(引自 zsh常见问题解答第1.7节)

You can try the chsh command. Are you sure zsh isn't installed on the distant computer? If not, you can do this (quoted from zsh FAQ Section 1.7)

基本思想是使用exec将当前的shell替换为zsh.通常,您可以在.profile(如果您的shell是sh或ksh)或.login(如果是csh)之类的登录文件中执行此操作.在尝试执行此操作之前,请确保您已通过某种方式(例如通过FTP)更改了文件,因为exec通常是相当不容忍的.

The basic idea is to use exec to replace the current shell with zsh. Often you can do this in a login file such as .profile (if your shell is sh or ksh) or .login (if it's csh). Make sure you have some way of altering the file (e.g. via FTP) before you try this as exec is often rather unforgiving.

如果主目录的子目录中有zsh,请将其放在.profile中:

If you have zsh in a subdirectory bin of your home directory, put this in .profile:

[ -f $HOME/bin/zsh ] && exec $HOME/bin/zsh -l

或者如果您的登录shell是csh或tcsh,请将其放在.login中:

or if your login shell is csh or tcsh, put this in .login:

if ( -f ~/bin/zsh ) exec ~/bin/zsh -l

(在每种情况下-l告诉zsh这是一个登录shell).

(in each case the -l tells zsh it is a login shell).

如果您想先确认它是否有效,则可以使登录Shell询问是否执行zsh.对于类似Bourne的贝壳,以下工作:

If you want to check this works before committing yourself to it, you can make the login shell ask whether to exec zsh. The following work for Bourne-like shells:

[ -f $HOME/bin/zsh ] && {
        echo "Type Y to run zsh: \c"
        read line
        [ "$line" = Y ] && exec $HOME/bin/zsh -l
}

以及对于类似C壳的壳:

and for C-shell-like shells:

if ( -f ~/bin/zsh ) then
        echo -n "Type Y to run zsh: "
        if ( "$<" == Y ) exec ~/bin/zsh -l
endif

将其(即使没有-l)放入.cshrc中也不是一个好主意,至少没有对csh应该做的事情进行任何测试,因为这将导致每个实例的csh转换为zsh并会导致不调用 csh -f 的csh脚本(是的,不幸的是,有人编写了这些脚本)失败.如果要告诉xterm运行zsh,请在执行zsh的同时将SHELL环境变量更改为zsh的完整路径(实际上,即使您不使用xterm,这对于保持一致性也很有意义).如果必须从.cshrc中执行zsh,则最小的安全检查是($?prompt)是否执行zsh.

It's not a good idea to put this (even without the -l) into .cshrc, at least without some tests on what the csh is supposed to be doing, as that will cause every instance of csh to turn into a zsh and will cause csh scripts (yes, unfortunately some people write these) which do not call csh -f to fail. If you want to tell xterm to run zsh, change the SHELL environment variable to the full path of zsh at the same time as you exec zsh (in fact, this is sensible for consistency even if you aren't using xterm). If you have to exec zsh from your .cshrc, a minimum safety check is if ($?prompt) exec zsh.

如果您希望登录shell以-zsh的形式显示在进程列表中,则可以将zsh链接到-zsh(例如,通过ln -s〜/bin/zsh〜/bin/-zsh)并将exec更改为exec-zsh.(确保-zsh在您的路径中.)这与-l选项具有相同的效果.

If you like your login shell to appear in the process list as -zsh, you can link zsh to -zsh (e.g. by ln -s ~/bin/zsh ~/bin/-zsh) and change the exec to exec -zsh. (Make sure -zsh is in your path.) This has the same effect as the -l option.

脚注:如果您确实具有root用户访问权限,请确保zsh进入所有适当计算机(包括NIS客户端)的/etc/shells中,否则您可能无法使用FTP到该计算机.

Footnote: if you DO have root access, make sure zsh goes in /etc/shells on all appropriate machines, including NIS clients, or you may have problems with FTP to that machine.

这篇关于在没有root用户访问权限的情况下安装zsh?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆