MEHDI.
RETURN_TO_INDEX

Linux Commands Every Developer Should Know by Heart

4 min read
#DevOps#Linux#Terminal#Productivity

Introduction

As a developer, I've found that having a strong grasp of Linux commands is crucial for efficient workflow and troubleshooting. In this article, I'll cover the essential commands that every developer should know by heart.

File Navigation

File navigation is a fundamental aspect of working with Linux. The following commands are used to navigate the file system:

  • cd: change directory
  • pwd: print working directory
  • ls: list files and directories
  • mkdir: make a directory
  • rm: remove a file or directory
  • cp: copy a file
  • mv: move or rename a file

For example, to create a new directory and navigate into it, you can use the following command:

mkdir mydir && cd mydir

File Permissions

Understanding file permissions is also important. The following commands are used to modify file permissions:

  • chmod: change file mode (permissions)
  • chown: change file owner

For example, to give the owner read, write, and execute permissions, you can use the following command:

chmod 700 myfile

Text Processing

Text processing is a common task in Linux. The following commands are used for text processing:

  • grep: search for a pattern in a file
  • awk: pattern scanning and processing language
  • sed: stream editor

For example, to search for a pattern in a file, you can use the following command:

grep 'pattern' myfile

To extract the first column from a CSV file, you can use the following command:

awk -F, '{print $1}' myfile.csv

To replace a string in a file, you can use the following command:

sed 's/oldstring/newstring/g' myfile

Process Management

Process management is critical for ensuring that your system runs smoothly. The following commands are used to manage processes:

  • ps: display process information
  • kill: send a signal to a process
  • bg: run a process in the background
  • fg: bring a process to the foreground

For example, to display all running processes, you can use the following command:

ps aux

To kill a process with a specific PID, you can use the following command:

kill 1234

Networking Basics

Networking basics are essential for any developer. The following commands are used for networking:

  • ping: test network connectivity
  • ssh: secure shell
  • scp: secure copy
  • wget: download a file from the internet

For example, to test network connectivity to a specific host, you can use the following command:

ping google.com

To download a file from the internet, you can use the following command:

wget http://example.com/file.txt

SSH

SSH is a secure way to access remote servers. The following commands are used for SSH:

  • ssh: secure shell
  • ssh-keygen: generate a public/private key pair
  • ssh-copy-id: copy a public key to a remote server

For example, to connect to a remote server, you can use the following command:

ssh user@remote-server

To generate a public/private key pair, you can use the following command:

ssh-keygen -t rsa

Practical Takeaways

In this article, we covered the essential Linux commands that every developer should know by heart. We also provided practical one-liners to demonstrate how these commands can be used in real-world scenarios. By mastering these commands, you'll be able to work more efficiently and effectively in Linux. Some key takeaways include:

  • Mastering file navigation and text processing commands
  • Understanding process management and networking basics
  • Using SSH to securely access remote servers
  • Using practical one-liners to simplify your workflow