> For the complete documentation index, see [llms.txt](https://strange-1.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://strange-1.gitbook.io/notes/shells/spawning-a-tty-shell.md).

# Spawning a TTY Shell

### Spawning TTY Shells

<pre class="language-bash"><code class="lang-bash">/bin/sh -i

/usr/bin/script -qc /bin/bash /dev/null

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

<strong># Python
</strong>python3 -c 'import pty;pty.spawn.("/bin/bash");'

<strong># Perl
</strong>perl —e 'exec "/bin/sh";'
perl: exec "/bin/sh"; # it should be run from a script

<strong># Ruby
</strong>ruby: exec "/bin/sh" # it should be run from a script

<strong># Lua
</strong>lua: os.execute('/bin/sh') # it should be run from a script

<strong># AWK
</strong>awk 'BEGIN {system("/bin/sh")}'

<strong># Find
</strong>find / -name nameoffile -exec /bin/awk 'BEGIN {system("/bin/sh")}' \\;
find . -exec /bin/sh \\; -quit

<strong># Vim
</strong>vim -c ':!/bin/sh'

<strong># Vim Escape
</strong>vim
:set shell=/bin/sh
:shell
</code></pre>

### Upgrading TTY Shells

```bash
# After getting a shell and spawing tty shell using one of the above methods, follow below step

# Hit ctrl[z]
^Z
# run below commands
stty raw -echo
fg
# If it shows blamk screen, press enter or input reset command to get the shell prompt
[Enter]
[Enter]
www-data@remotehost$

# To use full screen 
# In New Tab, note the output of both 
echo $TERM
stty size

# On our nc Shell on target
export TERM=xterm-256color
stty rows 67 columns 318 
```
