每天一个Linux命令(7)pwd命令
pwd命令以绝对路径的方式显示用户当前工作目录。命令将当前目录的全路径名称(从根目录)写入标准输出。全部目录使用/分隔。第一个/表示根目录,最后一个目录是当前目录。
(1)用法介绍:
pwd[选项]
(2)选项参数:
一般情况下不带任何参数
1) -L, --logical 显示当前目录
2) -P, --physical 显示当前目录的实际物理地址
3) --help 帮助
4) --version 版本
(3)功能:
执行pwd命令可立刻得知您目前所在的工作目录的绝对路径名称。
(4)运行实例:
1)[root@localhost Documents]# pwd 查看默认工作目录的完整路径,查看是否成功到达指定文件夹
[root@localhost sunjimeng]# mkdir Documents
[root@localhost sunjimeng]# cd ../../
[root@localhost /]# cd /home/sunjimeng/Documents
[root@localhost Documents]# pwd
/home/sunjimeng/Documents
[root@localhost Documents]#
2)[sunjimeng@localhost init.d]$ pwd -P 目录连接链接时,pwd -P 显示出实际物理路径,pwd显示连接路径
[sunjimeng@localhost mail]$ cd /
[sunjimeng@localhost /]$ cd etc
[sunjimeng@localhost etc]$ cd init.d
[sunjimeng@localhost init.d]$ pwd
/etc/init.d
[sunjimeng@localhost init.d]$ pwd -P
/etc/rc.d/init.d
[sunjimeng@localhost init.d]$
3)[sunjimeng@localhost init.d]$ pwd -L 与pwd命令具有一样的功能 显示当前目录的连接路径
[sunjimeng@localhost /]$ cd etc/init.d
[sunjimeng@localhost init.d]$ pwd
/etc/init.d
[sunjimeng@localhost init.d]$ pwd -L
/etc/init.d
[sunjimeng@localhost init.d]$
4)[sunjimeng@localhost /]$ man pwd
PWD() User Commands PWD() NAME
pwd - print name of current/working directory SYNOPSIS
pwd [OPTION]... DESCRIPTION
Print the full filename of the current working directory. -L, --logical
use PWD from environment, even if it contains symlinks -P, --physical
avoid all symlinks --help display this help and exit --version
output version information and exit
5)/bin/pwd同pwd的用法一样:
/bin/pwd [选项]
选项:
-L 目录连接链接时,输出连接路径
-P 输出物理路径
[root@localhost init.d]# cd /
[root@localhost /]# cd etc/init.d
[root@localhost init.d]# pwd
/etc/init.d
[root@localhost init.d]# pwd -P
/etc/rc.d/init.d
[root@localhost init.d]# pwd -L
/etc/init.d
[root@localhost init.d]# /bin/pwd
/etc/rc.d/init.d
[root@localhost init.d]# /bin/pwd -L
/etc/init.d
[root@localhost init.d]# /bin/pwd -P
/etc/rc.d/init.d
如果cd命令是逐级进入的化,区分连接路径和实际路径就没有意义了:
[root@localhost init.d]# cd / //无论什么命令,输出的工作路径都是/etc/rc.d/unit.d
[root@localhost /]# cd etc/rc.d/init.d
[root@localhost init.d]# pwd
/etc/rc.d/init.d
[root@localhost init.d]# /bin/pwd
/etc/rc.d/init.d
[root@localhost init.d]# pwd -L
/etc/rc.d/init.d
[root@localhost init.d]# pwd -P
/etc/rc.d/init.d
[root@localhost init.d]# /bin/pwd -L
/etc/rc.d/init.d
[root@localhost init.d]# /bin/pwd -P
/etc/rc.d/init.d
6)/bin/pwd与pwd命令的区别:(当前目录被删除了,而pwd命令仍然显示那个目录,而/bin/pwd则不会)
[root@localhost init.d]# cd /
[root@localhost /]# cd /home/sunjimeng/Documents
[root@localhost Documents]# mkdir removed
[root@localhost Documents]# ls -l
总用量
drwxr-xr-x. root root 5月 : removed
[root@localhost Documents]# cd removed
[root@localhost removed]# rmdir ../removed -rf //这里犯了一个错误,rmdir没有rf选项参数,rm ../removed -rf等价于 rmdir ../removed
rmdir:无效选项 -- r
Try 'rmdir --help' for more information.
[root@localhost removed]# rmdir ../removed
[root@localhost removed]# pwd
/home/sunjimeng/Documents/removed
[root@localhost removed]# /bin/pwd
/bin/pwd: 在匹配的inode ".." 上找不到目录入口 //这里的结果表明了他们的区别
[root@localhost removed]# cd ../
[root@localhost Documents]# ll
总用量
(5)其它
软链接与硬链接的区别(讲解):
Linux 软连接与硬连接
对于一个文件来说,有唯一的索引接点与之对应,而对于一个索引接点号,却可以有多个文件名与之对应。因此,在磁盘上的同一个文件可以通过不同的路径去访问该文件。注意在Linux下是一切皆文件的啊,文件夹、新加的硬盘 ...都可以看着文件来处理的啊。
连接有软连接和硬连接(hard link)之分的,软连接(symbolic link)又叫符号连接。符号连接相当于Windows下的快捷方式。
参考:http://www.linuxidc.com/Linux/2014-12/111056.htm
每天一个Linux命令(7)pwd命令的更多相关文章
- linux编程实现pwd命令
linux编程实现pwd命令 在linux中,一切皆文件.目录其实也是一种文件,只不过这种文件比较特殊,它里面存储的是一张对应表,即文件名和i节点的对应关系表,而i节点才是记录此文件详细信息的结构,如 ...
- 每天一个linux命令:pwd命令
Linux中用 pwd 命令来查看”当前工作目录“的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录. 在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置. ...
- 每天一个linux命令(1):pwd命令
1.命令简介 pwd(print work directory 打印当前目录)命令以绝对路径的方式显示用户当前工作目录. 2.用法 pwd [-LP] 3.选项 -L --logical 当目录为连接 ...
- linux常用命令:pwd 命令
Linux中用 pwd 命令来查看”当前工作目录“的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录.在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置. ...
- 20155322 2017-2018-1《信息安全系统设计》第九周 Linux命令:pwd命令学习与简单实现
pwd命令学习 功能 Linux中用 pwd 命令来查看"当前工作目录"的完整路径. 格式 pwd [选项] 实例 用 pwd 命令查看默认工作目录的完整路径: 用 pwd 命令查 ...
- linux常用命令(2)pwd命令
pwd 命令1 命令格式:pwd [选项]2 命令功能查看当前工作目录的完整路径3 常用参数一般不带任何参数如果目录是链接时:pwd -P 显示实际路径,而非使用链接路径4 常用实例:4.1 用pwd ...
- 【Linux常见命令】pwd命令
pwd - print name of current/working directory pwd命令用于显示工作目录. 执行pwd指令可立刻得知您目前所在的工作目录的绝对路径名称. 语法:pwd [ ...
- 简单解说Linux命令输出与命令替换
Linux命令能提高更方便的使用性能.下面就这就来讲术Linux命令.将一个程序或Linux命令的输出作为另一个程序或命令的输入,有两种方法,一种是通过一个临时文件将两个命令或程序结合在一起,例如上个 ...
- 关于pwd命令小技巧-确认当前工作目录的绝对路径中是否包含软链接目录名
Linux中任何一个命令,当你用心研究到深处时,也许总能有着新的发现或者有趣的用途,如下方的pwd命令 对于pwd命令,大家都知道是用于打印当前的工作目录路径,而且是绝对路径 pwd命令两个选项的,默 ...
- 每天一个linux命令(3):pwd命令
Linux中用 pwd 命令来查看”当前工作目录“的完整路径. 简单得说,每当你在终端进行操作时,你都会有一个当前工作目录. 在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置. ...
随机推荐
- Flex 自定义打印控件编写
打印历来是web应用一个比较棘手的问题,幸好flex web应用是运行在flash player上的,flash player可以访问打印机,所以flex 应用可以实现比较强大的打印功能.Flex 自 ...
- jQuery表单 Ajax向PHP服务端发送文件请求并返回数据
ImageAjaxUpLoad.htm <!DOCTYPE html> <head> <meta charset='utf-8'> <title>< ...
- BAT都来参加的 DevOps Master 培训
原文:http://www.sohu.com/a/128425731_262549 自高效运维社区开设 DevOps Master 认证培训以来,已经总共有120多人拿到证书,其中在今年春节后,有68 ...
- 笔记本中G-Sensor(加速计) M-Sensor 陀螺仪等传感器的区别与作用
1.G-sensor重力传感器 作用 G-sensor中文是加速度传感器的意思(英文全称是Accelerometer-sensor),它能够感知到加速力的变化,加速力就是当物体在加速过程中作用在物体上 ...
- [译]GLUT教程 - 改变窗体大小
Lighthouse3d.com >> GLUT Tutorial >> Basics >> Resizing the Window 上一章的例子创建了两个窗体,命 ...
- openWRT自学---对官方的开发指导文档的解读和理解 记录2:如何控制内核模块的编译
openwrt对于kernel module的处理分两类:随内核主线而来的kernel module 和 其他作为独立project的kernel module.而这两种,openwrt将采用相同的模 ...
- UIWebView的全屏截图
项目开发中,我们可能会遇到如下的应用场景:将一篇文章,进行截屏(需要全屏截取,包括滚动部分)后,分享到新浪微博.邮箱等等.前段时间,我在应用开发中实现了该功能,代码也是从网上找到的,自己整理了一下.主 ...
- vmware workstation导出ovf
ovf tool路径 /Applications/VMware Fusion.app/Contents/Library/VMware OVF Tool 上面红色的部分,需要右键点击应用程序中的VMwa ...
- 第四篇: Ansible 常用模块使用
一. command | shell 模块 该模块为:执行命令模块 (由于命令模块较为强大,可根据自身对操作系统的熟练程度而增加.所以这里不再介绍类似可以实现同功能模块,比如service模块,需要重 ...
- 【Mac + Mysql + Navicat Premium】之Navicat Premium如何连接Mysql数据库
参考文章: <mac用brew安装mysql,设置初始密码> 因为我需要连接数据库工具,需要密码,所以下面介绍如何设置.修改密码实现Navicat Premium连接Mysql数据库 建议 ...