Linux – Changing Directories with ‘cd’ Command
Changing directories is likely the second most common
command in Linux aside from ‘ls’. Using the ‘cd’ command, you can change your
current working directory.
Recall the ‘pwd’ command prints your current working
directory.
Also, it is important that you understand the use of the
following,
·
‘..’- Parent directory
·
‘.’- Current directory
·
‘~’- Home directory
Examples
Change to your home directory using ‘cd’,
$ pwd
/home/fred/folder1
$ cd
$ pwd
You can also use ‘cd ~’ to change to your home directory,
$ pwd
/home/fred/folder1
$ cd ~
$ pwd
/home/fred
Change to a subdirectory,
$ pwd
/home/fred
$ cd folder1/myfiles
$ pwd
/home/fred/folder1/myfiles
The above cd command is the same as ‘$ cd ./folder1/myfiles’, however the ‘./’ is not
necessary.
Change to the parent directory using ‘cd ..’,
$ pwd
/home/fred/folder1/myfiles
$ cd ..
$ pwd
/home/fred/folder1
Change to a directory in the parent directory,
$ pwd
/home/fred/folder1
$ cd ../folder2
$ pwd
/home/fred/folder2
stop blackmailing us on here: http://scamsites2.blogspot.com
ReplyDeleteremove the tags and the post please, thanku