10 useful Linux Commands that every developer should know

Gaurav Bhardwaj
Gaurav Bhardwaj
Modified on
#linux
Cover Image for 10 useful Linux Commands that every developer should know

In this article, I am going to show you the 10 useful Linux commands that every developer should know. I am sure after reading this article you will get to learn some of the stuff about Linux. Let’s begin.

Linux is experiencing a tremendous rise in the present technology world, so Linux commands are also in demand. Linux will further continue to rise in the future as well due to its power, simplicity, security, and open-source nature. Most of the Linux distributions are free and are much powerful than its competitive non-free platforms like Microsoft Windows and Apple Mac. I like Linux because of its open-source nature and you can customize the source code as you want. There are tons of Linux distributions, you can check my best distro picks here. If you are coming to this article, then I am sure that you are a also big fan or regular user of Linux.

Useful Linux Commands

1. grep

Grep is one of the very useful Linux commands to find the Patterns inside the File. Suppose, you need to search a word or many words inside a file you can easily do that by the “grep” command.

Usage:

Lets say we have a file – sites.txt with the content below

10 Linux Command that every developer should know - grep

If we need to search ittwist from the file we can easily do it with below command.

grep ittwist sites.txt
10 Linux Command that every developer should know - grep

You can also search for multiple texts in a file by simply executing

grep -e ittwist -e google sites.txt
10 Linux Command that every developer should know - grep

You can further explore this command by simply executing man grep

2. chmod

Linux is a very secure platform, you can deal with permissions by simply executing this command. Chmod is used to change the read, write, and execute permissions of files and directories.

Before diving deep into this command we need to briefly understand the basics.

  • User (u): A user can be a person or account which exists on Linux.
  • Group (g): A group can be a number of users in a single entity.
  • Others (o): Others are basically everyone who does not exist as a user or group.

Also, we have different permissions like:

  • Read (r): One can open & view the contents of a file.
  • Write (w): One can modify or delete a file
  • Execute (x): If a file is a script file you can execute that.
  • Denied (-): One will have no access to the file.

Now if you view the directory listing of a file, we have a different set of letters for each user, group, and owner. Each letter should contain different permissions of – Read (r), Write (w), Execute (x), and Denied (-).

<-d> <user_letters> <group_letters> <owner_letters> filename

Example:

ls -al
10 Linux Command that every developer should know - chmod
10 Linux Command that every developer should know - chmod

Coming back to chmod, we have another concept of octal digits for providing permission to a particular file in which Read has a value of (4), Write has a value of (2), and Execute has a value of (1).

Suppose we want to give read write and execute permission – We can easily give by summing up the values (octal digits).

No Permission = No Read + No Write + No Execute = 0 + 0 + 0 = 0

Only Read = Read + No Write + No Execute = 4 + 0 + 0 = 4

Read and Write = Read + Write + No Execute = 4 + 2 + 0 = 6

Read, Write and Execute = Read + Write + Execute + 4 + 2 + 1 =7

Pretty Simple right, just a simple mathematical calculation for giving permissions to a file.

In chmod we can give permission to each User, Group and Others like

10 Linux Command that every developer should know - chmod

Demonstration, I want to give only read permission to sites.txt file, I can easily give by.

chmod 444 sites.txt
10 Linux Command that every developer should know - chmod

You can further explore this command by simply executing man chmod

3. chown

chown stands for ChangeOwner – which has a purpose to change an owner of a file. Let’s say you have one book which is purchased by you but if you want to change the ownership of that book to someone you can do that by gifting that book to that person. Likewise in Linux, you can change the ownership of a file by executing this command.

Example:

chown gopal site.txt

This command will change the ownership of sites.txt file to user gopal.

You can further explore this command by simply executing man chown

4. kill

If you have an unresponsive program, you can terminate that program by sending any signals. There are total 64 signals, but commonly used signals are:

  • SIGTERM (15) — Requests a program to stop running and provides it time to save its progress. This is a default signal if you don’t specify any signal.
  • SIGKILL (9) — Forces programs to stop immediately. Unsaved progress will be lost.

Also, you need to have a Process Identification Number to kill a particular process which you can easily obtain by

ps ux

Then you can simply kill the program by:

kill [-signal] PID

Example:

For example, Let’s stop the chromium browser by executing the kill command. First, we will obtain the Process Identification number by executing the ps ux command.

10 Linux Command that every developer should know - kill

Then you can simply execute kill <PID> , the PID in my case is 6332.

10 Linux Command that every developer should know - kill

You can further explore this command by simply executing man kill

5. watch

Watch command is used to execute a program periodically showing output on a full screen. Say, you want to real-time see the contents of a particular folder. You can combine watch and ls commands.

watch -n <TIME_INTERVAL in Seconds> Command
10 Linux Command that every developer should know - watch

Output:

10 Linux Command that every developer should know - watch

You can further explore this command by simply executing man watch

6. wget

Wget is the non-interactive network downloader. Non-interactive means you can download a file from the web in the background, while the user is logged in. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.

wget full_network_path_of_the_file

Let’s download logo of ittwist website we can easily do that with wget.

wget https://ittwist.com/wp-content/themes/ittwist-wp-theme/img/logo.png
10 Linux Command that every developer should know - wget

You can further explore this command by simply executing man wget

7. curl

Curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.

curl https://www.google.com

This will transfer the content of google.com to your standard output screen.

10 Linux Command that every developer should know - curl
curl -o content.txt https://www.google.com

This will transfer the contents of google.com and save it to content.txt locally.

10 Linux Command that every developer should know - curl

You can further explore this command by simply executing man curl

8. awk

The AWK command is useful for the manipulation of data files, text retrieval and processing, and prototyping and experimenting with algorithms. This is a very powerful command, you can even generate files or datasets with this command.

Lets learn by taking a simple example. Assume, we have a file name student_result.txt with following records

RollNo StudentName StudentMarks
1 Gaurav 100
2 Gopal 100
3 Ram 100
10 Linux Command that every developer should know - awk

Now, Let’s assume we need to get only roll no and student name of student_results.txt with no student marks we can easily do it with awk.

awk '{print $1 , $2 }' student_result.txt
10 Linux Command that every developer should know - awk

You can further explore this command by simply executing man awk

9. cat

Cat command is used to concatenate files and print on the standard output.

cat <filename>
10 Linux Command that every developer should know - cat

You can further explore this command by simply executing man cat

10. find

Using find command we can easily search for files in a directory.

find <directory> -name <file>

Lets consider, We need to search a file student_record.txt inside a my home directory. We can simply achieve this by executing find command.

10 Linux Command that every developer should know - cat

You can further explore this command by simply executing man find

Hope you enjoyed this article about useful linux commands. Please feel free to ask questions or provide suggestions in the comment section below.

Tagslinux


0 Comments

Leave a Comment

Note : Your Email ID will not be published. Enter all the Required Fields *