DEV Community

Cover image for 40 Essential Linux Commands That Every Developer Should Know
MINHCT
MINHCT

Posted on

40 Essential Linux Commands That Every Developer Should Know

Linux is a family of open-source Unix operating systems based on the Linux Kernel. They include Ubuntu, Fedora, Debian, openSUSE, and Red Hat.

When operating Linux, you need to use a shell — a program that gives you access to the operating system’s services. Most Linux distribution use a graphical user interface (GUI), making them beginner — friendly.

However, I recommend utilizing the command-line interface (CLI) since it’s quicker and offers more control.

So, in case you want to utilize Linux, learning the command utilities or commands will go a long way. For that reason, in this article I will discuss the 40 basics commands to help you guys use your own Linux effectively.

🤷‍♂️ What is a Linux Command?

A Linux command is a program or utility that runs on the CLI — a console that interacts with the system via texts and processes.

Here is what Linux command look like

commandName [option(s)] [parameter(s)]

🕵️‍♂️ The 40 Most Commonly Used Linux Commands

👍 sudo command

Short for superuser do, sudo is one of the most widespread basic Linux commands that lets you perform tasks that require administrative or root permission.

sudo [command]

👍 pwd command

Use the pwd command to find the path that you are currently working in.

pwd

👍 cd command

To navigate through the Linux files and directories, use the cd command to solve this task. Depending on your current location, it requires either the full path or the directory name.

cd [path/directory]

👍 ls command

The ls command lists all files and directories inside your current path (include all the hidden folder or file if you are using flag -a)

ls

👍 cat command

Concatenate, or cat is one of the most frequently used in Linux commands. It lists and writes file to the standard output. In simple term, we print the content inside that file to our terminal.
cat [fileName]

👍 cp command

Cp stand for copy, what is does is copy files or directories and their contents. In this case, it will copy all the contents inside file 1 to file 2.

cp file1 file2

👍 mv command

The primary use of this command is to move and rename files and directories. In this case, it will rename the file 1 to file 2.

mv [file1] [file2]

👍 mkdir command

Use the mkdir to create one or multiple directories at once. But note that the use who executes this command must have root or administrative permission.

mkdir [folderName]

👍 rmdir and rm -r command

To permanently delete an empty folder, use the rmdir command to achive this. Now in order to delete a folder which is not empty, we can use the latter command.
rmdir [emptyFolderName]

rm -r [notEmptyFolderName]

👍 rm command

This command is used to delete a file inside a specific directory.
rm [fileName]

👍 touch command

The touch command allows you to create an empty file.

touch [fileName]

👍 grep command

Locate command can find a file in the database system. In this example, the command will search for blue in note.txt.

grep blue note.txt

👍 df command

Use the df command to report the system's disk space usage, show in percentage and kilobyte (KB).

df -h

👍 du command

If you want to check how much space a file or directory takes up, use the du command.
du [file/directory]

👍 head command

The head command allows you to view the first ten lines of a specific file.

head [fileName]

👍 tail command

Opposite to the head command, the tail views the last 10 lines inside a file.

tail [fileName]

👍 diff command

Short for different, the diff command compares two contents of a file line by line. After analyzing them, it will display the parts that do not match.

diff [file1] [file2]

👍 tar command

The tar command archives multiple files into a TAR file - a common Linux format similar to ZIP.

tar [achiveFile] [fileBeArchived]

👍 chmod command

chmod is a common command that modifies a file or directory's read (r), write (w), execute (e) permission. In Linux, each file is associated with three user classes - owner, group and others.

chmod [permission] [fileName]

👍 chown command

The chown command lets you change the ownership of a file, directory to a specified username.

chown [owner]:[group] [fileName]

👍 jobs command

A job is a process that the shell starts. The jobs command will display all the running processes along with their statuses.

jobs [jobID]

👍 kill command

Use the kill command to terminate an unresponsive program manually.
To kill a prgram, you must know its process identification number (PID). If you don't know the PID, run the first command to do it.

ps ux

kill [PID]

👍 ping command

The ping command is one of the most used basic Linux commands for checking whether a network or server is readable.

ping [IP/hostName]

👍 wget command

This command line lets you download the files from the internet using HTTP, HTTPS and FTP protocols.

wget [url]

👍 uname command

The uname or unix name command will print detailed information about your Linux system and hardware.

uname

👍 top command

The top command in Linux Terminal will display all the running processes and a dynamic real-time view of current system. It sums up the resource utilization, from CPU to memory usage.

top

👍 man command

The man command provides a user manual of any commands or utilities user can use in Terminal, including the name, description and options.

man [commandName]

👍 echo command

The echo command is a built-in utility that displays a line of text or string using the standard output.

echo [string]

👍 apt-get command

apt-get command line tool for handling Advanced Package Tool (APT) in Linux. It lets you retrieve information and bundles from authenticated sources to manage, update, remove and install software and its dependencies. Think APT like npm in NodeJS.

apt-get [command]

💕 Conclusion

Linux command let you perform basic and administrative tasks quickly and effectively from the Terminal.
Learning Linux basic command is essential to interact with your machine.

I hope this article has helped you learning Linux command. If you have any question, do not hesitate to drop a comment below 😉.

Again, thank you very much for giving this blog a read and don't forget to leave me a clap 👏 and follow me for more interesting content like this 😘.

In case you want to find more information about me, you can visit my portfolio website or my GitHub profile 💛.

Top comments (2)

Collapse
 
jonrandy profile image
Jon Randy 🎖️

The touch command allows you to create an empty file.

True, but that's not its actual purpose - touch is actually for updating the access date and/or modification date of the given file. The fact that it creates the file if it does not exist is merely a convenient side effect.

Collapse
 
trinhcamminh profile image
MINHCT

I'll note that bro. Thanks for your contribution 🧡.