Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The skills of using linux cd command

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "skills for using linux cd commands". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn the skills of using linux cd commands.

At the Linux command prompt, use the linux cd command to change the current directory. These are some basic uses of the linux cd command:

To change your root path, type the cd command and press enter.

Enter a subdirectory, type the cd command, a space, followed by the subpath name (for example: cd command Documents), and press enter.

Enter the directory one level above the current directory, type the cd command, spaces, two dots, and then press enter.

Enter a specific directory, type the cd command, a space, a path name (such as the cd command / usr/local/lib), and press enter.

To determine your directory, type pwd, press enter, and you will see the name of the current directory you are in.

Use pushd to switch between different directories.

In command-line mode, when you work in different directories, you will find that you have a lot of time to waste on repeated typing. If these directories are not in the same root directory, you have to enter the full pathname during the conversion, which is inevitably a bit unbearable. But you can use one or two of the following steps to avoid all redundant input: use the history in the command-line interpreter, or use the command-line function pushd.

The advantage of using history in the command line interpreter is that you only need to press a few keys. Use the up arrow on the command line to find the command you used until you find it, and then press enter. If the two directories you switch are close to each other in the subdirectory structure of the entire drive, using the history in the interpreter may be your choice.

However, if you switch between two distinct paths, you may want to take advantage of the pushd function, which you can use to create a directory stack (a list in memory).

Note: by default, the pushd function may not be included in your Linux; however, it is included in Red Hat and Red Hat-driven systems. If you do not have pushd functions in your system, you can download the relevant function tools on the ibiblio.org website.

Here's how to use pushd. Suppose you are now working in the / usr/share/fonts directory. You need to make some changes to / usr/share/fonts, and you will frequently switch between the two directories. To start in one directory, use the pushd function to change to another directory. In our example, to start under / usr/share/fonts, you type pushd/opt/wonderword/fonts and then press enter. Now, you will see the contents of the stack on the next line: / opt/wonderword/fonts / usr/share/fonts.

As you can see, when you type pushd and a pathname, a stack is automatically generated with the directory name you typed and the directory name you are currently working on. In our example, the path you typed (/ opt/wonderword/fonts) is at the top of the stack.

Quickly return to the previous directory, you can type pushd directly, if you do not follow the pathname, you will return to the previous directory in the stack.

If you need to delete a directory from the stack, type popd, followed by the directory name, and press enter. To see a list of directories in the stack, type dirs, and then press enter. The popd and dirs commands are also some of the common functions.

At this point, I believe that you have a deeper understanding of "linux cd command skills", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report