هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
Every session has a terminal device: a real console (/dev/tty1 … /dev/tty6) or a pseudo terminal for terminal windows and SSH (/dev/pts/0, /dev/pts/1 …).
tty prints the name of yours. When the input is not a terminal (for example in a cron job or a pipe), it prints "not a tty" and returns an error code — scripts use this to know if a person is watching.
طريقة الكتابة
tty [OPTION]...الخيارات 3
الأكثر استخدامًا
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 11
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Which terminal am I on?
tty /dev/pts/0pts = terminal window or SSH session.
2On the local text console
tty /dev/tty3A real virtual console (Ctrl+Alt+F3).
3Check in a script if a person is watching
Ask questions only when a person can answer.
4In a pipe there is no terminal
echo | tty not a ttystdin comes from the pipe, not from a terminal.
5Send a message to another session
who write admin pts/1writeandwalluse the terminal names thatttyandwhoshow.6End another session
pkill -KILL -t pts/3Logs out the session on pts/3 (find it with
who).7Set terminal options for your session
stty -aShows the settings of the current tty (like the erase key).
8Log the terminal in a script
echo "$(date) started on $(tty) by $USER" >> /var/tmp/run.logHelps to see later how and where a script was run.
9See the owner of your terminal device
ls -l $(tty) crw--w----. 1 admin tty 136, 0 Oct 25 09:02 /dev/pts/0Your terminal belongs to you; group tty may write messages to it.
10Find processes attached to a terminal
ps -t pts/0All processes of that session.
11Check that SSH gave you a terminal
Without -t a remote command has no terminal ("not a tty").
لا يوجد شيء يطابق هذا الفلتر.
نصائح للحفظ
- /dev/ttyN = console, /dev/pts/N = window or SSH.
tty -s= test in scripts.