sudo 사용하는 방법


package 및 application 관리
sudo systemctl enable docker –now
sudo yum install tmux -y


yum install tree -y
sudo !!

wheel,sudo 그룹의 구성원으로서 root 계정으로 변경하되 암호를 특별히 입력하지 않음(현재 위치 변경하지 않음)
sudo -s

wheel,sudo 그룹의 구성원으로서 root 계정으로 변경하되 암호를 특별히 입력하지 않음(현재 위치 치를 root 계정의 홈 디렉터리로 변경)
sudo -i

powershell에서 -computername을 사용할 때는 원격에 RemoteRegistry 서비스가 실행중이어야 한다


Get-Process -ComputerName client

Get-Service -ComputerName server

이렇게 명령을 내렸는데 “Couldn’t connect to remote machine”라는 메시지가 발생하면서 접속이 안되는 일이 있다.

이런 이유는 원격 컴퓨터의 서비스 중에서 RemoteRegistry 서비스가 시작되지 않았기 때문이다.

-ComputerName 파라메터는 Enable-PSRemoting -Force 설정과는 무관하다.

단지 원격 컴퓨터에 RemoteRegistry 서비스와 관려되어 있을 뿐이다

원하는 PowerShell 명령어 찾는 방법


<원하는 PowerShell 명령어 찾는 방법>
1) -Name
Get-Command -Name test-*
Get-Command -Name *-package

2) -CommandType
Get-Command -CommandType application/cmdlet/alias/function
Get-Command -CommandType application | Where-Object {$_.Name -like “.exe”} Get-Command -CommandType application | Where-Object {$_.Name -like “q.exe”}
Get-Command -CommandType application | Where-Object {$_.Name -like “.msc”} Get-Command -CommandType application | Where-Object {$_.Name -like “.cpl”}

3) -Parameter
Get-Command -ParameterName asstring
Get-Command -ParameterName filter

4) -Module
Get-Command -Module pscx
Get-Command -Module DNSServer

유용한 파워쉘 명령어



Get-WindowsDriver –Online –All


Export-WindowsDriver -Online -Destination c:\backup-drivers

<맬웨어 찾기>
Start-MpScan –ScanType QuickScan/FullScan –ScanPath “C:\Program Files”

<명령어 보기>
Get-Command -CommandType cmdlet/application/function/alias


Get-PSDrive
Get-PSDrive -PSProvider FileSystem/Alias/Registry

참고 영상: https://youtu.be/VFuobJbbDtU

워크 그룹의 Windows10/11에서 또 다른 워크그룹의 Hyper-V Server에 접속하기 위한 설정


워크 그룹의 Windows10/11에서 또 다른 워크그룹의 Hyper-V Server에 접속하기 위한 설정

보통은 Active Directory의 구성원이면 관리자로 로그인하면 쉽게 원격 관리가 된다.
하지만 우리는 AD가 없는 상황이다.
이 때 설정하는 방법은 아래와 같다

참고 영상: https://youtu.be/sIWoLpiczhg

  • Hyper-V Server에서 설정
    Enable-PSRemoting -Force
    Enable-WSManCredSSP -Role Server
  • Windows10/11의 Hyper-V Manager에서 설정
    gpedit.msc
    Administrative Template – System – Credential Delegation(자격 증명 위임) – Allow delegating fresh credentials with NTLM-only server Authenticatin(서버 인증이 NTLM 전용일 경우 새로운 자격 증명 허용)을 Enabled로 설정 – Show를 클릭하여 wsman/win2016 입력

Powershell을 관리자로 실행하여
Set-Item WSMan:\localhost\client\trustedhosts -value win2016

Enable-WSManCredSSP -Role Client -DelegateComputer win2016

이렇게 작업한 후 Windows10/11의 Hyper-V Manager를 실행하여 원격 Hyper-V server에 접속하면 잘 된다

Hyper-V에 NAT Virtual Switch 생성하기


Windows 10/11의 Hyper-V에는 Default Switch라는 NAT를 해주는 가상 스위치가 있다
하지만 이것의 IP 대역을 관리자 마음대로 정할 수가 없다
그래서 관리자 마음대로 IP 대역을 지정하기 위해서는 수동으로 Virtual Switch를 생성하면 된다
그리고 Windows Server의 Hyper-V에서는 Default Switch라는 NAT용 가상스위치가 없기 때문에,
수동으로 Virtual Switch를 만드는 방법을 알고 있어야 한다

  1. 내부용으로 사용하는 가상 스위치(NATSwitch) 생성하기
    New-VMSwitch -SwitchName “NATSwitch” -SwitchType Internal
    이 스위치를 New-NetNat 명령으로 NAT 기능을 구현하여 인터넷으로 연결할 수 있다

