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

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

6 important examples of cd command on Linux and Unix Systems

April 5, 2014 by Sharad Chhetri Leave a Comment

In Linux and Unix Systems, cd command is one the basic,essential and frequently use command.
Abbreviation of cd is “Change Directory” . For Linux/Unix System Administrator, it is important to know by how many ways cd command can be used. In this post, I have listed 6 examples which will help you in your daily system administration task.

Note: Directory is also known as folder .

cd command is used for changing current working directory.

cd command is shell builtin means internal command. You can verify about the shell buildin status by using type command.

What is directory

Directory is a logical section in filesystem which contains file. Directory can contain other directories which is known as subdirectory. With cd command you can move to parent directory,user’s current login directory, all directories in root directory also.

IMPORTANT NOTE : The current login user’s home directory is represented with tilda (~)

Change Directory To Currently Login User’s Home Directory

The login user’s home directory is represented with tilda sign (~) . In US keyboard, the ~ sign is available just beneath of ESC key and on the same key of backtick sign(`) . You can print ~ by pressing shift key along with backtick sign.

Syntax:

cd ~

When we use cd ~ command, users directly change to login user’s home directory.The user do not have to type absolute path to login user’s home directory.

cd command

Example:

Change Directory To Absolute Path

In absolute path, the path starts with / (slash). The / (slash) represents the root directory of file system in Unix like operating system(including Linux)

For eg. See the below absolute path. In starting of path we have used / (see bolded / given below)

/opt/google/chrome

Syntax:

cd /absolute/path/of/directory

Example

cd command absolute path

Change Directory To Relative Path

The relative path meaning is when the path is started without / (slash) .

For eg. ~/Desktop , usr/share/doc

Syntax:

cd Relative/Path/To/Directory

Example:

cd relative path

Change Directory To Previous Working Directory

With cd command when we use the option – (hyphen) . It will move back to previous working directory from your current working directory.

Syntax

cd -

Example:

cd -

Change Directory To One OR More Level Back

To change directory to n number of level back. It is like moving back from current working directory.

To going back to one level in tree directory we use two dotes one times (..)

cd ..

or

cd ../

To going back to two level in tree directory we use two dots two times ( .. )

cd ../..

or 

cd ../../

For N number of level back, we will use N times two dots.
For 3 level back ../../../
For 4 level back ../../../../
For 5 level back ../../../../../
And Soon

Example:

cd command

Change Directory To N Level Back Then Change To Relative Path

We can change directory to some level back and move to relative path directory.

Example:

cd command

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Useful tail command with examples in Linux/Unix
  2. How to backup and restore iptables on Linux systems
  3. How To Find Absolute Full Path Of Command On Linux / Unix : which command
  4. Learn Linux Date Command With Examples
  5. 6 df Command Examples To Check Mounted Filesystem On Linux
  6. Find exit status code of last executed command on Linux and Unix
  7. Linux / Unix : whoami command use and advantage
  8. Head command in Linux / Unix
  9. What is Linux/Unix Internal And External Command
  10. learn very useful alias command with examples

Filed Under: Linux, Linux Commands Tagged With: linux command

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

grep command to remove commented lines

How to find installation date and time of rpm package

rsync over ssh port number on Linux/Unix system

sed command to display text between two strings or keywords

type Command : Display Information About Command Type On Linux

Useful tail command with examples in Linux/Unix

Linux Basic Commands For Every Beginner

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

How to set JAVA environment variables in Linux or CentOS

Forward all incoming emails to other SMTP server or gateway

How to hide php version information in header

Convert new line to space by using sed command

linux release renew dhcp assigned ip address

Show visitor ip address php code

error command ‘gcc’ failed with exit status 1 in Ubuntu

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy