LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 820|回复: 9

命令别名问题

[复制链接]
发表于 2004-8-24 15:27:42 | 显示全部楼层 |阅读模式
在turbolinux 10下
输入useradd,出现

[brook@tgit-hhbsd brook]$ useradd
bash: useradd: command not found

输入groupadd也一样,必须输入/usr/sbin/groupadd和/usr/sbin/useradd才行
如果使用alias,终端重新启动之后就无效了,
请问怎么样才能直接输入groupadd,useradd就能生效?
应该配置哪个文件,怎么配置?
发表于 2004-8-24 15:54:15 | 显示全部楼层

回复: 命令别名问题

最初由 broook 发表
在turbolinux 10下
输入useradd,出现

[brook@tgit-hhbsd brook]$ useradd
bash: useradd: command not found

输入groupadd也一样,必须输入/usr/sbin/groupadd和/usr/sbin/useradd才行
如果使用alias,终端重新启动之后就无效了,
请问怎么样才能直接输入groupadd,useradd就能生效?
应该配置哪个文件,怎么配置?


su -
到root,别忘了,是有-的
PS:普通用户不可以useradd的。
因为没有权限。
 楼主| 发表于 2004-8-25 08:28:19 | 显示全部楼层
用root也一样需要输入/usr/sbin/useradd,直接在root权限下输入useradd还会报错,我想知道哪个文件是用来配置初始的命令。
发表于 2004-8-25 09:57:58 | 显示全部楼层
是什么样的错误呢?
把你的过程详细说一下。

或者直接把系统的输出写出来。
:thank :thank
发表于 2004-8-26 21:18:01 | 显示全部楼层
echo一下$PATH 看有没有useradd所在的目录.
没有的话把useradd 所在的目录加到PATH中.
发表于 2004-8-27 09:31:12 | 显示全部楼层

回复: 命令别名问题

这是为了安全,如果你不要用su,直接用root登录的话,
就可以直接用了。
我觉得这种设置比较合理,毕竟让su和root完全等同
不是很明智的做法。

最初由 broook 发表
在turbolinux 10下
输入useradd,出现

[brook@tgit-hhbsd brook]$ useradd
bash: useradd: command not found

输入groupadd也一样,必须输入/usr/sbin/groupadd和/usr/sbin/useradd才行
如果使用alias,终端重新启动之后就无效了,
请问怎么样才能直接输入groupadd,useradd就能生效?
应该配置哪个文件,怎么配置?
发表于 2004-8-27 11:32:37 | 显示全部楼层

回复: 回复: 命令别名问题

最初由 forfan 发表
这是为了安全,如果你不要用su,直接用root登录的话,
就可以直接用了。
我觉得这种设置比较合理,毕竟让su和root完全等同
不是很明智的做法。


su -
就是等同啊。
发表于 2004-8-27 12:10:04 | 显示全部楼层

回复: 回复: 回复: 命令别名问题

不一样的。
你可以试试,用su运行fdisk,应该运行不了,直接用root登录
就可以。
当然,这些所谓行或者不行,都可以自己设定,跟人觉得不要给
su太多权限,不安全。


最初由 hutigers 发表
su -
就是等同啊。
发表于 2004-8-27 14:45:49 | 显示全部楼层

回复: 回复: 回复: 回复: 命令别名问题

最初由 forfan 发表
不一样的。
你可以试试,用su运行fdisk,应该运行不了,直接用root登录
就可以。
当然,这些所谓行或者不行,都可以自己设定,跟人觉得不要给
su太多权限,不安全。


[PHP]su和su -是不同的[/PHP]

如果你说的不能运行fdisk是指不能命令补全或者是会提示没有这个命令的话,那就是你不了解su和su -的区别了。

通常情况下,不带任何参数的su可以使你获得root权限,但是环境变量使没有改变的;su -则不同,-参数会改变环境变量,使得你获得一个如同登陆的root,因此,和真实的root是没有区别的。

参见这里
http://hegel.ittc.ukans.edu/topi ... man1/su.1.html#toc4
[PHP]NAME
su - run a shell with substitute user and group IDs
SYNOPSIS
su [-flmp] [-c command] [-s shell] [--login] [--fast] [--preserve-environment] [--command=command] [--shell=shell] [-] [--help] [--version] [user [arg...]]
DESCRIPTION
This manual page documents the GNU version of su. su allows one user to temporarily become another user. It runs a shell with the real and effective user ID, group ID, and supplemental groups of USER. If no USER is given, the default is root, the super-user. The shell run is taken from USER's password entry, or /bin/sh if none is specified there. If USER has a password, su prompts for the password unless run by a user with real user ID 0 (the super-user).

