In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to enter a directory / folder without using the CD command in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
As we all know, we can't switch directories in Linux without the cd command. This is true, but we have a built-in Linux command called shopt that can help us solve this problem.
Shopt is a shell built-in command to set and unset various bash shell options, and since it is already installed, we do not need to install it again.
Yes, we can switch directories without using the cd command when this option is enabled.
We will show you how to do this in this article. This is a small adjustment, but it is very useful for beginners who migrate from Windows to Linux.
This doesn't work for Linux administrators because we don't change to that directory without the cd command, because we have experience with it.
If you try to switch between Linux directories / folders without the cd command, you will see the following error message. This is common in Linux.
$Documents/bash: Documents/: Is a directory
To do this, we need to append the following values to user .bashrc.
What is .bashrc?
.bashrc is a shell script that runs each time a user opens a new shell in interactive mode.
You can add any command you want to enter at the command prompt to this file.
The .bashrc file itself contains a series of configurations for the terminal session. Including setting and enabling: shading, completion, shell history, command aliases, etc.
$vi ~ / .bashrc
Join the business:
Shopt-s autocd
Run the following command to make the changes take effect.
$source ~ / .bashrc
We have completed all the configurations. Simply test this to see if it works.
$Documents/cd-Documents/ $daygeek/cd-daygeek/ $/ home/daygeek/Documents/daygeekcd-/ home/daygeek/Documents/daygeek $pwd/home/daygeek/Documents/daygeek
Yes, it works as expected.
Also, it works fine in fish shell without any changes to .bashrc.
If you want to do this temporarily, use the following command (set or unset). When you restart the system, it will disappear.
# shopt-s autocd # shopt | grep autocdautocd on # shopt-u autocd # shopt | grep autocdautocd off
The shopt command provides many other options, and if you want to verify them, run the following command.
$shoptautocd onassoc_expand_once offcdable_vars offcdspell oncheckhash offcheckjobs offcheckwinsize oncmdhist oncompat31 offcompat32 offcompat40 offcompat41 offcompat42 offcompat43 offcompat44 offcomplete_fullquote ondirexpand offdirspell offdotglob offexecfail offexpand_aliases onextdebug offextglob offextquote onfailglob offforce_fignore onglobasciiranges onglobstar offgnu_errfmt offhistappend onhistreedit offhistverify offhostcomplete onhuponexit offinherit_errexit offinteractive_comments onlastpipe offlithist offlocalvar_inherit offlocalvar_unset offlogin_shell offmailwarn offno_empty_cmd_completion offnocaseglob offnocasematch offnullglob offprogcomp Onprogcomp_alias offpromptvars onrestricted_shell offshift_verbose offsourcepath onxpg_echo off
In addition, I found some other programs that can help us change directories faster than the cd command in Linux.
They are pushd, popd, up shell scripts, and bd tools.
Thank you for reading! On "how to use the CD command in Linux to enter the directory / folder" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!
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.