- How to: Change User’s bash profile under Linux / UNIX
- Edit user .bash_profile file
- .bashrc vs .bash_profile files
- /etc/profile – System wide global profile
- 3 Ways to Change a Users Default Shell in Linux
- 1. usermod Utility
- 2. chsh Utility
- 3. Change User Shell in /etc/passwd File
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- How to Change Users in Linux Command Line
- Various user types in Linux
- 1. System Users
- 2. Regular Users
- 3. Super Users
- Switch users in the command line
- Switch to root user
- How To Change Shell To Bash in Linux / Unix
- How do I find out the default shell for a user?
- How do I see what shells are available on my system?
- How do I switch to a bash or different shell?
- How to change shells on a Linux or Unix-like systems?
- Summing up
How to: Change User’s bash profile under Linux / UNIX
Q . How do I change my own profile? How do I change profile for other users? How do I setup global profile for all users under BASH shell?
A .. You need to add user profile to
/.bash_profile. It is the personal initialization file, executed for login shells. There is also
/.bashrc file which is the individual per-interactive-shell startup file. Common uses for
/.bash_profile are to set environment variables such as PATH, JAVA_HOME, create aliases for shell commands and set the default permissions for newly created files etc. The file
/.bashrc is similar, with the exception that .bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.
Edit user .bash_profile file
Use vi command:
$ cd
$ vi .bash_profile
My same profile:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
.bashrc vs .bash_profile files
Let us see the difference with these two scripts:
/.bashrc file runs every time you open a new non-login bash shell such as xterm / aterm, and
/.bash_profile runs only with login shells i.e when you first log in into system.
/etc/profile – System wide global profile
The /etc/profile file is systemwide initialization file, executed for login shells. You can edit file using vi (login as root):
# vi /etc/profile
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
In order to get profile u need to have
/.bashrc
It contains setting
==> for your shell promt display
==> colour settings based on the permission (example exe fles appear green
So I suggest you copy the bashrc and bash_profile and bash from any linux server into your login and run the following command to change our profile
./bash
what is user profile and .profile in unix…waiting for your replay
My problem: Today I started to install sysstat monitor tool for my OS X by using 1. apt-get install sysstat 2. yum install sys stat 3. rpm -i sys stat.rpm none of then worked.
Even I cannot execute some unix commands from my Terminal.app.
Then I tried to see echo $PATH but the output is empty but I can start my TOMCAT and close.
NoW I cannot locate .profile or .bash_profile using the ls -a command. But still TOMCAt is working.. So It seems I messed up 🙂 Please let me know the reason? It is really deleted but how tomcat is working (as in OS x the java no need to be specified in .profile)?.
So Please help me to understand the problem and how to reconfigure it so that it can execute all commands.
maybe Fedora 17 is different
put aliases in .bashrc and it works
aliases not set when put into .bash_profile
]$ cat .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=.:$PATH
alias lsa=’ls -alF –color’
alias h=history
# User specific aliases and functions
[landon@Precision-380
by which commands i find out ORACLE_HOME,ORACLE_BASE,ORACLE_PATH,ORACLE_SID to create .bash_profile in
Источник
3 Ways to Change a Users Default Shell in Linux
In this article, we will describe how to change a user’s shell in Linux. The shell is a program that accepts and interprets commands; there are several shells such as bash, sh, ksh, zsh, fish and many other lesser known shells available on Linux.
Bash (/bin/bash) is a popular shell on most if not all Linux systems, and it’s normally the default shell for user accounts.
There are several reasons for changing a user’s shell in Linux including the following:
- To block or disable normal user logins in Linux using a nologin shell.
- Use a shell wrapper script or program to login user commands before they are sent to a shell for execution. Here, you specify the shell wrapper as a user’s login shell.
- To meet a user’s demands (wants to use a specific shell), especially those with administrative rights.
When creating user accounts with the useradd or adduser utilities, the —shell flag can be used to specify the name of a user’s login shell other than that specified in the respective configuration files.
A login shell can be accessed from a text based interface or via a SSH from remote Linux machine. However, if you login via a graphical user interface (GUI), you can access the shell from a terminal emulators like xterm, konsole and many more.
Let’s first list all available shells on your Linux system, type.
Before you proceed any further, note that:
- A user can change their own shell to any thing: which, however must be listed in the /etc/shells file.
- Only root can run a shell not listed in /etc/shells file.
- If an account has a restricted login shell, then only root can change that user’s shell.
Now let’s discuss three different ways to change Linux user shell.
1. usermod Utility
usermod is a utility for modifying a user’s account details, stored in the /etc/passwd file and the -s or —shell option is used to change the user’s login shell.
In this example, we’ll first check user tecmint’s account information to view his default login shell and then change its login shell from /bin/sh to /bin/bash as follows.
Change User Shell using Usermod
2. chsh Utility
chsh is a command line utility for changing a login shell with the -s or –shell option like this.
Change User Shell Using chsh
The two methods above all modify the shell specified in /etc/passwd file which you can edit manually as in the third method below.
3. Change User Shell in /etc/passwd File
In this method, simply open the /etc/passwd file using any of your favorite command line text editors and change a specific users shell.
Change User Shell in Passwd File
When your done editing, save and close the file.
Do not forget to read these related topics:
In this article, we described various ways of changing a user’s shell in Linux. To share any thoughts with us, use the comment section below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
How to Change Users in Linux Command Line
Linux systems have different types of users with different types or permissions as well.
Not all users can execute all commands and not all users are allowed to switch to other users neither. This all might sound confusing but, I will try to explain these so it can be easy to understand.
For the moment, here’s a quick summary of how to switch users in Linux command line.
To switch users, you need to know the password of that user. You can switch the users with this command:
To switch to root user in Ubuntu, you can use this command:
Various user types in Linux
If you list all users in Linux, you’ll see a lot of users that you didn’t know about. Who are these users? Where did they come from? I could write an entire article in regards of how users work in Linux, however, this is not the idea for this one.
Basically, there are 3 types of users in Linux:
1. System Users
These are the users that are automatically created in Linux systems to be able to run services or applications and are not intended to log in to the system (in fact you can’t log in as any of these users).
2. Regular Users
These are the (human) users who can log in to a system. Each of these users might have or not different permissions or levels in the system which is given by the groups they belong to.
3. Super Users
These are system administrators or users who can perform high-level tasks that can be considered critical or system dangerous.
Switch users in the command line
When using a Linux system you can log in with a user and then simply “switch” to another user through the same command line session. In order to do this, there is a command “su -“, which allows you to switch to become another user:
In the above example, you need to know the password of janedoe in order to switch to that user. Which makes sense because if you are going to switch to a user, you need to know the password of that user else it will be a security risk.
Switch to root user
For security reasons, some systems have ‘root’ account blocked for direct login, either locally or remotely, so this means it will not accept someone who tries to log in using ‘root’ even with the correct password.
So, how do you perform actions as the ‘root’ user? That’s what the ‘sudo’ command allows you to.
The sudo command will basically execute anything you want in the system as if the ‘root’ was doing it. You don’t need to know the ‘root’ user’s password, in fact, probably nobody knows it or there is no password assigned to ‘root’. You only need to know your own user’s password and that user must be in the ‘sudoers’ group, which is basically the group of users which can use ‘sudo’ in the system.
Normally, it is a good practice to run the commands with sudo that needs to run with root permission like this:
But if you want to change to root user so that all the subsequent commands will be run as root, you can use:
You’ll use your own password here, not the root account’s password.
As a sudo user yourself, you can create sudo user by adding the user to sudo group.
Conclusion
Linux systems allow you to easily switch users or execute high-level commands with the usage of ‘su‘ and ‘sudo’ commands. And remember: with great sudo power comes great responsibility!
Источник
How To Change Shell To Bash in Linux / Unix
H ow do I switch from a ksh shell to bash on Linux or Unix system? How to change shells on Unix-like system?
A shell is nothing but a command that provides a text-only user interface (also known as “command line interface”) for Linux, MacOS, and Unix-like operating systems. Bash shell read commands such as ls, date and others typed into a terminal and then run them. That is the primary function of bash shell.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | No |
Requirements | Linux or Unix-like OS |
Est. reading time | 2 minutes |
How do I find out the default shell for a user?
Type the following command to find out the default shell for a user named vivek using the grep command and /etc/passwd file:
$ grep vivek /etc/passwd
vivek:x:1005:1005. /home/vivek: /bin/zsh
OR
$ ps -p $$
PID TTY TIME CMD
14314 pts/9 00:00:00 zsh
OR
$ echo $0
zsh
All of the above output indicates that the shell is zsh for user named vivek in Linux operating system.
How do I see what shells are available on my system?
Type the cat command as follows:
$ cat /etc/shells
Fig.01: How to find list of available shells on Linux or Unix or MacOS?
How do I switch to a bash or different shell?
Type the name at the command line and then press the enter key. In this example, to change from any shell to the bash, type:
bash
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
How to change shells on a Linux or Unix-like systems?
You can change your default shell using the chsh (“change shell” ) command as follows. The syntax is:
chsh
chsh -s
chsh -s
chsh -s /bin/bash
chsh -s /bin/bash vivek
You can find full path to your shell using the following command:
type -a bash
type -a zsh
type -a ksh
Please note that a normal user may only change the login shell for her own account. The superuser (root) may change the login shell for any account using the following syntax:
$ sudo chsh -s /bin/bash raj
OR use the su command instead of sudo command:
$ su —
# chsh -s /bin/bash monika
Summing up
The only restriction placed on the login shell is that the shell command name must be listed in /etc/shells file, unless the invoker is the superuser/root user, and then any value may be added. An account with a restricted login shell may not change her login shell. For this reason, placing /bin/rsh in /etc/shells is discouraged since accidentally changing to a restricted shell would prevent the user from ever changing her login shell back to its original value.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник