Linux commands you must know as a beginner

Before directly jumping into the commands let us first know what Linux is and why it is important.

What is Linux?

Linux is an operating system that helps users like us communicate with the system hardware. It is a Kernal-based operating system which means most of the functionalities are achieved using commands. An operating system is a layer on our system hardware (ram, memory, CPU etc) that helps the users to communicate with the hardware and make our work done efficiently and effectively.

NOTE: You can run a Computer without an Operating System but with very very limited functionalities.

Few facts about Linux:

  • In the year 1991, Linux Torvalds released the first ever Linux Kernal.

  • It is Open Source which means you can use it for free though it has some paid variants too.

  • It has a monolithic kernel which means the whole Linux programs run as one unit.

  • It is faster and more efficient than the Windows operating system.

  • It is more secure and less prone to viruses.

Fun fact about Linux:

Linus Torvalds started creating Linux OS as a personal Project only.

Now as You have a basic understanding of Linux we can start with the basic commands.

  1. To check the current directory(a directory in Linux is a folder in Windows):

    pwd(present working directory)

  2. To list all the files and directories including hidden files:

     ls -l
     #to list all the files and directories.
    
     ls -la
     #to list all the files and directories including hidden files.
    

  3. To create a directory:

     mkdir directory1
    

  4. To create nested directories like d4 inside d3 inside d2 inside d1:

     mkdir -p d1/d2/d3/d4
    

  5. To create a file we can use the touch command which will create empty files.

     touch file1.txt
    

  6. To create a file with some contents in it we use the echo command.

     echo "This is a file " > file2.txt
     #here the "This is a file " is the file contents
    

  7. To create one file with some contents we can also use the text editors available for Linux. We will dig deep into them in a later blog but for now, remember the syntax only.

     #for the vi or vim text editor
     vi file3.txt
    
     #for the nano text editor 
     nano file4.txt
    
  8. To view the contents of a file we use the command cat.

     cat file2.txt
    

  9. To check the file permission we use the following command.

     ls -l
     #to check which one is having which permissions
    

  10. To check the commands we have run till now.

    history
    #out put will be the history of commands
    

  11. To remove a directory or folder from a Linux file system.

#we can use either of the below two commands
rmdir directory-name
#or
rm -r directory-name
#if the directory is having some content and you want to delete
#everything forcefully then the below command.
rm -rf directory-name #though it is not recomended to use -rf
  1. Check the top three lines of a given file or the bottom three lines of a given file.
#to check top 3 lines of a given file
head -n 3 filex.txt #assume filex is having 20 lines
#to check bottom 3 line of the given file
tail -n 3 filex.txt

Now we have come to the end , I would defenitely add here that there are a lot of Linux commands available and we use a very few of them as beginers , so start learning from the basics and keep practicing. In the next blog I will cover the two most used linux text editors vi and nano.