Basics and History of Linux

Basics and History of Linux

Day 2&3 of 90daysofchallenge, In this blog I briefly covered Linux.

ยท

6 min read

What is Linux

Linux is, a computer operating system created in the early 1990s by Linus Torvalds.

Linux is an open-source OS based on UNIX and developed in C. Linux is one of the best and most widely used operating systems that support all kinds of programming languages.

Features and advantages of Linux

  1. Open Source

  2. Secure

  3. Simplified updates of all Installed software lightweight

  4. Multiuser-Multitask

  5. Multiple distributions- Redhat, Debian, Fedora

The architecture of Linux

Basic Linux Tutorial for Begineers in details | What is linux and  Architecture of linux

  1. Hardware: The Hardware of the OS constitutes RAM, CPU, HDD, and other physical components required to run the OS.

  2. Kernel: It is the core component of the OS. It is involved with resource allocation, security management, process management, device management, etc.

  3. Shell: Shell acts as the interface to the kernel. It takes the user commands from the application and executes them in the kernel function.

  4. Application: It handles the main programs of the architecture. This is the layer where users interact with OS.

File system hierarchy in Linux

Linux File System Hierarchy โ€“ nepalisupport

/home --> Home directory for other users.

/root --> It is home directory for root user.

/boot --> It contains bootable files for linux eg:- inited

/etc --> It contains all configuration files.

/usr --> by default software are installed in this directory.

/bin --> It contains commands used by all users.

/sbin --> It contains commands used by only root user.

/opt --> Optional application software package.

/dev --> Essential device files. This include terminal devices, usb or any device attached to the system.

Basic Commands of Linux OS

Linux users use CLI (Command Line Interface) to communicate with the OS:

In this blog, we are going to discuss basic commands like listing commands and directory commands used in Linux.

ls option_flag arguments --> list the sub-directories and files available in the present directory

Examples:

  • ls -l--> list the files and directories in a long list format with extra information

  • ls -a --> list all including hidden files and directory

  • ls *.sh --> list all the files having .sh extension.

  • ls -i --> list the files and directories with index numbers in inodes

  • ls -d */ --> list only directories.(we can also specify a pattern)

Directory commands

  • pwd --> print work directory. Gives the present working directory.

  • cd path_to_directory --> change the directory to the provided path

  • cd ~ or just cd --> change the directory to the home directory

  • cd - --> Go to the last working directory.

  • cd .. --> change the directory to one step back.

  • cd ../.. --> Change directory to 2 levels back.

  • mkdir directoryName --> to make a directory in a specific location

Examples:

mkdir newFolder              # make a new folder 'newFolder'

mkdir .NewFolder              # make a hidden directory (also . before a file to make it hidden)

mkdir A B C D                  #make multiple directories at the same time

mkdir /home/user/Mydirectory   # make a new folder in a specific location

mkdir -p  A/B/C/D              # make a nested directory

Some more basic commands

echo

echo <text>

This command helps in providing the standard output.

clear

clear

This command helps in clearing the terminal screen. It just scrolls down and does not delete any history.

File Commands

cp

 cp <flag> {filename} /pathname/

This command helps in copying the files and directories. Some of the cp commands with flags are

cp -i #This command is used to get into interactive mode. CLI asks permission before overwriting.
cp -n #This command does not overwrite
cp -u #This command updates only when destination file is different from source file.
cp -r #This command helps in creating recursive copy for copying dir, also copies hidden files.
cp -v #This command behaves as a verbose. It prints informative messages.

mv

 mv <flag> {filename} /pathname/

This command helps in moving files/directories. Once the files are moved, they are deleted from the working directory.

rm

 rm <flag> {filename}

This removes files from a directory.

rm -r #This command removes non-empty directories.
rm -rp #This command removes non-empty firectories including parent and subdirectories.

grep

grep <flag> {filename}

grep command is used to search a particular string/word in a text file.

grep -i #This command returns the results for case insensitive strings.
grep -n #This command returns matching strings along with their line number.
grep -v #This command returns the results of lines not matching the search string.
grep -c #This command returns number of lines in which results have matched the search string.

cat

cat <flag> {filename}

The cat command is used to read, modify or concatenate text files. This command helps in displaying file contents.

Tasks for today

What is the Linux command to view what's written in a file?
The command used for viewing what's written in a file is the cat command. Syntax: cat <filename>
What is the Linux command to change the access permissions of files?
The chmod command is used to change the access of files and permissions. To change all the read, write and execute permissions 777 is used. Syntax: chmod 777 <foldername>
What is the Linux command to check which commands you have run till now?
The history command is used to display the history of the commands executed by the user. Syntax: history
What is the Linux command to remove a directory/file?
The rm command is used to remove a directory/file. Syntax: rm <filename> #For file, rmdir <foldername> #For Directory
What is the Linux command to create a fruits.txt file and view the content?
To create a fruits.txt file: touch fruits.txt To view the content: cat fruits.txt
Which Linux command to add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
Using a text editor open the file: vi devops.txt Later add the items one item per line in the editor: Apple Mango Cherry Kiwi Orange Guava Then save and exit the editor using the below command: :wq
Which Linux command is used to show only the top three fruits from the file?
The head command is used to show only the top three fruits from the file: Syntax: head -n 3 devops.txt -n is the flag used to print first those specified number of lines. The output of the command will be: Apple Mango Cherry
Which Linux command is used to show only the bottom three fruits from the file?
The tail command is used to show only the top three fruits from the file: Syntax: tail -n 3 devops.txt -n is the flag used to print first those specified number of lines. The output of the command will be: Kiwi Orange Guava
Which Linux command is used to create another file colors.txt and to view the content?
To create a new file: touch colors.txt To view the content: cat colors.txt
Which Linux command is used to add content in colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, or Grey?
Using a text editor open the file: vi colors.txt Later add the items one item per line in the editor: Red Pink White Black Blue Orange Purple Grey Then save and exit the editor using the below command-> :wq

See you in the next blog.๐Ÿ˜โœŒ๏ธ

ย