• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
KaliTut

KaliTut

Kali Linux tutorial and Linux system tips

  • Home
  • Raspberry Pi
  • Privacy Policy
  • About us

cd command in Linux

Last Updated on June 4, 2020 by Kalitut Leave a Comment

cd command in Linux is very important, When working in the terminal, all commands are bound to the current folder. Files will be created in it if the exact address has not been specified, temporary files can be created in it. And it is much more convenient to address files to a team from the current folder just by specifying the file name, and not the full path in the file system.

linux cd command

What does the cd command do in linux?

By default, the home folder is used as the current folder, but for more convenience we often have to change it to another. For this there is a command cd linux. In this short article we will look at how to use this command and what features it has.

linux cd command

Before we get to work with the utility, let’s look at its syntax and basic options. Strictly speaking, this is generally not a utility. It is not in the file system. This is a built-in Bash command and changes the current folder only for the shell in which it is executed. Here is the basic command syntax:
$ cd options_folder options
There are only two options, these are -P and -L. They influence how the return symbols to the previous directory and symbolic links will be handled:

  • -P – allows you to follow symbolic links before all the “..” transitions are processed;
  • -L – follows symbolic links only after “..” has been processed;
  • -e – if the folder in which you want to go could not be found – gives an error.

Next you need to specify the directory in which to go. If this is not done, but call cd without parameters, then your home directory will be selected as the working folder. And now let’s look at a few examples of working with cd linux.

How to use cd command in linux

I will not describe here what are the ways in Linux . We considered this topic in a separate article. By default, the user’s home folder is used as the working directory. Let’s first go to one of the subfolders Folder name Kalitut:

cd Kalitut
cd Linux Command

The home folder is denoted as ~ /. Therefore, the following command will perform the same action:

cd ~/Desktop/
How to use cd command in linux

True, there is an advantage. In the first command, the relative path is used, while the second is correctly executed from any folder. Now let’s move to the / usr / lib folder relative to the root:

cd /usr/lib/
What does the cd command do in linux?

Using the dash “-” character, you can return to the previous folder:

cd -
What does cd command do in linux?

Using the double dot “..” you can go to the parent directory:

cd ..
linux command

You can use several blocks with points to move up several levels:

cd ../../
You can use several blocks with points

As already mentioned, if you do not pass the folder to which you want to go, the home folder will be opened:

cd 

A similar result will be issued by the command:

cd ~

You can use the asterisk symbol to simplify folder navigation. True, auto-completion will work only if only one folder will be started for the specified characters.

cd /Desk*
change folder in Linux

In addition to cd, there are two additional commands, pushd and popd. It can be said that a simple stack implementation for working directories. When you pushd, the current working directory is stored in memory, and the following is set in its place:

pushd /var/www/html
pushd /var/www/html

Now type popd to return to the previous directory:

popd
popd

This is an implementation of the stack, so the number of directories in memory is not limited to two. You can navigate through as many folders as you need.

Now you know why you need the Linux cd command, and how to use it as efficiently as possible when working in a terminal. Hope this information was helpful to you. If you have any questions, ask in the comments!

Filed Under: Linux Commands Tagged With: cd command

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow us

  • Facebook
  • Twitter
  • YouTube

Categories

  • Android pentesting tools
  • Arduino
  • Books
  • Darknet
  • database
  • General
  • Github Tools
  • Hacking
  • Kali Linux
  • Linux
  • Linux Commands
  • Network Administrator
  • Penetration Testing
  • Penetration Testing Tools
  • PowerShell
  • Raspberry Pi
  • resources
  • Review
  • Termux
  • Tutorials
  • Ubuntu
  • Uncategorized
  • Video Tutorials
  • vmware
  • WiFi Adapter
  • WiFi Pentesting
  • Wireless Router
  • Wireshark

Recent Posts

  • Hijacked Wi-Fi? Thorough explanation of hacking techniques
  • Windows PowerShell tutorial for beginners
  • Learn to Hack Steps from Beginner to Hacker
  • PowerShell Tutorial – GUIDE introduction with basics
  • Top Hacking Tools
  • Home
  • About us
  • Privacy Policy
  • Affiliate disclaimer

Copyright © 2023