Saturday, November 8, 2014

C++ Beginners - Few Tips

Hi, Everyone

Hope you all are good.
From last year I was trying to return back and finally I'm back. :)
Lot's of people have requested me to return back and appreciated my blog.
I'm glad that so many people liked my blog so much. Thanks to all who spend there precisions time to read it.
Thanks Again!! :)

Today, in this post I want to point out few basic things which we need to know as a Professional Developer. When we are in college and Programming Beginner we never know or didn't get the opportunity to learn or we learn it but it's not a good practice to apply at professional world. This post will help you find your basic questions and tips to write a professional code.

Before we start let me share two important Mantras: 
"Never trust end users"
"You are responsible for your code"

Tips/Suggestions:
Tip 1.
#include <iostream>                                    // 1  
using namespace std;                                    // 2  
                                                                             

int main(int argc, const char * argv[]) {      // 3 
     cout << "I'm a Programmer";                // 4 
    return 0;                                                    // 5 
}                                                                           


Let me explain you the code.

Line 1: #include <iostream> 
Line beginning with a hash sign (#) are preprocessor directives which instructs the preprocessor to include a standard C++ code, known as header. Here, iostream has been included to allows our code to perform standard input and output operations.

Thinking, What's preprocessor? Just go though this image.



Line 2: using namespace std;
A namespace defines a new scope. They provide a way to avoid name collisions (of variables, types, classes or functions) without some of the restrictions imposed by the use of classes, and without the inconvenience of handling nested classes. 

std namespace is declared in iostream.


I shall always recommend to write Line 4 as std:cout << "I'm a Programmer"; in place of declaring namespace at top.

Why? Suppose there are two variables with same variable name in two separate namespace. Now, if you include both of those using "using". At the time of implementation section it's confusing which variable will be included which may lead to un expected results.



"Namespaces are a powerful addition to an already powerful language, giving the programmer more flexibility, provided he knows how to take advantage of it."


Line 3: int main(int argc, const char * argv[])
When our program will start executing OS will call main method to start it's operation. 
We can recevice paramter to our code. Say our program is complilted and output file name is DemoCode.

Now if we run our code like this:
$ DemoCode India USA UK
argc will give 4 as number of arguments and argv array will have 4 arguments, DemoCode, India, USA and UK.

Line 4: cout << "I'm a Programmer";
It's a way to print a message in Console/output stream.

Line 5: return 0; or return EXIT_SUCCESS;
Once a program has a successful execution it return 0 or use macro EXIT_SUCESS to OS. Otherwise, we can return 1 or EXIT_FAILURE macro which denotes execution failed.
Value of EXIT_SUCCESS and EXIT_FAILURE are declared in header <cstdlib>
                                                                                                                                                                    

Tip 2: 
Comma operator ( , )

For example:
int b;
int a = (b=5,b+2);

In this code, second line first the value 5 will be assigned to b after that 2 will be added to b and last it will be assigned to a. So, a will be 7.

Read More: http://en.wikipedia.org/wiki/Comma_operator
                                                                                                                                                                  

Tip 3:

Macros

Format:
#define [identifier name] [value]
Macro is familiar word for Beginners and a common use most of you may have seen:

#define M_PI 3.14159                                // Approx. value of PI used


float radious = 25.0; 

float circumference = 2 * M_PI * radious;
Read More: https://gcc.gnu.org/onlinedocs/cpp/Macros.html
                                                                                                                                                                

More will be updated soon....

Monday, September 16, 2013

Back Again

Hi!
Everyone,

It's been almost two years now since I last posted anything in my blog.
There are so many things to learn in my life. I still need a lot of time and effort for self study.

But, finally I'm back with more experience and topics. I shall try to share few good topics for everyone. Hope you all like it.

Soon, I shall post some interesting topics..... related to Programming, System, Linux and Networking.

Monday, November 14, 2011

How to get Window's minimize and maximize button in fedora 16

This is something which I believe should have been available by default.
Thou, the below steps to get that is not so difficult and also little bit of fun.

Step 1. Download gconf-editor
# yum install gconf-editor

Step 2. Open gconf-editor
# gconf-editor

Step 3. Go to / -> desktop -> gnome -> shell -> windows

Step4. Now click on value of button_layout and change it to:
"menu:minimize,maximize,close"

Step 5. Logout and Login back ...... it's done! :)

Note: if you want some space between menu buttons use "space" for eg:
"menu:minimize,maximize,space,close"

Friday, September 16, 2011

Tip / Trick for web developers

Today I was trying to install JEvent2.0 in Joomla1.5.23 for one of my client.
But, when ever I "upload and install" JEvent I was getting few MySQL error messages.
Something like this:
* Component Install: DB function failed with error number 2006
MySQL server has gone away SQL=INSERT INTO ULJoomla_components VALUES( 0, 'JEvents MVC', 'option=com_jevents', 0, 0, 'option=com_jevents', 'JEvents MVC', 'com_jevents', 0, 'js/ThemeOffice/component.png', 0, '', 1 )
SQL =

INSERT INTO ULJoomla_components VALUES( 0, 'JEvents MVC', 'option=com_jevents', 0, 0, 'option=com_jevents', 'JEvents MVC', 'com_jevents', 0, 'js/ThemeOffice/component.png', 0, '', 1 )

* Error Loading ModulesMySQL server has gone away SQL=SELECT id, title, module, position, content, showtitle, control, params FROM ULJoomla_modules AS m LEFT JOIN ULJoomla_modules_menu AS mm ON mm.moduleid = m.id WHERE m.published = 1 AND m.access <= 2 AND m.client_id = 1 ORDER BY position, ordering

Solution:
Extract the archive file and paste the complete path and press "Install" (not upload and install).
But, in my case I don't have full path since I have access to joomla's root directory using ftp only.
Here, goes the solution, how I made it worked for me:
1. upload the archive file into (joomla'root directory)/tmp/
2. now use "upload and install" method to install file.
Finally installed smoothly without a single issue.

Thursday, September 15, 2011

Alias to find process id of a running process

This is an example for those who believe in saving time.
You can create your own aliases to save your time from typing long commands again and again.
Create alias
# alias p_id='echo -n '\''process name:'\'';read a;ps -e | grep firefox | cut -d '\'' '\'' -f 2'
Execute it
# p_id
process name:[name of the running process]
[output will be the process id]

Monday, August 8, 2011

[Alpha version] Now it is simple to install rpm packages on other pc which don't have internet connection.

Run this script package-script.sh from the system which has internet connection then copy the package.tar.gz file.

Now,
How to install packages on other pc which don't have internet connection.
1. paste package.tar.gz into non-internet pc.
2. Switch to root user using
$ su -
3. Extract tarball
# tar -C packagepkd -xvf package.tar.gz
4.
# cd packagepkd/.package/
5. rpm -ivh ....
check "man rpm" for more details.

Note:

Kindly, report here if you find any bug.

How to remove all *.lnk files from pen drive

Yesterday, I have connected my pen drive on someone else's system. Now, when I return home and connected my pen drive on my system, I have found lnk files for each file and directory in my pendrive. It is a waste of time deleting those files one by one. So, here is a simple command to remove all lnk files.

# find /path/to/pendrive -name '*.lnk' -exec rm -v '{}' ';'

Friday, July 8, 2011

How to change MAC address in fedora

1. First step is to find the current MAC address and take a backup copy in a safe place.

To know your current MAC type:
$ ifconfig | grep HWaddr
eth0 Link encap:Ethernet HWaddr 00:19:48:2E:D1:27

The above hexadecimal numbers 00:19:48:2E:D1:27 is your MAC address for device eth0.
Simply copy and paste it in a file.

2. Now, time to change the MAC address this requires you to work as root user.
Take the network interface down
# ifdown eth0

Now, lets change the current MAC address to 00:E0:81:5C:B4:0F
# ifconfig eth0 hw ether 00:E0:81:5C:B4:0F

Take the network interface up again
# ifconfig eth0 up

Check if your MAC address is changed:
# ifconfig eth0 | grep HWaddr

Note:
Changing MAC address is only temporary. Once you reboot your machine, the operating system will reflect the physical MAC address burnt in your network card and not the MAC address you set.

Thursday, July 7, 2011

Default Permission

Default Permission:
For Normal Users:-
1. On File:
-rw-rw-r-- or 664
2. On Directory:
drwxrwxr-x or 775

For users with root permissions:-
1. On File:
-rw-r--r-- or 644
2. On Directory:
drwxr-xr-x or 655

File and Directory Permissions

File Permissions:
1. -r--
content of the file can be read using command such as cat, less or more.
2. -rw-
Note: read permission is required to write into any file.
file can be edited and saved
3. -r-x
Note: read permission is required to execute any file.
shell (bash or sh, etc) will attempt to execute the file when file's name is entered as a command.

Directory Permissions:
1. dr--
content of directory can be read as ls.
Few examples:
$ ls testing/
ls: cannot access testing/file2: Permission denied
ls: cannot access testing/file1: Permission denied
file1 file2

Note: long listing requires execute permission.
Few examples:
$ ll testing/
ls: cannot access testing/file2: Permission denied
ls: cannot access testing/file1: Permission denied
total 0
-????????? ? ? ? ? ? file1
-????????? ? ? ? ? ? file2

2. d-wx
files may be created or delected in the directory.
Note:
a). execute permission required.
b). A file can be deleted by anyone who has write permission to directory in which the file resides regardless of the ownership or permission for that file.
Few examples:
a). $ ls testing/ [Failed]
ls: cannot open directory .: Permission denied

