본문 바로가기

Computer/Linux

리눅스 기본 명령어

디렉토리 내용보기 (Dos의 Dir과 동일)

ls 

ls -l 

ls -lf


Path 에 포함된 파일이름 찾기

which python

which reboot


화면지움 (Dos의 cls 와 같음)

Clear


리눅스의 32, 64비트 확인

getconf LONG_BIT


CPU 온도 체크

vcgencmd measure_temp

Full path :  /opt/vc/bin/vcgencmd measure_temp

소유자의 권한변경
테스트 파일의 그룹 Pi 소유권한을 Pi  로 변경, (파일명 대신 *를 입력하면 해당 디렉토리의 모든 파일의 권한이 변경됨)

CHOWN Pi:Pi text.txt


시간확인

date


시간대 변경

ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime


로그 위치

/var/log/syslog


가동시간 확인

uptime


현재 폴더 위치

pwd


파일의 위치

whereis




Expect 사용해서 sftp를 통해 파일 전송

sudo apt-get install expect


Script

#!/usr/bin/expect

spawn sftp username@hostname.com

expect "password:"

send "yourpasswordhere\n"

expect "sftp>"

send "cd /var/www\n"

expect "sftp>"

send "put /var/www/house.log\n"

expect "sftp>"

send "exit\n"

interact


프로그램 삭제(예:아파치2)

sudo apt-get purge apache2*

sudo apt-get autoremov



모든 py 파일 맨 첫줄에 아래 문구를 삽입해야 다른 파일(php)에서 py실행을 할 수 있음

#!/usr/bin/env python



SSH 접속

예를들어 ID 가 test 를 example.com 에 접속시

ssh test@example.com


#SSH to Chorok-farm server

ssh id@domain.com



CPU Temperature check

/opt/vc/bin/vcgencmd measure_temp


Update command

sudo apt-get update

sudo apt-get upgrade



Unistall programs

udo apt-get --purge remove programname

--purge option is to remove all data


Show strage size

df command - Shows the amount of disk space used and available on Linux file systems.

du command - Display the amount of disk space used by the specified files and for each subdirectory.


apache server setting #Location of APACHE Config file

sudo nano /etc/apache2/apache2.conf

sudo service apache2 restart



mysql 압축 및 해제
mysqldump -u root -p[password] --all-databases | gzip > /var/backup/mysql-`/bin/date +\%Y\%m\%d\%H\%M`.sql.gz
gunzip backup.sql.gz
mysql -uroot -p[password] < backup.sql

Tar 압축
압축
tar -czvf filename.tar.gz /location/file
해제
tar -xzvf filename.tar.gz

압축 해제

sudo tar -xvf file.name




Raspberrypi Camera


Webstreaming to http://domain.com:8081

raspivid -o - -t 0 -w 640 -h 480 -fps 24 |cvlc -vvv stream:///dev/stdin --sout #standard{access=http,mux=ts,dst=:8081}' :demux=h264


Still cut (resolution 640x480 )

raspistill -t 2000 -o image.jpg -w 640 -h 480

#Update & Upgrade

apt-get update

apt-get upgrade


#Check CPU temerature = figures/1000

cat /sys/devices/virtual/thermal/thermal_zone0/temp


#change root's password

sudo passwd root


# Install python3 or upgrade

sudo apt-get install python3

sudo apt-get upgrade python3


#check installed program

apt list --installed | grep PROGRAMNAME


# IP address check

ip add show



# Show program list

dpkg --list


# Uninstall program # Including configure file

sudo apt-get --purge remove PROGRAMNAME

# Uninstall program # without configure file

sudo apt-get remove gimp PROGRAMNAME