A tty is a terminal (it stands for teletype - the original terminals used a line printer for output and a keyboard for input!). A terminal is a basically just a user interface device that uses text for input and output.
A pty is a pseudo-terminal - it’s a software implementation that appears to the attached program like a terminal, but instead of communicating directly with a “real” terminal, it transfers the input and output to another program. For example, when you ssh in to a machine and run ls, the ls command is sending its output to a pseudo-terminal, the other side of which is attached to the SSH daemon. A pts is the slave part of a pty. A ptmx is the master part of a pty.
You can use “man pty” command to get more information about “pty/pts/ptmx”.
The “tty” is also a valid command which can be used to tell you the current terminal file name you are using. In another word, it can tell you the current terminal name. Let’s say when you are using “gnome-terminal” to execute some commands in different tabs and you get the following output by running “ps -ef” command:
UID PID PPID C STIME TTY TIME CMD
Note the “pts/4” and “pts/8” terminals. Now you can run “tty” command in each of your “gnome-terminal” tab:
# In tab 1.
Now you can see which process is started by which “gnome-terminal” tab.