Sunday, June 16, 2024

Install Virtual-box in Linux

 How to Install Virtual-Box in Linux?

Virtual Machine abstracts the hardware of our personal computers such as CPU, disk drives, memory, NIC (Network Interface Card), etc., into many different execution environments as per our requirements, hence giving us a feeling that each execution environment is a single computer. For example, VirtualBox. We can create a virtual machine for several reasons, all of which are fundamentally related to the ability to share the same basic hardware yet can also support different execution environments, i.e., different operating systems simultaneously.

There are Three ways to Install Virtual Box on our Debain-based Linux system.

1) Install VirtualBox from Ubuntu Repository

Open the terminal and run this command.

sudo apt install VirtualBox
sudo apt install VirtualBox

sudo apt install VirtualBox

To check if it is installed. 

We use the `dpkg` command which is used to manage installed packages on Debain-based system like Ubuntu.

dpkg -l | grep virtualbox
dpkg -l | grep virtualbox

dpkg -l | grep virtualbox

2) Install VirtualBox using GUI (Graphical User Interface)

Downloading and Installing VirtualBox

To download VirtualBox, go to the official site virtualbox.org and download the latest version for Linux. 

For example: We want to install VirtualBox for Ubuntu 

Step 1: Double Click on this

select Ubuntu 22.04

select Ubuntu 22.04

Step 2: Follow the numbering. 

First Right click and select ‘open with other application’, then follow the numbering.

Steps for installing Virtualbox

Steps for installing Virtualbox

Step 3: Click on Install

Click on Install

Click on Install

Step 4: Search Virtualbox and Double click on application.

Virtualbox application

Virtualbox application

VirtualBox application Opened.

VirtualBox in Ubuntu

VirtualBox in Ubuntu

3) Installing VirtualBox using Oracle’s repository

Step 1: Run this command in your terminal (adding key for the repository)

 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo gpg --dearmor -o /usr/share/keyrings/oracle-virtualbox-2016.gpg

Step 2: Run this command in your terminal (adding Oracal VirtualBox repository in the repository list)

 sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib"

Step 3: Update the package list.

sudo apt-get update

Step 4: Command for installation of virtualbox

sudo apt-get install virtualbox

Saturday, June 15, 2024

Linux

What is Linux Operating System

The Linux Operating System is a type of operating system that is similar to Unix, and it is built upon the Linux Kernel. The Linux Kernel is like the brain of the operating system because it manages how the computer interacts with its hardware and resources. It makes sure everything works smoothly and efficiently. But the Linux Kernel alone is not enough to make a complete operating system. To create a full and functional system, the Linux Kernel is combined with a collection of software packages and utilities, which are together called Linux distributions. These distributions make the Linux Operating System ready for users to run their applications and perform tasks on their computers securely and effectively. Linux distributions come in different flavors, each tailored to suit the specific needs and preferences of users.

What is Linux

Linux is a powerful and flexible family of operating systems that are free to use and share. It was created by a person named Linus Torvalds in 1991. What’s cool is that anyone can see how the system works because its source code is open for everyone to explore and modify. This openness encourages people from all over the world to work together and make Linux better and better. Since its beginning, Linux has grown into a stable and safe system used in many different things, like computers, smartphones, and big supercomputers. It’s known for being efficient, meaning it can do a lot of tasks quickly, and it’s also cost-effective, which means it doesn’t cost a lot to use. Lots of people love Linux, and they’re part of a big community where they share ideas and help each other out. As technology keeps moving forward, Linux will keep evolving and staying important in the world of computers.

Linux Distribution

Linux distribution is an operating system that is made up of a collection of software based on Linux kernel or you can say distribution contains the Linux kernel and supporting libraries and software. And you can get Linux based operating system by downloading one of the Linux distributions and these distributions are available for different types of devices like embedded devices, personal computers, etc. Around 600 + Linux Distributions are available and some of the popular Linux distributions are: 

  • MX Linux
  • Manjaro
  • Linux Mint
  • elementary
  • Ubuntu
  • Debian
  • Solus
  • Fedora
  • openSUSE
  • Deepin

_____________________________________________________________

Basic Linux Commands for day to day life

1. ls: How would we know what a folder contains? With a graphical interface, you’d do this by opening a folder and inspecting its contents. From the command line, you use the command ls instead to list a folder’s contents. 

ls

By default, ls will use a very compact output format. Many terminals show the files and subdirectories in different colors that represent different file types. Regular files don’t have special coloring applied to their names. Some file types, like JPEG or PNG images, or tar and ZIP files, are usually colored differently, and the same is true for programs that you can run and for directories. Try ls for yourself and compare the icons and emblems your graphical file manager uses with the colors that ls applies on the command line. If the output isn’t colored, you can call ls with the option –color: 

$ ls --color

2. man: You can learn about options and arguments to be used in any command in Linux. man(man is short for manual) is used to give a description of any Linux command like this: 

$ man ls

man ls

Here, the man is being asked to bring up the manual page for ls. You can use the arrow keys to scroll up and down in the screen that appears, and you can close it using the q key (for quit). 

3. info: An alternative to obtaining comprehensive user documentation for a given program is to invoke info instead of man: 

$ info ls

This is particularly effective to learn how to use complex GNU programs. You can also browse the info documentation inside the editor Emacs, which greatly improves its readability. But you should be ready to take your first step into the larger world of Emacs. You may do so by invoking: 

$ emacs -f info-standalone 

That should display the Info main menu inside Emacs (if this does not work, try invoking emacs without arguments and then type Alt + x info, i.e. by pressing the Alt key, then pressing the x key, then releasing both keys, and finally typing info followed by the Return or Enter key). If you type then m ls, the interactive Info documentation for ls will be loaded inside Emacs. In the standalone mode, the q key will quit the documentation, as usual with man and info. 

4. apropos: If you don’t know what something is or how to use it, the first place to look is its manual and information pages. If you don’t know the name of what you want to do, the apropos command can help. Let’s say you want to rename files, but you don’t know what command does that. Try apropos with some word that is related to what you want, like this: 

$ apropos rename
...
mv (1)               - move (rename) files
prename (1)          - renames multiple files 
rename (2)           - change the name or location of a file
...

apropos

Here, apropos searches the manual pages that man knows about and prints commands. On your computer, this command might (and probably will) display more information but it’s very likely to include the entries shown. 

5. mv: The mv command is used to move or rename files. 

$ mv oldname newname

