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,A few of them are:
- 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. Forgot to mention, the OS that runs in about 80% of the Smartphones in the World, Android, is also made from the Linux Kernel. Yes, Linux is amazing! A simple example of its security is that most of the viruses in the world run on Windows, but not on Linux!
Linux Shell or “Terminal”
So, basically, 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.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.
We can open the terminal by Ctrl+Alt+T in Ubuntu, or by pressing Alt+F2 and then typing in gnome-terminal and press Enter.
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
The “Is” command is used to know what files are there in the directory you are in. You can see all the hidden files by using the command “ls -a”.
3. cd
“cd” is the command used 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. But there is a problem with these commands. Imagine you have a folder named “Raspberry Pi”. In this case, when you type in “cd Films Jo”, the shell will take the second argument of the command as a different one, so you will get an error saying that the directory does not exist. Here, you can use a backward slash. That is, you can use “cd Films \ Jo” in this case. Spaces are denoted like this: If you just type “cd” and press Enter, it takes 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 & rmdir
The mkdir command is used when you need to create a folder or a directory. For Example, if you want to make a directory called “Home”, then you can type “mkdir Home”. Remember, as told before, if you want to create a directory named “Home Sub”, then you can type “mkdir Home \ Sub”.
rmdir is the command used for deleting a directory. But, rmdir can only be used to delete an empty directory. To delete a directory containing files, rm is used.
5. rm
The rm command is used to delete files and directories. rm cannot simply delete a directory. “rm -r” is used to delete a directory. In this case, it deletes both the folder and the files in it.
6. 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”
7. man & –help
To know more about a command and on how to use it, the man command is used. 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 (Example – cd –help).
8. cp
The cp command is used to copy files through the command line. It takes two arguments, the first one is location of the file to be copied, the second iswhere to copy.
9. mv
The mv command is used 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.
10. locate
The locate command is used to locate a file in a Linux System, just like the search command in Windows. This command is useful when you don’t know where a file is saved or the actual name of the file. Using the –i argument with the command, helps to ignore the case (it doesn’t matter if it is Capital or Small). So, if you want a file that has the word “hello”, it gives the list of all the files in your Linux System containing the word “hello” when you type in “locate -i hello”. If you remember two words, you can separate it using asterisk (*). For example, to locate a file containing the words “hello” and “this”, you can use the command “locate –i *hello*this ”