Moving "Down" in Linux Directories
The Linux cd command can be used with "spacebar directoryname " to move "down" into a directory below the current directory without having to type in the full path to a directory that is below the current directory.
Moving "Up" in Linux Directories
You can use "spacebar .." to move up a directory (level) to go to the "parent" directory of the current directory.
- Linux Commands Training Tips: You can use a; (semicolon) between Linux commands to run more than one command on the same line. And the pwd command shows the fill path to your current directory.
Examples of Using the cd Command To Move Up and Down Directories
The Linux cd command below changes into the directory named man, below the path of / usr / share.
The ls command below uses the – d option to show the d irectory names (only) in the man directory and not the contents of the directories (which are subdirectories) of the man directory.
The filename "pattern" of man ? used with the ls command below causes the output to show only the directories beginning with "man" and ending in any other single character (only), due to the single? wildcard character.
These directories can be referred to as the man x directories, where x is a number from one to nine.
- $ cd / usr / share / man; ls -ld man?
To change into the man2 directory below the current directory, use "cd spacebar dirctoryname", where the directoryname is a man2 directory.
- $ cd man2; pwd
The full path to the man2 directory is: / usr / share / man / man2
Now, to easily change up one directory "level" use "spacebar ..", instead of typing in cd and then the full path of / usr / share / man.
- $ cd ..; pwd
Now change into the man5 directory below the current directory.
- $ cd man5; pwd
Now combine the two dots with a directory name (and use a slash between the two dots and the directory name) to go up one directory level and then down into the man7 directory!
- $ cd ../man7; pwd
The Linux commands covered here apply to ALL Linux distros, including Red Hat, Ubuntu, openSUSE, SUSE, Debian, Fedora and Slackware Linux.