Skip to main content

Basic Linux Commands for Beginners

What Is Linux?

Linux is an operating system's kernel. You might have heard of UNIX. Well, Linux is a UNIX clone. But it was actually created by Linus Torvalds from Scratch. Linux is free and open-source, that means that you can simply change anything in Linux and redistribute it in your own name! There are several Linux Distributions, commonly called “distros”.
·         Ubuntu Linux
·         Red Hat Enterprise Linux
·         Linux Mint
·         Debian
·         Fedora
Linux is Mainly used in servers. About 90% of the internet is powered by Linux servers. This is because Linux is fast, secure, and free! The main problem of using Windows servers are their cost. This is solved by using Linux servers. The OS that runs in about 80% of the smartphones in the world, Android, is also made from the Linux kernel. Most of the viruses in the world run on Windows, but not on Linux!
Linux Shell or “Terminal”

So, basically, a shell is a program that receives commands from the user and gives it to the OS to process, and it shows the output. Linux's shell is its main part. Its distros come in GUI (graphical user interface), but basically, Linux has a CLI (command line interface). In this tutorial, we are going to cover the basic commands that we use in the shell of Linux.
To open the terminal, press Ctrl+Alt+T in Ubuntu, or press Alt+F2, type in gnome-terminal, and press enter. In Raspberry Pi, type in lxterminal. There is also a GUI way of taking it, but this is better!
Linux Commands

Basic Commands
1. pwd — When you first open the terminal, you are in the home directory of your user. To know which directory you are in, you can use the “pwd” command. It gives us the absolute path, which means the path that starts from the root. The root is the base of the Linux file system. It is denoted by a forward slash( / ). The user directory is usually something like "/home/username".

2. ls — Use the "Is" command to know what files are in the directory you are in. You can see all the hidden files by using the command “ls -a”.

3. cd — Use the "cd" command to go to a directory. For example, if you are in the home folder, and you want to go to the downloads folder, then you can type in “cd Downloads”. Remember, this command is case sensitive, and you have to type in the name of the folder exactly as it is. you to the home directory. To go back from a folder to the folder before that, you can type “cd ..” . The two dots represent back.

4. mkdir — Use the mkdir command when you need to create a folder or a directory. For example, if you want to make a directory called “new”, then you can type “mkdir new”.

    rmdir — Use rmdir to delete a directory. But rmdir can only be used to delete an empty directory. To delete a directory containing files, use rm.

5. touch — The touch command is used to create a file. It can be anything, from an empty txt file to an empty zip file. For example, “touch new.txt”.

6. man & --help — To know more about a command and how to use it, use the mancommand. It shows the manual pages of the command. For example, “man cd” shows the manual pages of the cd command. Typing in the command name and the argument helps it show which ways the command can be used (e.g., cd –help).

7. cp — Use the cp command 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.

8. mv — Use the mv command to move files through the command line. We can also use the mv command to rename a file. For example, if we want to rename the file “text” to “new”, we can use “mv text new”. It takes the two arguments, just like the cp command.

Intermediate Commands
1. echo — The "echo" command helps us move some data, usually text into a file. For example, if you want to create a new text file or add to an already made text file, you just need to type in, “echo hello, my name is alok >> new.txt”. You do not need to separate the spaces by using the backward slash here, because we put in two triangular brackets when we finish what we need to write.
2. cat — Use the cat command to display the contents of a file. It is usually used to easily view programs.

3. nano, vi, jed — nano and vi are already installed text editors in the Linux command line. The nano command is a good text editor that denotes keywords with color and can recognize most languages. And vi is simpler than nano. You can create a new file or modify a file using this editor.
4. sudo — A widely used command in the Linux command line, sudo stands for "SuperUser Do". So, if you want any command to be done with administrative or root privileges, you can use the sudo command. You can also use the command “su” to do this, but you need to set a root password before that. For that, you can use the command “sudo passwd”(not misspelled, it is passwd). Then type in the new root password.

5. df — Use the df command to see the available disk space in each of the partitions in your system. You can just type in df in the command line and you can see each mounted partition and their used/available space in % and in KBs. If you want it shown in megabytes, you use the command “df -m”.

6. tar — Use tar to work with tarballs (or files compressed in a tarball archive) in the Linux command line. It has a long list of uses. It can be used to compress and uncompress different types of tar archives like .tar, .tar.gz, .tar.bz2,etc. It works on the basis of the arguments given to it. For example, "tar -cvf" for creating a .tar archive, -xvfto untar a tar archive, -tvf to list the contents of the archive, etc. Since it is a wide topic, here are some examples of tar commands.
7. zip, unzip — Use zip to compress files into a zip archive, and unzip to extract files from a zip archive.
8. uname — Use uname to show the information about the system your Linux distro is running. Using the command “uname -a” prints most of the information about the system. This prints the kernel release date, version, processor type, etc.

9. apt-get — Use apt to work with packages in the Linux command line. Use apt-get to install packages. This requires root privileges, so use the sudo command with it.

10. hostname — Use hostname to know your name in your host or network. Basically, it displays your hostname and IP address. Just typing “hostname” gives the output. Typing in “hostname -I” gives you your IP address in your network.


13. ping — Use ping to check your connection to a server. Wikipedia says, "Ping is a computer network administration software utility used to test the reachability of a host on an Internet Protocol (IP) network". Simply, when you type in, for example, “ping google.com”.
Tips and Tricks for Using Linux Command Line
       You can use the clear command to clear the terminal if it gets filled up with too many commands.TAB can be used to fill up in terminal. For example, You just need to type “cd Doc” and then TAB and the terminal fills the rest up and makes it “cd Documents”.Ctrl+C can be used to stop any command in terminal safely. If it doesn't stop with that, then Ctrl+Z can be used to force stop it.You can exit from the terminal by using the exit command.You can power off or reboot the computer by using the command sudo halt and sudo reboot.

Comments

Popular posts from this blog

Basics of SQL - Every Hacker need to know

The key to becoming a competent white hat is knowing how the technology that you are trying to exploit actually works. SQL injection is one of the most common methods of attack used today and also one of the easiest to learn. What Is SQL Injection? SQL, which stands for structured query language, is a standard language used for retrieving and manipulating data in a relational database management system (RDBMS). Data is accessed through the use of queries, which allow information to be created, read, updated, and deleted (you will often see web applications referred to as CRUD apps for this reason). Databases can be used in a variety of situations, but one of the most common configurations is a database serving as the backend to a web application. When certain actions are performed, such as logging in or searching, queries are sent from the web app to the database i njection is allowed to occur when input fields are not properly sanitized or escaped. An attacker can enter malic

A Complete Guide to BlockChain Development

In 2016, tech and finance companies alone invested $1 billion in blockchain.  Blockchain has rapidly progressed from an esoteric technology to the forefront of R&D for major financial institutions, governments, universities and multinational corporations. This guide is designed for founders, entrepreneurs, product managers, innovators and developers looking to learn how blockchain development works, how to incorporate blockchain into their businesses and what’s needed to start a blockchain project right now. Introducing the Blockchain As techies and innovators at heart, we could go on for days about blockchain. Regardless, the technology produces some powerful benefits: Decentralization  by removing single points of failure Trust  through mass consensus Transparency  with public transactions Security  through immutability What Is “The Blockchain”? Blockchain simply refers to a type of database — one that’s massive, decentralized, transparent and immutable. It’

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04

Introduction A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the  L inux operating system, with the  A pache web server. The site data is stored in a  M ySQL database, and dynamic content is processed by  P HP. In this guide, we will install a LAMP stack on an Ubuntu 18.04 server. Prerequisites In order to complete this tutorial, you will need to have an Ubuntu 18.04 server with a non-root  sudo -enabled user account and a basic firewall. This can be configured using our initial server setup guide for Ubuntu 18.04. Step 1 — Installing Apache and Updating the Firewall The Apache web server is among the most popular web servers in the world. It's well-documented and has been in wide use for much of the history of the web, which makes it a great default choice for hosting a website. Install Apache using Ubuntu&