路径
- 绝对路径:以正斜线“/”根开头,描述道文件位置的完整说明,任何时候你想指定文件名的时候都可以使用
# cd /tmp/aa
- 相对路径:不以正斜线开头,制定相对于你的当前工作目录而言的位置,可以使用做制定文件名的快捷方式
# cd ../tmp
用户命令
[root@localhost ~]# id #查看当前用户
uid=0(root) gid=0(root) 组=0(root)
[root@localhost ~]# id abc #查看指定的abc用户信息
uid=1001(abc) gid=1001(abc) 组=1001(abc)
[root@localhost ~]# id tom
id: tom: no such user
#切换用户----su 注销用户----exit
[root@localhost ~]# su - upl #切换为upl用户 ‘-’且重新加载该用户的环境变量
[root@localhost ~]# su upl #切换为upl用户 环境变量不会重新加载
[upl@localhost ~]$ exit #注销当前用户的登陆
#查看当前系统登陆在线的账号 who w
[root@localhost ~]# who
root pts/0 2023-02-02 09:44 (192.168.182.1)
root pts/1 2023-02-02 09:44 (192.168.182.1)
[root@localhost ~]# w
14:40:34 up 6:47, 2 users, load average: 0.00, 0.01, 0.03
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.182.1 09:44 2.00s 0.25s 0.01s w
root pts/1 192.168.182.1 09:44 8:26 0.07s 0.07s -bash
查看当前登陆用户名whoami
[root@localhost ~]# whoami
root
#pwd查看当前所在的工作目录
[root@localhost tmp]# pwd
/tmp
#查看某个外部命令文件所在的路径----which
[root@localhost tmp]# which id
/usr/bin/id
#whatis --查看命令的完整名称
[root@localhost tmp]# whatis cp
cp (1) - copy files and directories
#whereis --查看某个命令相关的文件的路径
[root@localhost tmp]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
=========================================================
cd(change the working directory)更改路径:
cd --直接回到当前用户的家目录
cd ~ --直接回到当前用户的家目录
cd <path具体的路径(包括绝对和相对路径)> --切换到指定的路径
cd.. --返回上级目录
cd. --回到当前目录
cd /tmp --去到根目录下的 tmp目录
cd ./tmp ---去到当前目录下的tmp目录,等价于 cd tmp
cd /usr/share/dict
cd - --返回到上一次所在目录
内部命令与外部命令
- shell: 命令解释器,是用户与内核的桥梁. 。centos默认的shell程序为bash,windows使用的shell程序为dos。
内部命令:包含在shell程序中的一段功能代码。
外部命令: 以独立的可执行的程序存在,又shell调用执行。 - 如何界定是内部或者外部命令:type 命令,如 type cd 或者 type ls
[root@localhost ~]# type exit
exit 是 shell 内嵌
[root@localhost ~]# type ls
ls 是 `ls --color=auto' 的别名