Basic Linux/Unix commands that you need to know

Basic Linux/Unix commands that you need to know

In this article, we will go through some Linux commands that will help you use your Linux/Unix operating system through a terminal

Let's get started

First of all, open your terminal, most probably The keybinding to open a terminal session will be Alt+Ctrl+t . What you will see is a clean terminal screen. Don't know where to go from here? Don't worry let us get your screen filled with text.

  1. The ls command. ls stands for 'List'. It lists all your directories and files in your current working directory.

    What is the current working directory?

    The current working directory is the directory that is currently opened in your terminal session. If you just opened your terminal you will be in the ~ which is the home directory for your current user.

  2. To check your current working directory you can use the pwd command. pwd stands for 'Print working directory'.

  3. Now that we see some directories on our screen. Let us change to those directories with the cd <directory name> command. cd stands for 'change directory'. To change to a particular directory in this case let's change to the Downloads directory we can write cd Downloads (note: it is case sensitive).

    Now that we know how to move forward, let us learn how to move backward.

    We can use cd .. to move a directory backward.

  4. Let us make a new directory now. Using the mkdir <directory name> command we can make a new directory. mkdir stands for 'make directory'. For example, let us make a new directory test, mkdir test . (cd into that directory)

  5. Now that we are inside our newly made directory, let us make some files, using the touch <filename> command. touch is used to make new files. For example, touch newfile.txt, this will create a new file newfile.txt.

  6. To edit the contents of a file. We have several terminal-based text editors, to keep it simple let us go with nano. To edit the text file using nano let us type nano newfile.txt. Now you can write whatever you want and after that to save and exit, press Ctrl+x -> y -> Enter .

  7. To print the contents of a file we use the cat <filename> command. cat stands for 'concatenate', cat newfile.txt will print all the contents of our file on our terminal screen.

  8. Now let us learn how to delete files, for that, we use the rm <filename> command. rm stands for 'remove'. rm newfile.txt will remove the text file that we just created.

  9. Remember we were inside the directory test that we just created. To delete that director we will have to go a directory backward. rmdir <directory name> will delete our directory for us. rmdir stands for 'remove directory' rmdir test will delete the test directory.

  10. To exit our terminal we will use the exit command.

So these were some basic Linux commands that we learned today. Stay tuned for more such tutorials.