User Tools

Site Tools


bash

If you want to send us your comments, please do so. Thanks
More on comments


bash (on Debian)

Difference between bash and sh:
sh is the original Bourne SHell originating from Unix. It is POSIX compilant
bash is the Bourne Again SHell. Not everything that runs in bash runs well in sh. bash provides a superset of POSIX

In Debian Squeeze and newer sh is symlinked to dash:

ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Jan 24  2017 /bin/sh -> dash


In Busybox the ash shell is used

dash is faster and uses less memory than bash
dash is for non-interactive script execution 1)

Conclusion: use bash

man 1 bash chapters

GNU Bash 5.0 2018 December 7

  • NAME
  • SYNOPSIS
  • COPYRIGHT
  • DESCRIPTION
  • OPTIONS
  • ARGUMENTS
  • INVOCATION
  • DEFINITIONS
  • RESERVED WORDS
  • SHELL GRAMMAR
  • COMMENTS
  • QUOTING
  • PARAMETERS
  • EXPANSION
  • REDIRECTION
  • ALIASES
  • FUNCTIONS
  • ARITHMETIC EVALUATION
  • CONDITIONAL EXPRESSIONS
  • SIMPLE COMMAND EXPANSION
  • COMMAND EXECUTION
  • COMMAND EXECUTION ENVIRONMENT
  • ENVIRONMENT
  • EXIT STATUS
  • SIGNALS
  • JOB CONTROL
  • PROMPTING
  • READLINE
  • HISTORY
  • HISTORY EXPANSION
  • SHELL BUILTIN COMMANDS
  • RESTRICTED SHELL
  • SEE ALSO
  • FILES
  • AUTHORS
  • BUG REPORTS
  • BUGS

User ID

EUID is an environment variable containing the effective user ID (euid) of the current process. The euid represents the real user ID (rid) of the owner of the current process or the set-user-ID (suid) bit of an executable file.

When a process executes a set-user-executable binary file, the euid temporarily becomes the uid of the owner of the binary file. Similarly, when a privileged user runs a command using sudo or su, the euid switches to the rid of the superuser. In both cases, after the operation completes, the euid returns to the uid of the actual user.

echo "Showing EUID: $EUID"

Stopped jobs

When you do exit and get:

There are stopped jobs

there are jobs running in the background

Check with jobs what is running

With fg you can get a job to the foreground if there is only one job in the background. Otherwise you need to specify a number, which you can find with the job command. Example output:

[1] + Stopped  sftp-server (wd: /tmp)

wd: working directory
and then run fg 1

See also man bash

Append to a string

PATH="${PATH}:/usr/lib"; echo $PATH
PATH="PATH"":/usr/lib"; echo $PATH
PATH+=":/usr/lib"; echo $PATH
string1="Hello"; string2="$string1, how are you?"; echo $string2

Variables

List all variables and their values: printenv
To unset (remove) a variable do: unset thevariablename

Errors

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Transport endpoint is not connected

Solution: close the terminal and start it again

What is the point of sh being linked to dash
Difference between sh and bash
Globbing: * ? [a-z] [a,t,h,y,] [!d,t,h,i]. Globbing is not the same as regular expressions!


Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
bash.txt · Last modified: 16-05-2023 12:29 by wim