Get-VMSwitch (##생성한 Virtual Switch 확인하기)
Get-NetAdapter (##Application에 의해 Virtual Switch가 생성되면 Virtual Adapter가 생성된다)

  1. 생성된 Virtual Adapter에 IP Address 지정하기
    New-NetIPAddress -IPAddress 10.10.10.1 -PrefixLength 24 -InterfaceAlias “vEthernet (NATSwitch)”
    이것이 NATSwitch를 사용하는 VM들의 Default Gateway 역할을 한다
  2. 10.10.10.0/24 대역의 Internal IP를 NAT 해주도록 설정하기
    New-NetNat -Name “NATNetwork” -InternalIPInterfaceAddressPrefix “10.10.10.0/24”
  3. 생성한 NAT의 IP 대역 설정 보기
    Get-NetNat -Name NATNetwork | fl
  4. Hyper-V Manager에서 각 VM들의 Network Adapter를 NATSwitch라는 가상 스위치를 사용하도록 변경한다
  5. NATSwitch 스위치를 사용하는 VM들의 NIC에 10.10.10.0/24의 IP를 수동으로 설정해주어야 한다
    10.10.10.10
    255.255.255.0
    10.10.10.1
    8.8.8.8

이렇게 수동으로 입력하면 VM간의 통신을 위해서 추가적인 Virtual Switch가 필요가 없다

이렇게 만든 NATSwitch는 virtual Box의 NATNetwork와 동일하다. 즉, 인터넷 접속도 되고, VM간의 통신도 된다

  1. Virtual Switch 생성으로 만들어진 Virtual Adapter 삭제하기
    Get-VMSwitch
    Get-NetAdapter

Get-VMSwitch -Name Natswitch | Remove-VMSwitch -Force (##가상 스위치 제거하기)
Get-HNSNetwork | Where-Object {$_.Name -Like “*NATSwitch”} | Remove-HNSNetwork (##삭제한 가상 스위치에서 생성된 Virtual Adapter 삭제하기)

Get-VMSwitch
Get-NetAdapter
성공!!

리눅스 find 명령어 40개 예제


참고 자료: https://bit.ly/3DTvDpA

Example 1: Check Find command version
find -version

Example 2: Find all the files Only created in last 40 mins
find /home/example -type f -cmin -40
-cmin n: File’s status was last changed n minutes ago.
-type f: regular file

Example 3: Find all the files Only modified in last 40 mins
find /home/example -type f -mmin -40
-mmin n: File’s data was last modified n minutes ago.

Example 4: Find all the files Only accessed in last 40 mins
find /home/example -type f -amin -40
-amin n: File was last accessed n minutes ago

Example 5: Find all the files and directories created in last 40 mins
find /home/example -cmin -40

Example 6: Find all the files and directories modified in last 40 mins
find /home/example -mmin -40

Example 7: Find all the files and directories accessed in last 40 mins
find /home/example -amin -40

Example 8: Find all the files only created in last 40 mins
find /home/example -type f -cmin -40

Example 9: Find all the files only modified in last 40 mins
find /home/example -type f -mmin -40

Example 10: Find all the files only accessed in last 40 mins
find /home/example -type f -amin -40

Example 11: Find all the created files and directories older than 40 mins
find /home/example -cmin +40

Example 12: Find all the modified files and directories older than 40 mins
find /home/example -mmin +40

Example 13: Find all the accessed files and directories older than 40 mins
find /home/example -amin +40

Example 14: Find all the created files only in last 5 days
find /home/example -type f -mtime -5
-mtime n: File’s data was last modified n*24 hours ago.

Example 15: Find all the modified files only older than 5 days
find /home/example -type f -mtime +5

Example 16: Find all the files and directories modified in last 5 days
find /home/example -mtime -5

Example 17: Find all the modified files and directories older than 5 days
find /home/example -mtime +5

Example 18: Find a file “test.txt” at the maxdepth of level 2
find /home/example/ -maxdepth 2 -name test.txt
-maxdepth levels: Descend at most levels (a non-negative integer) levels of directories below the starting-points

Example 19: Find a file “test.txt” at the mindepth of level 2
find /home/example/ -mindepth 2 -name test.txt
-mindepth levels: Do not apply any tests or actions at levels less than levels(a non-negative integer)

Example 20: Find a file test.txt between mindepth of 2 and maxdepth of 4
find /home/example -mindepth 2 -maxdepth 4 -name test.txt

Example 21: Find all the files created by User “example”
find /home -user example

Example 22: Find all Empty Files
find /home/example -empty
-empty: File is empty and is either a regular file or a directory

Example 23: Find all Executable Files and Directories
find /home/example -executable
-executable: Matches files which are executable and directories which are searchable (in a file name resolution sense) by the current user.

Example 24: Find all Executable Files Only
find /home/example -type f -executable

Example 25: Find all Empty Files Only
find /home/examples -type f -empty

Example 26: Find all the Case Insensitive match pattern
find /home/example -iname File1
-iname pattern: Like -name, but the match is case insensitive

Example 27: Find all the files on ext4 filesystem
find . -fstype ext4
-fstype type: File is on a filesystem of type ext4

Example 28: Find all the files with group name test
find /home/example -group test
-group gname: File belongs to group gname (numeric group ID allowed)

Example 29: Find all the files which does not belong to any known group
find . -nogroup
-nogroup: No group corresponds to file’s numeric group ID.

Example 30: Find all the files which does not belong to any known User
find . -nouser
-nouser: No user corresponds to file’s numeric user ID.

Example 31: Find all the files by their Group ID
find /home/example -group 500

Example 32: Find all the files by their User ID
find /home/example -user 500
-user uname: File is owned by user uname (numeric user ID allowed

Example 33: Find all the files which are either executable by User or by Group
find /home/example -perm /u=x,g=x
-perm -mode: Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify u',g’ or `o’ if you use a symbolic mode.

Example 34: Find all the files which are executable by both User and Group
find /home/example -perm -g+w,u+w
-perm -mode: All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them. You must specify u',g’ or `o’ if you use a symbolic mode

Example 35: Find all files and directories having execute permission
find /home/example -perm /111

Example 36: Find all the files created between last 5-10 days
find . -ctime -10 -ctime +5

Example 37: Find all the files accessed between last 5-10 days
find . -atime -10 -atime +5

Example 38: Find all the files modified between last 5-10 days
find . -mtime -10 -mtime +5

Example 39: Find all the files which is either readable by User or by Group
find /home/example -perm /u=r,g=r

Example 40: Find all the files which is readable by both User and Group
find /home/example -perm -g+r,u+r