• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

15 Practical Examples of ‘cd’ Command in Linux

How VPS by How VPS
November 2, 2018
in Linux, Operating System
0
0
SHARES
10
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Tutorial Details

In Linux ‘cd‘ (Change Directory) command is one of the most important and most widely used command for newbies as well as system administrators. For admins on a headless server, ‘cd‘ is the only way to navigate to a directory to check log, execute a program/application/script and for every other task. For newbie it is among those initial commands they make their hands dirty with.

15 Practical Examples of ‘cd’ Command in Linux

15 cd command examples in linux

Thus, keeping in mind, we here bringing you 15 basic commands of ‘cd‘ using tricks and shortcuts to reduce your efforts on the terminal and save time by using these known tricks.

Tutorial Details
  1. Command Name : cd
  2. Stands for : Change Directory
  3. Availability : All Linux Distribution
  4. Execute On : Command Line
  5. Permission : Access own directory or otherwise assigned.
  6. Level : Basic/Beginners

1. Change from current directory to /usr/local.

[email protected]:~$ cd /usr/local

[email protected]:/usr/local$ 

2. Change from current directory to /usr/local/lib using absolute path.

[email protected]:/usr/local$ cd /usr/local/lib 

[email protected]:/usr/local/lib$ 

3. Change from current working directory to /usr/local/lib using relative path.

[email protected]:/usr/local$ cd lib 

[email protected]:/usr/local/lib$ 

4. (a) Switch back to previous directory where you working earlier.

[email protected]:/usr/local/lib$ cd - 

/usr/local 
[email protected]:/usr/local$ 

4. (b) Change Current directory to parent directory.

[email protected]:/usr/local/lib$ cd .. 

[email protected]:/usr/local$ 

5. Show last working directory from where we moved (use ‘–‘ switch) as shown.

[email protected]:/usr/local$ cd -- 

/home/avi 

6. Move two directory up from where you are now.

[email protected]:/usr/local$ cd ../ ../ 

[email protected]:/usr$

7. Move to users home directory from anywhere.

[email protected]:/usr/local$ cd ~ 

[email protected]:~$ 

or

[email protected]:/usr/local$ cd 

[email protected]:~$ 

8. Change working directory to current working directory (seems no use of in General).

[email protected]:~/Downloads$ cd . 
[email protected]:~/Downloads$ 

or

[email protected]:~/Downloads$ cd ./ 
[email protected]:~/Downloads$ 

9. Your present working Directory is “/usr/local/lib/python3.4/dist-packages/ ”, change it to “/home/avi/Desktop/ ”, in one line command, by moving up in the directory till ‘/’ then using absolute path.

[email protected]:/usr/local/lib/python3.4/dist-packages$ cd ../../../../../home/avi/Desktop/ 

[email protected]:~/Desktop$ 

10. Change from current working directory to /var/www/html without typing in full using TAB.

[email protected]:/var/www$ cd /v<TAB>/w<TAB>/h<TAB>

[email protected]:/var/www/html$ 

11. Navigate from your current working directory to /etc/v__ _, Oops! You forgot the name of directory and not supposed to use TAB.

[email protected]:~$ cd /etc/v* 

[email protected]:/etc/vbox$ 

Note: This will move to ‘vbox‘ only if there is only one directory starting with ‘v‘. If more than one directory starting with ‘v‘ exist, and no more criteria is provided in command line, it will move to the first directory starting with ‘v‘, alphabetically as their presence in standard dictionary.

12. You need to navigate to user ‘av‘ (not sure if it is avi or avt) home directory, without using TAB.

[email protected]:/etc$ cd /home/av? 

[email protected]:~$ 

13. What are pushd and popd in Linux?

Pushd and popd are Linux commands in bash and certain other shell which saves current working directory location to memory and bring to the directory from memory as current working directory, respectively as well as changes directory.

[email protected]:~$ pushd /var/www/html 

/var/www/html ~ 
[email protected]:/var/www/html$ 

The above command saves the current location to memory and changes to the requested directory. As soon as popd is fired, it fetch the saved directory location from memory and makes it current working directory.

[email protected]:/var/www/html$ popd 
~ 
[email protected]:~$ 

14. Change to a directory containing white spaces.

[email protected]:~$ cd test/ tecmint/ 

[email protected]:~/test tecmint$ 

or

[email protected]:~$ cd 'test tecmint' 
[email protected]:~/test tecmint$ 

or 

[email protected]:~$ cd "test tecmint"/ 
[email protected]:~/test tecmint$ 

15. Change from current working directory to Downloads and list all its settings in one go.

[email protected]:/usr$ cd ~/Downloads && ls

…
.
service_locator_in.xls 
sources.list 
teamviewer_linux_x64.deb 
tor-browser-linux64-3.6.3_en-US.tar.xz 
.
...

This is our attempt, to make you aware of Linux Workings and executions in least possible words and with as much as user friendliness as it used to be before.

That’s all for now. I’ll be here again with another interesting topic soon. Till then stay tuned and connected to Tecmint. Don’t forget to provide us with your valuable feedback in the comments below.

Source: tecmint.com

Tags: Linux Commandslinux guidelinux vps setup guide
Previous Post

How to Show Asterisks While Typing Sudo Password in Linux

Next Post

How to Manipulate Filenames Having Spaces and Special Characters in Linux

Next Post

How to Manipulate Filenames Having Spaces and Special Characters in Linux

Leave a Reply Cancel reply

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

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet