- less /etc/passwd
- getent passwd
- getent passwd | cut -d: -f1
- less /etc/group
- getent group
- getent group | cut -d: -f1
https://stackoverflow.com/questions/50904342/etc-passwd-vs-usr-bin-passwd
The two files are different, and serve different purpose.
/etc/passwd
is user database (fun fact: contrary to its name, it doesn't store passwords - those are stored (possibly in hashed form) in /etc/shadow
) - see man 5 passwd
(i.e. passwd(5)), man 5 shadow
(i.e. shadow(5)).
/usr/bin/passwd
is utility that is supposed to modify user records stored in /etc/passwd
and /etc/shadow
. See man 1 passwd
(i.e. passwd(1))
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
https://unix.stackexchange.com/questions/5915/difference-between-bin-and-usr-bin
/sbin
- Binaries needed for booting, low-level system repair, or maintenance (run level 1 or S)
/bin
- Binaries needed for normal/standard system functioning at any run level.
/usr/bin
- Application/distribution binaries meant to be accessed by locally logged in users
/usr/sbin
- Application/distribution binaries that support or configure stuff in /sbin.
/usr/share/bin
- Application/distribution binaries or scripts meant to be accesed via the web, i.e. Apache web applications
*local*
- Binaries not part of a distribution; locally compiled or manually installed. There's usually never a /local/bin
but always a /usr/local/bin
and /usr/local/share/bin
.
/bin
: For binaries usable before the /usr
partition is mounted. This is used for trivial binaries used in the very early boot stage or ones that you need to have available in booting single-user mode. Think of binaries like cat
, ls
, etc.
/sbin
: Same, but for binaries with superuser (root) privileges required.
/usr/bin
: Same as first, but for general system-wide binaries.
/usr/sbin
: Same as above, but for binaries with superuser (root) privileges required.
sudo pam_tally2 -u 703247699 --reset
https://stackoverflow.com/questions/5163144/what-are-the-special-dollar-sign-shell-variables
$1
, $2
, $3
, ... are the positional parameters."$@"
is an array-like construct of all positional parameters, {$1, $2, $3 ...}
."$*"
is the IFS expansion of all positional parameters, $1 $2 $3 ...
.$#
is the number of positional parameters.$-
current options set for the shell.$$
pid of the current shell (not subshell).$_
most recent parameter (or the abs path of the command to start the current shell immediately after startup).$IFS
is the (input) field separator.$?
is the most recent foreground pipeline exit status.$!
is the PID of the most recent background command.$0
is the name of the shell or shell script.Most of the above can be found under Special Parameters in the Bash Reference Manual. There are all the environment variables set by the shell.
For a comprehensive index, please see the Reference Manual Variable Index.
sudo su
interactive non-login shell.
sudo su -
It is a login shell
To explain this you need to know what the programs do:
su
- The command su
is used to switch to another user (s witch u ser), but you can also switch to the root user by invoking the command with no parameter. su
asks you for the password of the user to switch, after typing the password you switched to the user's environment.sudo
- sudo
is meant to run a single command with root privileges. But unlike su
it prompts you for the password of the current user. This user must be in the sudoers file (or a group that is in the sudoers file). By default, Ubuntu "remembers" your password for 15 minutes, so that you don't have to type your password every time.bash
- A text-interface to interact with the computer. It's important to understand the difference between login, non-login, interactive and non-interactive shells:Types of shells:
So the cases are:
sudo su
Calls sudo
with the command su
. Bash is called as interactive non-login shell. So bash only executes .bashrc
. You can see that after switching to root you are still in the same directory:
user@host:~$ sudo su
root@host:/home/user#
sudo su -
This time it is a login shell, so /etc/profile
, .profile
and .bashrc
are executed and you will find yourself in root's home directory with root's environment.
sudo -i
It is nearly the same as sudo su -
The -i (simulate initial login) option runs the shell specified by the password database entry of the target user as a login shell. This means that login-specific resource files such as .profile
, .bashrc
or .login
will be read and executed by the shell.
sudo /bin/bash
This means that you call sudo
with the command /bin/bash
. /bin/bash
is started as non-login shell so all the dot-files are not executed, but bash itself reads .bashrc
of the calling user. Your environment stays the same. Your home will not be root's home. So you are root, but in the environment of the calling user.
sudo -s
reads the $SHELL
variable and executes the content. If $SHELL
contains /bin/bash
it invokes sudo /bin/bash
(see above).
scp -i mykey.pem somefile.txt root@my.ec2.id.amazonaws.com:/
https://stackoverflow.com/questions/6558080/scp-secure-copy-to-ec2-instance-without-password
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass