Pretty much the first task that we are going to be presented with on Linux is to log in. We are going to need to know how to access the command line in CentOS 7 to. get the most out of the OS. Hence this is the first objective in the RH124 course. So we will take a look at how we can log in the the GUI and Terminal and how we can gain access to the command line interface or CLI.
The CLI will always be important in Enterprise Linux as many servers will not have a GUI and you will gain access not from the Server itself but in many cases using SSH from your client, perhaps PuTTY on windows. If we do have access to the server or desktop and it does have a GUI we can gain access to the command line via the GUI and pseudo terminals or directory on a physical console.
We start by logging in to the GUI Gnome environment that CentOS installs by default if the desktop is selected. The username is display to us so this is not an issue in the GUI but if logging into to a console be aware that the username and password are both case-sensitive in Linux.
Once we have logged in we can gain access to the command line by right-clicking the desktop and choosing “Open in terminal“. The Desktop folder will then be our file-system context from the command line using the gnome-terminal. We could also start the terminal via the Menu: Applications > Utilities > Terminal. Yet another mechanism would be to use ALT + F2 and type gnome-terminal as the command to run, the ALT+F2 run dialog is shown in the next graphic:
Once we have a terminal open the great thing with the GUI terminal is that we can increase the size of the font: CTRL + SHIFT + + and reduce with CTRL + – . To full screen the terminal we are in, we can use F11
If we enter the command tty at the console then it most likely will show as /dev/pts/0 (unless other pseudo terminals are in use). This is a file in the filesystem but links directly to the console that we are in. We can see this is we enter the following command:
$ echo "hello" > /dev/pts/0
We send the word hello to the file using redirection. As the file repesents the terminal we see the word in our terminal. If you are still a little unsure as to the terminal you are connect to. Then we can combine the echo command with the tty command:
$ echo "hello" > $(tty)
This will work no matter the TTY you are connected to. We first evaluate the output of the tty command. Brackets are processed first. We can then pass that through to the redirection form the command echo. You will see hello being printed out on your terminal.
We also have physical terminals on the device. /dev/tty1 is used by the GUI but that leaves /dev/tty2 – 6 . We can access these using CTRL + ALT + F2 to access the tty2 and F3, to access tty3 etc.
We can login in to the physical consoles and again use the tty command to display the terminal name. To return to the GUI we can use CTRL + ALT + F1. Do not forget though that we will need to logout from any terminal. We can do this using:
- exit
- logout
- CTRL + d
To check where we are logged into and who else is logged in, we can use the command who.