How to Change Default Shell in Linux

If we are a non-root user we can not make direct changes to /etc/passwd file to change the default shell we have. To change the default shell we can use the command chsh. You can see the default shell and View the available shells on your computer before changing your default shell. The syntax of chsh command as follows:

chsh -s

The shell name contains the new shell name you will use and is an absolute path. for example if your default shell is bash (/ bin / bash) and you want to convert to csh (/ bin / csh), then the command you should use:

[lica @ canada ~] $ chsh -s /bin/csh
Changing shell for lica.
Shell changed.

When changing shell with chsh command you will be prompted for password. fill in with your user password and not the root password (if you have root access). to see the changes we can see the contents of /etc/passwd

[lica @ canada ~] $ grep lica / etc / passwd
lica: x: 500: 500: lica: / home/lica: /bin/csh

If you are running chsh from root, you can add username parameters as input to chsh to change a specific user shell in your system.

when you run chsh with no option, chsh will run in interactive mode, for example :

[lica @ canada ~] $ chsh
Changing shell for lica.
New shell [/ bin / csh]: / bin / bash
Shell changed.

Good luck!

View Default Shell

The default shell for each user is stored in the last /etc/passwd file. As an example :

[lica @ clarisa ~] $ grep lica /etc/passwd
lica: x: 500: 500: lica: /home/lica: /bin/bash

In the above example the default shell for lica user is /bin/bash. If you have root access you can of course directly edit this file and change the final column for the user who will change the default shell. The non-root user can only see the contents of the file /etc/password but can not write in the file.

In addition to viewing the contents of the file /etc/passwd you can see the default shell by looking at the contents of the $ SHELL variable.

[lica @ clarisa ~] $ echo $ SHELL

Know Who’s Who Are Logging And What The User Is Doing

If you are a system administrator or sysadmin of a Linux computer, where multiple users can log in simultaneously, you may be wondering how we can find out who I am currently logged in and what your users are doing using w command.

[lica @ canada ~] # w
11:18:03 up 3 days, 23:31, 1 user, load average: 1.22, 1.20, 1.05
lica pts / 1 gw.kurungsiku 11:05 0.00s 0.01s 0.00s w
From the above info we can see there is 1 user with:

  • username lica
  • login from pseudo terminal pts / 1
  • from my gw.kurungs
  • logged in at 11:05
  • idle for 0.05s
  • JCPU 0.01s, is the amount of time used by all processes related to the tty used by the user, but excludes previous background jobs and only includes the currently running background jobs
  • The PCPU0.00s time used by the current process is written in the WHAT column
  • The last/last command is executed w

Knowing How Long a Computer Has Been On With Uptime

If you want to know how long a computer with a Linux operating system has turned on, you can read the file / proc / uptime, or for easy you can use uptime commands. as an example

$ uptime

11:05:23 up 3 days, 23:18, 1 user, load average: 1.01, 1.11, 1.01
The output of the above uptime command gives us the following info

Current time (11:05:23)
How long the system has been on (3 days, 23:18)
Number of current user login (1 user)
Average system load (Load Averages) for last 1, 5 and 15 minutes
Maybe useful!