The cd
command in Linux is used to navigate directories.
cd folder_path
folder_path
: This is the path to the folder which we want to navigate to.
cd ..
: This moves one directory up.
cd
: This moves to the home folder.
cd ~
: This moves to a previous directory.
# print current directorypwdecho ............# navigate to current directorycd /usercode# list files in current directoryls
Line 2: We print the current directory to the console.
Line 6: We navigate to the /usercode
directory.
Line 8: We print the files in the /usercode
directory to the console.
# print the current folderecho "print current folder..."pwd# list files in curren folderls# move to a directory one level upecho "changing folder..."cd ..# print files in the navigated directoryls
Line 3: We print the current directory.
Line 6: The files in the current directory are printed to the console.
Line 10: We move to a directory one level up.
Line 13: We print all the files present in the directory.