By default, su does not change the current directory. It sets the environment variables `HOME' and `SHELL' from the password entry for USER, and if USER is not the super-user, sets `USER' and `LOGNAME' to USER. By default, the shell is not a login shell.

If one or more ARGs are given, they are passed as additional arguments to the shell.

su does not handle /bin/sh or other shells specially (setting argv[0] to "-su", passing -c only to certain shells, etc.).

On systems that have syslog, su can be compiled to report failed, and optionally successful, su attempts using syslog.

This program does not support a "wheel group" that restricts who can su to super-user accounts, because that can help fascist system administrators hold unwarranted power over other users.
OPTIONS

-c COMMAND, --command=COMMAND
    Pass COMMAND, a single command line to run, to the shell with a -c option instead of starting an interactive shell.
-f, --fast
    Pass the -f option to the shell. This probably only makes sense with csh and tcsh, for which the -f option prevents reading the startup file (.cshrc). With Bourne-like shells, the -f option disables filename pattern expansion, which is not a generally desirable thing to do.
--help
    Print a usage message on standard output and exit successfully.
-, -l, --login
    Make the shell a login shell. This means the following. Unset all environment variables except `TERM', `HOME', and `SHELL' (which are set as described above), and `USER' and `LOGNAME' (which are set, even for the super-user, as described above), and set `PATH' to a compiled-in default value. Change to USER's home directory. Prepend "-" to the shell's name, to make it read its login startup file(s).
-m, -p, --preserve-environment
    Do not change the environment variables `HOME', `USER', `LOGNAME', or `SHELL'. Run the shell given in the environment variable `SHELL' instead of USER's shell from /etc/passwd, unless the user running su is not the superuser and USER's shell is restricted. A restricted shell is one that is not listed in the file /etc/shells, or in a compiled-in list if that file does not exist. Parts of what this option does can be overridden by --login and --shell.
-s, --shell shell
    Run SHELL instead of USER's shell from /etc/passwd, unless the user running su is not the superuser and USER's shell is restricted.
--version
    Print version information on standard output then exit successfully. [/PHP]

当然,我回去也会尝试fdisk,因为单位没有linux。
发表于 2004-8-27 14:56:39 | 显示全部楼层

回复: 回复: 回复: 回复: 回复: 命令别名问题

你说的是对的,我指的就是不带参数的su。
我很少用带参数的su。

呵呵,搞错了。
不过最好还是限制su的使用,不安全。

最初由 hutigers 发表
[PHP]su和su -是不同的[/PHP]

如果你说的不能运行fdisk是指不能命令补全或者是会提示没有这个命令的话,那就是你不了解su和su -的区别了。

通常情况下,不带任何参数的su可以使你获得root权限,但是环境变量使没有改变的;su -则不同,-参数会改变环境变量,使得你获得一个如同登陆的root,因此,和真实的root是没有区别的。

参见这里
http://hegel.ittc.ukans.edu/topi ... man1/su.1.html#toc4
[PHP]NAME
su - run a shell with substitute user and group IDs
SYNOPSIS
su [-flmp] [-c command] [-s shell] [--login] [--fast] [--preserve-environment] [--command=command] [--shell=shell] [-] [--help] [--version] [user [arg...]]
DESCRIPTION
This manual page documents the GNU version of su. su allows one user to temporarily become another user. It runs a shell with the real and effective user ID, group ID, and supplemental groups of USER. If no USER is given, the default is root, the super-user. The shell run is taken from USER's password entry, or /bin/sh if none is specified there. If USER has a password, su prompts for the password unless run by a user with real user ID 0 (the super-user).

By default, su does not change the current directory. It sets the environment variables `HOME' and `SHELL' from the password entry for USER, and if USER is not the super-user, sets `USER' and `LOGNAME' to USER. By default, the shell is not a login shell.

If one or more ARGs are given, they are passed as additional arguments to the shell.

su does not handle /bin/sh or other shells specially (setting argv[0] to "-su", passing -c only to certain shells, etc.).

On systems that have syslog, su can be compiled to report failed, and optionally successful, su attempts using syslog.

This program does not support a "wheel group" that restricts who can su to super-user accounts, because that can help fascist system administrators hold unwarranted power over other users.
OPTIONS

-c COMMAND, --command=COMMAND
    Pass COMMAND, a single command line to run, to the shell with a -c option instead of starting an interactive shell.
-f, --fast
    Pass the -f option to the shell. This probably only makes sense with csh and tcsh, for which the -f option prevents reading the startup file (.cshrc). With Bourne-like shells, the -f option disables filename pattern expansion, which is not a generally desirable thing to do.
--help
    Print a usage message on standard output and exit successfully.
-, -l, --login
    Make the shell a login shell. This means the following. Unset all environment variables except `TERM', `HOME', and `SHELL' (which are set as described above), and `USER' and `LOGNAME' (which are set, even for the super-user, as described above), and set `PATH' to a compiled-in default value. Change to USER's home directory. Prepend "-" to the shell's name, to make it read its login startup file(s).
-m, -p, --preserve-environment
    Do not change the environment variables `HOME', `USER', `LOGNAME', or `SHELL'. Run the shell given in the environment variable `SHELL' instead of USER's shell from /etc/passwd, unless the user running su is not the superuser and USER's shell is restricted. A restricted shell is one that is not listed in the file /etc/shells, or in a compiled-in list if that file does not exist. Parts of what this option does can be overridden by --login and --shell.
-s, --shell shell
    Run SHELL instead of USER's shell from /etc/passwd, unless the user running su is not the superuser and USER's shell is restricted.
--version
    Print version information on standard output then exit successfully. [/PHP]

当然,我回去也会尝试fdisk,因为单位没有linux。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表