Unix tty command and file command?

I am new to UNIX, and when I read a book about UNIX, I ran into two problems that I did not understand. I would really appreciate your help.

1) See the man page for the file command, and then use it for all files in the / dev directory. Can you combine these files into two categories?

2) Run the tty command and pay attention to the device name of your terminal. Now use this device name (/ dev / pst / 6) in the cp / etc / passwd / dev / pts / 6 command. what are you watching

+3
source share
1 answer

The fair question is really ... it's so easy for us to do as much for granted.

file, ...

man file

..., , , , , , . , file - , , . ...

file /dev/*

..., /dev/. "shell", , . file . [SHELL-PROMPT] , /dev/ *, :

[SHELL-PROMPT] file /dev/*
...lots of stuff...
/dev/cevt:      character special (255/176)
/dev/console:   character special (5/1)
/dev/core:      symbolic link to `/proc/kcore'
/dev/cpqci:     character special (10/209)
/dev/cpqhealth: directory
/dev/crom:      character special (255/180)
...lots of stuff...
/dev/md8:       block special (9/8)
/dev/md9:       block special (9/9)
/dev/mem:       character special (1/1)
/dev/mice:      character special (13/63)
/dev/mouse0:    character special (13/32)
/dev/mptctl:    character special (10/220)
/dev/net:       directory
/dev/nflog:     character special (36/5)
/dev/null:      character special (1/3)
/dev/parport0:  character special (99/0)
...lots of stuff...

/ ( ) , . , , : " ", - " ", - , - (.. ls /dev/net/*). "" - , . , , , , . "" . , /dev/tty, , tty - - . , , , , ( ), , , , . /dev/null : , , ( ). /dev/random, ... , - .

2) tty . (/dev/pst/6) cp/etc/passwd/dev/pts/6. ?

"tty", , ...

[SHELL-PROMPT] tty
/dev/pts/11

, /dev/tty - , "tty", . , tty , , . , , , /dev/tty... - . ...

cp /etc/passwd /dev/pts/6

... 6 , tty (, 11 ), , ...

cp /etc/passwd /dev/tty

... /etc/passwd . , /etc/password - , , . ...

echo "i said hello" > /tmp/hello.file
cp /tmp/hello.file /dev/tty

... , - ( tmp ( ), .

( , /dev/pts/NN, , . echo 'boo' > /dev/tty/NN. , .)

+10

Source: https://habr.com/ru/post/1764874/


All Articles