Depending on your system configuration, you may not be warned when renaming a file will overwrite an existing file whose name happens to be a newname. So, as a safeguard, always use the `-i’ option when issuing mv like this: 

$ mv -i oldname newname

If the last argument happens to be an existing directory, mv will move the file to that directory instead of renaming it. Because of this, you can provide mv more than two arguments: 

$ mv first_file second_file third_file ~/stuff 

If ~/stuff exists, then mv will move the files there. If it doesn’t exist, it will produce an error message, like this:  

$ mv first_file second_file third_file ~/stuff 
mv: target 'stuff' is not a directory

6. mkdir: mkdir command is used to create a subdirectory in your current working directory type. 

$ mkdir practice

To see the directory practice you have just created, type ls. If you wish to create a subdirectory (say the directory bar) inside another directory (say the directory foo) but you are not sure whether this one exists or not, you can ensure to create the subdirectory and (if needed) its parent directory without raising errors by typing:  

$ mkdir -p ~/foo/bar  

This will work even for nested sub-sub-…-directories. 

7. cd: The command cd directory means change the current working directory to ‘directory’. The current working directory may be thought of as the directory you are in, i.e. your current position in the file-system tree. 
To change to the directory you have just made, type:  

$ cd practice

Now, if you go back to your home directory, type  

$ cd ..

Note: There is a space between cd and the dot 

8. rmdir: Now, that you are in the home directory and try to remove the directory called practice, rmdir will produce an error message: 

$ cd ..
$ rmdir practice
rmdir: failed to remove 'practice': Directory not empty

If the directory you wish to remove is not empty, rmdir will produce an error message and will not remove it. If you want to remove a directory that contains files, you have to empty it. 

9. rm: rm removes each specified file like this: 

$ rm practice/fstab practice/hosts practice/issue practice/mod

And now you can try removing the directory again:  

$ rmdir practice

And now it works, without showing any output. But what happens if your directories have directories inside that also have files, you could be there for weeks making sure each folder is empty! The rm command solves this problem through the amazing option -R, which as usual stands for “recursive”. In the following example, the command fails because foo is not a plain file:  

$ rm ~/foo/ 
rm: cannot remove `~/foo/`: Is a directory

So maybe you try rmdir, but that fails because foo has something else under it: 

$ rmdir ~/foo
rmdir: ~/foo: Directory not empty

So you use rm -R, which succeeds and does not produce a message. 

$ rm -R ~/foo/

So when you have a big directory, you don’t have to go and empty every subdirectory. But be warned that -R is a very powerful argument and you may lose data you wanted to keep! 

10. cat: You don’t need an editor to view the contents of a file. What you need is just to display it. The cat program fits the bill here: 

$ cat myspeech.txt
Friends, Coders, Linux-lovers! This is an article in GeeksForGeeks.

11. less: Here, the cat just opens the file myspeech.txt and prints the entire file to your screen, as fast as it can. However, if the file is really long, the contents will go by very quickly, and when cat is done, all you will see are the last few lines of the file. To just view the contents of a long file (or any text file) you can use the less program: 

$ less myspeech.txt

Just as with using man, use the arrow keys to navigate, and press q to quit. 

12. pwd: When have to work with the multiple directories on the Linux system and we go on moving from one directory to another, then to check out our current working directory this pwd command is very useful. On executing the pwd command on the terminal the absolute path of the current working directory is printed on the terminal window.

$ pwd

13. cal: This is a very useful command in the Linux systems to view the calendar of any particular month or whole year on the Linux terminal window.

$ cal # prints calendar of current month
$ cal 2021 # prints calendar of whole year (2021)

1.

2.

14. date: This command is frequently used to print the current day, date, time, and time zone on the terminal window. By default, the time zone is the one on which the Linux system is configured.

$ date

Basic Shell Commands in Linux


shell is a special user program that provides an interface to the user to use operating system services. Shell accepts human-readable commands from the user and converts them into something which the kernel can understand. It is a command language interpreter that executes commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or starts the terminal. 

1). Displaying the file contents on the terminal: 

  • cat: It is generally used to concatenate the files. It gives the output on the standard output.
  • more: It is a filter for paging through text one screenful at a time.

  • less: It is used to viewing the files instead of opening the file.Similar to more command but it allows backward as well as forward movement.

  • head : Used to print the first N lines of a file. It accepts N as input and the default value of N is 10.
  • tail : Used to print the last N-1 lines of a file. It accepts N as input and the default value of N is 10.

2). File and Directory Manipulation Commands: 

  • mkdir : Used to create a directory if not already exist. It accepts the directory name as an input parameter.

  • cp : This command will copy the files and directories from the source path to the destination path. It can copy a file/directory with the new name to the destination path. It accepts the source file/directory and destination file/directory.

  • mv : Used to move the files or directories. This command’s working is almost similar to cp command but it deletes a copy of the file or directory from the source path.

  • rm : Used to remove files or directories.

  • touch : Used to create or update a file.

3). Extract, sort, and filter data Commands: 

  • grep : This command is used to search for the specified text in a file.

  • grep with Regular Expressions: Used to search for text using specific regular expressions in file.

  • sort : This command is used to sort the contents of files.

  • wc : Used to count the number of characters, words in a file.

  • cut : Used to cut a specified part of a file.

4). Basic Terminal Navigation Commands: 

  • ls : To get the list of all the files or folders.
  • ls -l: Optional flags are added to ls to modify default behavior, listing contents in extended form -l is used for “long” output
  • ls -a: Lists of all files including the hidden files, add -a  flag 
  • cd: Used to change the directory.
  • du: Show disk usage.
  • pwd: Show the present working directory.
  • man: Used to show the manual of any command present in Linux.
  • rmdir: It is used to delete a directory if it is empty.
  • ln file1 file2: Creates a physical link.
  • ln -s file1 file2: Creates a symbolic link.
  • locate: It is used to locate a file in Linux System
  • echo:  This command helps us move some data, usually text into a file.
  • df: It is used to see the available disk space in each of the partitions in your system.
  • tar: Used to work with tarballs (or files compressed in a tarball archive)

5). File Permissions Commands: The chmod and chown commands are used to control access to files in UNIX and Linux systems. 

  • chown : Used to change the owner of the file.
  • chgrp : Used to change the group owner of the file.
  • chmod : Used to modify the access/permission of a user.