50 Linux Commands you need to know as a Developer

50 Linux Commands you need to know as a Developer

Are you looking to get started with Linux? Then you are in right place!


Table of Contents

  • Introduction

  • Installation of Linux in Windows

  • Download Vmware & ubuntu 22.04.1

  • Download WSL

  • Getting started with Linux Commands

  • Shortcuts for Terminal

Introduction

This Blog is written to help you familiarize with Linux & its Terminal Commands which every Developer should know. Linux is a family of Open-Source Operating System with many popular distributions like Ubuntu & Kali Linux OS.

Many Developers or you can say most of the experienced Developers prefer Linux for its efficiency over Windows OS.

By the end of this blog, You will be able to operate Linux OS with Command Line Interface. So Let’s begin with it.


Installation of Linux on Windows OS users

If you are MacOS user, feel free to skip this part as MacOS is based on Unix Operating System.

To be able to execute these commands you should have WSL ( Window Subsystem for Linux) in your machine.

OR

You can install Vmware & Ubuntu, which i would recommend because some commands may not work in WSL.

Download Vmware & Ubuntu from here

Vmware

Ubuntu 22.04.1

For WSL, execute the following command in Window PowerShell Terminal

wsl --install -d Ubuntu

Here, Ubuntu is one of the distribution of Linux OS, also being the most recommended distro for beginners.

After the installation you can set up the username and password for it.


Getting started with Linux Commands

Now, you will have a Terminal like this, where you can execute all the commands we are going to learn.

commandIts purpose
lsTo list out all the files in current directory.
ls -lTo list out all the files in current directory in a detailed manner.
cd directory/folder NameTo move into specified folder or directory.
cd . .To move into previous directory.
pwdTo print the current directory you are in.
ls -aTo show all the hidden files/folder.
mkdir folder-nameTo create a new directory/folder.
rmdir folder-nameTo remove an existing directory.
touch fileNameTo create a new file.
cat file-NameTo display the content of the file.
cat > file-NameTo create a file and edit it in command line, it will override the content if the file already exist.
cat >> file-NameTo edit a file content in command line without overriding (preferred).
cp source-file target-fileTo copy the content of source file into target file
mv file-name folder-nameTo move file into specified folder name.
mv file-one file-twoTo rename file-one into file-two.
rm file-nameTo remove a file, use this with caution as it will deleted permanently
rm -R folder-nameTo delete a folder permanently.
man any-commandTo check any commands description & detail about it.
df -hTo report file system disk space usage.
head - n 5 filenameTo display first 5 lines of the file.
Tail - n 2 filenameTo display first % lines of the file in a reverse manner.
diff file-one file-twocompares two files and display lines that do not match.
locate “*.txt”display all the txt files present.
locate filenamedisplay the path of file where it is located.
find .finds all the files/folder in the present directory.
find . .Finds all the files/folder in the previous directory.
find . -type f -name “*.txt”find all the txt files present in the current directory.
find . -type f -name “file name”find file with specified name in the current directory.
find . -type f -mmin +5find all the files that were modified more than 5 minutes ago in the current directory.
find . -type f -mtime -10shows all files that were modified less than ten days.
find . -type f -size +1Mshows all the file that are more than 1 MB in size.
find . -type f -size +1Kshows all the file that are more than 1 KB in size.
whoamiTo check the effective user ID.
grep “text” filenameallows us to search for specific text in a filename.
grep -w “word” filenameTo search for specific word in a file, this is case sensitive.
grep -iw “word” filenameTo search for specific word in a file, not case sensitive.
grep -n “word” filenameTo show line number in which the word exist.
grep -win “word” filenameTo show line number in which word exist, not case sensitive.
grep -r “word” filenameTo search for word in sub directories, in a recursive manner.
grep -B 3 “word” filenameTo display last three lines before the specified word in the file.
historyTo check the history of all the commands used.
historygrep "command"To search for command in history.
! history ID numberTo execute the same command used in history.
clearTo clear the terminal.
sort fileNameIt will display file in sorted manner.
sort -r fileNameIt will display file in reversed sorted manner.
sort -n fileNameIt will sort in numerical way.
hostname -iIt will return the IP address of the host user.
zip source-file.zip fileNameIt will compress original file into a zip file.
unzip source-file.zipIt will unzip a zip file.

Shortcuts for Terminal

Key CombinationUse
CTRL + CTo exit from Command Line
CTRL + ATo move cursor at start
CTRL + ETo move cursor at end
CTRL + KTo remove everything after the cursor
CTRL + RFor searching commands
TAB KEYFor autocompletion
Page Up/ Page DownTo navigate up and down for commands that were used

Get to know me

I'm Apala Gupta, an aspiring Full Stack Developer, I hope this article helped you in a way. Follow me for more such detailed blog to help you in your development journey. Don't forget to share this blog with your friends!

My Twitter Handle

My linkedIn