10 Linux Commands Every Programmer Should Know

10 Linux Commands Every Programmer Should Know

·

5 min read

Introduction

If you've never used Linux, then you're in for a treat. It's one of the most versatile operating systems out there, and it can do anything from browsing the web to playing games. But if you want to get good at using Linux, then knowing the right commands is essential. Here are some of my favourite commands that every user should know:

ls

  • ls -l

  • ls -a

  • ls -R

  • This command lists the contents of directories in alphabetical order, describing each file or directory with a brief description and its permissions, owner, size, and type. The options are:

  • -l : Display file permission bits as well as size for each item on screen; only display files if they're not empty (i.e., don't list hidden files). Also displays several links for files with hard links instead of just one link count total per item line. This option can be specified multiple times to get multiple lists if needed!

cd

cd is the command that you use to change your current working directory.

  • Change to the specified directory:

    • cd path/to/directory
  • Change to the parent directory:

    • cd ..(the parent of your current workingDirectory)
  • Change to home directory:

    • cd ~ (your home directory)

mkdir

The mkdir command creates a new directory. It can be used in any Linux shell, but it's especially useful for creating subdirectories and organizing files:

  • To create a new folder called test, enter this command: mkdir test

  • To create a subfolder within the current working directory called myprojects, enter this command: mkdir -p ~/myprojects

rmdir

The rmdir command is used to remove empty directories. For example, if you have a directory called "children" that is holding files from your kids and you want it gone, use the following command:

  • $ rmdir children

If there are no subdirectories under this directory named 'children', then it will not be removed. You can also clean up an entire tree of directories at once by using the -R option:

  • $ rmdir -R /home/user/public_html

cp

You can use the cp command to copy files, directories, and entire filesystems. You can even use it to copy a file to multiple locations at once.

For example, suppose you have two directories on your computer: /home/user1 and /home/user2. You want to copy your home directory from one system onto another system (say, from Windows 10/Windows 7/Linux Mint 17.3 into Ubuntu 19.04). To do this with cp command:

  • $ cp -rvF ~/user1 ~/user2/*

mv

The mv command is used to move files from one location to another. It can also be used to move directories, which is useful if you want to change the name of a directory or its contents. To use this command, type:

mv /path/to/oldfile /path/to:newfile

If you want to rename an existing file instead of moving it, use this syntax instead: mv oldfile new_name

rm

If you're just starting with Linux, or if you're looking for a way to quickly remove files in your home directory, this command is perfect. It's also helpful if you're trying to find out which files are used by other programs on your computer.

rm will remove any specified file (or directory) and any empty directories listed by its owner or group ID (and sometimes others). You can also use rm with multiple parameters:

  • To remove all files from a specific directory: rm -i /path/to/directory

less

Less is a pager that can be used to view text files, binary files, and compressed files, and search for text. It's more powerful than cat in many ways:

  • You can use it to view multiple pages at once so you don't have to keep typing that one command over and over again (like "cat file1 | grep -i 'word'").

  • You can also use less with pipe commands like "less | grep word" or "more | less".

cat

cat is a command that can be used to concatenate files. It's a simple, but powerful tool for viewing the contents of files and printing them out on your screen or another file.

cat stands for concatenate, which means it combines multiple files into one long string. This makes it easy to view multiple documents at once without having to open each one individually in a separate window or program window. You can also use cat without any parameters as an interactive command that allows you to enter commands after typing them into the terminal session (in other words: hitting Enter).

clear

You can use the clear command to clear the terminal screen and history. This is a built-in shell command, so you don't need to type it in yourself.

The syntax for clearing the terminal screen is:

clear

For example, if you type "clear" at any point on your Linux machine's command line, it will clear everything from that point forward—down to zero!

These commands should be used every day to make your life in Linux easier

If you've ever had to navigate a file system in Linux, then you'll know that it can be a pain. Some powerful commands simplify this process and make your life much easier!

  • ls: List directory contents

  • cd: Change directory (change the current working folder)

  • mkdir: Make a new directory (create a new folder)

  • rmdir: Remove directories and files from your system -- including those in other accounts

Conclusion

The above commands are some of the basic Linux commands everyone should know. They are very easy to remember and can be used in day-to-day life.