In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use cd and alias commands in Linux to quickly return to the superior directory". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
When you want to return to your parent directory under a multi-level directory, you often need to use cd.. /. As for how many.. / you need, it all depends on the number of directory levels you need to return, such as the following example:
one
two
three
four
five
six
seven
# mkdir-p
/ tmp/very/long/directory/structure/that/is/too/deep
# cd / tmp/very/long/directory/structure/that/is/too/deep
# pwd / tmp/very/long/directory/structure/that/is/too/deep
# cd.. /
# pwd
/ tmp/very/long/directory/structure
You can use the following four methods to replace cd.. /, so that you can quickly return to the four-level directory.
Method 1: return to the high-level directory with ". N"
In the following method, ".. 4" is used to return a level 4 directory, ".. 3" to return a level 3 directory, and ".. 2" to return a level 2 directory. Write the following aliases to ~ / .bashrc (other Linux/Unix may be ~ / .bashrc), and then log in again.
one
two
three
four
five
Alias.. = "cd.."
Alias.. 2 = "cd.. /.."
Alias.. 3 = "cd. /.. /.."
Alias.. 4 = "cd.. /.."
Alias.. 5 = "cd.. /.."
one
two
three
four
five
# cd / tmp/very/long/directory/structure/that/is/too/deep
#.. 4
[note: use.. 4 to return to level 4 directory]
# pwd
/ tmp/very/long/directory/structure/
Method 2: use only "." Return to the parent directory
In the following example,. (5 dots) is used to return the four-level directory up. Using five dots to represent a return to a four-level directory is actually easy to remember, when you enter the previous point, it means going back to the parent directory, and then each time you enter a dot, it means going up to the first-level directory. So use. (4 dots) represents a return to the level 3 directory, and 2 dots represents a return to a level 1 directory. To make. (5 dots) work properly, add the following alias to the. / .bash _ profile file and log in again.
one
two
three
four
five
Alias.. = "cd.."
Alias... = "cd.. /.."
Alias.... = "cd.. /.. /.."
Alias. = "cd.. /.."
Alias. = "cd.. /.."
one
two
three
four
five
# cd / tmp/very/long/directory/structure/that/is/too/deep
#.
[note: use. (5 dots) means going up to the four-level directory]
# pwd
/ tmp/very/long/directory/structure/
Method 3: return to the high-level directory with cd command plus continuous "dots"
In the following example, using cd. (cd followed by five dots) represents an upward return to the four-level directory. When you enter the first two points, it means you want to go back to the parent directory, and then each point you enter means to return to the first level of the directory, so it is easy to remember to use 5 points to return to the level 4 directory. Use cd... (cd followed by 4 dots) to return up to level 3 directories, and cd... (followed by 3 dots to cd) to return up level 2 directories. To make cd. (5 dots) work properly, add the following alias to the. / .bash _ profile file and log in again.
one
two
three
four
five
Alias cd..= "cd.."
Alias cd...= "cd.. /.."
Alias cd....= "cd.. /.. /.."
Alias cd.= "cd.. /.."
Alias cd.= "cd.. /.."
one
two
three
four
five
# cd / tmp/very/long/directory/structure/that/is/too/deep
# cd.
[note: use cd. Return to the four-tier directory]
# pwd
/ tmp/very/long/directory/structure
Method 4: return to the high-level directory with cd followed by numbers
In the following example, use "cd4" (cd followed by the number 4) to return a four-tier directory.
one
two
three
four
five
Alias cd1= "cd..."
Alias cd2= "cd.. /.."
Alias cd3= "cd. /.. /.."
Alias cd4= "cd.. /.."
Alias cd5= "cd.. /.."
This allows us to quickly return to the parent directory using the cd and alias commands.
"how to use cd and alias commands in Linux to quickly return to the parent directory" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
MT/SN:8408-E8D/2111E4VFRU: 74Y6496 Disk Drive (DASD)
© 2024 shulou.com SLNews company. All rights reserved.