LINUX: Zero to Expert
top of page

LINUX: Zero to Expert

In this series of tutorials, you are going to learn the Linux commands and how to use them with practical hands-on using commands. We assure you after going through all the lessons on Linux you will be comfortable with the Linux Operating System you can rate yourself from Zero to Expert. So, let's get started without wasting time.



LINUX
LINUX

Part 1: Setting Up

If you have already working with the Linux environment no need to install the additional software on your machine. You are ready to go by just writing the commands.


Step1: Download Virtual Box (It is Open Source/Free Available). Click Here to Download


Step2: Download the Ubuntu Mate as per your machine specification. Click Here to Download


Step3: Run the Virtual Box .exe File and Run it as administrator.


Step4: Once the virtual box is installed, insert the Ubuntu_Mate.iso file that we have downloaded in the second step.


Step5: Open the terminal and you are ready to go.



Part 2: Getting Started


Basic Command and Working with Directories.

Date- $date

Calendar- $cal

Get from Web- $wget htttps://www.nationin.com

Unzip the download file- $unzip

List the directory- $ls

List the directory recursively- $ls -R

Change the directory- $cd

To clear the Screen- $clear

Create new directory- $mkdir

Create multiple directories in single command- $mkdir -p D1/D2/D3

Present working directory- $pwd

Parent directory- $cd ..

Current directory- $cd .


Working with Files

To view the content of the file in the terminal- $cat file.txt

To count the number of words in the file- $wc file.txt

Command to know the description of each command: $whatis wc

Command to know the detailed description of command: $man wc

