Here will start a new topic on Linux Fundamental – A Journey with Linux Series, as it is part 1 will go through the Basics of Linux and top Linux commands which can be helpful for newcomers in this journey.
Linux is an Operating System, which is a clone of Unix. Linux is actually developed by Linus Torvalds.
Linux is free and open-source, Which means you can make changes and keep your own distribution name.
There is several well-known Linux distribution are:
3. Kali Linux
7. Red Hat Enterprise
8. Arch Linux
Mostly we used Linux for servers, This is because Linux is more secure, Fast, and free. 90% of the smartphone runs Android which is also made from Linux kernels.
What are Linux shell and Terminal?
A Shell is a user interface for accessing the operating system ( OS ) and the user interacts with the shell using a command line interface ( CLI ).
A Terminal is a graphical window that can help you to interact with the shell.
ADVANTAGE OF LINUX
- One of the main advantages of Linux is that it is an open-source operating system i.e. its source code is easily available to everyone. Anyone capable of coding can contribute, modify, enhance, and distribute the code to anyone and for any purpose.
- Linux is more secure in comparison to other operating systems such as Windows. Linux is not completely secure as there is some malware for it also but it is less vulnerable than others.
- Linux provides high performance on various networks and workstations. It allows a large number of users to work simultaneously and handles them efficiently.
A different way to use Linux on systems
There are 3 ways to install Linux on our systems, they are:
- Single Boot: Install Linux as the main OS
- Dual Boot: Two or more OS simultaneously process on the same system
- Virtual Environment: Using Linux on virtual environment software like VirtualBox or VMWare.
Linux Top Commands
The Linux commands are the utility of the Linux operating system, All basic and advanced tasks can be executed on Linux by the commands.
The command is executed on the Linux Terminal and commands in Linux are Case Sensitive.
The following are the Basic Linux Commands:
- id: used to print genuine and effective current user ID and group ID.
2. sudo: Super User Do is the command to execute it into root privilege access.
3. pwd: used to display the location of the current working directory(folder).
4. mkdir: mkdir(make directory) used to create new directory
5. cd: change directory used to change from the current directory
Ops! As we already know that on Linux commands it’s case sensitive, here we should use “n” as upper case.
6. touch: used to create empty files.
7. ls: used to show the list of files and directories, in current or other directories.
Now will go through the above commands and have proper practice to make it in different ways.
Here have tried the “cd ../../” command to comeback two directories, If want to come back one directory we should try “cd ../“
8. mv: used to move a file or a directory from one location to another location.
I will check the newWorld directory, if this file has been moved into this or not rather than changing the directory from the current directory.
Yes, It existed in the directory.
9. cp: used to copy a file or a directory.
10. rm: used to remove a file.
11. rmdir: used to remove a directory
So, I’ve tried to remove another directory name as new2
But it failed to remove because the directory is not empty, we have to try another way as “rm -rf“.
Here “r” is recursive mode and “f” is force mode.
12. history: history keeps track of all executed commands.
history -c used to clear the history.
13. echo: used for displaying lines of text or string that are passed as arguments on the command line
If you to continue the text from the next line on the same file, you can use “>>” in the place of “>” which appends the text to the next one.
14. whoami: allows Linux users to see the currently logged-in user.
15. locate: will look for files on your Linux database
14. find: search for the specified files in all of your computer’s directories
As this file we got, now will try with another file.
So, here below output, you can be noticed that it was giving results as so much no file present. It means the file we search was not present there.
After moving to another directory and searching for the file, as we got in this directory that is how find command is helpful if you have more number of file and want to search.
If we want to search for a file in other directories so we can use “/” to start searching from the root directory of the file system, as shown below.
-type: which type of file
-name: name of the file
The error we got was permission denied to this current user due to we don’t have privilege permission on this directory to search for the file, so we can encounter this error into /dev/null.
In Linux, “
/dev/null" is a special device file that discards all data written to it and provides an endless stream of null bytes when read from. It is often used to redirect unwanted output from commands or scripts.
2> is used which indicates a file redirection to send the standard error into this special file, to know more about the file descriptors and relevant topics you can go through here.
16. updatedb: creates and updates the database of file names used by locate
As of now we’ve created a new file and searched the file by using locate
We didn’t get any recently created files, in this scenario we should always update the database to create and update for locate command.
After using updatedb, can search for the exact file with a path.
17. which: allows users to search the list of paths in the $PATH environment variable and outputs the full path of the command specified as an argument
18. man: to display the user manual of any command that we can run on the terminal.
19. alias: lets you create a shortcut name for a command, file name, or any shell text
As shown in the above screenshot, by using the alias command we’ll able to store the commands with the options in one word
Text Editor on Linux command line
- nano: Command line text editor
We’ll get the interface where we can write content.
For saving any contents on nano, enter Ctrl+O to save and enter the key to confirm the file name.
Press Ctrl+X to exit from nano.
2. cat: The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display the content of the file, copy the content of one file to another file, and more.
For writing the contents on file, can try this way by using the cat tool and saving the file by entering ctrl+c on the line which doesn’t want to save out.
3. vim: vim is a free and open-source, screen-based text editor program.
We’ll get the interface where can write content.
For writing, we should get the insert mode by entering the “i” key.
Once we’re done with the context, now will save it.
First, we have to get the command execution area for that press the “ESC” key after coming out of the insert mode.
Then write “w” to write out (save) and “q” for quite the vim interface.
I hope you’ve learned and enjoyed this Walkthrough.