Getting Started with Linux & Terminal Commands

Play this article


Linux is a free, open-source, Unix-like operating system's kernel. It was created by Linux Torvalds in 1991. The kernel sits between applications and hardware and makes the connections between all of your software and the physical resources that do multiple processes. I personally prefer 'Arch Linux' but there are several Linux Distributions, commonly called 'distros'.

  • Ubuntu
  • Fedora
  • Arch Linux
  • Manjaro
  • Pop!_OS


Linux Emulator: A terminal emulator is a program that helps us to use the Linux command-line in a graphical environment. Linux command line is often referred to as shell, terminal, console, prompt and so on.

Here are some commonly used terminal emulators by the operating systems.

  • Windows: PuTTY
  • Linux: Gnome Terminal, KDE Konsole, XTerm, Terminator, Guake
  • Mac OS: Terminal (Default), iTerm 2

Linux Commands

  • ls will list all the contents of the current directory.
    $ ls
  • ls -a will enlist the whole list of the current directory including the hidden files.
    $ ls -a
  • ls -R lists all the files of current and the subdirectories also.

    $ ls -R
  • mkdir <folder_name> is used to create a new directory.

    $ mkdir new_folder
  • cd is used to change the current working directory.

    $ cd <directory_name>
  • cd .. is used to move to the parent directory of the current directory. . means current and .. means the previous directory.

    $ cd ..
  • pwd stands for print working directory. the command prints the complete path of the current working directory.

    $ pwd


  • cat > file_name.extension will create a new file and it allows us to write some texts into a file.

    $ cat > file.txt
    add some text here and exit by pressing ctrl+shift+c
  • cat is also used to print the content of a file onto the standard output stream.

    $ cat <file_name>


  • The following command will merge all the contents of both file1.txt and file2.txt in file3.txt.
    $ cat file1.txt file2.txt > file3.txt
  • echo is used to display lines of text/string that is passed as an argument. echo.png

  • echo also overrides new text/string in a file. echo2.png

  • man is used to display the user manual of any command that we can run on the terminal.

    $ man echo


  • cp command is used to create a copy of the file.

    $ cp file1.txt newfile.txt
  • mv is used to move files

    $ mv file.txt <path>


  • rm is used to remove files or directories

    $ rm file.txt

    rm -r removes directories and their contents recursively. rm -rf removes directories and their contents forcefully. rm -d removes empty directories only.

  • sudo stands for SuperUser DO and is used to access restricted files and operations. sudo was developed to temporarily grant a user administrative rights without login as a root user.

    $ sudo [command]
  • df is a standard Unix command used to display the amount of available disk space of the file systems. df.png

  • Using ' -h ' parameter with df -h will show the file system disk space stats in “human-readable” format. df -h.png

  • head prints the first 10 lines of the specified files.

    $ head file.txt
  • By default, tail prints the last 10 lines of the specified files.
    $ tail file.txt
  • grep searches a file for a particular pattern/ string and displays all lines that contain that pattern.
    $ grep [options] [pattern/string] [filename]
    Options for grep

-c : Prints only a count of the lines that match a pattern.

-h : Display the matched lines, but do not display the filenames.

-i : Ignores, the case for matching.

-l : Displays list of filenames only.

-n : Display the matched lines and their line numbers.

-v : This prints out all the lines that do not match the pattern.

-w : Match whole word.

-o : Print only the matched parts of a matching line.

  • history is used to view the previously executed command in the terminal.

    $ history
  • history | grep '<keyword>' will show all the previously executed commands with the specified keyword. historygrep.png

  • wget will download the resource specified in the [url] to the current directory. bash $ wget [URL] If you want download files in different name, that add -O parameter like wget -O [file_name] [URL].

  • top command will show all the current Linux processes.

    $ top


  • If you know any process Id and want to stop that process, you can kill it by using the command.

    $ kill [PID]
  • uname prints the name of the kernel.

    $ uname

    More commands using uname uname.png

  • zip is a command that helps you to create Zip archives.

    $ zip [archive_name] [file_name]
  • Similarly, unzip helps you to unzip archives.

    $ unzip
  • nslookup (Name Server Lookup) is a useful command for getting information from the DNS server. nslookup.png

  • ps aux command is a tool to monitor processes running on your Linux system.

    $ ps aux
  • ping [URL] (Packet Internet Groper) command is used to check the network connectivity between host and server.

    $ ping