File sorting or file matching: $ls Directory_name/*.csv


History and Fast Tracking Commands

To view the past command: $Up Arrow (^)

To view the command history: $history

Press $Ctrl+R and search the keyword.


Tracking Commands
Tracking Commands

Part 3: Inter-process Communication


Pipes and Chaining Commands

Command to count the number of words, lines, and sizes: $wc iris.csv (here iris.csv is the dataset)


To print the first ten lines of the dataset: $head iris.csv


We want to cat the iris.csv file and pass it to wc to count the number of lines of iris.csv files: $cat iris.csv | wc ( Here "|" known as pipe symbol is the medium between two commands).


Find the "setosa" keyword from iris.csv file using grep and pass it to the wc: $grep "setosa" iris.csv


In the iris.csv file find the setosa keyword and pass it to the wc command: $cat iris.csv | grep "setosa" | wc


Redirecting Output to the Files.

Output to the console, whatever you write the text on terminal: $echo "Nation Innovation"


Redirecting(>) the console output to the file : $echo "Nation Innovation" > temp


Sorting the keyword "setosa" using grep from the iris.csv file and displaying to the console and directed the sorted data to the setosat.csv


$cat iris.csv | grep "setosa" > setosat.csv


Rename, Remove, Move and Copy.

Command to rename a file1.csv to file2.csv : $mv file1.csv file2.csv


Command to copy file file1.csv and save with name file2.csv: $cp file1.csv file2.csv


Move the file1.csv to the backup directory and rename it as file2.csv: $mv file1.csv backup/file2.csv


Remove the file: $rm filename.csv

To copy the directory: $cp -r dir1 dir2

Remove the directory: $rm -r dir


Part 4:Disc Usage & Working with multiple files

Disc Usage and Folder Sizes

$df: output the usage of the folder in your drive.

$df -h: Human readable usage.

$du: We can analyze which folder is taking more space.

$du -h: We can analyze which folder takes more space (Human Understandable).

$du -sh: It represents that the present directory takes up how much space.

$du -sh*: It summarizes all the folders in the present working directory.


Keyboard Shortcuts:

Use the Tab: It covers all the ambiguous letters.

Clear Screen : $Ctrl+L or $clear

To yank the current command before the cursor: $Ctrl+U and this command will not go permanently using the $Ctrl+Y we can get the yanked control.

To remove the command after the cursor: $Ctrl+K

To take the cursor to the right to the beginning of the command: $Ctrl+A

To take the cursor the end of the command: $Ctrl+E


Finding Files with Powerful Criteria:

To Find the file: $find. -type "*.csv" (Here . represent the present directory)

To Find the file of size greater than 100k: $find. -type f -size +100k

To Find all the files in the Home directory having a size greater than 100M: $find /home/nam -type f -size +100M

To get more details about the find command: $man find

Command to get more info about the particular file: $ls -l lesson-04/housing-data

Command to get more info about the particular file in human-readable format: $ls -lh lesson-04/housing-data


Tailing Files (Power of Debugging):

$tail file_name.csv: Here tail output the last ten lines as similar to the $head command.

$tail -f file_name.txt: This tail command will keep tailing the file or keep following the file and whenever some content is put into the file it will output it here.


Part 5:Process Listings & Basics of Networking

Process Listings:

$ps u: List the process of the current user.

$ps au: List the process of all users.

$ps aux | grep firefox: To sort the lines which have firefox.

$kill -9 <job_id>: Kill word is used to send the signal, -9 is to terminate the process immediately and 1364 is the process id of firefox.

$killall firefox: Kill all the processes of firefox.

Basics of Networking:

$ifconfig: To check the interfaces we have and IP Addresses.

$nslookup nationin.com: To Debug network connecting problem or check DNS server is working ( Here ns stands for "name server").

$ping nationin.com: Continuously ping the yahoo.com while in windows need to switch to continuously ping the server.

$netstat -ntlp : Network statics, it will represent all the connections in my machine in listening mode. ( n means 'numeric address', t means 'tcp', l means show listening sockets only, and p shows all the processes with listening on different ports).

$netstat -ntlp | grep 22: It shows the netstat which has only 22 IP addresses.


Case Study: How to download Playlist from Youtube using the command line?

Step1: Use the package manager for ubuntu to install the package manager for python and within the python package manager 'pip' we are going to install the 'youtube dl'

$sudo apt install python3-pip -y

$sudo pip install youtube-dl

Step 2: You have to follow step 1 only one time. Now use the youtube-dl and playlist URL to download the youtube playlist.

$youtube-dl 'https://www.youtube.com/watch?v=DUwlGduupRI'

Part 6: Getting started with Vi Editor, Moving Around, and Operations.


Getting started with Vi Editor.

$sudo apt install vim: To install the vim updates.

$vi filename: To open the file with vi editors, to quit the file use ':q!' to save the file with changes use 'wq!'

To open the file using vi editor and to make the changes you have to go to the insert mode. Use Key 'i' to go to the insert mode and use 'Esc' to go back to command mode and then save your changes.


Moving Around across File content:

$set number: To set the line numbers

$line_number: To go to any line number.

$Ctrl+G: To go to the end of the file.

$:/nationin: To search the keyword "nationin" across the file content. Use key "N" to go the next instant with the word nationin.

Use key 'F' followed by the keyword you are seeking for. Now the pointer will move to the specific letter.

To go to the beginning of the line use a simple key "0". To go to the first line use key ":0"


Delete, Undo, Copy and Paste:

$vi": To select the particular words (v is visual, I mean inside, and " means inside ") and press key "x" to delete the selected word.

$dw: To delete the particular word.

$dd: To delete a complete line.

$d3d: To delete three lines.

$u: To undo.

$p: To paste copy or cut line.

$yy: To copy a line.


Part 7:Ownership and Permission and Introduction to Remote Connections.


Ownership and Permissions:

To create a directory inside root: $sudo mkdir

To go to the root directory: $cd /

To check the permission of the directory created: $ls -lh | grep "<>"

To create the file inside the root user: $sudo touch <file_name>

To change the ownership of the directory created in root is: $sudo chown <user> <dir_name>

To make the download file/script as executable: $chmod +x <file_name>.

To check the list of locations for which Linux search for command: echo $PATH

"rwx" "rwx" "rwx": "What can be done by the Owner of the file", "People who are in Group", "Others".


Remote Connections:

  • We need to connect the client and server with each other to establish communication between them. For client machines just download and install the PuTTy application as per your machine. (www.putty.org)

  • For the server go to the Linux virtual machine and open the terminal and issue a command: $sudo apt install openssh-server

  • Once the connection will be established then you will be able to access the server on the client machine.

  • No Hangup at Disconnect: $nohup tail -f .bashrc &

  • To check about the tail command: $ps aux | grep "tail"

  • And if you want to kill the process forcibly: $kill -9 <process id>

Formore details, internships, courses & internships visit our website www.nationin.com



35 views0 comments
bottom of page