Using windows? Then you need to install wsl.
You have folders in your pc right? In programming we call it directories.
When you open wsl, it opens in a default directory. Now to know the contents of that directory, use the following command
ls
ls, list command, lists all the files and directory in your current directory.
To go into another directory you can use the cd
command.
cd <directory_address>
For example, to go your desktop, you can use the following command
cd /mnt/c/users/<your_username>/desktop
/
:- This is called root directory. That is, the parent directory. All files and directory come under this, that is why you use this in front of all the address.mnt
:- mnt
stands for mount point. It contains all the files and directories of different OS present in the pc. This is used to access the files in windows.To create a new directory use the following command
mkdir <new_dir_name>
Note: To create directory in some other location, you can give the full address. This is applicable to most of the commands, that is, you can use the commands to access files/directories from other directories by giving the full path
So, to create a directory on your desktop while you are in some other directory, you can use
mkdir /mnt/c/users/<user_name>/desktop/<new_directory_name>
To delete a empty directory, use (deletes permanently!)
rmdir <dir_name>
To delete a directory which is not empty you can use,
rm -r <dir_name>
NOTE:- THE ABOVE COMMAND IS EXTREMELY DANGEROUS AND REMOVES THE FILES WITHOUT WARNING. DONOT USE UNLESS NECCESSARY. FOR EXAMPLE, IF YOU ENTER "rm -r / " ALL THE FILES IN THE ROOT DIRECTORY WILL GET PERMENANTLY DELETED, WHICH TECHNICALLY IS ALL OF YOUR DATA.
To change the directory, entering the full path is very inconvenient. So you can use
./
:- It refers to the current directory.../
:- It refers to the previous directory.cd ./<dir_name>
If you are in desktop directory, /mnt/c/users/<user_name>/desktop
and you want to access another user, you can use
cd ../../<another_user_name>/desktop
The above command will first go to the <user_name>
directory >> users
directory, then it will look for any user in your pc named <another user>
and enter the directory >> desktop
(of the other user). Thus you can use the ../
in chains to go to previous directories.
(deletes permanently!) use the following command,
rm <file_address>
If the file is in your current directory, you don’t need to mention the complete address and only file name is enough, rm <file_name>
.
You can use the command
history
to view the list of commands you have used till now.
To delete your history you can use`
history -c && history -w