Learning how to use commands on ubuntu

 

Objectives: Learn how to use the following commands

  • pwd
  • ls
  • cd
  • mkdir

Pwd :print working directory 
General format: pwd {options}


1.pwd
Running pwd by itself gives the filepath of the current directory 
As we current are in the home directory running ls will give the parh of the home directory





ls : List current directory
General format : ls {options} {file/directory name}

1.ls
Running ls by itself gives the files present in the current directory.
As we current are in the home directory running ls will give the contents of the home directory 


2. ls {directory name}
-Gives us the contents of the directory
-Ex ls Downloads/



3.ls ..
-Gives us the contents of the previous directory
-Ex ls .. gives us the contents of file2 when the current directory is Downloads/file2/contents



4.ls../..
-Gives us the contents of two directories back
-Ex ls../.. gives us the contents of Downloads when the current directory is Downloads/file2/contents



5.ls -l
Gives the contents of the directory in long format



6.ls -a
Lists all the files , including hidden files
Note :Hidden files start from . 
Ex .profile



7.ls -al
Combines the previous two options




8.ls {file name/path}/*.{file type}
Ex ls download/file1/*.pdf
Displays only .pdf files




cd : change directory
General format: cd {directory name}


1.cd
Running cd by itself will move you to the home directory


2.cd {directory path} 
- will move you to the directory 
Ex cd Downloads



3.cd {directory name}
-relative path; since we are in the home directory 
 Ex cd/downloads will move you to the downloads folder 



4.cd ..
-will move you to the parent of the current folder
Ex using cd .. when we are in the files2 folder will move us to the Downloads folder



5. :-How to move to a folder that has a space in its name
Ex cd/the folder will return an error
:- cd/the\ folder or cd/"the folder" can be used




mkdir : make directory 


1.mkdir (folder name)
Creates a folder (folder name) in the current directory 
Ex mkdir folder1 will create a folder with the name folder1


2.mkdir (directory name)/(sub directory name)
Creates a sub directory (sub directory name) in the (directory name) folder
Ex mkdir folder1/subcont1 will create a subfolder with the name subcont1 in the already existing folder folder1


3.mkdir --parents (directory name)/(sub directory name) or mkdir -p (directory name)/(sub directory name)
Ex mkdir -p folder2/subcont1 will create both the directory and sub directory .



4.mkdir -p (directory name)/{(subdir1),(subdir2)}
Ex mkdir -p folder3/{subcont1,subcont2,subcont3} Creates the directory and the list of sub directories



Finally (command) --help can be used to get information about a specific command



Comments

Popular posts from this blog

Learning How to use git

Learning about Post Quantum cryptography (PQC)