Linux Command
Linux 명령어 모음
- User create
- Tips
- Command
- HTTP Command
- Windows command
- Converting Video
- Mount Disk
- BackUp
- Network Masquerade
- xhost
- ssh 패스워드 없이
- Tar 분할 압축 / 풀기
- dnf 저장소 추가하기
- Download Youtube contents
User create
- 두 작업 모두 root 로 해야하며 home directory 는 별도로 만들고 chown 명령어로 적당하게 owner와 group 를 바꾸세요.
- 반드시 /etc/passwd , /etc/group 파일을 확인하시구요.
- Group add 예제입니다.
-
groupadd -g 800 ftpgroup => 800: group id number => ftpgroup : group name
* AIX mkgroup id=520 batch
-
- User add 예제입니다.
-
useradd -u 515 -g 1008 -d /app/mbatapp -s /bin/ksh mbatapp => 515: user id number => 1008 : group id number => /app/mbatapp : home directory => /bin/ksh : shell name (보통 ksh 로) => mbatapp : username 나머지 –u, -g, -d, -s 는 option 입니다. 그리고 home directory 에 .profile 파일을 만들어서 적절히 setup 하세요. 그리고 root user 로 password setup 하시구요. # passwd mbatapp
-
- chown, chmod 참고하시구요.
-
chown -R esb:apgroup ESB : ESB Directory 의 owner 를 esb , group 을apgroup 으로 하위 디렉토리까지(-R) Set chmod -R 775 CHECK : CHECK Directory 를 755(read(4) + write(2) + excute(1) : read(4) + execute(1) : : read(4) + execute(1)) 로하위 디렉토리까지(-R) Set
-
- .Profile 만들기
-
echo "###################################################################" echo " " banner evd-test echo " " echo "###################################################################" HOSTNAME=`/usr/bin/uname -n`;export HOSTNAME PS1="`id |cut -d '(' -f2|cut -d ')' -f1' '`@`uname -n`[\$PWD]" TERM=vt100;export TERM export EDITOR=vi set -o vi stty erase ^H stty -istrip -parenb ulimit -n 8192
-
Tips
Terminal color
- R : 192
- G : 122
- B : 0
Command
-
total count 방법
find ./Pictures -name '*.bmp' | wc -l | xargs printf "\nTotal Count = \"%s\" files \n\n"
-
하위 폴더 모두 EUC-8에서 UTF-8로 변경
find ./ -name '*.txt' -exec iconv -c -f euc-kr -t utf-8 {} -o {}-u.txt \;
-
nmon root로 실행
nmon -f -d -t -s 60 -c 240
-
20일 전 파일 삭제
find /app/ldsp/backup -mtime +20 -print | xargs rm -f <-- 폴더까지는 -rf로 처리 주의 필요 !
-
3004-303 There have been too many unsuccessful login attempts;
chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -swebtob chuser account_locked=false webtob passwd webtob pwdadm -f NOCHECK webtob
-
폴더 삭제 10일이전 모든 디렉토리
0 2 * * * find /swlog/batch/log -mtime +10 -type d -name '20*' -print | xargs rm -rf
-
파일 삭제 10일이전 모든 디렉토리
0 2 * * * find /swlog/webtob -name 'system*' -mtime +15 -print | xargs rm -f
-
파일명 rename 변경
for x in `du -a | cut -d '/' -f2- | grep JPG`; do mv "$x" "${x%.JPG}.jpg"; done
-
폴더별 사이즈 조사
find ./ -name '*Job' -type d -print | xargs du -sg
-
사이즈 조사
du --max-depth=1 --human-readable
-
CPU 코어 전체
grep -c processor /proc/cpuinfo
-
물리 CPU
grep "physical id" /proc/cpuinfo | sort -u | wc -l
-
CPU당 물리 코어
grep 'cpu cores' /proc/cpuinfo | tail -1
-
하이퍼쓰레딩
cat /proc/cpuinfo | egrep 'siblings|cpu cores' | head -2
HTTP Command
- HTTP Command
$ telnet 124.xxx.59.xxxx 80
Trying...
Connected to 124.243.59.5.
Escape character is '^]'.
GET /index.html HTTP/1.1
HOST: 124.xxx.59.xxxx
HTTP/1.1 200 OK
Date: Tue, 04 Oct 2016 14:48:21 GMT
ETag: "0-e-57f3b2e5"
Last-Modified: Tue, 04 Oct 2016 13:47:17 GMT
Accept-Ranges: bytes
Content-Length: 14
Content-Type: text/html
<h1>TEST</h1>
Connection closed.
$
Windows command
- 포트 확인
- netstat -ano | fondstr 40022
Converting Video
-
sudo apt-get install mencoder mencoder -oac copy -ovc lavc -o video.avi video.flv
-
작업 시작 : C:\Documents and Settings\Administrator\바탕 화면\DanielPink_2009G-medium.flv "C:\BADAK\mencoder.exe" "C:\Documents and Settings\Administrator\바탕 화면\DanielPink_2009G-medium.flv" -o "C:\Documents and Settings\Administrator\바탕 화면\[U10]DanielPink_2009G-medium.avi" -mc 0 -audio-preload 0.0 -noodml -ofps 15.000 -vf-add crop=360:240:-1:-1 -vf-add scale=320:212 -vf-add expand=320:240:-1:-1:1 -ovc lavc -lavcopts vcodec=mpeg4 -lavcopts vbitrate=350 -ffourcc DIVX -srate 44100 -oac mp3lame -lameopts vbr=0 -lameopts br=128 -lameopts mode=0 -lameopts aq=7 -lameopts padding=3 -af volnorm
#!/bin/sh
# 파일작성자 : simplism (simplism86@gmail.com)
# 최초작성일 : 2010.02.07
# 관련패키지 : mencoder
# 지원확장자 : *.avi, *.smi
# 관련페이지 : http://simplism.kr/wordpress/?p=576
mencoder $1 -o ./converted/$1.avi -mc 0 -audio-preload 0.0 -noodml -ofps 30.000 -ovc lavc -lavcopts vcodec=mpeg4 -lavcopts vbitrate=640 -ffourcc DIVX -srate 44100 -oac mp3lame -lameopts vbr=0 -lameopts br=128 -lameopts mode=1 -lameopts aq=7 -font 나눔고딕.ttc -sub $1.smi -utf8 -subpos 97 -subfont-text-scale 4 -subfont-blur 1 -subfont-outline 2 -af volnorm -xvidencopts max_bframes=0:chroma_opt:turbo -xvidopts deblock-chroma -vf scale=480:272:::0:1.00 -vf-add softskip -sws 2 -lavdopts threads=6
관련 문서 : dnf 저장소 추가하기
Mount Disk
- NTFS 경우
디스크 확인 hyunsu@schmitt:~$ sudo fdisk -l [sudo] password for hyunsu: Disk /dev/sda: 320.0 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x7cbe7cbe Device Boot Start End Blocks Id System /dev/sda1 1 38914 312568832 7 HPFS/NTFS Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x000c5d0b Device Boot Start End Blocks Id System /dev/sdb1 * 1 60770 488134993+ 8e Linux LVM /dev/sdb2 60771 60801 249007+ 5 Extended /dev/sdb5 60771 60801 248976 83 Linux hyunsu@schmitt:~$
sudo mount -t ntfs /dev/sda1 /home/hyunsu/interfacefolder
mount -t smbfs -o username=vivek,password=D1W4x9sw //ntserver/download /mnt/ntserver
UUID를 알아내기 ls -l /dev/disk/by-uuid/ sudo vi /etc/fstab ==> 추가 : UUID=E4C2A819C2A7EE4C /home/hyunsu/700G ntfs defaults,nls=utf8,umask=007,gid=46 0 1 sudo mount -a
- FAT32 경우
sudo mount -t vfat -o rw,utf8,uid=hyunsu /dev/sda1 /home/hyunsu/700G
- FTP 인경우
- In /etc/fstab use
curlftpfs#ftpUsername:ftpPassword@ftp://ftpUrl /localDirectory fuse rw,uid=1000,umask=0777,user,suid,allow_other,exec,auto,utf8 0 1 mount -a
- command
sudo curlftpfs -o umask=0777,uid=1000,gid=1000,allow_other ftp://hxxxxx:17XXXXXq@192.168.0.5 /home/hyunsu/NFS -o modules=iconv,from_code=euc-kr,to_code=utf8 mount -a
- In /etc/fstab use
- NFS인 경우
- USB Disk
`mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sde1" "/media/schmitt/Seagate Backup Plus Drive"'
BackUp
Linux Backup
2G 한계 tar -czvf /media/700G/BackUp/20101013/20101013.tar.gz --exclude=/home/hyunsu/ /home/hyunsu/Public/*
600메가로 나누기
tar -zcvf - /apps | split -b 600m - /home/hyunsu/apps.tar.gz 풀 때 cat home.tar.gz* | tar -zxvpf -
AIX
tar -cvf - dDIMSRep/ | gzip | split -b 2048m - dDIMSRep.tar.gz_ tar -cvf - dDIMSLog/ | gzip | split -b 2048m - dDIMSLog.tar.gz_ cat ./dDIMSLog.tar.gz_* | gunzip | tar -xvf - cat ./dDIMSRep.tar.gz_* | gunzip | tar -xvf -
Network Masquerade
Network Masquerade
NetworkMasquerade
-
#! /bin/sh # IP Masquerading - iptables sudo route del default eth1 sudo route add default eth0 sudo iptables -t nat -A POSTROUTING -s 192.168.1.101 -d ! 192.168.1.101 -j MASQUERADE sudo iptables -t nat -A POSTROUTING -s 192.168.1.102 -d ! 192.168.1.102 -j MASQUERADE sudo iptables -t nat -A POSTROUTING -s 192.168.1.103 -d ! 192.168.1.103 -j MASQUERADE sudo iptables -t nat -A POSTROUTING -s 192.168.1.104 -d ! 192.168.1.104 -j MASQUERADE sudo iptables -t nat -A POSTROUTING -s 192.168.1.105 -d ! 192.168.1.105 -j MASQUERADE sudo iptables -t nat -L sudo mount -t smbfs -o username=2004710,password=2004710,workgroup=clt.net,iocharset=utf8,file_mode=0777,dir_mode=0777 //203.246.153.2/nis2010$ /home/hyunsu/Mountpoint/NIS2010 sudo mount -t smbfs -o username=2004710,password=2004710,workgroup=clt.net,iocharset=utf8,file_mode=0777,dir_mode=0777 //203.246.153.2/nis2010dev$ /home/hyunsu/Mountpoint/NIS2010DEV
xhost
xhost
- 두 대의 컴퓨터를 사용할 경우 xhost와 display 옵션으로 윈도우 애플리케이션을 다른 컴퓨터의 화면에 띄울 수 있다.
-
export DISPLAY=127.0.0.1:0.0 startx
-
ssh -X oracle@dynamic.joang.com
ssh 패스워드 없이
백업을 만들고 원격지로 백업 폴더로 전송하기 위해서는 백업을 하는 서버가 출발지가 되고 백업 파일을 받는 서버가 도착지가 된다.
연결을 하려고하는 client 서버(출발지)에서 아래 실행
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub [user]@[host]
수신 서버(수신지) 아래 실행 -- 필요 없을 수 있음
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys
Tar 분할 압축 / 풀기
tar -cvzf - ./2023 | split -b 1024m - 2023.tar
cat 2023.tar* | tar -xvzf
dnf 저장소 추가하기
dnf 저장소 추가하기
Raven Multimedia 저장소 추가 , mencoder 설치를 위하여
[hyunsu@joang yum.repos.d]$ sudo wget $(echo "https://pkgs.dyn.su/el9/base/x86_64/raven-release.el9.noarch.rpm" | sed "s/el9/el$(rpm -q --queryformat '%{RELEASE}' rpm | grep -oP 'el\K[0-9]+')/g")
--2024-10-21 00:42:04-- https://pkgs.dyn.su/el9/base/x86_64/raven-release.el9.noarch.rpm
Resolving pkgs.dyn.su (pkgs.dyn.su)... 191.101.33.144
Connecting to pkgs.dyn.su (pkgs.dyn.su)|191.101.33.144|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9553 (9.3K) [application/x-redhat-package-manager]
Saving to: `raven-release.el9.noarch.rpm'
raven-release.el9.noarch.rpm 100%[==============================================================================================================>] 9.33K --.-KB/s in 0.001s
2024-10-21 00:42:06 (17.9 MB/s) - `raven-release.el9.noarch.rpm' saved [9553/9553]
[hyunsu@joang yum.repos.d]$ sudo rpm -ivh raven-release*.rpm
경고: raven-release.el9.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 2dcd03a2: NOKEY
Verifying... ################################# [100%]
준비 중... ################################# [100%]
Updating / installing...
1:raven-release-1.0.1-1.el9 ################################# [100%]
!!! WARNING !!!
You have installed an unofficial repository configuration. Some parts of it may
break compatibility with the base packages of your OS, so you use it at YOUR OWN RISK!
Unstable and/or conflicting repository parts are not enabled by default,
you can use the --enablerepo=raven-extras or --enablerepo=raven-testing option
to enable them temporarily.
[hyunsu@joang yum.repos.d]$ sudo dnf clean all && sudo dnf update --assumeyes
86 파일이 삭제되었습니다
Extra Packages for Enterprise Linux 9 - x86_64 8.4 MB/s | 23 MB 00:02
Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64 344 B/s | 2.5 kB 00:07
google-chrome 7.0 kB/s | 3.7 kB 00:00
Raven's RPM repo for el9-x86_64 - base 331 kB/s | 970 kB 00:02
Raven's RPM repo for el9-x86_64 - multimedia 27 kB/s | 133 kB 00:04
Rocky Linux 9 - BaseOS 1.9 MB/s | 2.3 MB 00:01
Rocky Linux 9 - AppStream 1.4 MB/s | 8.0 MB 00:05
Rocky Linux 9 - Extras 22 kB/s | 15 kB 00:00
Oracle Linux / RHEL / CentOS-9 / x86_64 - VirtualBox 113 kB/s | 145 kB 00:01
종속성이 해결되었습니다.
==========================================================================================================================================================================================================
꾸러미 구조 버전 저장소 크기
==========================================================================================================================================================================================================
향상 중:
libdvdnav x86_64 6.1.1-5.el9 raven-multimedia 57 k
libmpeg2 x86_64 0.5.1-26.el9 raven-multimedia 78 k
libseccomp x86_64 2.5.3-1.el9 raven 72 k
nano x86_64 8.2-1.el9 raven 761 k
python3-dbus x86_64 1.2.18-5.el9 raven 138 k
vulkan-loader x86_64 1.3.283.0-2.el9 raven 149 k
연결 요약
==========================================================================================================================================================================================================
향상 6 꾸러미
전체 내려받기 크기: 1.2 M
꾸러미 내려받기 중:
(1/6): python3-dbus-1.2.18-5.el9.x86_64.rpm 98 kB/s | 138 kB 00:01
(2/6): nano-8.2-1.el9.x86_64.rpm 373 kB/s | 761 kB 00:02
(3/6): libseccomp-2.5.3-1.el9.x86_64.rpm 32 kB/s | 72 kB 00:02
(4/6): vulkan-loader-1.3.283.0-2.el9.x86_64.rpm 134 kB/s | 149 kB 00:01
(5/6): libdvdnav-6.1.1-5.el9.x86_64.rpm 119 kB/s | 57 kB 00:00
(6/6): libmpeg2-0.5.1-26.el9.x86_64.rpm 133 kB/s | 78 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
합계 448 kB/s | 1.2 MB 00:02
Raven's RPM repo for el9-x86_64 - base 1.7 MB/s | 1.7 kB 00:00
GPG키 0x2DCD03A2 가져오는 중:
사용자 ID : "Raven <raven@sysadmins.ws>"
지문: 3957 8A93 8FB4 A975 8428 7E7F 00BE DE30 2DCD 03A2
출처 : /etc/pki/rpm-gpg/RPM-GPG-KEY-raven
키 가져오기에 성공했습니다
연결 확인 실행 중
연결 확인에 성공했습니다.
연결 시험 실행 중
연결 시험에 성공했습니다.
연결 실행 중
준비 중 : 1/1
향상 중 : libmpeg2-0.5.1-26.el9.x86_64 1/12
향상 중 : libdvdnav-6.1.1-5.el9.x86_64 2/12
향상 중 : vulkan-loader-1.3.283.0-2.el9.x86_64 3/12
향상 중 : python3-dbus-1.2.18-5.el9.x86_64 4/12
향상 중 : nano-8.2-1.el9.x86_64 5/12
구현 중 : nano-8.2-1.el9.x86_64 5/12
향상 중 : libseccomp-2.5.3-1.el9.x86_64 6/12
정리 : libmpeg2-0.5.1-24.el9.0.1.x86_64 7/12
정리 : libdvdnav-6.1.0-4.el9.x86_64 8/12
정리 : vulkan-loader-1.3.268.0-1.el9.x86_64 9/12
정리 : python3-dbus-1.2.18-2.el9.0.1.x86_64 10/12
정리 : nano-5.6.1-5.el9.x86_64 11/12
정리 : libseccomp-2.5.2-2.el9.x86_64 12/12
구현 중 : libseccomp-2.5.2-2.el9.x86_64 12/12
확인 중 : libseccomp-2.5.3-1.el9.x86_64 1/12
확인 중 : libseccomp-2.5.2-2.el9.x86_64 2/12
확인 중 : nano-8.2-1.el9.x86_64 3/12
확인 중 : nano-5.6.1-5.el9.x86_64 4/12
확인 중 : python3-dbus-1.2.18-5.el9.x86_64 5/12
확인 중 : python3-dbus-1.2.18-2.el9.0.1.x86_64 6/12
확인 중 : vulkan-loader-1.3.283.0-2.el9.x86_64 7/12
확인 중 : vulkan-loader-1.3.268.0-1.el9.x86_64 8/12
확인 중 : libdvdnav-6.1.1-5.el9.x86_64 9/12
확인 중 : libdvdnav-6.1.0-4.el9.x86_64 10/12
확인 중 : libmpeg2-0.5.1-26.el9.x86_64 11/12
확인 중 : libmpeg2-0.5.1-24.el9.0.1.x86_64 12/12
향상되었습니다:
libdvdnav-6.1.1-5.el9.x86_64 libmpeg2-0.5.1-26.el9.x86_64 libseccomp-2.5.3-1.el9.x86_64 nano-8.2-1.el9.x86_64 python3-dbus-1.2.18-5.el9.x86_64 vulkan-loader-1.3.283.0-2.el9.x86_64
완료되었습니다!
[hyunsu@joang yum.repos.d]$ dnf repolist
저장소 ID 저장소 이름
appstream Rocky Linux 9 - AppStream
baseos Rocky Linux 9 - BaseOS
epel Extra Packages for Enterprise Linux 9 - x86_64
epel-cisco-openh264 Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64
extras Rocky Linux 9 - Extras
google-chrome google-chrome
raven Raven's RPM repo for el9-x86_64 - base
raven-multimedia Raven's RPM repo for el9-x86_64 - multimedia
virtualbox Oracle Linux / RHEL / CentOS-9 / x86_64 - VirtualBox
[hyunsu@joang yum.repos.d]$
Download Youtube contents
Download Youtube contents
단건 받기
#!/bin/bash
URL=$1
DOWN_DIR=/media/pi/RaspRefp
#DOWN_DIR=/home/pi
YOUTUBE_DL=`which youtube-dl`
echo "Download URL :" $URL
echo "Download PATH :" $DOWN_DIR
echo $YOUTUBE_DL
cd $DOWN_DIR
#$YOUTUBE_DL -f 'best' -o $DOWN_DIR/'%(title)s.%(ext)s' $URL
$YOUTUBE_DL -f bestvideo+bestaudio -o $DOWN_DIR/'%(title)s.%(ext)s' $URL
exit 0
그룹 받기
#!/bin/bash
TITLE=$1
URL=$2
DOWN_DIR=/media/pi/RaspRefp
#DOWN_DIR=/home/pi
YOUTUBE_DL=`which youtube-dl`
echo "Download URL :" $URL
echo "Download PATH :" $DOWN_DIR
echo "Youtube-Dl :" $YOUTUBE_DL
echo "Create Directory :" $DOWN_DIR/$TITLE
mkdir $DOWN_DIR/$TITLE
cd $DOWN_DIR/$TILTE
#$YOUTUBE_DL -cit $URL
$YOUTUBE_DL -f best --ignore-errors -o "$DOWN_DIR/$TITLE/%(playlist)s/%(playlist_index)s- %(title)s.%(ext)s" $URL
#$youtube-dl -f best --ignore-errors -o "~/Videos/Youtube-dl/videos/%(playlist)s/%(playlist_index)s- %(title)s.%(ext)s" --yes-playlist
#$youtube-dl -ic -o "~/Videos/Youtube-dl/audios/%(playlist)s/%(playlist_index)s- %(title)s.%(ext)s" --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0