Common terms 01

Using windows? Then you need to install wsl.

Directories

You have folders in your pc right? In programming we call it directories.

list

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.

change 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

Creating and deleting directories

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

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.

Files

deleting files

(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>.

History

accessing history

You can use the command

history 

to view the list of commands you have used till now.

delete history

To delete your history you can use`

history -c && history -w

Credits: secuRIT Core :)

Edit this page