What command should I type when I want to move two level up from the current directory in Linux?

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    cd command in linux known as change directory command. It is used to change current working directory. 

    Syntax:  

    $ cd [directory]

    To move inside a subdirectory : to move inside a subdirectory in linux we use 

    $ cd [directory_name]

    What command should I type when I want to move two level up from the current directory in Linux?

    In the above example, we have checked number of directories in our home directory and moved inside the Documents directory by using cd Documents command. 

    Different functionalities of cd command : 

    • cd /: this command is used to change directory to the root directory, The root directory is the first directory in your filesystem hierarchy. 
       
    $ cd /

    What command should I type when I want to move two level up from the current directory in Linux?

    • Above, / represents the root directory.
    • cd dir_1/dir_2/dir_3: This command is used to move inside a directory from a directory 
       
    $ cd dir_1/dir_2/dir_3

    What command should I type when I want to move two level up from the current directory in Linux?

    • In above example, we have the document directory and inside the document directory we have a directory named geeksforgeeks and inside that directory we have example directory. To navigate example directory we have used command cd Documents/geeksforgeeks/example.
    • cd ~ : this command is used to change directory to the home directory. 
       
    $ cd ~

    What command should I type when I want to move two level up from the current directory in Linux?

                  or 

    $ cd
    • cd : this command also work same as cd ~ command. 

    What command should I type when I want to move two level up from the current directory in Linux?

    • cd .. : this command is used to move to the parent directory of current directory, or the directory one level up from the current directory. “..” represents parent directory. 
       
    $ cd ..

    What command should I type when I want to move two level up from the current directory in Linux?

    • cd “dir name”: This command is used to navigate to a directory with white spaces.Instead of using double quotes we can use single quotes then also this command will work. 
    $ cd "dir name"

    What command should I type when I want to move two level up from the current directory in Linux?

    • In above example, we have navigated the My songs directory by using cd “My songs” command. 
      or 
    $ cd dir\ name :
    • this command work same as cd “dir name” command. 

    What command should I type when I want to move two level up from the current directory in Linux?

    System navigation is one of the most basic tasks that a user can perform on an operating system. While many file managers are available that allow you to switch directories and navigate your disk drives in a graphical way, doing the same using the command line can provide you better control over your system.

    Luckily, Linux provides you with a command known as cd, which allows you to easily change the current working directory on your terminal.

    Here's how you can use the cd command on Linux, the only utility that you'll ever need to traverse through directories on your system storage.

    How To Use the cd Command in Linux

    The cd command stands for Change Directory. One of the most fundamental commands in Linux, cd has become a global command for switching directories. Some other implementations of the command such as chdir, used in MS-DOS systems, are also present.

    Basic Syntax

    The basic syntax of the cd command is:

    cd [options] [path]

    ...where options are the arguments passed with the command and path is the absolute or relative path to the directory.

    Absolute and Relative Pathnames

    Before you can use the cd command to its full extent, you must know the difference between absolute and relative pathnames. The absolute pathname is the complete path to the directory, starting from the / (root) folder.

    On the other hand, the relative pathname is derived from the current working directory. You can move up and down the directory tree efficiently with the cd command if you're well-versed on relative paths.

    For example, if your current working directory is /home, and you want to change the directory to /Desktop. Then, using the absolute pathname:

    cd /home/username/Desktop

    On the other hand, if you want to switch to the /Desktop directory using a relative path, all you have to type is:

    cd /Desktop

    Cd keeps track of what directories are above and below the current directory, to allow a user to quickly shift to other directories without having to type the whole pathname.

    If you don't know the exact name of the subfolder that you want to switch to, use the ls command to list down every directory in that folder.

    Switch to the Home Directory

    On a Linux system, the /home directory is a special directory reserved for a user's personal files, programs, and subfolders. When you log in to your system, the home directory is set as the current working directory by default.

    The home directory has a special character assigned to it---the ~ (tilde) character. Instead of specifying the complete path to your home directory (/home/username), you can just pass the ~ character with the cd command to change the current working directory to /home.

    cd ~

    Similarly, you can navigate to other user's home directory as follows.

    cd ~username

    In the previous section, we switched the present working directory to /Desktop. In the command, you can use the ~ character to denote the /home directory and strip down the command to half of its size.

    cd ~/Desktop

    Just like the home directory, the / character denotes the /root directory on a Linux-based operating system. To switch to the root folder anytime:

    cd /

    Change to the Previous Working Directory

    If you're working with multiple directories at a time, you can easily switch back and forth to the previous working directory using the - (hyphen) character.

    For example, if the current working directory is /home and you switch to the /root directory. Then, /root will become the current working directory, and /home will be the previous working directory.

    Typing the following command will take you to the previous directory i.e. /home.

    cd -

    Also, issuing the cd command followed by a space character will take the user to the previous working directory.

    cd

    Switch to the Parent Directory

    The directory which consists of one or more sub-directories is known as the parent directory. Simply put, if you have /Desktop and /Downloads folders in your /home directory, then the /home directory will be the parent directory for /Desktop and /Downloads.

    The .. and . characters stand for the parent directory and the current directory respectively.

    Use the double dots character (..) to switch to the parent directory.

    cd ..

    The aforementioned command will take you one level up the directory tree. You can also pass additional .. characters to move further up the directory tree.

    To move two levels above your current working directory:

    cd ../../

    You can also pass a specific directory one level above the present working directory.

    cd ../Folder

    Change to a Directory Name With Spaces

    Not every folder on your system will have a one-word name. Some of them might include the space character. For example, /home/username/Important Documents.

    In such situations, specifying the directory name will return an error.

    cd /Important Documents

    Output:

    bash: cd: too many arguments

    To switch to directories that have spaces in the name, wrap the pathname in quotes as follows. Note that you can use both single and double quotes in the command.

    cd 'Important Documents'
    cd "Important Documents"

    Alternatively, you can use the backward slash (\) character to escape the spaces.

    cd Important\ Documents

    System Navigation Through the Command Line

    The Linux terminal is a powerful text interface for controlling the working of your computer. You can carry out almost any task using the command line. Changing directories, copying files and folders remotely, listing file information, editing configuration files, you name it. There's a command for everything that you want to do on Linux.

    However, there's a drawback to having so many commands. Not everyone can learn and memorize the commands, not to mention the hefty amount that's available to use in the first place. But as a beginner Linux user, you won't be using all of the utilities that are available on your system.

    Instead, learning some basic commands that will help you in performing fundamental operations is more than enough to get started with the operating system.

    Which command is used to goes up two directory level?

    Use pushd to add a directory to your ring - this becomes your current directory. Obviously, use cd to navigate between directories without affecting your ring.

    What is the command to move up one level in the folder directory choose one?

    To go up one level of the directory tree, type the following: cd .. The special file name, dot dot ( .. ), refers to the directory immediately above the current directory, its parent directory.

    Which command will always change the working directory up two levels from the current location?

    The cd command, also known as chdir (change directory), is a command-line shell command used to change the current working directory in various operating systems.

    What command will move you from the current directory to the one above it?

    The command cd .. tells your system to go up to the directory immediately above the one in which you are currently working. cd ../..