Linux环境下如何快速切换到用户tom
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux环境下如何快速切换到用户tom相关的知识,希望对你有一定的参考价值。
参考技术A 我们可以使用su命令在系统下切换用户。u命令可以实现普通用户和root用户之间相互切换。值得注意的是:普通用户-root需要密码,密码就是普通用户的。
使用sudo命令当我们只需要短时间内使用其他用户的身份完成某个命令,可以使用sudo。
Linux -- 目录基本操作
cd 切换目录
1.切换到指定目录下
#cd 相对/绝对目录 [[email protected] ~]# cd /home/tom/demo [[email protected] demo]#
2.切换到某个用户的主文件夹
[[email protected] /]# cd ~tom [[email protected] tom]#
3.切换到自己的主文件夹
[[email protected] tom]# cd ~ [[email protected] ~]# 或者 [[email protected] demo]# cd [[email protected] ~]#
4.返回上级目录
[[email protected] demo]# cd .. [[email protected] tom]#
5.回到刚才在的目录
[[email protected] tom]# cd - /home/tom/demo [[email protected] demo]#
pwd 显示当前路径
[[email protected] demo]# pwd /home/tom/demo
mkdir 新建目录
1.简单创建一个目录 mkdir 目录名
[[email protected] demo]# mkdir work [[email protected] demo]# ls work
2.创建目录时同时赋予目录权限
[[email protected] demo]# mkdir -m 777 test [[email protected] demo]# ll 总用量 8 drwxrwxrwx 2 root root 4096 2月 12 20:15 test drwxr-xr-x 2 root root 4096 2月 12 20:09 work
3.创建多层目录
[[email protected] demo]# mkdir -p test1/test2/test3 [[email protected] demo]# cd test1/test2/test3/ [[email protected] test3]# pwd /home/tom/demo/test1/test2/test3
4.rmdir 删除文件夹
只能删除没有文件的目录,如果删除有文件的目录可以使用 rm -r 目录名
[[email protected] tom]# rmdir demo/ rmdir: 删除 "demo/" 失败: 目录非空 #清除文件后,再次删除可成功 [[email protected] tom]# rmdir demo/
以上是关于Linux环境下如何快速切换到用户tom的主要内容,如果未能解决你的问题,请参考以下文章