Basic Linux Commands

Basic Linux Commands

·

3 min read

What is Linux?

Symbol-Linux.jpeg

Linux itself is a kernel, which was written in the C programming language and developed by Linus Torvalds. It is open source software, which means that anyone can download the underlying source code, modify it and use it. Many companies have modified the source code and added additional features and tools to make it a complete operating system. For example, RedHat Software company.

There are several Linux Distributions, commonly called “distros”.

  • Ubuntu Linux
  • Red Hat Enterprise Linux
  • Arch Linux
  • Debian
  • Fedora

Linux Shell or “Terminal”

Shell is a text-based command interpreter. It can be used in interactive mode or to execute programs written in the programming language (called Shell scripts). In interactive mode, the Shell displays a prompt at the beginning of the line (prompt). The command is interpreted and executed after hitting the "Enter" key.

What are command in Linux? A command line is an interface that accepts lines of text and processes them into instructions for your computer.

Command Structure

Linux commands share the following form:

command option(s) argument(s)

For Example:

head -n 20 /etc/passwd

where:

Command -> head

Option -> -n 20

Argument -> /etc/passwd

  • Linux is case sensitive; be sure to type each character of a command in the proper case.
  • Most commands come with certain options, which modify how the command is run.
  • An argument is some information you pass to the command when it is started.
  • Options and arguments are sometimes not mandatory.

Basic Commands

1. pwd - For inexperienced Linux users who could get lost in the middle of folders, the pwd command is useful. It gives us the absolute path, which means the path that starts from the root (/).

1.png

2. cd - Change Directory (cd) command used for navigating through the Linux directories. For Example, We are in "/home/rabie/" and we want to go to Downloads directory. We will just type cd Downloads

2.png

As you can see, the directory has been switched to Downloads, and if we run the previous command, we can see that we are in the right place.

3. ls - To find out what files are in the directory you are in.

3.png

4. mkdir - To create an empty directory.

mkdir.png

We have created the "Linux_Commands" directory using the mkdir command and if we check with the previous command, we can see that the directory has been created.

5. rm - To delete files. "rm -r" will delete both the folder and the files it contains.

We have here this file "rm_cmd.txt"

5.png

We will use rm command to delete this file.

rm.png

In order to delete a non empty directory, we will use rm with r option.

rm-r.png

6. cp - To copy files through the command line. It takes two arguments: The first is the location of the file to be copied, the second is where to copy.

copy.png

7. mv - To move files through the command line. We can also use the mv command to rename a file.

Example1: Moving "Scripts" directory to Desktop

mv.png

Example2: Rename "file1" to "new"

rename.png

8. man & --help - To know more about any command we can use man and then our command as argument or we can use --help option for any command.

Example1: man ls

man.png

Example2: ls --help

ls -h.png

as you can see, in both man command and --help option we are able to see the formal documentation for any executable program.

There are so many other commands, I have chosen only the most used ones in this article.

Did you find this article valuable?

Support Rabie Bml by becoming a sponsor. Any amount is appreciated!