588
TIL (lemmy.world)
submitted 11 months ago by yogurtwrong@lemmy.world to c/linux@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] lhamil64@programming.dev 21 points 11 months ago

What is /dev/pty23? From context, I assume another users terminal so it just spams garbage to their screen?

[-] nicoweio@lemmy.world 9 points 11 months ago

What OP said. But here's a more detailed answer courtesy of GPT-4:

Adding cat /dev/random > /dev/pty23 to your .profile would result in an interesting situation whenever you start a login shell.

  1. Behavior of the Command: The command cat /dev/random continuously reads random data from the /dev/random device file, which generates an endless stream of random bytes. Redirecting this to /dev/pty23 means it attempts to write this data to the pseudo-terminal device /dev/pty23.

  2. Impact on Shell Startup: When you add this to your .profile, every time you start a login shell (like when you open a new terminal session), it will execute this command. Since /dev/random produces an endless stream of data, the cat command will not terminate on its own. This means your shell will be stuck executing this command, and you won't get a prompt to enter new commands.

  3. Interactive Shell Issue: The shell remains technically interactive, but because the cat command doesn't complete, you won't get a chance to interact with it. The shell is effectively blocked by the cat command continuously running.

  4. Potential Problems: There's a possibility that /dev/pty23 might not exist on your system, or you might not have the permission to write to it. In such cases, the command would fail, but it would still block the shell if it doesn't exit properly.

  5. Fixing the Issue: To regain control of your shell, you might need to edit your .profile from a different context where it doesn't get executed, like using a non-login shell or booting into a recovery mode.

In summary, it's a kind of a "prank" command that can render your login shell unusable until you remove it from your .profile. It's an example of how powerful shell startup scripts can be, and also a reminder to be cautious about what gets added to them!

[-] crispy_kilt@feddit.de 5 points 11 months ago

Please don't spam gpt rubbish

this post was submitted on 22 Nov 2023
588 points (100.0% liked)

Linux

48132 readers
366 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS