> For the complete documentation index, see [llms.txt](https://squid22.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://squid22.gitbook.io/notes/shells/spawn-a-shell.md).

# Spawn a Shell

![](https://3391461163-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M-SeUOaaky_0dmtDTFu%2F-M0saIS3yORT3u76VKBZ%2F-M0saXqfI985M-FVSOLr%2Fimage.png?alt=media\&token=a3e3b43e-e41d-4ff6-b5ad-4a8f9f3307d9)

**Same as above ( easy to copy and paste )**

```bash
# Python
python -c 'import pty; pty.spawn("/bin/bash")'

# Bash
echo os.system('/bin/bash')

# Bash
/bin/sh -i

# Perl
perl —e 'exec "/bin/sh";'

# Perl
perl: exec "/bin/sh";

# Ruby
ruby: exec "/bin/sh"

# Lua
lua: os.execute('/bin/sh')

# (From within IRB)
exec "/bin/sh"

# (From within vi)
:!bash

# (From within vi)
:set shell=/bin/bash:shell

# (From within nmap)
!sh
```
