sudo 고양이 /dev 또는 /proc

sudo 고양이 /dev 또는 /proc

/proc및 와 같은 특정 디렉토리에서 데이터 출력을 얻으려고 합니다 /dev. 에서 대부분의 데이터를 얻을 수 있습니다 /proc. 그러나 /dev. 주요 출력은 컴퓨터에 연결된 장치라는 것을 알고 있습니다.

1- 작업 내용은 이미지를 참고하세요.

#! /bin/bash
echo "Hello, this is your data horde program. Please continue."
sleep 5s
#
#
# This is a auto download and install applications
echo "Installing software for scan."
yes Y | apt-get install cat
yes Y | apt-get install nmap
sleep 5s
echo "Installation complete."
#
#
# This area of the script will scan for IP information and output to certain 
text files.
echo "Scanning for IP address."
ifconfig &>> bashscanip.txt
sudo ss -tulwn &>> bashscanip.txt
sudo top -b -n 5  &>> processme.txt
sleep 5s
echo "Scan complete, scanning computer data."
#
# Cat export data into easy read text file hardware scan from /proc & /dev
sudo cat /proc/*  &>> bashdevinfo.txt
sudo cat /dev/*  &>> bashdevinfo.txt
set -e
sleep 5s
echo "Scan complete, please continue to check files."
sleep 5s
echo "Exiting Program"
sleep 5s
kill $$
#
# References
# https://stackabuse.com/how-to-permanently-set-path-in-linux/
# https://bash.cyberciti.biz/guide/Shell_Comments
# https://vitux.com/find-devices-connected-to-your-network-with-nmap/
# https://www.tecmint.com/save-top-command-output-to-a-file/
# https://unix.stackexchange.com/questions/130829/how-to-self-terminate-a- 
bash-script-after-timeout

감사해요

답변1

당신은 원하지 않습니다 cat. cat단순히 입력으로 제공한 내용을 복사하여 인쇄하는 프로그램입니다. 따라서 다음과 같은 작업을 수행 cat /dev/sda1 > file하면fileISO 이미지하드 드라이브의 첫 번째 파티션. 이는 파티션과 동일한 크기이므로 파티션에 저장할 수도 없습니다. 그것은 또한 쓸모없는 정보이고 텍스트가 아니며 여기서는 의미가 없습니다.

ls다음을 사용하여 디렉토리의 내용을 나열 할 수 있습니다 .

ls /proc >> bashdevinfo.txt
ls /dev >> bashdevinfo.txt

하지만 이것도 당신이 해서는 안 되는 일입니다. 관련 파일에서 정보를 수집해야 합니다. 따라서 무엇이 무엇인지, 어떻게 작동하는지 읽어 /proc보고 그 안에 있는 파일에서 유용한 정보를 추출하는 방법을 알아보세요. 몇 가지 힌트:

  • 우선 파일과 을 참조 /proc/meminfo하세요 /proc/mounts./proc/uptime
  • 보여주고 싶은 것이 무엇인지 파악하고그 다음에어떻게 보여줄 수 있을지 생각해 보세요. 모든 것을 맹목적으로 보지 마십시오.

관련 정보