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
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.
command | Its purpose | |
ls | To list out all the files in current directory. | |
ls -l | To list out all the files in current directory in a detailed manner. | |
cd directory/folder Name | To move into specified folder or directory. | |
cd . . | To move into previous directory. | |
pwd | To print the current directory you are in. | |
ls -a | To show all the hidden files/folder. | |
mkdir folder-name | To create a new directory/folder. | |
rmdir folder-name | To remove an existing directory. | |
touch fileName | To create a new file. | |
cat file-Name | To display the content of the file. | |
cat > file-Name | To create a file and edit it in command line, it will override the content if the file already exist. | |
cat >> file-Name | To edit a file content in command line without overriding (preferred). | |
cp source-file target-file | To copy the content of source file into target file | |
mv file-name folder-name | To move file into specified folder name. | |
mv file-one file-two | To rename file-one into file-two. | |
rm file-name | To remove a file, use this with caution as it will deleted permanently | |
rm -R folder-name | To delete a folder permanently. | |
man any-command | To check any commands description & detail about it. | |
df -h | To report file system disk space usage. | |
head - n 5 filename | To display first 5 lines of the file. | |
Tail - n 2 filename | To display first % lines of the file in a reverse manner. | |
diff file-one file-two | compares two files and display lines that do not match. | |
locate “*.txt” | display all the txt files present. | |
locate filename | display 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 +5 | find all the files that were modified more than 5 minutes ago in the current directory. | |
find . -type f -mtime -10 | shows all files that were modified less than ten days. | |
find . -type f -size +1M | shows all the file that are more than 1 MB in size. | |
find . -type f -size +1K | shows all the file that are more than 1 KB in size. | |
whoami | To check the effective user ID. | |
grep “text” filename | allows us to search for specific text in a filename. | |
grep -w “word” filename | To search for specific word in a file, this is case sensitive. | |
grep -iw “word” filename | To search for specific word in a file, not case sensitive. | |
grep -n “word” filename | To show line number in which the word exist. | |
grep -win “word” filename | To show line number in which word exist, not case sensitive. | |
grep -r “word” filename | To search for word in sub directories, in a recursive manner. | |
grep -B 3 “word” filename | To display last three lines before the specified word in the file. | |
history | To check the history of all the commands used. | |
history | grep "command" | To search for command in history. |
! history ID number | To execute the same command used in history. | |
clear | To clear the terminal. | |
sort fileName | It will display file in sorted manner. | |
sort -r fileName | It will display file in reversed sorted manner. | |
sort -n fileName | It will sort in numerical way. | |
hostname -i | It will return the IP address of the host user. | |
zip source-file.zip fileName | It will compress original file into a zip file. | |
unzip source-file.zip | It will unzip a zip file. |
Shortcuts for Terminal
Key Combination | Use |
CTRL + C | To exit from Command Line |
CTRL + A | To move cursor at start |
CTRL + E | To move cursor at end |
CTRL + K | To remove everything after the cursor |
CTRL + R | For searching commands |
TAB KEY | For autocompletion |
Page Up/ Page Down | To 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!