Everything in Command Line/ Terminal – Navigation

Here, we learn about Navigating through Directories using the Command Line

searchforterminal

 

  • pwd = print working directory
pwd
/home/all/wild
  • ls = list : lists all folders/files in working directory
ls
animals  birds  flowers.txt
  • cd <directory> = change directory :

Moving to an internal directory
provide name of the folder to move to a directory within the current directory , example – ‘cd animals’ will move directory to path /home/all/wild/animals

cd animals
pwd
/home/all/wild/animals

Moving to an external directory(outside the current working directory : provide the path)

cd /home/all/domestic/birds
pwd
/home/all/domestic/birds

Moving to one directory up or one step back

cd ..
pwd
/home/all/domestic

mkdir <directory_name> = make a new directory :

Make a new directory within the working directory

mkdir cattle
pwd
/home/all/domestic
ls
cattle fish friendly.txt

Make a new directory outside the working directory
Here, making directory ‘cuckoo’ under birds in wild.

mkdir /home/all/wild/birds/cuckoo
cd /home/all/wild/birds
ls
cuckoo parrot.txt

touch <filename> = creates a new file :

Create a new file in current working directory

pwd
/home/all/wild/birds
touch owl.txt
ls
cuckoo parrot.txt owl.txt

Create a new file in outside working directory

touch /home/all/wild/animals/lion.txt
cd /home/all/wild/animals
ls
lion.txt