Linux: 5 Command Line Basics for Developers (part 1)

If you are developing any program or app that runs on your server or laptop with a Linux OS, you need to be able to find your way into the terminal. Although it is a challenge to master Linux terminal and generally Linux server maintenance, we can always start little and gradually grow. Even in the end, there are few people around you who can really claim that they know everything about Linux and its terminal.

It may look scary, but it is not. As a matter of fact, you can make lots of fun in a Linux terminal if you pass the learning curve.

Let’s start today!

Here I introduce 5 basic but hand commands that you often need when doing application deployment or and debug and maintenance in a Linux machine.

Note: These are based on the Debian distribution.

sudo -i

This is a very basic one: Switch to the root user.

In Linux, by default, you are not root. You have your own account. But if you have sudo access, then you can become a root temporally to perform some tasks that only a root user can do. Be careful!

ls -ltrha

This one I use a lot. The command is “ls” which you can use to list the files and directories in your current location. But the handy part is the option “-ltrha”. This is a combination of these options:

  • -l: show the list of things with their permissions
  • -t: sorted by time and date
  • -r: reverse sorted
  • -h: file size in human-readable format
  • -a: list the hidden files and directories too. (in Linux they start with “.”)

Cool, ha?

tail -n NUMBER

Your cool friend when dealing with log files. This command shows the last N Number of lines for a file.

Example:

tail -n 1000 My_Log_File

df -h

Stands for dist-free,

It is a server and disks can always get full. So use this to examine how much of the disk is free and how much is in use.

top -i

The other resources that can get full are the CPU and RAM.

You can use this to list the processes and programs based on their resource usage. The command can get options where you can indicate the sorting field such as sort based on the CPU usage.

Good start! I hope you enjoy your trip to Linux!

The End.