In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to use the linux cd command to change the directory", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the linux cd command to change your directory.
As long as you know where it is and how it relates to the location you want to change to, it's easy to change the directory using the linux cd command.
To change the directory, use the linux cd command. Using this command alone will always return you to your home directory; to convert to another directory, you need a pathname (pathname).
You can use absolute (absolute) or relative (relative) pathnames. The absolute path starts with / (refers to the root) and then sequentially to the directory you want; the relative path starts from your current directory, which can be anywhere. The tree diagram below shows how the linux cd command works.
/ / directory1/ directory1/directory2/ directory1/directory2/directory3
If you are currently under directory3 and you want to switch to directory1, you need to move to the upper level of the directory tree.
Execute the linux cd command
Cd directory1
When you are still in the directory3 directory, this command will give you an error message that the directory does not exist. This is because there is no directory1 directory under directory3.
To move up to directory1, type:
Cd / directory1
This is an example of an absolute path. It tells Linux to convert from the top of the directory tree (/) all the way down to directory1. If the * character of a path is /, then the path is the absolute path, otherwise, it is the relative path.
Using an absolute path allows you to change to a directory that starts with the / directory, which requires you to know the full path. Using a relative path allows you to change to a directory relative to your current directory. If you want to change to a subdirectory under your current directory, it will be convenient to use relative paths.
Command cd.. Tell your system to move up to the immediate parent directory of your current directory. To move up two levels of directory, type cd.. /.. Orders.
Use the following exercises to test what you have learned so far about absolute and relative paths. In your home directory, type the relative path:
Cd.. /.. / etc/X11
In the above example, after using the full command, you should be in the directory X11, where you will find the configuration files and directories related to the X window system.
Take a look at your * one using the linux cd command. You let your system:
Move up one level to the parent directory of your login directory (possibly / home)
Then, move up to the parent directory of the directory (root or / directory)
Again, move down to the etc directory
*, move to X11 directory
Conversely, using an absolute path will take you to the / etc/X11 directory more quickly. For example:
Cd / etc/X11
The absolute path starts with the root directory (/), and then moves down to the directory you specify.
Note: before you indicate the relative path to the directory or file you want to access, make sure you know where you are working. However, if you indicate an absolute path to another directory or file, you don't have to worry about your location in the file system. If you're not sure, type the pwd command, and your current working directory will be displayed on the screen, which you can use as a guide to convert directories using relative pathnames.
The following is a detailed description of the linux cd command:
Cd sends you back to your login directory
Cd ~ will also send you back to your login directory
Cd / takes you to the root of the entire system
Cd / root takes you to the home directory of the root user or superuser (the account created during installation); you must be a root user to access this directory
Cd / home takes you to the home directory, where the user's login directory is usually stored
Cd.. Move up one level of directory
Cd ~ other users if other users grant you the appropriate permissions, it will take you to the login directory of other users
Cd / dir1/subdirfoo No matter which directory you are in, this absolute path will take you directly to subdirfoo, a subdirectory of dir1
The relative path cd. /.. / dir3/dir2 will move you up two levels, to the root directory, then to dir3, and then to the dir2 directory.
Linux cd command options
Now, you should begin to understand how to change the directory. When you change to the root user's login directory (superuser account), see what happens. Type:
Cd / root
If you are not logged in as root, you will see denied permission when you visit the directory.
Denying access to the accounts (or login directories) of root and other users is a measure of the Linux system to prevent intentional or unintentional tampering.
To change to the root login and root directory, use the su command.
Su
Tip: the command su means "substitute users" (instead of the user), which allows you to log in temporarily as another user. When you just type the su command itself and press the [Enter] key, you are still in your login shell (your user's home directory), but your identity has become the root user (also known as superuser). Type su-make you the root user with the root login shell-as if you were already logged in as the root user.
As soon as you give the root password, you will see that the command prompt has changed, which shows your newly acquired superuser status, with the root account name at the front of the prompt and "#" at the back of the prompt.
When you have finished your work as root, type the exit command at the prompt and you will return to your user account.
Therefore, it is easy to change the directory using the linux cd command.
At this point, I believe you have a deeper understanding of "how to use the linux cd command to change the directory". You might as well do it in practice. 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.
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
© 2024 shulou.com SLNews company. All rights reserved.