• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
sharadchhetri.com

sharadchhetri.com

Linux,Cloud Computing And DevOps

  • Home
  • Linux
  • CloudComputing
    • Introduction Cloud Computing
    • Amazon AWS
  • Free E-Books
  • About Me

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.

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.

Example:
cd command

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

Do'nt be greedy, share the knowledge!

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)

Related

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

Follow Us

  • Facebook
  • Twitter
  • GitHub
  • YouTube

Recent Posts

  • Activate.ps1 cannot be loaded because running scripts is disabled on this system
  • How to install Java (OpenJDK) on Ubuntu Linux
  • How to install Groovy on Ubuntu 20.04 LTS
  • How to Disable selinux in Red Hat or CentOS
  • How to remove date from WordPress Post URL

Top Posts & Pages

  • How to delete mail queue in Postfix
  • How to fix read only USB pen drive in Ubuntu
  • How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7
  • 4 different commands to check the load average in linux
  • How to set hostname and FQDN on CentOS 7 and RHEL 7
  • How to find absolute path of command on Linux / Unix : which command
  • How to create Jenkins user by command line and GUI
  • How to print particular line number by using sed command
  • How to setup Jenkins Credentials for Git repo access
  • make command not found in linux CentOS Red Hat ubuntu Debian

DevOps Posts

  • vagrant cloud flow

    Install Vagrant on Ubuntu and create first VM

  • git jenkins credential github

    How to setup Jenkins Credentials for Git repo access

  • terraform

    how to install terraform in Linux : CentOS-Ubuntu

  • docker image

    How to create Ubuntu docker base image

  • Install Ansible on Ubuntu / CentOS / RHEL

Footer

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Sharad Chhetri is an experienced Linux - Cloud Engineer & freelancer. Working on Open Source Technology since RHEL 4.0 (Red Hat Enterprise Linux). He loves sharing the knowledge which earned from real scenarios. Don't be surprised if you find him in technology seminars and meetup groups. You can contact him on email for freelance projects at admin@sharadchhetri.com. Read More…

Tags

Amazon AWS apache automation awk bash script CentOS centos 7 debian devops docker freebsd ftp ghost git grep hostname jenkins kvm linux linux command linux commands MariaDB Server mysql Nagios nginx Octopress owncloud Owncloud 6 php postfix postgres python Red Hat rpm sed selinux ssh swap ubuntu user management vagrant varnish virtualbox vsftp wordpress

Recent Comments

  • Sharad Chhetri on How to fix read only USB pen drive in Ubuntu
  • iain mckeand on How to fix read only USB pen drive in Ubuntu
  • Sharad Chhetri on Secondary Logging : save all users history command output as log
  • Sharad Chhetri on How to fix read only USB pen drive in Ubuntu
  • er on What is /dev/shm and how to mount /dev/shm
  • Bala on Send nagios report as pdf file via email
  • Terry on How to fix read only USB pen drive in Ubuntu
  • Terry on How to fix read only USB pen drive in Ubuntu

Copyright © 2009 - 2022 · All Rights Reserved sharadchhetri.com · · Privacy Policy ·
· sitemap.xml · ·The content is copyrighted to sharadchhetri.com and may not be reproduced on other websites without our permission. ·

Copyright © 2022 · Genesis Sample on Genesis Framework · WordPress · Log in

 

Loading Comments...