cd ..命令可以返回到上一层目录。
我们都知道使用cd ../是回到系统的上一层目录,但是当你进入到一个很深的目录的时候,你想回到前3层的目录,你就要用cd ../../../来达到目的,如果是目录更深,或许你需要的../就要写的更多。现在通过cd alisa命令来减轻或减少../的输入次数。
假设有如下的目录:
jack@Ubuntu: mkdir -p /tmp/very/long/directory/structure/that/is/too/deep
jack@Ubuntu:cd /tmp/very/long/directory/structure/that/is/too/deep
jack@Ubuntu:/tmp/very/long/directory/structure/that/is/too/deep$ pwd
/tmp/very/long/directory/structure/that/is/too/deep
jack@Ubuntu:/tmp/very/long/directory/structure/that/is/too/deep$ cd ../../../../
jack@Ubuntu:/tmp/very/long/directory/structure$ pwd
/tmp/very/long/directory/structure
通常的做法是我们要../四次才能回到structure目录
现在提供如下方法:
方法1:定义..n别名来指定到第几层目录。如果要永久生效要把命令写入~/.bash_profile并重启系统。
jack@Ubuntu:/tmp/very/long/directory/structure$ alias ..1="cd ../"
jack@Ubuntu:/tmp/very/long/directory/structure$ alias ..2="cd ../../"
jack@Ubuntu:/tmp/very/long/directory/structure$ alias ..3="cd ../../../"
jack@Ubuntu:/tmp/very/long/directory/structure$ alias ..4="cd ../../../../"
jack@Ubuntu:/tmp/very/long/directory/structure/that/is/too/deep$ pwd
/tmp/very/long/directory/structure/that/is/too/deep
jack@Ubuntu:/tmp/very/long/directory/structure/that/is/too/deep$ ..4
jack@Ubuntu:/tmp/very/long/directory/structure$ pwd
/tmp/very/long/directory/structure
比较方便吧。
其他方法跟方法1类似,区别就是对别名的定义如何能更好的让使用者能够快速记住,比如定义为alias cd1="cd ../"等。了解了alias 命令我们就可以自己去定义一些比较常用的命令。
例如:公司通常都不会给普通的开发在prod环境配很高的权限,所以有时候我们就需要sudo 到某个有特定权限的帐号去做一些操作。例如:sudo -u devderiv 切换到devderiv帐号,这个命令经常用,为了节约时间,可以定义alias,alias devderiv=“sudo -u devderiv” 这样就可以直接输入devderiv来切换帐号了。如果命令更长的话,定义别名会更加的方便快捷。
--EOF--
分享到:
相关推荐
Use CD Alias to Navigate Up the Directory 通过设置`cd`的别名,可以在当前目录的父目录间快速切换。 ```bash alias up='cd ..' ``` 这样,在终端中输入`up`即可进入当前目录的父目录。 #### Hack 3. Perform ...
Use CD Alias to Navigate Up the Directory** 通过定义`cd`的别名,可以轻松实现向上导航多级目录。例如,可以设置`cd ..`的别名为`cdu`,这样输入`cdu`即可返回上一级目录;设置`cd ../..`的别名为`cddu`,则...
3.6 Learn to Navigate Through the Program. . . . . . 28 3.7 Learn to Inspect Data: Variables and Expressions . . . . 29 3.8 A Debug Session on a Simple Example . . . . . . 30 4 Fixing Memory Problems...
1. In a terminal, navigate to the directory where you want to install the app 2. $ ssh -T git@github.com 3. $ git clone git@github.com:shaunculrich77/dod-external-integrations-template 自签名本地证书 ...
Use recognized change-management techniques to guide the enterprise to agility while minimizing disruption and resistance Navigate the many challenges that can derail the transition to agility ...
Use up & down arrow keys to navigate the menu. Use Enter key to go into a submenu, Escape key to go out or to exit. Type ? to see a help screen. Enter key exits the help screen. Use Space key, or Y ...
After completing the driver download, extract the zipped file;...Navigate to the folder of the driver you downloaded and select the file "ser2pl"; Press OK and proceed to perform the installation
Graphical browsers require you to navigate the Web manually. In an effort to diminish the amount of tedious pointing-and-clicking you do with your browser, this book shows you how to liberate ...
2. Copy the extracted folders and paste them into the main BDS directory: C:\Program Files (x86)\Embarcadero\RAD Studio\11.0 3. In the IDE, install the IBX package: A. Choose Component > Install ...
Angular2中Router路由跳转Navigate的使用与刷新页面问题详解 Angular2中Router路由跳转Navigate的使用是Angular2路由跳转的核心部分,而刷新页面问题则是开发中常见的问题。本文将详细介绍Angular2中Router路由跳转...
- Use a command like `tar xzf <PREFIX>.tar.gz` to extract the files into the directory. - Replace `<PREFIX>` with the actual prefix name of the compressed tar file. **Setting Up the Environment:** ...
本文实例讲述了微信小程序出现wx.navigateTo页面不跳转问题的解决方法。分享给大家供大家参考,具体如下: 今天在做微信小程序的时候,做的商品购买...https://mp.weixin.qq.com/debug/wxadoc/dev/api/ui-navigate.htm
Book Description Ajax Starter Kit – Phil Ballard. Everything you need to start learning Ajax today! Ajax Programmer’s ...2. Navigate to the CD folder and double-click on the file named start.html.
2. Navigate to the project folder of the sample app, e.g. SampleApplications/Samples/NetCoreConsoleClient 3. Run the script ./createcert.sh to create the certificates for the sample applications. 4. ...
小程序wx.navigateTo路由方法中新增加了events属性,可以用于监听被打开页面发送到当前页面的数据。基础库 2.7.3 开始支持。 相关文档链接:...
绿色、小巧,不占用多少资源...You may now use the drive letter as if it were a local CD-ROM device. When you are finished you may unmount, stop, and remove the driver from memory using the driver control.
4. Usability: The system should be user-friendly and easy to navigate. System Assumptions The hospital registration and scheduling system assumes the following: 1. The system will be used by ...
Learn to use the interface, navigate the desktop, and secure your account Take advantage of the Windows Firewall and customize startup options Set up social media accounts, manage contacts, and use ...