Linux

 

 

 

 

Tips/FAQ

 

This page would various tips on Linux based on my own experience. The tips on Network Interface would not be described in this page and all the network interface related tips will be explained in separate page : Linux Network.

 

 

 

 

How to check on the login account ?

 

The simplest way to check is to use whoami command as below.

    $ whoami   ==> this would print out the account name

 

 

 

How to check whether I am in root account or not ?

 

The simplest way to check is to use whoami command as below.

    $ whoami   ==> this should print out 'root' as below.

    root

 

 

 

How to log into root account ?

 

First thing you can try is to use su command as below.

    $ su       ==> Hit enter and it will prompt you to type in the password

    Password : ******

If you fail with su, e.g getting the message 'su:Authentication Failure', try following

    $ sudo su       ==> Hit enter and it will prompt you to type in the password

    Password : ******

NOTE :  'su:Authentication Failure' may be because you may forgot root password. You may set or change root password as explained in How to set/change root password and try 'su' again.

 

 

How to set/change root password ?

 

You can change the root password with the command : passwd as shown below.

    $ sudo passwd root       ==> Hit enter and it will prompt you to type in the password

    New password : ******

    Retype new password :

 

 

 

How to boot in Terminal Mode ?

 

It may vary a little bit depending on what kind of Linux you are using... following is what I confirmed with Fedora 33.

 

    $ sudo systemctl set-default multi-user.target  ==> Hit enter and it prints as below.

    Removed /etc/systemd/system/default.target

    Created symlink /etc/systemd/system/default.target -> /user/lib/systemd/system/multi-user.target

Then reboot the PC.. and you will get the command prompt asking for user and password.

 

 

 

How to boot in Graphic Mode ?

 

It may vary a little bit depending on what kind of Linux you are using... following is what I confirmed with Fedora 33.

 

    $ sudo systemctl set-default graphical.target  ==> Hit enter and it prints as below.

    Removed /etc/systemd/system/default.target

    Created symlink /etc/systemd/system/default.target -> /user/lib/systemd/system/graphical.target

Then reboot the PC.. and you will get the log in screen for GUI

 

 

 

How to run Graphic Mode from Terminal Mode ?

 

It may be different depending on the variants of the Linux that you are using. In case of Fedora, you can easily run Graphics Interface with following command.

Assuming that you logged into a Terminal Mode. Run the following command from command line

    $ startx

NOTE : If you want to log into Graphic Mode when you turn on the PC, see How to boot in Graphic Mode ?

 

 

 

How to switch to Terminal Mode from Graphic Mode ?

 

Let's suppose you are with Graphic Mode now and want to switch to terminal mode. What I am doing is open a Terminal and typing in the following command.

    $ sudo init 3  ==> this mean 'return to Run Level 3 which is terminal mode'.

 

NOTE : If this cause any problem, try the following two command in sequence

    $ su -   ==> this is to switch to root account. this would prompt you to go through root login.

    $ sudo init 3

     

 

 

 

How to Fix 'SSH connection' problem ?

 

Step 1 : Check if ssh port is open and listening

 

    $ ss -lt ==> you should see the ssh is listening as shown below. If not, check next step

     

    State   Recv-Q  Send-Q    Local Address:Port        Peer Address:Port  Process

    LISTEN  0       4096            0.0.0.0:hostmon          0.0.0.0:*

    LISTEN  0       128           127.0.0.1:5939             0.0.0.0:*

    LISTEN  0       4096      127.0.0.53%lo:domain           0.0.0.0:*

    LISTEN  0       128             0.0.0.0:ssh              0.0.0.0:*

    LISTEN  0       5             127.0.0.1:ipp              0.0.0.0:*

    LISTEN  0       4096               [::]:hostmon             [::]:*

    LISTEN  0       128                [::]:ssh                 [::]:*

    LISTEN  0       5                 [::1]:ipp                 [::]:*

 

 

Step 2 : Check if ssh service is running

 

    $ service sshd status ==> you should get the result as follows. If not, check next step

     

    Redirecting to /bin/systemctl status sshd.service

    ● sshd.service - OpenSSH server daemon

         Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)

         Active: active (running) since Fri 2020-12-04 14:03:23 EST; 19min ago

           Docs: man:sshd(8)

                 man:sshd_config(5)

       Main PID: 3793 (sshd)

          Tasks: 1 (limit: 9328)

         Memory: 5.5M

            CPU: 275ms

         CGroup: /system.slice/sshd.service

                 └─3793 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

 

 

Step 3 : Check if ssh server is installed.

 

This would vary depending on the Linux variation that you are using

 

On Fedora, you can check in the following way

    $ rpm -qa | grep openssh-server  ==> If you see a result like below, it mean ssh server is installed. If it is not installed, install ssh server first. If it is installed, but not activated as shown in Step 2. Run the ssh server as in step 4.

     

    openssh-server-8.4p1-1.1.fc33.x86_64

 

 

Step 4 : Run the ssh service

 

    $ systemctl start sshd.service  ==> After running the service, check Step 1,2,3 again to make it sure it is running properly

 

 

 

How to enable ssh root login ?

 

In most case of default ssh installation, ssh root login is set to be prohibited. so you would experience the case where it is successful to login into a user's account, but you get 'access denined' when you are trying to log into 'root' account. In this case, you have to configure ssh server settings to allow root access.

You have to change settings in /etc/ssh/sshd_config

 

Step 1 : open nano /etc/ssh/sshd_config file using nano or any text editor you are familiar with (NOTE : I used sudo to open the file. If you logged into root account, you don't need to use 'sudo' but you need to use it otherwise).

 

$ sudo nano /etc/ssh/sshd_config

 

 

Step 2 : Add a line as in yellow line and save it.

 

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

 

 

Step 3 :Restart the ssh server as follows.

 

$ service sshd restart

 

 

 

how to make sshd (ssh server) to listen to both IPv4 and IPv6 ?

 

Step 1 : open nano /etc/ssh/sshd_config file using nano or any text editor you are familiar with (NOTE : I used sudo to open the file. If you logged into root account, you don't need to use 'sudo' but you need to use it otherwise).

 

$ sudo nano /etc/ssh/sshd_config

 

 

Step 2 : Add a line as in yellow line and save it.

 

#Port 22
AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

 

 

Step 3 :Restart the ssh server as follows.

 

$ service sshd restart

 

 

 

How to disable Wayland ?

 

Some application does not allow Wayland. So you need to disable Wayland to make it work (In my case, I had this problem when I tried to use TeamViewer on fedora 33).

 

Step 1 : Check which gdm you are using ?

 

There can be several different ways to check, but I am checking the /etc folder to get this information.

    $ ls /etc | grep 'gdm'

     

    Following is an example result from my pc. It shows that I am using gdm (in some case you may see other version like gdm3).

$ ls /etc | grep 'gdm'

gdm

 

 

Step 2 : edit gdm configuration file and disable Wayland

    $ sudo nano /etc/gdm/custom.config

     

    put the WayloadEnable=false under [daemon] section.

# GDM configuration storage

 

[daemon]

# Uncomment the line below to force the login screen to use Xorg

WaylandEnable=false

 

[security]

 

[xdmcp]

 

[chooser]

 

[debug]

# Uncomment the line below to turn on debugging

#Enable=true

 

 

Step 3 : reboot the pc