Skip to main content

Advance Unix Command Part 2 #DOTC_Mdb

Advance Unix Command Part 2.

Hello Everyone,

In my Previous blogs I already discussed about several commands which commonly used in Unix . Today I will discuss some more command which commonly used in Unix . Before starting new commands I will suggest you to please go through my below blogs for Unix command .

https://dheeraj60.blogspot.com/2020/08/advance-unix-command-part1-dotcmdb.html

https://dheeraj60.blogspot.com/2020/08/basic-and-some-advance-command-in-unix.html

https://dheeraj60.blogspot.com/2020/08/basic-and-commonly-used-command-in-unix.html

 

Let’s start with Unix command :

Connect to a remote mysql database. Below is the command to connect remote mysql database as well as local mysql database.

Note : You should first now the host name to connect mysql database as well as password.

$ mysql -u u255474504_root -p -h 127.0.0.1

Connect to a local mysql database.

$ mysql -u  u255474504_root –p

Below is the output of above command in putty Terminal.



 How to change your password from command line.

For this we use  passwd command . First it will prompt for the old password followed by the new password and after entering the new password you will see message as  all authentication tokens updated successfully. Command is as below.

$ passwd

Note : Super user can use passwd command to reset others password.  But this will not prompt for current password of the user. Command for this is as below .

$ passwd USERNAME

See the output of above command in Putty Terminal . I haven’t used the second command as i don’t need to reset other user password.



Less command is very efficient while seeing large files, as it doesn’t need to load the full file while opening, but once you use less command two commands/Keys are very useful

1. CTRL+F – forward one window

2. CTRL+B – backward one window

less command to to see large file is as below

$ less dheeraj2.txt

Below is the output in putty terminal .


 
After this I use CTRL+B command to back to command prompt.

 

Command that will output the sorted contents of a file dheeraj2.TXT and place the output in another file with same content name OUT.TXT, below is the command for this.

sort dheeraj2.TXT | uniq > OUT.TXT

Output of the above command is as below in Putty Terminal:



Command that will allow a UNIX system to shut down in 10 minutes, after which it will perform a reboot. Below is the command.

/sbin/shutdown –r +10

Note: I am not issuing this command in my terminal now.

How to zip and unzip the file in Unix .

Here we zip dheeraj2.txt file and unzip the same file . Below is the command to zip and unzip file in unix.

$ gzip dheeraj2.txt

To zip the file

$ gunzip dheeraj2.txt

To unzip the file

Below is the output in Putty Terminal for above commands.



cut command mainly used to extracts a given number of characters or columns from a file . Extract characters 5 to 10 from each line from text dheeraj2.txt we use below cut command in unix .

$ cut -c 5-10 dheeraj2.txt

Below is the output of above command in putty terminal.



Creating one text file table.txt through which I use cut command I will display 1st value of position 3 in column for all 5 records by using below cut command and create table .txt file.

Creating table .txt command by using cat command

cat > table.txt

emp_id;emp_name;salary

101;Ashish;20000

102;Krishna;15000

103;Prashant;25000

104;Deepak;22000

Cut command to display records for particular 3rdposition for all the 5 records in table.txt file.

 $ cut -c 3 table.txt

Below is the output of above command in putty terminal. 


Using Cut command if you want to see starting position from name to destination as per your need from text file table.txt use the below command.

$ cut -c 1-22 table.txt

Below is the output of above command in putty terminal.


 
Note : Still so many commands is available in Unix to use which I will cover in next  blog and also overview about Unix shell scripts as are familiar with Unix command. Please also see my previous blog related with Unix command for your reference.

Please go through this blog carefully and also my previous blogs related to Unix as this commands are very important if you are working in Unix environment and also if you are preparing for interview. Please let me know if you have any questions on this. In next blog I will come up with more Unix command and some basic idea about shell scripting.

Thanks.


Comments

Post a Comment

Popular posts from this blog

SQL and Classification of SQL in Oracle Database #Diksha Oracle Training Centre

  SQL and Classification of SQL in Oracle Database.   SQL is Structured Query Language , which is used for storing, manipulating and retrieving data stored in a relational database .SQL is the standard language for RDBMS. All the Relational Database Management Systems (RDMS) like Oracle, MySQL, Sybase, Informix, IBM DB2 and Microsoft SQL Server use SQL as their standard database language. Oracle is one of the more secured database as compared to other databases. Importance of   SQL : SQL and PL/SQL is a backend process where all data is stored and retrieved in GUI which created either by any programming languages like Java, C++, PHP etc. so we need to have very secure database so that there will be no impact for users. SQL allows users to access data in the relational database management systems. SQL is used to communicate with a database.SQL and PL/SQL allows users to create and drop databases tables , views , stored procedures , functions , packages , trigger etc. SQL allows

Materialized View uses and Benefits in Database #DOTC_Mdb

Materialized View uses and Benefits in Database. Hello Everyone, Today we will discuss about Materialized view as it’s play important role in database. We already discussed about Simple Views and complex views in my previous blog. Before Materialized view go through my previous blog which related to simple view. https://dheeraj60.blogspot.com/2020/05/benefits-of-creating-and-using-view-in.html As we know View is not a database object and not like table which is stored in database, but view can be created from base table a view is an SQL statement that’s stored in the database. This statement, or view, has a name.A view looks and acts a lot like a table. It has columns and rows, and can be included in SELECT queries just like a table. In other word we can say View is a virtual/logical table which is basically used for security purpose. Let’s understand   about   Materialized view : A materialized view is a view that stores the results of the view’s query. Whenever you query the ma

Top 50 Interview Questions On SQL and PL/SQL #DOTC_Mdb

                    Top 50 Interview Questions On SQL and PL/SQL. Today we will Discuss Top 50 interview questions and answers of SQL and PL/SQL which is frequently asked in interview.     Question 1: What is SQL and Classification of SQL? Answer SQL is a Structure Query Language which is vastly used in RDBMS database like Oracle, Sybase, DB2 , Microsoft SQL server etc.   Classification of SQL is as below: DDL (Data Definition Language):  Commands are  create , alter , drop , truncate etc DML (Data Manipulation Language) : Commands are  insert,update and delete . TCL (Transaction Control Language ) : Commands are  Commit , Rollback and Save point. DCL (Data Control Language) : Commands are Grant , Revoke Question 2:    What is meant by Joins? What are the types of join? Answer Joins are basically used to extract/get data from multiple tables using some common columns or conditions and also by using alias to fulfill the condition.   There are various types of Joins as li