Hello World In Python Tutorial

How do I write my first program in python? How do I print “hello world” message in Python?

Tutorial details
Difficulty level Easy
Root privileges No
Requirements Python
Est. reading time N/A
Python is easy to use, general-purpose high-level programming language. ython is often used as a scripting language and for writing tasks such as:

=> Sys admin programming

=> Web projects

=> GUI projects etc

Task: Write “Hello world” program in python

Use a text editor such as vi, gedit or any other text editor. Create a program file called hello.py:
$ vi hello.py
Now type the following program:

#!/usr/bin/python
# My first python program
print "Hello, World!\n"

Save and close the file. Type the following command to set permission:
$ chmod +x hello.py
To run a program, enter:
$ ./hello.py


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Philippe Petrinko Mar 31, 2010 @ 12:55

    Yeah, right, but it misses your usual and useful “Further Readings” chapter… ;-)

  • punktyras Feb 28, 2013 @ 15:55

    language. ython is often

  • Hammad Khan Mar 26, 2013 @ 7:00

    You can also execute your scripts with this command line.

    python yourpythonfile.py

  • Matt T. Apr 27, 2014 @ 1:54

    You need to update this. Python 2.xx uses print ” “, while python 3.xx uses print(” “)

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum