Welcome to this tutorial on how to install a tar.gz file on Linux using PyCharm as an example.
PyCharm is a popular integrated development environment (IDE) for Python, but it does not come pre-installed in Linux systems.
Therefore, if you want to use PyCharm on Linux, you need to download and install it manually.
In this tutorial, we will guide you through the process of extracting a tar.gz file in Linux, using PyCharm as an example.
By the end of this tutorial, you will have learned how to install any tar.gz file on Linux using the same approach. So, let’s get started!
Download PyCharm .tar.gz file
First, download the PyCharm Community Edition from the official website: https://www.jetbrains.com/pycharm/download/#section=linux.
This will download a “pycharm-community-xx.tar.gz” file.
A .tar.gz is a compressed format file, similar to .zip files in Windows.
How to find the .tar.gz file in your Downloads Directory
To see the .tar.gz file, you can navigate to your Downloads directory in Linux by typing the following command in the Terminal:
cd ~/Downloads
Now type ls
which means to “list”. In other words,we are telling Linux to list the contents of this directory.
ls
Alternatively, you can combine the cd
and ls
commands into a single command:
cd ~/Downloads; ls
You should now see the “pycharm-community-xx.tar.gz” file listed there.
Great, now it’s time to extract it.
How to Extract a .tar.gz file
After downloading the file, we need to extract it into a directory or “folder”.
To extract the downloaded tar.gz file to a directory of your choice. You can use the following command to extract the file:
tar -xzf pycharm-*.tar.gz -C /opt/
Remember to replace pycharm-*.tar.gz with the name of the downloaded file. In this case i downloaded the “pycharm-community-2023.1.tar.gz” files so my command would be:
tar -xzf pycharm-community-2023.1.tar.gz -C /opt/
You can skip the breakdown section below to continue the install, but if you want to have a full understanding of what each part of this command does, then I have included this for you as well.
Breakdown of the “tar -xzf pycharm-*.tar.gz -C /opt/” command:
Here is a breakdown of each part of this command: tar -xzf pycharm-community-2023.1.tar.gz -C /opt/
that we are using to extract and install this .tar.gz file:
tar
The tar
command is a tool used for creating and manipulating tar archives, which are a type of compressed file that can contain multiple files and directories.
-xzf
The -xzf
options used with the tar
command specifies that the operation being performed is to extract:
- (“-x”) a compressed archive file that is in the gzip format
- (“-z”), and to display the progress of the extraction
- (“-f”) on the terminal.
-.tar.gz
The pycharm-.tar.gz
argument is a file pattern that specifies the name of the archive file to be extracted. The asterisk () is a wildcard character that matches any sequence of characters, so this pattern will match any file in the current directory that begins with “pycharm-” and ends with “.tar.gz“.
-C /opt/
Finally, the -C /opt/
option tells the “tar” command to extract the contents of the archive to the “/opt/” directory.
The “-C” option changes the directory before performing any operations, so all extracted files and directories will be placed in the “/opt/” directory.
The “/opt” directory is a standard directory in a Unix/Linux file system, which stands for “Optional software”. The “/opt” directory is meant to contain software packages that are completely self-contained, with all of their files and dependencies in a single directory. Thus, its typically used for installing third-party software that is not included with the operating system, and that does not follow the system’s file hierarchy conventions.
This makes it easy to manage and uninstall the software, and it also helps to prevent conflicts with other software installed on the system.
This is a common convention for installing software packages on Unix/Linux systems, as it allows users to easily manage and uninstall the software, and ensures that it does not interfere with other system files or applications.
How to Navigate to the /opt directory
To navigate and find the folder we created when extracting the “.tar.gz“, we need to use the cd
command which stands for “Change Directory” to its parent “opt’ folder.
To do this, simply type the following command in the Unix/Linux terminal terminal:
cd /opt
You can verify that you are in the “/opt” directory by typing pwd
(print working directory):
pwd
This will print the current working directory on the terminal, which should show “/opt” as the output if you have successfully navigated to the directory.
How to see what’s currently in the /opt directory
To see what’s in the “/opt” directory, you can again type the following list command in the Unix/Linux terminal terminal:
ls
Alternatively, you can combine the “cd” and “ls” commands into a single command:
cd /opt; ls
What if I see nothing in the opt directory?
If you have navigated to the “/opt” directory using the cd
command and executed the ls
command but do not see any files or directories listed, then it is possible that the directory is empty or that there are no files or directories that are visible to your user account.
You can try running the ls
command with the “-a” option to show all files, including hidden files and directories. Hidden files and directories are those that start with a dot (“.”) in their name.
To do this, type:
s -a /opt
This will show all files and directories in the “/opt” directory, including hidden files.
If the directory is still empty or there are no files or directories visible to your user account, then it is possible that there is no software installed in the “/opt” directory or that your user account does not have sufficient permissions to view the files and directories in the directory.
How to Change to PyCharm extracted Directory
If the extraction was successful, you should see a “pycharm-community-2023.1” directory listed when you type:
cd /opt; ls
Here you should see the “pycharm-community-2023.1” directory created from the extraction of the .tar.gz file.
To now navigate into it simply type:
cd /opt/pycharm-community-2023.1/
We are now in the extracted “pycharm-community-2023.1” directory or “folder”.
Here we can again list its contents by simply typing:
ls
How to Launch Pycharm from extracted directory
Now that the .tar.gz file is extracted to the pycharm-community-2023.1 directory or “folder”, it’s time to install it. If you list the contents of the following command:
cd /opt/pycharm-community-2023.1; ls
You will see a bin directory listed there. We now need to do the same and change directory to this bin directory by typing:
cd /opt/pycharm-community-2023.1/bin; ls
In the “opt/pycharm-community-2023.1/bin” directory, you will see a “pycharm.sh” file listed. This is similar to a .exe file in Windows, meaning that we will use this to install PyCharm by using the following command:
pycharm.sh
PyCharm will launch, and you can now configure it according to your preferences.
How to create a Desktop Launcher
Optionally, you can create a desktop launcher for PyCharm by creating a file with the “.desktop” extension in the “/usr/share/applications/” directory using Javascript:
[Desktop Entry]
Name=PyCharm
Comment=Python IDE
Exec=/opt/pycharm-community-2023.1/bin/pycharm.sh
Icon=/opt/pycharm-community-2023.1/bin/pycharm.png
Terminal=false
Type=Application
Categories=Development;IDE;
Save the file and exit.
PyCharm should now be available in your applications menu.
Conclusion for Installing tar.gz file in Linux
In this tutorial, we have covered the process of installing a tar.gz file in Linux using PyCharm as an example.
We started with downloading the PyCharm tar.gz file from the official website and then moved on to extracting the file into the /opt directory.
We have also explained each part of the “tar -xzf” command in detail, which is used for extracting the contents of the tar.gz file. Additionally, we have provided guidance on how to navigate to the /opt directory and verify the contents of the directory.
Here is a summary of the steps we covered
Download PyCharm tar.gz
Go to the PyCharm website and download the Linux version of PyCharm Community Edition.
.tar.gz file to your downloads folder:
cd ~/Downloads; ls
Extract the .tar.gz file
Open your terminal and navigate to the directory where the file is located.
Type the following command to extract the file:
tar -xvzf pycharm-community-2023.1.tar.gz
Navigate to the PyCharm extracted directory
Type the following command to change to the PyCharm extracted directory:
cd /opt/pycharm-community-2023.1/
Change to Pycharm bin Directory
Type the following command to change to the bin directory:
cd bin/
Launch PyCharm from the extracted directory
Type the following command to launch PyCharm:
./pycharm.sh
PyCharm will launch, and you can now configure it according to your preferences.
Note: Make sure you have the necessary permissions to install software on your Linux machine using sudo
if you are able to.
By following the steps in this tutorial, you should be able to install any tar.gz file on your Linux system.