3. d--x
enter into directory using command cd
Few examples:
a). $ ls testing/
ls: cannot open directory testing/: Permission denied
b). $ cd testing/ [Okay]

Tuesday, June 14, 2011

[Solved] Starting LSB: start and stop the WLM configuration [1;31mfailed [0m, see 'systemctl status cgconfig.service' for details.

Most simple solution:
# yum update libcgroup-0.37.1-3.fc15

My problem is solved after this update.

[Solved]- Starting /dev/disk/by-uuid/ad5290fc-d073-45db-bfaf-86f25f401a07 [1;31maborted [0m because a dependency failed.

If you got any error like this at f15 booting time:
Starting /dev/disk/by-uuid/ad5290fc-d073-45db-bfaf-86f25f401a07 [1;31maborted [0m because a dependency failed.
Case I:
First check your /etc/fstab,
if you got any line starting with
UUID=ad5290fc-d073-45db-bfaf-86f25f401a07
Note: In my case UUID=ad5290fc-d073-45db-bfaf-86f25f401a07. But in case UUID will be something else.

Reason:
Reason for this failed message can be due to change in the partition like partition recreated after delete or filesystem type change (say ext3 to ext4).

Solution:
If it is due to change in partition you can use any one of the two methods:
1. Use blkid to find the UUID of /dev/sda5 (say the partition which has been changed is /dev/sda5)
# blkid
copy the UUID value from the output of the above command for /dev/sda5 only and paste it in place of previous UUID in /etc/fstab

Note: If the changed partition is your root partition you must have to edit /etc/grub.conf file
root=UUID=^new UUID^

2. open /etc/fstab file as root.
Now, edit only first field.
for example:
if it is like:
UUID=ad5290fc-d073-45db-bfaf-86f25f401a07 swap swap defaults 0 0
Replace the first field with partition name /dev/sda5 (say the partition which has been changed is /dev/sda5)
/dev/sda5 swap swap defaults 0 0
Note: If the changed partition is your root partition you must have to edit /etc/grub.conf file
root=/dev/sda5 (say the partition which has been changed is /dev/sda5)

Monday, June 6, 2011

We configure DSL connection using Network Manager. I like to know which file does it edit??

Yesterday, I was searching for this file. Googled alot, asked on #fedora, even I have thrown this question on #nm but didn't find any answer.
After searching for one hours, I have found this of my own and like to share with you all.

When you create a new DSL Connection using Network Manager your configurations are saved at
# cd /etc/NetworkManager/system-connections
Inside this folder you can find all DSL Connection's configuration files.

Friday, June 3, 2011

How to Configure Network Connection in fedora 15

Now, a days most of end-users have a common question i.e., How to configure network connection for usb-modem, mobile phone and broadband etc.

Today, I will try to cover all different types of network setup in fedora 15.

First step
First step for network configuration is to open Network Manager where you have to enter LAN and Service Provider's Info.
You can open Network Manager by:

1. Right click on the icon of two Computer -> Edit Connections
2. Left click on the icon of two Computer -> VPN Connections -> Configure VPN
Or Using command:
3. $ nm-connection-editor

Now, after this you can find a small window something like this:



I. Router/modem in bridge mode.
Most of the bsnl users, use this mode of network setup.
Before you start your network setup you must need two things:
1. username provided by bsnl.
2. password provided by bsnl.

Now, click on the DSL tab of Network Manager -> Add/Edit


Enter you username and password provided by bsnl, and service can be any name. (better to use service provider's name)
At the end don't forget to "Save" your changes.

II. Router/modem in pppoe mode.
This mode of network setup is mostly used in Corporate sectors and sometime people having dual boot System.
Now, click on the Wired tab of Network Manager -> Add/Edit

Here, the IP, Netmask and other information may not be the same for your case.

Note: All the information which are entered here are similar to the information entered in case of "Network Places -> LAN Connection" in Windows XP.

III. Internet Connection on PC using Mobile Phone.
Here, mobile phone works as a modem and mobile phone is connected to PC using a data cable.
Now, click on the Wireless tab of Network Manager -> Add/Edit


From "Any Device" drop down select your device and simply follow the steps.
Note: At the end must check if APN Name is corret.

IV. For usb-modem.
For bsnl and other dial-up usb-modem, same as "I. Router/modem in bridge mode."
For other, "III. For Mobile Phone."

Tips:
1. At a time enable "Connect Automatically" for only one device.
2. There are other ways of network connection too available but all above steps are simple and less risky.

Saturday, May 28, 2011

Data Recovery in Linux

Yesterday was really an unlucky day for me. An example for this may be, I have deleted a lot of my useful data by mistake. I was going to delete a folder using SHIFT + DEL, but in doing so by mistake I had pressed SHIFT + END then SHIFT + DEL. Grrrrrrrrrrrr :x.
So, now I need a software for data recovery for ext4 filesystem.


TestDisk - CGSecurity

TestDisk is wonderful FOSS under GNU Public License. It is capable enough to data recovery from lost partitions and/or make non-booting disks bootable again when caused by faulty software, certain types of viruses or human error (such as accidentally deleting a Partition Table).
TestDisk can run under
* DOS (either real or in a Windows 9x DOS-box),
* Windows (NT4, 2000, XP, 2003, Vista, 2008, Windows 7 (x86 & x64),
* Linux,
* FreeBSD, NetBSD, OpenBSD,
* SunOS and
* MacOS X


How to recover data?

Open terminal and type:
1. Installation:
# yum install testdisk
2. Run:
# testdisk
Now, you can see a text user interface like this:

Note: Use keyboard: left arrow move left, right arrow to move right, Up arrow to move up, down arrow to move down and Press Enter to Select an option.
Now, select an option which you think best for you. But, I prefer to main a log.


Select the disk from which you want to recover data and Proceed.


Select partition type, here in my case Intel and Press Enter.


Select Analyse and Press Enter.


Just Select Quick search and Press Enter. First time, it will take some time, in my case it took half an hour.


Now, select the partition from which you want to recover data and Press P. It will list all files and directories inside the partition.

Note: White Color files indicate existing files and Red color files indicates deleted files.

Just select the deleted file which you want to recover and Press c to copy. Now, you will get a options asking about destination location. Choose your destination location and Press Y. This copy process will take some time depending upon files size. When the 'Copying, please wait...' message will be replaced by 'Copy done!' message, then you can find your files on destination location.

I hope this post will help you. Thanks for Visiting by blog.

Cheers. :)

Google Summer Of Code 2011- Student

GSOC

Port Infrastructure TurboGears1 apps to TurboGears2

This year, I am participating in Google Summer Of Code 2011 as a student.
From Summer coding ideas for 2011 , I have selected Port Infrastructure TurboGears1 apps to TurboGears2 as my Summer Of Code project. Thou, I am interested to work on another project hopefully Fedora Medical. But, my semester exams are going to begin from 19th May 2011. So, till now looks like situation is not favouring me to accept another project.

Here, you can find my proposal in Summer Of Code 2011 for Port Infrastructure TurboGears1 apps to TurboGears2.
I have already conversation with Matt Domsch (mentor) and Toshio Kuratomi on #fedora-admin about this issue. With the permission Of Matt Domsch and his suggestion, I have decided to working on fas application first.
Yesterday, I have cloned fas app from "git clone git://git.fedorahosted.org/git/fas.git" and successfully completed modiication on setup.py and convert.py files.

I love development work and enjoying my work in GSoC 2011. :D
Thanks To Google for Conducting Summer Of Code.

Fedora And Open Source Event, GCECT

Before I start, I like to Thanks Rahul Sundaram, Prosun Sir, all Speakers, all Volunteers and my college teachers who help me a lot to organise this event successfully.
Thou, I agree that there where few mistakes may be since this was my first event or first FOSS event in our college (strange na) or may be due to lack of any Senior fedora Ambassador.

What ever may be I put you to decide the perfect reason for this.


Event Details: https://fedoraproject.org/wiki/Fedora_14_release_party_gcect
Total Event Registration: 200+
Total Event Attended: almost 150

2nd Feb 2011, I entered into my college campus at 9:00 A.M (1 and half hour before event was going to begin), my friend (responsible for managing auditorium and audio system setup) called both the person (lives beside our college campus) who were responsible for auditorium and audio system setup. Event's starting time was 10:30 A.M, but auditorium and Audio system setup was completed at 11:30 A.M in simple 1 and half hour late. Few people may be thinking why we haven't go for Auditorium and Audio system setup day before the event's day. The reason is simple, we already had a cost related problem and going for those setup day before that means we had to pay charges for two days. Ok! Atlast event started almost at 12:00 P.M.
Note: I have learned a new thing and I like to share this with my friends those who are first time going to organize any Event. Try to maintain that Event's beginning time must not be before 11:30am.

Event started with the speech of Mr.Indranil Das Gupta. Really very inspiring speech in which he had explained us about FOSS, importance of FOSS. Few information about fedora like total number of languages currently available in fedora. He had also mentioned about Fedora Project and Google Summer Coding. Here I can't stop myself saying about the best example of the importance of FOSS given by Mr. Indranil. i.e., air we breath is like FOSS and we can't live without it, may be we can hold our-self for few secs but after that we will start choking for air. He also mentioned about people like Sayamindu Das Gupta, Gopal V, Subhodip Biswas, Arindam Ghosh, Susmit Shannigrahi, Máirín Duffy and about their contributions to FOSS and Fedora.

-- break for 30mins --

After his speech I found a lot of attendees, specially new faces taking interest into FOSS and asking me about how to make contribution on FOSS and Fedora projects. Before, he leave he suggested me to create a group with other WBUT Board (West Bengal University Of Technology) students. I really found this very important after this event.

After break, my friend Er. Rahul Ghose came on stage to speak on “Awareness On Programming tools in linux”. Really very important topic for attendees since almost all attendees were Computer Science Engineering and Information Technology students. Before, event many students asked me about programming tools which are available in Linux. I hope this speech has solved a lot of queries regarding that.

After that around 2:20, Mr A.Mani was holding the mic for his speech on “Digitization of Documents in Fedora Linux”. Few people may be don't know that Mr. A.Mani is an Ambassador from India and has a lot of experience on events. Also, he coordinates the activities of ILUG-CALINFO. “Digitization of Documents” - a new topic for me too. So, I was trying to lessen his speech carefully. Few topics which I liked a lot from his speech are Copy-Left Licenses, Creative Common Licenses, Open Hardware, Scan Tailor and few others.

Next came Abhishek Jha, I guess this was his first speech on FOSS event speech (please correct me if I am wrong). He answered about one of the question asked by attendees “How to make money from FOSS projects”. He used examples of his friends and some tips during his speech for his explanation regarding this.

Next my turn, it was almost around 4:50, I guess. I have heard a lot of attendees were interested to hear on this topic “Cloud Computing and OpenStack-swift”. But, everyone was tired a lot during my speech, So I have to cut down my speech. I told them about What is cloud computing?, Importance of Cloud Computing, Public Cloud and Private Cloud, Cloud Infrastructure, OpenStack Servers, Swift tool, and few other topics.

During, speech I have found lots of questions from attendees. So, I have added a Question and Answer section at the end. Few of the question which I remember now are:
1. What is Fedora??
2. How to make money from FOSS projects??
3. When FOSS project's codes are open to be changed by anyone, what about the security from harmful code, if someone intentionally adds a harmful code??
4. About Fedora bugs and where to report, etc

Conclusion and Suggestion:

I think we need to create a mailing list or fedora-wbut group for wbut-students on fedora (if possible). Since for each and every fedora release there is at-least one fedora event by WBUT students. But, these events lacks co-ordinators, also searching for them before event is almost not possible due to exams, campussing, college etc. I guess a group or mailing list will be best to bind them all at a common place.

Reset Cisco Router Password using Minicom

Suppose you have a cisco router with configuration and password set. Today, I am going to tell you how to reset the Cisco router using Minicom (linux application).

Install MiniCom in fedora:
To install minicom in fedora type
# yum install minicom

Configure Minicom:
The configuration has to be done as root or user with root privilege.
# minicom -s or #minicom -s -c on
The -c on will enable the colour mode on.

Use the 'Up/Down' arrow to select "Serial port setup" and press "Enter".
Now type A to change serial device. Here, you have to know which tty is assigned for serial port. To know that type,

$ dmesg | grep ttyS
[ 1.297446] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 1.297896] 00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

So, In this case tty for serail port is ttyS0.
Select "E", now change the "Bps/Par/Bits" to "Current: 9600 8N1"or something else by pressing "A" next or "B" previous or using default C = 9600, D = 38400 and E=115200. Press "Enter".
Select "F", to disable Hardware Flow Control and press "Enter" to save the settings and exit back to the configuration menu.



Use the "Up/Down" arrow to select the "Save setup as dfl".
Now, your configuration is saved.
From now type
$ minicom or minicom -c on
as a normal user to connect with the Router.

Note: for more info about available functions in minicom
$ minicom
Now, press Ctrl+A, then Z for help

Reset Password:
First, Power off the Cisco router then Power on again. When the moment after CISCO ISO will be Self decompressing the image, you have to send the router the break signal as it is booting. In minicom, press Ctrl+A then F to send break signal.
This should bring you to the "rommon" prompt:
rommon 1 >

Now, for the rest part I guess you already know and don't have to write here....
Thou, if you need I will write it for you.

Install multiple linux OS on a single PC

Now a days there are so many Linux distributions and also each of them has their own speciality. There are many users those who have dual boot OS(two different OS on a single machine). Many of my own friends have fedora/Ubuntu and Windows OS installed.

Today I am going to say about how to install fedora, Ubuntu, and Windows XP on a same PC.
1: Install XP
2: Install Ubuntu
3: Install fedora.

Note: When you install fedora after the installation of Ubuntu your Ubuntu's grub will be removed and you can't see Ubuntu on the Grub's list.

Now, to get the Ubuntu on the Grub's List follow these Steps:
1. boot with fedora
2. open terminal
$su -

as root type this command.
# fdisk -l

Hint: Check Column "System"
Lets /dev/sda3 partition contains your Ubuntu OS.
3. mount your Ubuntu partition.
# mount /dev/sda3 /mnt
4. Open the grub menu.lst file
# cd /mnt/boot/grub
# gedit menu.lst
Now search for similar lines:


title Ubuntu 8.10, kernel 2.6.30.9
uuid 84c1144f-93ff-4f12-8a6a-90f12f51421c
kernel (hd0,2)/boot/vmlinuz-2.6.30.9 root=UUID=84c1144f-93ff-4f12-8a6a-90f12f51421c ro quiet splash
initrd (hd0,2)/boot/initrd.img-2.6.30.9
quiet

title Ubuntu 8.10, kernel 2.6.30.9 (recovery mode)
uuid 84c1144f-93ff-4f12-8a6a-90f12f51421c
kernel (hd0,2)/boot/vmlinuz-2.6.30.9 root=UUID=84c1144f-93ff-4f12-8a6a-90f12f51421c ro single
initrd (hd0,2)/boot/initrd.img-2.6.30.9

title Ubuntu 8.10, memtest86+
uuid 84c1144f-93ff-4f12-8a6a-90f12f51421c
kernel (hd0,2)/boot/memtest86+.bin
quiet



Copy these lines and paste these inside the fedora's grub menu list file:
# gedit /boot/grub/menu.lst
now restart fedora OS
This time you can see few more options on your Grub's List.

Setting custom Prompt

As much as I know maximum linux family's users were Windows users previously or using Linux parallel with Windows/Mac OS. I was too a Windows user previously, now fully switched to Linux.
In Windows, we have seen prompt command in command prompt(cmd) to change the prompt of the cmd.

Today I am going to discuss about same thing for linux.
In Linux, PS1 shell variable sets the prompt. We can use this variable to set our own custom prompt with the use of special escaped sequences.
Here, are few common escape sequences:
\h - short hostname
\u - username
\w - current working directory
\! - history number of the current command
\$ - this shows the privilege i.e for root users # and for non-root users $
Setting custom prompt using special escaped sequences:
1. temporary change:
$ PS1="\u@\h: \w \$" this will give you prompt something like this:
prabindatta@localhost: /home/prabindatta $

2. to make this change permament:
$ vi /.bashrc
at the end append your line something like this:
PS1='\u@\h: \w \$'